diff --git a/README.md b/README.md index 0927427..e199e38 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/app/code/community/Uni/Fileuploader/Block/Fileuploader.php b/app/code/community/Uni/Fileuploader/Block/Fileuploader.php index d26fef3..ba3ec82 100644 --- a/app/code/community/Uni/Fileuploader/Block/Fileuploader.php +++ b/app/code/community/Uni/Fileuploader/Block/Fileuploader.php @@ -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; diff --git a/app/code/community/Uni/Fileuploader/Helper/Data.php b/app/code/community/Uni/Fileuploader/Helper/Data.php index 9f7fd66..51bf350 100644 --- a/app/code/community/Uni/Fileuploader/Helper/Data.php +++ b/app/code/community/Uni/Fileuploader/Helper/Data.php @@ -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 = ''.$this->__('Download').''; + + 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 = 'View File' . (($showTitle) ? '' . $title . '' : ''); + $mediaIcon = Mage::getBaseUrl('media') . 'custom/upload/icons/' . $ext . '.png'; + $mediaIconImage = '' . $ext . ''; $wh = ($showTitle) ? '16' : '22'; - if ($size) { - $file = $this->updateDirSepereator($url); - $mediaDir = Mage::getBaseDir('media'); - $filePath = $mediaDir . DS . $file; - if (file_exists($filePath)) - $fileSize = '   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 = '' . $title . '' . (($showTitle) ? '' . $title . '' : '') . ''; + $fileTyp = '' . $title . ''; } 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 = '' . $mediaIconImage . ' '; + $fileTyp = $mediaIconImage; } else if ($ext == 'avi') { - $url = $mediaUrl . $url; - $onclick = "javascript:playerAviOpen('" . $title . "',this.rel); return false;"; - $onmouseover = "window.status=''; return true;"; - $html = '' . $mediaIconImage . ''; + $fileTyp = $mediaIconImage; } else if ($ext == 'flv') { - $url = $mediaUrl . $url; - $onclick = "javascript:playerFlvOpen('" . $title . "',this.rel,'" . $playerPath . "'); return false;"; - $onmouseover = "window.status=''; return true;"; - $html = '' . $mediaIconImage . ''; + $fileTyp = $mediaIconImage; } else if ($ext == 'mov') { - $url = $mediaUrl . $url; - $onclick = "javascript:playerMovOpen('" . $title . "',this.rel); return false;"; - $onmouseover = "window.status=''; return true;"; - $html = '' . $mediaIconImage . ''; + $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 = '' . $mediaIconImage . ''; + $fileTyp = $mediaIconImage; } else { - $mediaIcon = Mage::getBaseUrl('media') . '/custom/upload/icons/plain.png'; - $mediaIconImage = 'View File' . (($showTitle) ? '' . $title . '' : ''); - $url = $this->getDownloadFileUrl($url, $disposition); - $onclick = "return fileUploaderPopup.open({url:this.rel, title: '" . str_replace(' ', '_', $title) . "'});"; - $html = '' . $mediaIconImage . ' '; + $mediaIcon = Mage::getBaseUrl('media') . 'custom/upload/icons/plain.png'; + $mediaIconImage = '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 = '' . $title . '' . (($showTitle) ? '' . $title . '' : '') . ''; + $fileTyp = '' . $title . ''; } 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 = '' . $mediaIconImage . ' '; + $fileTyp = $mediaIconImage; } else if ($ext == 'avi') { - $url = $this->getDownloadFileUrl($url, $disposition); - $html = '' . $mediaIconImage . ''; + $fileTyp = $mediaIconImage; } else if ($ext == 'mov') { - $url = $this->getDownloadFileUrl($url, $disposition); - $html = '' . $mediaIconImage . ''; + $fileTyp = $mediaIconImage; } else if ($ext == 'wmv' || $ext == 'wav' || $ext == 'mp3') { - $url = $this->getDownloadFileUrl($url, $disposition); - $html = '' . $mediaIconImage . ''; + $fileTyp = $mediaIconImage; } else { - $mediaIcon = Mage::getBaseUrl('media') . '/custom/upload/icons/plain.png'; - $mediaIconImage = 'View File' . (($showTitle) ? '' . $title . '' : ''); - $url = $this->getDownloadFileUrl($url, $disposition); - $html = '' . $mediaIconImage . ' '; + $mediaIcon = Mage::getBaseUrl('media') . 'custom/upload/icons/plain.png'; + $mediaIconImage = 'View File'; + $fileTyp = $mediaIconImage; } } - return $html . $fileSize; + return $fileTyp; } public function getVersionLow() { diff --git a/app/code/community/Uni/Fileuploader/etc/config.xml b/app/code/community/Uni/Fileuploader/etc/config.xml index 3218a54..ca916d9 100644 --- a/app/code/community/Uni/Fileuploader/etc/config.xml +++ b/app/code/community/Uni/Fileuploader/etc/config.xml @@ -11,7 +11,7 @@ - 0.2.6 + 0.2.7 diff --git a/app/design/frontend/base/default/layout/fileuploader.xml b/app/design/frontend/base/default/layout/fileuploader.xml index 498bfde..5490328 100644 --- a/app/design/frontend/base/default/layout/fileuploader.xml +++ b/app/design/frontend/base/default/layout/fileuploader.xml @@ -10,16 +10,11 @@ --> - - - - - - - - - + + + - \ No newline at end of file + diff --git a/app/design/frontend/base/default/template/fileuploader/desc_attachments.phtml b/app/design/frontend/base/default/template/fileuploader/desc_attachments.phtml index 8bc6b40..3dd8c81 100644 --- a/app/design/frontend/base/default/template/fileuploader/desc_attachments.phtml +++ b/app/design/frontend/base/default/template/fileuploader/desc_attachments.phtml @@ -7,39 +7,34 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> - getProductAttachments($_product->getId()); -$_description = $_product->getDescription(); -$version = substr(Mage::getVersion(), 0, 3); if (count($attachments) > 0): ?> - -
- -
-

__('Product Attachments') ?>

-
- -

__('Product Attachments') ?>

- -
- - - - - - - - - -
- -
-
+

__('Product Attachments') ?>

+
+ + + + + + + + + + + + + + + + + + + + + +
__('Name') ?>__('Description') ?>__('Typ') ?>__('Size') ?>__('Download Link') ?>
+
\ No newline at end of file diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..8329f58 --- /dev/null +++ b/composer.json @@ -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/"] + ] + } +} diff --git a/modman b/modman new file mode 100644 index 0000000..97ad349 --- /dev/null +++ b/modman @@ -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/ diff --git a/var/connect/Unicode_FileUploader.xml b/var/connect/Unicode_FileUploader.xml index 50e8d47..c903b0b 100644 --- a/var/connect/Unicode_FileUploader.xml +++ b/var/connect/Unicode_FileUploader.xml @@ -10,7 +10,7 @@ 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 "jpg", "jpeg", "gif", "png", "bmp", "txt", "csv", "htm", "html", "xml", "css", "doc", "docx", "xls", "rtf", "ppt", "pdf", "swf", "flv", "avi", "wmv", "mov", "wav", "mp3", "zip" and many more. GPL http://www.gnu.org/copyleft/gpl.html - 0.2.6 + 0.2.7 stable Original version from Unicode: 0.2.1 @@ -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" +* Add function "_isAllowed()" to "app/code/community/Uni/Fileuploader/controllers/Adminhtml/FileuploaderController.php" + +Version 0.2.7 +* Enhance Template Unicode Systems