Skip to content

Commit

Permalink
Enhance Template (Thanks to sickdaflip)' - Version 0.2.7
Browse files Browse the repository at this point in the history
  • Loading branch information
MaWoScha committed Nov 7, 2016
1 parent 6f322f6 commit 4f2751f
Show file tree
Hide file tree
Showing 9 changed files with 124 additions and 101 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,7 @@ Fixes:
Updated Admin Routing to make this module compatible with Patch SUPEE-6788 (MatthijsIJ)

## 0.2.6
Add function "_isAllowed()" to "app/code/community/Uni/Fileuploader/controllers/Adminhtml/FileuploaderController.php"
Add function "_isAllowed()" to "app/code/community/Uni/Fileuploader/controllers/Adminhtml/FileuploaderController.php" (Thanks to EliasKotlyar)

## 0.2.7
Enhance Template (Thanks to sickdaflip)
4 changes: 3 additions & 1 deletion app/code/community/Uni/Fileuploader/Block/Fileuploader.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ public function getProductAttachments($productId=0) {
foreach ($record as $rec) {
$i++;
$file = $_helper->getFilesHtml($rec['uploaded_file'], $rec['title'],$i,true,$rec['content_disp'],true);
$attach[] = array('title' => $rec['title'], 'file' => $file, 'content' => $rec['file_content']);
$size = $_helper->getFilesSize($rec['uploaded_file']);
$typ = $_helper->getFilesTyp($rec['uploaded_file']);
$attach[] = array('name' => $rec['title'], 'desc' => $rec['file_content'], 'typ' => $typ, 'size' => $size, 'link' => $file);
}
}
return $attach;
Expand Down
95 changes: 39 additions & 56 deletions app/code/community/Uni/Fileuploader/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,90 +25,73 @@ protected function getFileSize($file) {
$size = filesize($file);
$sizes = array(" Bytes", " KB", " MB", " GB", " TB", " PB", " EB", " ZB", " YB");
if ($size == 0) {
return('n/a');
return ('n/a');
} else {
return (round($size / pow(1024, ($i = floor(log($size, 1024)))), 2) . $sizes[$i]);
}
}

public function getFilesHtml($url, $title, $id = null, $showTitle = false, $disposition = 0, $size = false) {
$html = '';
$fileSize = '';
$url = $this->getDownloadFileUrl($url, $disposition);
$html = '<a class="button" title="' . $title . '" target="_blank" href="' . $url . '">'.$this->__('Download').'</a>';

return $html;
}

public function getFilesSize($url) {
$file = $this->updateDirSepereator($url);
$mediaDir = Mage::getBaseDir('media');
$filePath = $mediaDir . DS . $file;
if (file_exists($filePath))
$fileSize = $this->getFileSize($filePath);

return $fileSize;
}

