Joachim Werner avatar Joachim Werner committed 0002d4e

Added missing assets (filetype icons)
DDMediaFile: Added legacy function mime_content_type

Comments (0)

Files changed (32)

 *.swo
 *.out
 moveItem.txt
-assets/*
 protected/config/db.ini
 protected/config/main-local.php
 protected/config/console-local.php
 protected/data/users/*
 lib/PEAR*
 protected/runtime/*
+*.php.merged
 # Directories
 files/*/
 runtime/gii-*
     public $logTag = 'application.modules.media';
 
     public $baseDir;
+    
+    // getAssetsUrl()
+    //    return the URL for this module's assets, performing the publish operation
+    //    the first time, and caching the result for subsequent use.
+    private $_assetsUrl;
+ 
     // }}} 
     // {{{ *** Methods ***
     // {{{ init
         )));
         
 	} // }}} 
+    public function getAssetsUrl()
+    {
+        if ($this->_assetsUrl === null)
+            $this->_assetsUrl = Yii::app()->getAssetManager()->publish(
+                Yii::getPathOfAlias('media.assets') );
+        return $this->_assetsUrl;
+    }
     // {{{ beforeControllerAction
 	public function beforeControllerAction($controller, $action)
 	{
Add a comment to this file

assets/filetypeicons/compressed.png

Added
New image
Add a comment to this file

assets/filetypeicons/css.png

Added
New image
Add a comment to this file

assets/filetypeicons/developer.png

Added
New image
Add a comment to this file

assets/filetypeicons/excel.png

Added
New image
Add a comment to this file

assets/filetypeicons/fileicon_bg.png

Added
New image
Add a comment to this file

assets/filetypeicons/fireworks.png

Added
New image
Add a comment to this file

assets/filetypeicons/flash.png

Added
New image
Add a comment to this file

assets/filetypeicons/folder.png

Added
New image
Add a comment to this file

assets/filetypeicons/html.png

Added
New image
Add a comment to this file

assets/filetypeicons/illustrator.png

Added
New image
Add a comment to this file

assets/filetypeicons/image.png

Added
New image
Add a comment to this file

assets/filetypeicons/keynote.png

Added
New image
Add a comment to this file

assets/filetypeicons/movie.png

Added
New image
Add a comment to this file

assets/filetypeicons/music.png

Added
New image
Add a comment to this file

assets/filetypeicons/numbers.png

Added
New image
Add a comment to this file

assets/filetypeicons/pages.png

Added
New image
Add a comment to this file

assets/filetypeicons/pdf.png

Added
New image
Add a comment to this file

assets/filetypeicons/photoshop.png

Added
New image
Add a comment to this file

assets/filetypeicons/powerpoint.png

Added
New image
Add a comment to this file

assets/filetypeicons/text.png

Added
New image
Add a comment to this file

assets/filetypeicons/word.png

Added
New image

config/messages.php

 return array(
     'sourcePath' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '..',  //root dir of all source
     'messagePath' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'messages',  //root dir of message translations
-    'languages'  => array('de',),  //array of lang codes to translate to, e.g. es_mx
+    'languages'  => array('en_us', 'de',),  //array of lang codes to translate to, e.g. es_mx
     'fileTypes' => array('php','js',), //array of extensions no dot all others excluded
     'exclude' => array( //list of paths or files to exclude
         '.svn',

controllers/DefaultController.php

         // $basePath = DDMediaDirectory::pathToUnix(realpath(Yii::app()->basePath.'/../files'));
         // Get base path from module settings
         $basePath = DDMediaDirectory::pathToUnix(realpath($this->module->baseDir));
+        // DEBUG echo "<li>basePath: $basePath";
         /*
         if(!is_dir($basePath))
             throw new CHttpException(500, 'Directory '.$basePath.' is not a valid directory');
         $defaultPath = '.';
         $path = isset($_GET['p']) ? urldecode($_GET['p']) : '.';
         $currentPath = DDMediaDirectory::pathToUnix(realpath($basePath.'/'.$path));
+        // DEBUG echo "<li>currentPath: $currentPath";
         if($currentPath==$basePath) {
             if(isset($_GET['p']))
                 Yii::app()->user->setFlash('error',"Can't change above base dir $basePath/$defaultPath");
         } else {
             $path = str_replace($basePath.'/','',$currentPath);
         }
+        // DEBUG echo "<li>path: $path";
         $currentPath = DDMediaDirectory::pathToUnix(realpath($basePath.'/'.$path.'/'));
         if(!isset($_POST['DDMediaAction'])) {
             $mediaAction->name=' ';
             // No image
             if(preg_match("/\.([^\.]+)$/",$image,$matches)){
                 $extension = $matches[1];
-                $extensionIcon = 'images/filetypeicons/'.$extension.'.png';
+                $iconPath = dirname(__FILE__).'/../../../../'.str_replace(Yii::app()->baseUrl.'/', '',$this->module->assetsUrl).'/filetypeicons';
+                $extensionIcon = $iconPath.'/'.$extension.'.png';
                 if(!file_exists($extensionIcon))
-                    $extensionIcon='images/filetypeicons/unknown.png';
+                    $extensionIcon=$iconPath.'/fileicon_bg.png';
                 header('Content-Type: image/png');
                 readfile($extensionIcon);
                 die;

messages/de/main.php.merged

-<?php
-/**
- * Message translations.
- *
- * This file is automatically generated by 'yiic message' command.
- * It contains the localizable messages extracted from source code.
- * You may modify this file by translating the extracted messages.
- *
- * Each array element represents the translation (value) of a message (key).
- * If the value is empty, the message is considered as not translated.
- * Messages that no longer need translation will have their translations
- * enclosed between a pair of '@@' marks.
- *
- * Message string can be used with plural forms format. Check i18n section
- * of the guide for details.
- *
- * NOTE, this file must be saved in UTF-8 encoding.
- *
- * @version $Id: $
- */
-return array (
-  'Create' => 'Anlegen',
-  'Delete' => 'Löschen',
-  'Destination' => 'Ziel',
-  'File to delete' => 'Zu löschende Datei',
-  'Move' => 'Verschieben',
-  'New Directory' => 'Neues Verzeichnis',
-  'New Name' => 'Neuer Name',
-  'Rename' => 'Umbenennen',
-  'Upload' => 'Hochladen',
-  'Action' => 'Aktion',
-  'Base Path' => 'Basis-Pfad',
-  'Confirm to delete this item:' => 'Bestätigen Sie das Löschen dieses Objekts',
-  'Create New Dir' => 'Neues Verzeichnis anlegen',
-  'Date' => 'Datum',
-  'Delete directory {dir}' => 'Verzeichnis {dir} löschen',
-  'Delete file {file}' => 'Datei {file} löschen',
-  'Directory' => 'Verzeichnis',
-  'Enter the name for the new directory:' => 'Geben Sie den Namen für das neue Verzeichnis ein:',
-  'Enter the new location:' => 'Geben Sie den neuen Ort ein:',
-  'Enter the new name:' => 'Geben Sie den neuen Namen ein:',
-  'Icon' => 'Icon',
-  'IconDelete' => 'X',
-  'IconMove' => 'V',
-  'IconRename' => 'U',
-  'Media Browser' => 'Media-Browser',
-  'Media Type' => 'Medien-Typ',
-  'Move directory {dir}' => 'Verzeichnis {dir} verschieben',
-  'Move file {file} to another location' => 'Datei {file} an einen anderen Ort verschieben',
-  'Name' => 'Name',
-  'Old Name' => 'Bisheriger Name',
-  'Parameter 1' => 'Parameter 1',
-  'Path' => 'Pfad',
-  'Rename directory {dir}' => 'Verzeichnis {dir} umbenennen',
-  'Rename file {file}' => 'Datei {file} umbenennen',
-  'Select a file to be uploaded:' => 'Wählen Sie eine Datei zum Hochladen aus:',
-  'Size' => 'Größe',
-  'The directory <em>{p1}</em> has been created.' => 'Das Verzeichnis <em>{p1}</em> wurde angelegt.',
-  'The file <em>{name}</em> has been uploaded.' => 'Die Datei <em>{p1}</em> wurde hochgeladen.',
-  'The {mediaType} <em>{name}</em> has been deleted.' => '{mediaType} <em>{name}</em> wurde gelöscht.',
-  'The {mediaType} <em>{name}</em> has been moved to <em>{path}/{p1}</em>.' => '{mediaType} <em>{name}</em> wurde verschoben nach <em>{path}/{p1}</em>.',
-  'The {mediaType} <em>{name}</em> has been renamed to <em>{p1}</em>.' => '{mediaType} <em>{name}</em> wurde umbenannt nach <em>{p1}</em>.',
-  'Type' => 'Typ',
-  'Upload File' => 'Datei hochladen',
-  'directory' => 'Verzeichnis',
-  'file' => 'Datei',
-);

messages/en-us/main.php

-<?php
-/**
- * Message translations.
- *
- * This file is automatically generated by 'yiic message' command.
- * It contains the localizable messages extracted from source code.
- * You may modify this file by translating the extracted messages.
- *
- * Each array element represents the translation (value) of a message (key).
- * If the value is empty, the message is considered as not translated.
- * Messages that no longer need translation will have their translations
- * enclosed between a pair of '@@' marks.
- *
- * Message string can be used with plural forms format. Check i18n section
- * of the guide for details.
- *
- * NOTE, this file must be saved in UTF-8 encoding.
- *
- * @version $Id: $
- */
-return array (
-  'Action' => 'Aktion',
-  'Base Path' => 'Basis-Pfad',
-  'Date' => 'Datum',
-  'Icon' => 'Icon',
-  'IconDelete' => 'X',
-  'IconMove' => 'V',
-  'IconMoveM' => '',
-  'IconRename' => 'U',
-  'Name' => 'Name',
-  'Rename file {file}' => 'Datei {file} umbenennen',
-  'Size' => 'Größe',
-  'Type' => 'Typ',
-  'Media Browser' => 'Media-Browser',
-  'The directory <em>{p1}</em> has been created.' => 'Das Verzeichnis <em>{p1}</em> wurde angelegt.',
-  'The file <em>{name}</em> has been uploaded.' => 'Die Datei <em>{p1}</em> wurde hochgeladen.',
-  'The {mediaType} <em>{name}</em> has been deleted.' => '{mediaType} <em>{name}</em> wurde gelöscht.',
-  'The {mediaType} <em>{name}</em> has been moved to <em>{path}/{p1}</em>.' => '{mediaType} <em>{name}</em> wurde verschoben nach <em>{path}/{p1}</em>.',
-  'The {mediaType} <em>{name}</em> has been renamed to <em>{p1}</em>.' => '{mediaType} <em>{name}</em> wurde umbenannt nach <em>{p1}</em>.',
-);

messages/en-us/main.php.merged

-<?php
-/**
- * Message translations.
- *
- * This file is automatically generated by 'yiic message' command.
- * It contains the localizable messages extracted from source code.
- * You may modify this file by translating the extracted messages.
- *
- * Each array element represents the translation (value) of a message (key).
- * If the value is empty, the message is considered as not translated.
- * Messages that no longer need translation will have their translations
- * enclosed between a pair of '@@' marks.
- *
- * Message string can be used with plural forms format. Check i18n section
- * of the guide for details.
- *
- * NOTE, this file must be saved in UTF-8 encoding.
- *
- * @version $Id: $
- */
-return array (
-  'Delete File {file}' => 'Datei {file} löschen',
-  'Move file {file} to another location' => 'Datei {file} an einen anderen Ort verschieben',
-  'Action' => 'Aktion',
-  'Base Path' => 'Basis-Pfad',
-  'Date' => 'Datum',
-  'Icon' => 'Icon',
-  'IconDelete' => 'X',
-  'IconMove' => 'V',
-  'IconRename' => 'U',
-  'Media Browser' => 'Media-Browser',
-  'Name' => 'Name',
-  'Rename file {file}' => 'Datei {file} umbenennen',
-  'Size' => 'Größe',
-  'The directory <em>{p1}</em> has been created.' => 'Das Verzeichnis <em>{p1}</em> wurde angelegt.',
-  'The file <em>{name}</em> has been uploaded.' => 'Die Datei <em>{p1}</em> wurde hochgeladen.',
-  'The {mediaType} <em>{name}</em> has been deleted.' => '{mediaType} <em>{name}</em> wurde gelöscht.',
-  'The {mediaType} <em>{name}</em> has been moved to <em>{path}/{p1}</em>.' => '{mediaType} <em>{name}</em> wurde verschoben nach <em>{path}/{p1}</em>.',
-  'The {mediaType} <em>{name}</em> has been renamed to <em>{p1}</em>.' => '{mediaType} <em>{name}</em> wurde umbenannt nach <em>{p1}</em>.',
-  'Type' => 'Typ',
-);

messages/en-us/site.php

-<?php
-/**
- * Message translations.
- *
- * This file is automatically generated by 'yiic message' command.
- * It contains the localizable messages extracted from source code.
- * You may modify this file by translating the extracted messages.
- *
- * Each array element represents the translation (value) of a message (key).
- * If the value is empty, the message is considered as not translated.
- * Messages that no longer need translation will have their translations
- * enclosed between a pair of '@@' marks.
- *
- * Message string can be used with plural forms format. Check i18n section
- * of the guide for details.
- *
- * NOTE, this file must be saved in UTF-8 encoding.
- *
- * @version $Id: $
- */
-return array (
-  'The directory <em>{p1}</em> has been created.' => '',
-  'The file <em>{name}</em> has been uploaded.' => '',
-  'The {mediaType} <em>{name}</em> has been deleted.' => '',
-  'The {mediaType} <em>{name}</em> has been moved to <em>{path}/{p1}</em>.' => '',
-  'The {mediaType} <em>{name}</em> has been renamed to <em>{p1}</em>.' => '',
-);

messages/en/main.php

+<?php
+/**
+ * Message translations.
+ *
+ * This file is automatically generated by 'yiic message' command.
+ * It contains the localizable messages extracted from source code.
+ * You may modify this file by translating the extracted messages.
+ *
+ * Each array element represents the translation (value) of a message (key).
+ * If the value is empty, the message is considered as not translated.
+ * Messages that no longer need translation will have their translations
+ * enclosed between a pair of '@@' marks.
+ *
+ * Message string can be used with plural forms format. Check i18n section
+ * of the guide for details.
+ *
+ * NOTE, this file must be saved in UTF-8 encoding.
+ *
+ * @version $Id: $
+ */
+return array (
+  'Action' => '',
+  'Base Path' => '',
+  'Confirm to delete this item:' => '',
+  'Copy' => '',
+  'Copy directory {dir}' => '',
+  'Copy file {file}' => '',
+  'Create' => '',
+  'Create New Dir' => '',
+  'Date' => '',
+  'Delete' => '',
+  'Delete directory {dir}' => '',
+  'Delete file {file}' => '',
+  'Destination' => '',
+  'Directory' => '',
+  'Enter the name for the new directory:' => '',
+  'Enter the new destination and name:' => '',
+  'Enter the new location:' => '',
+  'Enter the new name:' => '',
+  'File to delete' => '',
+  'Icon' => '',
+  'IconCopy' => 'C',
+  'IconDelete' => 'X',
+  'IconMove' => 'M',
+  'IconRename' => 'R',
+  'Item: ' => '',
+  'Media Browser' => '',
+  'Media Type' => '',
+  'Move' => '',
+  'Move directory {dir}' => '',
+  'Move file {file} to another location' => '',
+  'Name' => '',
+  'New Dest. and Name' => '',
+  'New Directory' => '',
+  'New Name' => '',
+  'Old Name' => '',
+  'Parameter 1' => '',
+  'Path' => '',
+  'Rename' => '',
+  'Rename directory {dir}' => '',
+  'Rename file {file}' => '',
+  'Select a file to be uploaded:' => '',
+  'Size' => '',
+  'The directory <em>{p1}</em> has been created.' => '',
+  'The file <em>{oldName}</em> has been uploaded as <em>{name}</em>.' => '',
+  'The {mediaType} <em>{name}</em> has been copied to <em>{p1}</em>.' => '',
+  'The {mediaType} <em>{name}</em> has been deleted.' => '',
+  'The {mediaType} <em>{name}</em> has been moved to <em>{path}/{p1}</em>.' => '',
+  'The {mediaType} <em>{name}</em> has been renamed to <em>{p1}</em>.' => '',
+  'Type' => '',
+  'Upload' => '',
+  'Upload File' => '',
+  'directory' => '',
+  'file' => '',
+);

models/DDMediaFile.php

     } // }}} 
     // }}} End Methods
 }
+if(!function_exists('mime_content_type')) {
+    function mime_content_type($filename)
+    {
+        if(!is_file($filename))
+            return false;
+        $finfo = new finfo(FILEINFO_MIME);
+        $mime_type = $finfo->file($finfo, $filename);
+        finfo_close($finfo);
+
+        return $mime_type;
+    }
+}

views/default/index.php

         <?php foreach($files['dirs'] as $dirPath=>$stats) : ?>
         <?php /* $onclick=""; if(!in_array($stats['name'],array('.', '..'))) */ $onclick=' onclick="selectMedia(\'directory\',\''.$dirPath.'\',\''.$stats['name'].'\');"'; ?>
         <tr class="dirsFilesRows"<?php echo $onclick; ?>>
-            <td class="folder"><?php echo CHtml::image(Yii::app()->baseUrl.'/images/filetypeicons/folder.png',$stats['name']); ?></td>
+            <td class="folder"><?php echo CHtml::image($this->module->assetsUrl.'/filetypeicons/folder.png',$stats['name']); ?></td>
             <td><?php echo CHtml::link($stats['name'],array('index','p'=>urlencode($path.'/'.$stats['name']))); ?></td>
             <td>&ndash;</td>
             <td><?php echo CHtml::encode(Yii::t('main','Directory')); ?></td>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.