public function getFilesTyp($url) {

$mediaUrl = Mage::getBaseUrl('media');
$ext = $this->getFileExtension($url, 1); //"jpg","jpeg","gif","png","txt","csv","htm","html","xml","css","doc","docx","xls","rtf","ppt","pdf","swf","flv","avi","wmv","mov","wav","mp3","zip"
$mediaIcon = Mage::getBaseUrl('media') . '/custom/upload/icons/' . $ext . '.png';
$playerPath = Mage::getBaseUrl('media') . '/custom/upload/player/';
$mediaIconImage = '<span class="attach-img"><img src="' . $mediaIcon . '" alt="View File" style="margin-right: 5px;"/></span>' . (($showTitle) ? '<span class="attach-title">' . $title . '</span>' : '');
$mediaIcon = Mage::getBaseUrl('media') . 'custom/upload/icons/' . $ext . '.png';
$mediaIconImage = '<img src="' . $mediaIcon . '" alt="' . $ext . '" /></span>';
$wh = ($showTitle) ? '16' : '22';
if ($size) {
$file = $this->updateDirSepereator($url);
$mediaDir = Mage::getBaseDir('media');
$filePath = $mediaDir . DS . $file;
if (file_exists($filePath))
$fileSize = '&nbsp; &nbsp;Size: (' . $this->getFileSize($filePath) . ')';
}
if ($disposition) {
if ($ext == 'jpg' || $ext == 'jpeg' || $ext == 'gif' || $ext == 'png' || $ext == 'bmp') {
$image = $mediaUrl . $url;
$onclick = "return fileUploaderPopup.open({url:this.rel, title: '" . str_replace(' ', '_', $title) . "'});";
$url = $this->getDownloadFileUrl($url, $disposition);
$html = '<a class="prod-attach" title="' . $title . '" rel="' . $url . '" href="javascript:;" onclick="' . $onclick . '"><span class="attach-img"><img src="' . $image . '" id="' . $id . '_image" title="' . $title . '" alt="' . $title . '" height="' . $wh . '" width="' . $wh . '" class="small-image-preview v-middle" style="margin-right: 5px; width: ' . $wh . 'px; height: ' . $wh . 'px"/></span>' . (($showTitle) ? '<span class="attach-title">' . $title . '</span>' : '') . '</a>';
$fileTyp = '<img src="' . $image . '" id="' . $id . '_image" title="' . $title . '" alt="' . $title . '" height="' . $wh . '" width="' . $wh . '" class="small-image-preview v-middle" style="width: ' . $wh . 'px; height: ' . $wh . 'px"/>';
} else if ($ext == 'txt' || $ext == 'rtf' || $ext == 'csv' || $ext == 'css' || $ext == 'htm' || $ext == 'html' || $ext == 'xml' || $ext == 'doc' || $ext == 'docx' || $ext == 'xls' || $ext == 'xlsx' || $ext == 'ppt' || $ext == 'pdf' || $ext == 'swf' || $ext == 'zip') {
$url = $this->getDownloadFileUrl($url, $disposition);
$onclick = "return fileUploaderPopup.open({url:this.rel, title: '" . str_replace(' ', '_', $title) . "'});";
$html = '<a class="prod-attach" title="' . $title . '" rel="' . $url . '" href="javascript:;" onclick="' . $onclick . '">' . $mediaIconImage . '</a> ';
$fileTyp = $mediaIconImage;
} else if ($ext == 'avi') {
$url = $mediaUrl . $url;
$onclick = "javascript:playerAviOpen('" . $title . "',this.rel); return false;";
$onmouseover = "window.status=''; return true;";
$html = '<a class="prod-attach" title="' . $title . '" onmouseover="' . $onmouseover . '" onclick="' . $onclick . '" target="_blank" rel="' . $url . '" href="javascript:;"><span style="font-weight:bold">' . $mediaIconImage . '</span></a>';
$fileTyp = $mediaIconImage;
} else if ($ext == 'flv') {
$url = $mediaUrl . $url;
$onclick = "javascript:playerFlvOpen('" . $title . "',this.rel,'" . $playerPath . "'); return false;";
$onmouseover = "window.status=''; return true;";
$html = '<a class="prod-attach" title="' . $title . '" onmouseover="' . $onmouseover . '" onclick="' . $onclick . '" target="_blank" rel="' . $url . '" href="javascript:;"><span style="font-weight:bold">' . $mediaIconImage . '</span></a>';
$fileTyp = $mediaIconImage;
} else if ($ext == 'mov') {
$url = $mediaUrl . $url;
$onclick = "javascript:playerMovOpen('" . $title . "',this.rel); return false;";
$onmouseover = "window.status=''; return true;";
$html = '<a class="prod-attach" title="' . $title . '" onmouseover="' . $onmouseover . '" onclick="' . $onclick . '" target="_blank" rel="' . $url . '" href="javascript:;"><span style="font-weight:bold">' . $mediaIconImage . '</span></a>';
$fileTyp = $mediaIconImage;
} else if ($ext == 'wmv' || $ext == 'wav' || $ext == 'mp3') {
$url = $mediaUrl . $url;
$onclick = "javascript:playerOpen('" . $title . "',this.rel); return false;";
$onmouseover = "window.status=''; return true;";
$html = '<a class="prod-attach" title="' . $title . '" onmouseover="' . $onmouseover . '" onclick="' . $onclick . '" target="_blank" rel="' . $url . '" href="javascript:;"><span style="font-weight:bold">' . $mediaIconImage . '</span></a>';
$fileTyp = $mediaIconImage;
} else {
$mediaIcon = Mage::getBaseUrl('media') . '/custom/upload/icons/plain.png';
$mediaIconImage = '<span class="attach-img"><img src="' . $mediaIcon . '" alt="View File" style="margin-right: 5px;"/></span>' . (($showTitle) ? '<span class="attach-title">' . $title . '</span>' : '');
$url = $this->getDownloadFileUrl($url, $disposition);
$onclick = "return fileUploaderPopup.open({url:this.rel, title: '" . str_replace(' ', '_', $title) . "'});";
$html = '<a class="prod-attach" title="' . $title . '" rel="' . $url . '" href="javascript:;" onclick="' . $onclick . '">' . $mediaIconImage . '</a> ';
$mediaIcon = Mage::getBaseUrl('media') . 'custom/upload/icons/plain.png';
$mediaIconImage = '<img src="' . $mediaIcon . '" alt="View File">';
$fileTyp = $mediaIconImage;
}
} else {
if ($ext == 'jpg' || $ext == 'jpeg' || $ext == 'gif' || $ext == 'png' || $ext == 'bmp') {
$image = $mediaUrl . $url;
$url = $this->getDownloadFileUrl($url, $disposition);
$html = '<a class="prod-attach" target="_blank" title="' . $title . '" href="' . $url . '"><span class="attach-img"><img src="' . $image . '" id="' . $id . '_image" title="' . $title . '" alt="' . $title . '" height="' . $wh . '" width="' . $wh . '" class="small-image-preview v-middle" style="margin-right: 5px; width: ' . $wh . 'px; height: ' . $wh . 'px"/></span>' . (($showTitle) ? '<span class="attach-title">' . $title . '</span>' : '') . '</a>';
$fileTyp = '<img src="' . $image . '" id="' . $id . '_image" title="' . $title . '" alt="' . $title . '" height="' . $wh . '" width="' . $wh . '" class="small-image-preview v-middle" style="width: ' . $wh . 'px; height: ' . $wh . 'px"/>';
} else if ($ext == 'txt' || $ext == 'rtf' || $ext == 'csv' || $ext == 'css' || $ext == 'htm' || $ext == 'html' || $ext == 'xml' || $ext == 'doc' || $ext == 'docx' || $ext == 'xls' || $ext == 'xlsx' || $ext == 'ppt' || $ext == 'pdf' || $ext == 'swf' || $ext == 'flv' || $ext == 'zip') {
$url = $this->getDownloadFileUrl($url, $disposition);
$html = '<a class="prod-attach" target="_blank" title="' . $title . '" href="' . $url . '">' . $mediaIconImage . '</a> ';
$fileTyp = $mediaIconImage;
} else if ($ext == 'avi') {
$url = $this->getDownloadFileUrl($url, $disposition);
$html = '<a class="prod-attach" target="_blank" title="' . $title . '" href="' . $url . '"><span style="font-weight:bold">' . $mediaIconImage . '</span></a>';
$fileTyp = $mediaIconImage;
} else if ($ext == 'mov') {
$url = $this->getDownloadFileUrl($url, $disposition);
$html = '<a class="prod-attach" target="_blank" title="' . $title . '"href="' . $url . '"><span style="font-weight:bold">' . $mediaIconImage . '</span></a>';
$fileTyp = $mediaIconImage;
} else if ($ext == 'wmv' || $ext == 'wav' || $ext == 'mp3') {
$url = $this->getDownloadFileUrl($url, $disposition);
$html = '<a class="prod-attach" target="_blank" title="' . $title . '" href="' . $url . '"><span style="font-weight:bold">' . $mediaIconImage . '</span></a>';
$fileTyp = $mediaIconImage;
} else {
$mediaIcon = Mage::getBaseUrl('media') . '/custom/upload/icons/plain.png';
$mediaIconImage = '<span class="attach-img"><img src="' . $mediaIcon . '" alt="View File" style="margin-right: 5px;"/></span>' . (($showTitle) ? '<span class="attach-title">' . $title . '</span>' : '');
$url = $this->getDownloadFileUrl($url, $disposition);
$html = '<a class="prod-attach" target="_blank" title="' . $title . '" href="' . $url . '">' . $mediaIconImage . '</a> ';
$mediaIcon = Mage::getBaseUrl('media') . 'custom/upload/icons/plain.png';
$mediaIconImage = '<img src="' . $mediaIcon . '" alt="View File">';
$fileTyp = $mediaIconImage;
}
}
return $html . $fileSize;
return $fileTyp;
}

public function getVersionLow() {
Expand Down
2 changes: 1 addition & 1 deletion app/code/community/Uni/Fileuploader/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<config>
<modules>
<Uni_Fileuploader>
<version>0.2.6</version>
<version>0.2.7</version>
</Uni_Fileuploader>
</modules>
<frontend>
Expand Down
15 changes: 5 additions & 10 deletions app/design/frontend/base/default/layout/fileuploader.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,11 @@
-->
<layout version="0.1.0">
<catalog_product_view>
<reference name="head">
<action method="addJs">
<script>fileuploader/filepop.js</script>
</action>
</reference>
<reference name="content">
<reference name="product.description">
<action method="setTemplate"><template>fileuploader/fileuploader.phtml</template></action>
<block type="fileuploader/fileuploader" name="product.attachments" template="fileuploader/desc_attachments.phtml"/>
<reference name="content">
<reference name="product.info">
<block type="fileuploader/fileuploader" name="product.attachments" as="attachments"
template="fileuploader/desc_attachments.phtml" />
</reference>
</reference>
</catalog_product_view>
</layout>
</layout>
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,34 @@
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
-->
<style type="text/css">
div.attachment-specs td.label a.prod-attach{text-decoration: none; cursor: pointer;}
div.attachment-specs td.label span.attach-img{float: left;}
div.attachment-specs td.label span.attach-title{float: left; text-decoration: underline;}
</style>
<?php
$_product = Mage::registry('current_product');
$attachments = $this->getProductAttachments($_product->getId());
$_description = $_product->getDescription();
$version = substr(Mage::getVersion(), 0, 3);
if (count($attachments) > 0):
?>
<?php if ($_description && $version != '1.4'): ?></div><?php endif; ?>
<div class="collateral-box box-collateral box-attachments">
<?php if ($version == '1.3'): ?>
<div class="head">
<h4><?php echo $this->__('Product Attachments') ?></h4>
</div>
<?php else: ?>
<h2><?php echo $this->__('Product Attachments') ?></h2>
<?php endif; ?>
<div class="collateral-box attachment-specs">
<table cellspacing="0" id="product-attachment-specs-table" class="data-table">
<tbody>
<?php foreach ($attachments as $attachment): ?>
<tr>
<td class="label"><?php echo $attachment['file']; ?></td>
<td class="data"><?php echo $attachment['content']; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<script type="text/javascript">decorateTable('product-attachment-specs-table')</script>
</div>
<?php if (($_description == null) || $version == '1.4'): ?></div><?php endif; ?>
<h2><?php echo $this->__('Product Attachments') ?></h2>
<div class="box-collateral">
<table class="product-attachments">
<thead>
<tr>
<th><?php echo $this->__('Name') ?></th>
<th width="400"><?php echo $this->__('Description') ?></th>
<th><?php echo $this->__('Typ') ?></th>
<th><?php echo $this->__('Size') ?></th>
<th><?php echo $this->__('Download Link') ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($attachments as $attachment): ?>
<tr>
<td class="name"><?php echo $attachment['name']; ?></td>
<td><?php echo $attachment['desc']; ?></td>
<td><?php echo $attachment['typ']; ?></td>
<td><?php echo $attachment['size']; ?></td>
<td><?php echo $attachment['link']; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php endif; ?>
34 changes: 34 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "mawoscha/unicode-fileuploader",
"type": "magento-module",
"license": "",
"description": "",
"authors":[
{
"name":"Unicode Systems"
},
{
"name":"MaWoScha"
}
],
"homepage": "http://www.magentocommerce.com/magento-connect/product-attachments-extension.html",
"require": {
"magento-hackathon/magento-composer-installer": "*"
},
"extra": {
"magento-force": "override",
"map": [
["app/design/adminhtml/default/default/layout/*", "app/design/adminhtml/default/default/layout/"],
["app/design/adminhtml/default/default/template/*", "app/design/adminhtml/default/default/template/"],
["app/design/frontend/base/default/layout/*", "app/design/frontend/base/default/layout/"],
["app/design/frontend/base/default/template/*", "app/design/frontend/base/default/template/"],
["app/code/community/Uni/Common/*", "app/code/community/Uni/Common/"],
["app/code/community/Uni/Fileuploader/*", "app/code/community/Uni/Fileuploader/"],
["app/etc/modules/*", "app/etc/modules/"],
["js/fileuploader/*", "js/fileuploader/"],
["lib/Varien/Data/Form/Element/*", "lib/Varien/Data/Form/Element/"],
["media/custom/upload/icons/*", "media/custom/upload/icons/"],
["media/custom/upload/player/*", "media/custom/upload/player/"]
]
}
}
8 changes: 8 additions & 0 deletions modman
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
app/design/adminhtml/default/default/layout/* app/design/adminhtml/default/default/layout/
app/design/adminhtml/default/default/template/* app/design/adminhtml/default/default/template/
app/design/frontend/base/default/template/* app/design/frontend/community/default/template/
app/code/community/Uni/Common/* app/code/community/Uni/Common/
app/code/community/Uni/Fileuploader/* app/code/community/Uni/Fileuploader/
app/etc/modules/* app/etc/modules/
js/fileuploader/* js/fileuploader/
lib/Varien/Data/Form/Element/* lib/Varien/Data/Form/Element/
7 changes: 5 additions & 2 deletions var/connect/Unicode_FileUploader.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<description>Product Attachments extension provides uploading of multiple audio (QuickTime), video, pdf, and many other files and download or view these files on product page using content-disposition property. Supported extensions &quot;jpg&quot;, &quot;jpeg&quot;, &quot;gif&quot;, &quot;png&quot;, &quot;bmp&quot;, &quot;txt&quot;, &quot;csv&quot;, &quot;htm&quot;, &quot;html&quot;, &quot;xml&quot;, &quot;css&quot;, &quot;doc&quot;, &quot;docx&quot;, &quot;xls&quot;, &quot;rtf&quot;, &quot;ppt&quot;, &quot;pdf&quot;, &quot;swf&quot;, &quot;flv&quot;, &quot;avi&quot;, &quot;wmv&quot;, &quot;mov&quot;, &quot;wav&quot;, &quot;mp3&quot;, &quot;zip&quot; and many more.</description>
<license>GPL</license>
<license_uri>http://www.gnu.org/copyleft/gpl.html</license_uri>
<version>0.2.6</version>
<version>0.2.7</version>
<stability>stable</stability>
<notes>Original version from Unicode: 0.2.1

Expand Down Expand Up @@ -39,7 +39,10 @@ Version 0.2.5
* Updated Admin Routing to make this module compatible with Patch SUPEE-6788

Version 0.2.6
* Add function "_isAllowed()" to "app/code/community/Uni/Fileuploader/controllers/Adminhtml/FileuploaderController.php"</notes>
* Add function "_isAllowed()" to "app/code/community/Uni/Fileuploader/controllers/Adminhtml/FileuploaderController.php"

Version 0.2.7
* Enhance Template</notes>
<authors>
<name>
<name>Unicode Systems</name>
Expand Down

0 comments on commit 4f2751f

Please sign in to comment.