Commits

Joachim Werner committed b8c76e5 Merge with conflicts

Merge branch 'master' of http://bitbucket.org/jwerner/yii-ddmedia into develop

Conflicts:
README.md
controllers/DefaultController.php
messages/de/main.php
models/DDMediaAction.php
views/default/index.php

Changed path selector dropdowns t a widget (to be re-usable later on?)

models: Added 'static' keyword to methods

Comments (0)

Files changed (11)

     public $logTag = 'application.modules.media';
 
     public $baseDir;
+
+    public $tableCssClass;
     
     // getAssetsUrl()
     //    return the URL for this module's assets, performing the publish operation
 [php]
 return array(
     ...
-    'media'=>array(
-        // Base dir for media browser (app/files):
-        'baseDir'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'files',
-    ),
-    ...
+    'modules'=>array(
+        'media'=>array(
+            // Base dir for media browser (app/files):
+            'baseDir'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'files',
+        ),
+        ...
+    ),
+    ....
 );
 ~~~
 ***protected/config/main.php***
 # To Do's
 
 * Show media meta data on clicking an item in a sidebar widget
-* Allow to select multiple items and do batch actions with them
 * Add config option to hide/show hidden files or folders
-

controllers/DefaultController.php

             if($mediaAction->validate()) {
                 $result = $mediaAction->doAction();
                 if($result==true) {
-                    $mediaAction->mediaType = $mediaAction->mediaType=='directory' ? Yii::t('main', 'directory') : Yii::t('main', 'file');
+                    $mediaAction->mediaType = $mediaAction->mediaType=='directory' ? Yii::t('MediaModule.main', 'directory') : Yii::t('MediaModule.main', 'file');
                     switch($mediaAction->action)
                     {
                         case 'rename':
-                            Yii::app()->user->setFlash('success',Yii::t('main','The {mediaType} <em>{name}</em> has been renamed to <em>{p1}</em>.',array('{mediaType}'=>$mediaAction->mediaType,'{name}'=>$mediaAction->selectedItemsOld,'{p1}'=>$mediaAction->p1)));
+                            Yii::app()->user->setFlash('success',Yii::t('MediaModule.main','The {mediaType} <em>{name}</em> has been renamed to <em>{p1}</em>.',array('{mediaType}'=>$mediaAction->mediaType,'{name}'=>$mediaAction->selectedItemsOld,'{p1}'=>$mediaAction->p1)));
                             break;
                         case 'copy':
-                            Yii::app()->user->setFlash('success',Yii::t('main','The {mediaType} <em>{name}</em> has been copied to <em>{p1}</em>.',array('{mediaType}'=>$mediaAction->mediaType,'{name}'=>$mediaAction->selectedItemsOld,'{p1}'=>$mediaAction->p1)));
+                            Yii::app()->user->setFlash('success',Yii::t('MediaModule.main','The {mediaType} <em>{name}</em> has been copied to <em>{p1}</em>.',array('{mediaType}'=>$mediaAction->mediaType,'{name}'=>$mediaAction->selectedItemsOld,'{p1}'=>$mediaAction->p1)));
                             break;
                         case 'delete':
-                            Yii::app()->user->setFlash('success',Yii::t('main','The {mediaType} <em>{name}</em> has been deleted.',array('{mediaType}'=>$mediaAction->mediaType,'{name}'=>$mediaAction->selectedItemsOld)));
+                            Yii::app()->user->setFlash('success',Yii::t('MediaModule.main','The {mediaType} <em>{name}</em> has been deleted.',array('{mediaType}'=>$mediaAction->mediaType,'{name}'=>$mediaAction->selectedItemsOld)));
                             break;
                         case 'move':
-                            Yii::app()->user->setFlash('success',Yii::t('main','The {mediaType} <em>{name}</em> has been moved to <em>{path}/{p1}</em>.',array(
+                            Yii::app()->user->setFlash('success',Yii::t('MediaModule.main','The {mediaType} <em>{name}</em> has been moved to <em>{path}/{p1}</em>.',array(
                                 '{mediaType}'=>$mediaAction->mediaType,
                                 '{name}'=>$mediaAction->selectedItemsOld,
                                 '{path}'=>$mediaAction->path,
                                 '{p1}'=>$mediaAction->p1)));
                             break;
                         case 'upload':
-                            Yii::app()->user->setFlash('success',Yii::t('main','The file <em>{oldName}</em> has been uploaded as <em>{name}</em>.',array('{name}'=>$mediaAction->selectedItems, '{oldName}'=>$mediaAction->selectedItemsOld)));
+                            Yii::app()->user->setFlash('success',Yii::t('MediaModule.main','The file <em>{originalName}</em> has been uploaded as <em>{newName}</em>.',array('{originalName}'=>$mediaAction->selectedItemsOld, '{newName}'=>basename($mediaAction->selectedItems))));
                             break;
                         case 'newdir':
-                            Yii::app()->user->setFlash('success',Yii::t('main','The directory <em>{p1}</em> has been created.',array('{p1}'=>$mediaAction->p1)));
+                            Yii::app()->user->setFlash('success',Yii::t('MediaModule.main','The directory <em>{p1}</em> has been created.',array('{p1}'=>$mediaAction->p1)));
                             break;
                     }
                 } else {
  * of the guide for details.
  *
  * NOTE, this file must be saved in UTF-8 encoding.
- *
- * @version $Id: $
  */
 return array (
-  'Copy' => 'Kopieren',
-  'New Dest. and Name' => 'Neues Ziel und Name',
-  'Selected Items' => 'Ausgewählte Objekte',
-  'Selected Items (old)' => 'Ausgewählte Objekte (vorher)',
-  'The {mediaType} <em>{name}</em> has been copied to <em>{p1}</em>.' => '',
+  'Item: ' => 'Auswahl:',
+  'The file <em>{originalName}</em> has been uploaded as <em>{newName}</em>.' => 'Die Datei <em>{originalName}</em> wurde hochgeladen als <em>{newName}</em>.',
+  'The {mediaType} <em>{name}</em> has been copied to <em>{p1}</em>.' => 'Das Objekt {mediaType} <em>{name}</em> wurde kopiert nach <em>{p1}</em>.',
   '(Batch Action)' => '(Mehrfach-Aktion)',
   'Action' => 'Aktion',
   'Base Path' => 'Basis-Pfad',
+  'C' => 'C',
   'Confirm to delete this item:' => 'Bestätigen Sie das Löschen dieses Objekts:',
+  'Copy' => 'Kopieren',
   'Copy directory {dir}' => 'Verzeichnis {dir} kopieren',
   'Copy file {file}' => 'Datei {dir} kopieren',
   'Create' => 'Anlegen',
   'Enter the new name:' => 'Geben Sie den neuen Namen ein:',
   'File to delete' => 'Zu löschende Datei',
   'Icon' => 'Icon',
-  'IconCopy' => 'C',
-  'IconDelete' => 'X',
-  'IconMove' => 'V',
-  'IconRename' => 'U',
-  'Item: ' => 'Objekt: ',
+  'M' => 'V',
   'Media Browser' => 'Media-Browser',
   'Media Type' => 'Medien-Typ',
   'Move' => 'Verschieben',
   'Move directory {dir}' => 'Verzeichnis {dir} verschieben',
   'Move file {file} to another location' => 'Datei {file} an einen anderen Ort verschieben',
+  'Multiple Selection' => 'Mehrfach-Auswahl',
   'Name' => 'Name',
+  'New Dest. and Name' => 'Neues Ziel und Name',
   'New Directory' => 'Neues Verzeichnis',
   'New Name' => 'Neuer Name',
   'Parameter 1' => 'Parameter 1',
   'Path' => 'Pfad',
+  'R' => 'U',
   'Rename' => 'Umbenennen',
   '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:',
+  'Selected Items' => 'Ausgewählte Objekte',
+  'Selected Items (old)' => 'Ausgewählte Objekte (vorher)',
   'Size' => 'Größe',
   'The directory <em>{p1}</em> has been created.' => 'Das Verzeichnis <em>{p1}</em> wurde angelegt.',
-  'The file <em>{oldName}</em> has been uploaded as <em>{name}</em>.' => 'Die Datei <em>{oldName}</em> wurde hochgeladen als <em>{name}</em>.',
   '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' => 'Hochladen',
   'Upload File' => 'Datei hochladen',
+  'X' => 'X',
   'directory' => 'Verzeichnis',
   'file' => 'Datei',
 );
   'Enter the new name:' => '',
   'File to delete' => '',
   'Icon' => '',
-  'IconCopy' => 'C',
-  'IconDelete' => 'X',
-  'IconMove' => 'M',
-  'IconRename' => 'R',
+  'C' => 'C',
+  'X' => 'X',
+  'M' => 'M',
+  'R' => 'R',
   'Item: ' => '',
   'Media Browser' => '',
   'Media Type' => '',

models/DDMediaAction.php

     public function attributeLabels()
     {
         return array(
-            'path'              => Yii::t('main','Path'),
-            'selectedItems'     => Yii::t('main','Selected Items'),
-            'selectedItemsOld'  => Yii::t('main','Selected Items (old)'),
-            'mediaType'         => Yii::t('main','Media Type'),
-            'action'            => Yii::t('main','Action'),
-            'p1'                => Yii::t('main','Parameter 1'),
-            'uploadedFile'      => Yii::t('main','Upload File'),
+            'path'              => Yii::t('MediaModule.main','Path'),
+            'selectedItems'     => Yii::t('MediaModule.main','Selected Items'),
+            'selectedItemsOld'  => Yii::t('MediaModule.main','Selected Items (old)'),
+            'mediaType'         => Yii::t('MediaModule.main','Media Type'),
+            'action'            => Yii::t('MediaModule.main','Action'),
+            'p1'                => Yii::t('MediaModule.main','Parameter 1'),
+            'uploadedFile'      => Yii::t('MediaModule.main','Upload File'),
         );
     } // }}}
     // {{{ doAction
                 while(is_file($filePathAndName.$add))
                     $add = '.'.(++$i+1);
                 $result = $this->uploadedFile->saveAs($this->path.'/'.basename($fileName).$add);
-                if($this->selectedItemsOld!==basename($fileName).$add)
-                    $this->selectedItems = basename($fileName).$add;
+                $this->selectedItems = $this->path.'/'.basename($fileName).$add;
                 break; // }}} 
             case 'newdir': // {{{ 
                 $newDir = $this->path.'/'.$this->p1;
         return strtoupper(substr(php_uname('s'), 0, 3)) === 'WIN';
     } // }}} 
     // {{{ removes files and non-empty directories
-    public function rrmdir($dir) 
+    public static function rrmdir($dir) 
     {
         echo "<li>dir: ".$dir;
         echo "<li>realpath(dir): ".realpath($dir);

models/DDMediaDirectory.php

 
     } // }}}
     // {{{ getSubDirs
-    public function getSubDirs($dir)
+    public static function getSubDirs($dir, $showHiddenDirs=false)
     {
         if ($handle = opendir($dir)) {
             $dirs =array();
             /* This is the correct way to loop over the directory. */
             while (false !== ($entry = readdir($handle))) {
-                if($entry!=='.' and $entry !=='..' and is_dir($dir.'/'.$entry))
-                    $dirs[] = $entry;
+                if($entry!=='.' and $entry !=='..' and is_dir($dir.'/'.$entry)) {
+                    if(substr($entry,0,1)=='.') {
+                        if($showHiddenDirs==true)
+                            $dirs[] = $entry;
+                    } else {
+                        $dirs[] = $entry;
+                    }
+                }
             }
             sort($dirs);
             return $dirs;
         );
     } // }}}
     // {{{ pathToUnix
-    public function pathToUnix($dir)
+    public static function pathToUnix($dir)
     {
         return str_replace("\\", '/', $dir);
     } // }}} 
     // {{{ pathToWindows
-    public function pathToWindows($dir)
+    public static function pathToWindows($dir)
     {
         return str_replace("/", "\\", $dir);
     } // }}} 
     /**
      *  recursively remove a directory
      */
-    function rrmdir($dir) 
+    public static function rrmdir($dir) 
     {
         if (!is_file($dir)) { 
             $objects = @scandir($dir); 

views/default/index.php

 <style type="text/css">
 <!--
-table.media-dir-nav { width:0; }
-table.media-dir-nav td { padding: 1px; } 
-table.media-items td.folder img { width: 40px; height: 40px; } 
 .datahighlight { background-color: #ffdc87 !important; }
 .datahighlight2 { background-color: #C3D9FF !important; }
 div.ui-dialog form div.simple { margin: 5px 3px 5px 3px; }
     //array('label'=>'Rename','url'=>'javascript:void(0)', 'linkOptions'=>array('onclick'=>"showDialog('rename');")),
     //array('label'=>'Move','url'=>'javascript:void(0)', 'linkOptions'=>array('onclick'=>"showDialog('move');")),
     //array('label'=>'Delete','url'=>'javascript:void(0)', 'linkOptions'=>array('onclick'=>"showDialog('delete');")),
-    array('label'=>Yii::t('main','Create New Dir'),'url'=>'javascript:void(0)', 'linkOptions'=>array('onclick'=>"doShowDialog=true;showDialog('newdir');")),
-    array('label'=>Yii::t('main','Upload File'),'url'=>'javascript:void(0)', 'linkOptions'=>array('onclick'=>"doShowDialog=true;showDialog('upload');")),
+    array('label'=>Yii::t('MediaModule.main','Create New Dir'),'url'=>'javascript:void(0)', 'linkOptions'=>array('onclick'=>"doShowDialog=true;showDialog('newdir');")),
+    array('label'=>Yii::t('MediaModule.main','Upload File'),'url'=>'javascript:void(0)', 'linkOptions'=>array('onclick'=>"doShowDialog=true;showDialog('upload');")),
 );
 ?>
 
-<h1><?php echo CHtml::encode(Yii::t('main', 'Media Browser')); ?></h1>
+<h1><?php echo CHtml::encode(Yii::t('MediaModule.main', 'Media Browser')); ?></h1>
 
 <?php 
 /* DEBUG
 <h2><?php echo str_replace(array($basePath.'/','/'),array('',' / '),$currentPath); ?></h2>
 
 <?php
+/*
 // echo "<li>basePath: $basePath";
 // echo "<li>currentPath: $currentPath";
 $relativePath = str_replace($basePath.'/','',$currentPath);
 // var_dump($dirsBreadcrumbs2);
 $links[] = array(
     'link'=>CHtml::link(
-        Yii::t('main','Base Path'),
+        Yii::t('MediaModule.main','Base Path'),
         array('index')),
     'subDirs'=>DDMediaDirectory::getSubDirs($basePath)
 );
 // echo "<h3>links</h3>";
 // var_dump($links);
 
+ */
+
+/*
 echo '<form id="dirForm" method="get" action="'.$this->createUrl('index').'">';
 echo '<input type="hidden" id="r" name="r" value="media" />';
 echo '<input type="hidden" id="p" name="p" size="20" />';
         echo '<td style="font-weight:bold;padding: 0 3px 0 3px;vertical-align:top">/</td>';
 }
 echo "</tr></table></form>";
+ */
 ?>
 
+<?php $this->widget('media.widgets.DDMediaPathSelector', array('basePath'=>$basePath,'currentPath'=>$currentPath, 'showHiddenDirs'=>false)); ?>
+
 <?php if(trim($msg)!=='') : ?>
 <p>
 <?php echo $msg; ?>
 // DDVarDumper::dumpAsList($files); 
 ?>
 
-<table class="media-items">
+<table class="media-items<?php echo !is_null($this->module->tableCssClass) ? ' '.$this->module->tableCssClass : ''; ?>">
     <thead>
         <tr>
             <th><input type="checkbox" value="" onclick="toggleAll(this.checked);" /></th>
-            <th><?php echo CHtml::encode(Yii::t('main', 'Icon')); ?></th>
-            <th><?php echo CHtml::encode(Yii::t('main', 'Name')); ?></th>
-            <th><?php echo CHtml::encode(Yii::t('main', 'Date')); ?></th>
-            <th><?php echo CHtml::encode(Yii::t('main', 'Type')); ?></th>
-            <th><?php echo CHtml::encode(Yii::t('main', 'Size')); ?></th>
-            <th><?php echo CHtml::encode(Yii::t('main', 'Action')); ?></th>
+            <th><?php echo CHtml::encode(Yii::t('MediaModule.main', 'Icon')); ?></th>
+            <th><?php echo CHtml::encode(Yii::t('MediaModule.main', 'Name')); ?></th>
+            <th><?php echo CHtml::encode(Yii::t('MediaModule.main', 'Date')); ?></th>
+            <th><?php echo CHtml::encode(Yii::t('MediaModule.main', 'Type')); ?></th>
+            <th><?php echo CHtml::encode(Yii::t('MediaModule.main', 'Size')); ?></th>
+            <th><?php echo CHtml::encode(Yii::t('MediaModule.main', 'Action')); ?></th>
         </tr>
     </thead>
     <tbody>
             <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>
+            <td><?php echo CHtml::encode(Yii::t('MediaModule.main','Directory')); ?></td>
             <td style="white-space:nowrap;font-size:smaller;text-align:right"><?php echo $stats['size']; ?></td>
             <td style="white-space:nowrap;font-size:smaller">
                 <?php if(!in_array($stats['name'],array('..'))) : ?>
-                <a href="javascript:void(0)" onclick="selectMedia('directory','<?php echo $dirPath; ?>','<?php echo $stats['name']; ?>');showDialog('rename');" title="<?php echo Yii::t('main', 'Rename directory {dir}', array('{dir}'=>$stats['name'])); ?>"><?php echo CHtml::encode(Yii::t('main', 'IconRename')); ?></a>&nbsp;
-                <a href="javascript:void(0)" onclick="selectMedia('directory','<?php echo $dirPath; ?>','<?php echo $stats['name']; ?>');showDialog('copy');" title="<?php echo Yii::t('main', 'Copy directory {dir}', array('{dir}'=>$stats['name'])); ?>"><?php echo CHtml::encode(Yii::t('main', 'IconCopy')); ?></a>&nbsp;
-                <a href="javascript:void(0)" onclick="selectMedia('directory','<?php echo $dirPath; ?>','<?php echo $stats['name']; ?>');showDialog('move');" title="<?php echo Yii::t('main', 'Move directory {dir}', array('{dir}'=>$stats['name'])); ?>"><?php echo CHtml::encode(Yii::t('main', 'IconMove')); ?></a>&nbsp;
-                <a href="javascript:void(0)" onclick="selectMedia('directory','<?php echo $dirPath; ?>','<?php echo $stats['name']; ?>');showDialog('delete');" title="<?php echo Yii::t('main', 'Delete directory {dir}', array('{dir}'=>$stats['name'])); ?>"><?php echo CHtml::encode(Yii::t('main', 'IconDelete')); ?></a>
+                <a href="javascript:void(0)" onclick="selectMedia('directory','<?php echo $dirPath; ?>','<?php echo $stats['name']; ?>');showDialog('rename');" title="<?php echo Yii::t('MediaModule.main', 'Rename directory {dir}', array('{dir}'=>$stats['name'])); ?>"><?php echo CHtml::encode(Yii::t('MediaModule.main', 'R')); ?></a>&nbsp;
+                <a href="javascript:void(0)" onclick="selectMedia('directory','<?php echo $dirPath; ?>','<?php echo $stats['name']; ?>');showDialog('copy');" title="<?php echo Yii::t('MediaModule.main', 'Copy directory {dir}', array('{dir}'=>$stats['name'])); ?>"><?php echo CHtml::encode(Yii::t('MediaModule.main', 'C')); ?></a>&nbsp;
+                <a href="javascript:void(0)" onclick="selectMedia('directory','<?php echo $dirPath; ?>','<?php echo $stats['name']; ?>');showDialog('move');" title="<?php echo Yii::t('MediaModule.main', 'Move directory {dir}', array('{dir}'=>$stats['name'])); ?>"><?php echo CHtml::encode(Yii::t('MediaModule.main', 'M')); ?></a>&nbsp;
+                <a href="javascript:void(0)" onclick="selectMedia('directory','<?php echo $dirPath; ?>','<?php echo $stats['name']; ?>');showDialog('delete');" title="<?php echo Yii::t('MediaModule.main', 'Delete directory {dir}', array('{dir}'=>$stats['name'])); ?>"><?php echo CHtml::encode(Yii::t('MediaModule.main', 'X')); ?></a>
                 <?php endif; ?>
             </td>
         </tr>
             <td><?php echo $stats['mimeType']; ?></td>
             <td style="white-space:nowrap;font-size:smaller;text-align:right"><?php echo $stats['sizeFormatted']; ?></td>
             <td style="white-space:nowrap;font-size:smaller">
-                <a href="javascript:void(0)" onclick="selectMedia('file','<?php echo $filePath; ?>','<?php echo $stats['name']; ?>');showDialog('rename');" title="<?php echo Yii::t('main', 'Rename file {file}', array('{file}'=>$stats['name'])); ?>"><?php echo CHtml::encode(Yii::t('main', 'IconRename')); ?></a>&nbsp;
-                <a href="javascript:void(0)" onclick="selectMedia('file','<?php echo $filePath; ?>','<?php echo $stats['name']; ?>');showDialog('copy');" title="<?php echo Yii::t('main', 'Copy file {file}', array('{file}'=>$stats['name'])); ?>"><?php echo CHtml::encode(Yii::t('main', 'IconCopy')); ?></a>&nbsp;
-                <a href="javascript:void(0)" onclick="selectMedia('file','<?php echo $filePath; ?>','<?php echo $stats['name']; ?>');showDialog('move');" title="<?php echo Yii::t('main', 'Move file {file} to another location', array('{file}'=>$stats['name'])); ?>"><?php echo CHtml::encode(Yii::t('main', 'IconMove')); ?></a>&nbsp;
-                <a href="javascript:void(0)" onclick="selectMedia('file','<?php echo $filePath; ?>','<?php echo $stats['name']; ?>');showDialog('delete');" title="<?php echo Yii::t('main', 'Delete file {file}', array('{file}'=>$stats['name'])); ?>"><?php echo CHtml::encode(Yii::t('main', 'IconDelete')); ?></a>
+                <a href="javascript:void(0)" onclick="selectMedia('file','<?php echo $filePath; ?>','<?php echo $stats['name']; ?>');showDialog('rename');" title="<?php echo Yii::t('MediaModule.main', 'Rename file {file}', array('{file}'=>$stats['name'])); ?>"><?php echo CHtml::encode(Yii::t('MediaModule.main', 'R')); ?></a>&nbsp;
+                <a href="javascript:void(0)" onclick="selectMedia('file','<?php echo $filePath; ?>','<?php echo $stats['name']; ?>');showDialog('copy');" title="<?php echo Yii::t('MediaModule.main', 'Copy file {file}', array('{file}'=>$stats['name'])); ?>"><?php echo CHtml::encode(Yii::t('MediaModule.main', 'C')); ?></a>&nbsp;
+                <a href="javascript:void(0)" onclick="selectMedia('file','<?php echo $filePath; ?>','<?php echo $stats['name']; ?>');showDialog('move');" title="<?php echo Yii::t('MediaModule.main', 'Move file {file} to another location', array('{file}'=>$stats['name'])); ?>"><?php echo CHtml::encode(Yii::t('MediaModule.main', 'M')); ?></a>&nbsp;
+                <a href="javascript:void(0)" onclick="selectMedia('file','<?php echo $filePath; ?>','<?php echo $stats['name']; ?>');showDialog('delete');" title="<?php echo Yii::t('MediaModule.main', 'Delete file {file}', array('{file}'=>$stats['name'])); ?>"><?php echo CHtml::encode(Yii::t('MediaModule.main', 'X')); ?></a>
             </td>
         </tr>
         <?php endforeach; ?>
                 &dArr;&rArr;&nbsp;
                 <input type="hidden" name="path" id="path" value="<?php echo $path; ?>" size="20" />
                 <select name="batchAction" id="batchAction" onchange="if(this.value!=='') { doBatchJob=true; doShowDialog=true; showDialog(this.value); }">
-                    <option value=""><?php echo CHtml::encode(Yii::t('main', '(Batch Action)')); ?></option>
-                    <option value="move"><?php echo CHtml::encode(Yii::t('main', 'Move')); ?></option>
-                    <option value="delete"><?php echo CHtml::encode(Yii::t('main', 'Delete')); ?></option>
+                    <option value=""><?php echo CHtml::encode(Yii::t('MediaModule.main', '(Batch Action)')); ?></option>
+                    <option value="move"><?php echo CHtml::encode(Yii::t('MediaModule.main', 'Move')); ?></option>
+                    <option value="delete"><?php echo CHtml::encode(Yii::t('MediaModule.main', 'Delete')); ?></option>
                 </select>
             </td>
         </tr>
         jQuery('#mydialog').dialog('open');
         if(doBatchJob==false) {
             // Single file
-            jQuery('#mydialog').dialog({title:'<?php echo CHtml::encode(Yii::t('main', 'Item: ')); ?>'+selectedItem /* +' &rArr; '+action */ });
+            jQuery('#mydialog').dialog({title:'<?php echo CHtml::encode(Yii::t('MediaModule.main', 'Item: ')); ?>'+selectedItem /* +' &rArr; '+action */ });
             jQuery('#DDMediaAction_selectedItems, #DDMediaAction_selectedItemsOld').val(selectedItem);
         } else {
             // Multiple files - batch job
             collectChSelectedItems();
-            jQuery('#mydialog').dialog({title:'Multiple Selection'});
+            jQuery('#mydialog').dialog({title:'<?php echo CHtml::encode(Yii::t('MediaModule.main','Multiple Selection')); ?>'});
             jQuery('#batchAction').val('');
         }
         jQuery('#DDMediaAction_action').val(action);
         switch(action)
         {
             case 'rename': // {{{ 
-                jQuery('#mediaActionSubmitButton').val('<?php echo CHtml::encode(Yii::t('main', 'Rename')); ?>');
-                jQuery('.msg').html('<?php echo CHtml::encode(Yii::t('main', 'Enter the new name:')); ?>').show();
+                jQuery('#mediaActionSubmitButton').val('<?php echo CHtml::encode(Yii::t('MediaModule.main', 'Rename')); ?>');
+                jQuery('.msg').html('<?php echo CHtml::encode(Yii::t('MediaModule.main', 'Enter the new name:')); ?>').show();
                 jQuery('#nameRowDisplayOnly, #p1Row').show();
-                jQuery('label[for=DDMediaAction_p1]').html('<?php echo CHtml::encode(Yii::t('main', 'New Name')); ?>');
+                jQuery('label[for=DDMediaAction_p1]').html('<?php echo CHtml::encode(Yii::t('MediaModule.main', 'New Name')); ?>');
                 jQuery('#DDMediaAction_p1').val(selectedItem);
                 jQuery('#DDMediaAction_p1').focus().select();
                 break; // }}} 
             case 'copy': // {{{ 
-                jQuery('#mediaActionSubmitButton').val('<?php echo CHtml::encode(Yii::t('main', 'Copy')); ?>');
-                jQuery('.msg').html('<?php echo CHtml::encode(Yii::t('main', 'Enter the new destination and name:')); ?>').show();
+                jQuery('#mediaActionSubmitButton').val('<?php echo CHtml::encode(Yii::t('MediaModule.main', 'Copy')); ?>');
+                jQuery('.msg').html('<?php echo CHtml::encode(Yii::t('MediaModule.main', 'Enter the new destination and name:')); ?>').show();
                 jQuery('#p1Row').show();
-                jQuery('label[for=DDMediaAction_p1]').html('<?php echo CHtml::encode(Yii::t('main', 'New Dest. and Name')); ?>');
+                jQuery('label[for=DDMediaAction_p1]').html('<?php echo CHtml::encode(Yii::t('MediaModule.main', 'New Dest. and Name')); ?>');
                 jQuery('#DDMediaAction_p1').val('./'+selectedItem);
                 jQuery('#DDMediaAction_p1').focus().select();
                 break; // }}} 
             case 'move': // {{{
-                jQuery('#mediaActionSubmitButton').val('<?php echo CHtml::encode(Yii::t('main', 'Move')); ?>');
-                jQuery('.msg').html('<?php echo CHtml::encode(Yii::t('main', 'Enter the new location:')); ?>').show();
+                jQuery('#mediaActionSubmitButton').val('<?php echo CHtml::encode(Yii::t('MediaModule.main', 'Move')); ?>');
+                jQuery('.msg').html('<?php echo CHtml::encode(Yii::t('MediaModule.main', 'Enter the new location:')); ?>').show();
                 if(doBatchJob==false) {
                     jQuery('#DDMediaAction_p1').val('./'+selectedItem);
                 } else {
                     jQuery('#DDMediaAction_p1').val('./');
                 }
-                jQuery('label[for=DDMediaAction_p1]').html('<?php echo CHtml::encode(Yii::t('main', 'Destination')); ?>');
+                jQuery('label[for=DDMediaAction_p1]').html('<?php echo CHtml::encode(Yii::t('MediaModule.main', 'Destination')); ?>');
                 jQuery('#p1Row').show();
                 jQuery('#DDMediaAction_p1').show().focus().select();
                 break; // }}} 
             case 'delete': // {{{ 
-                jQuery('#mediaActionSubmitButton').val('<?php echo CHtml::encode(Yii::t('main', 'Delete')); ?>');
-                jQuery('.msg').html('<?php echo CHtml::encode(Yii::t('main', 'Confirm to delete this item:')); ?>').show();
+                jQuery('#mediaActionSubmitButton').val('<?php echo CHtml::encode(Yii::t('MediaModule.main', 'Delete')); ?>');
+                jQuery('.msg').html('<?php echo CHtml::encode(Yii::t('MediaModule.main', 'Confirm to delete this item:')); ?>').show();
                 jQuery('#nameRowDisplayOnly').show();
-                jQuery('label[for=DDMediaAction_p1]').html('<?php echo CHtml::encode(Yii::t('main', 'File to delete')); ?>');
+                jQuery('label[for=DDMediaAction_p1]').html('<?php echo CHtml::encode(Yii::t('MediaModule.main', 'File to delete')); ?>');
                 break; // }}} 
             case 'newdir': // {{{ 
-                jQuery('#mediaActionSubmitButton').val('<?php echo CHtml::encode(Yii::t('main', 'Create')); ?>');
-                jQuery('.msg').html('<?php echo CHtml::encode(Yii::t('main', 'Enter the name for the new directory:')); ?>').show();
+                jQuery('#mediaActionSubmitButton').val('<?php echo CHtml::encode(Yii::t('MediaModule.main', 'Create')); ?>');
+                jQuery('.msg').html('<?php echo CHtml::encode(Yii::t('MediaModule.main', 'Enter the name for the new directory:')); ?>').show();
                 jQuery('#DDMediaAction_path').val(jQuery('#path').val());
                 jQuery('#selectedItemsRow').hide();
                 jQuery('#p1Row').show();
-                jQuery('label[for=DDMediaAction_p1]').html('<?php echo CHtml::encode(Yii::t('main', 'New Directory')); ?>');
+                jQuery('label[for=DDMediaAction_p1]').html('<?php echo CHtml::encode(Yii::t('MediaModule.main', 'New Directory')); ?>');
                 jQuery('#DDMediaAction_p1').val('').focus().select();
                 break; // }}} 
             case 'upload': // {{{ 
-                jQuery('#mediaActionSubmitButton').val('<?php echo CHtml::encode(Yii::t('main', 'Upload')); ?>');
-                jQuery('.msg').html('<?php echo CHtml::encode(Yii::t('main', 'Select a file to be uploaded:')); ?>').show();
+                jQuery('#mediaActionSubmitButton').val('<?php echo CHtml::encode(Yii::t('MediaModule.main', 'Upload')); ?>');
+                jQuery('.msg').html('<?php echo CHtml::encode(Yii::t('MediaModule.main', 'Select a file to be uploaded:')); ?>').show();
                 jQuery('#DDMediaAction_path').val(jQuery('#path').val());
                 jQuery('#selectedItemsRow').hide();
                 jQuery('#uploadedFileRow').show();

widgets/DDMediaPathSelector.php

+<?php
+/**
+ * DDMediaPathSelector class file
+ *
+ * @author Joachim Werner <joachim.werner@diggin-data.de>
+ * @package DDMedia
+ */
+
+/**
+ * DDMediaPathSelector class
+ *
+ * Displays a widget to select a path
+ *
+ * @author Joachim Werner <joachim.werner@diggin-data.de>
+ * @package DDMedia
+ */
+class DDMediaPathSelector extends CWidget
+{
+    public $cssFile;
+    public $basePath;
+    public $currentPath;
+    public $showHiddenDirs = false;
+    public $formActionId='index';
+    public $pathFieldId='p';
+
+    private $_links;
+
+    public function init()
+    {
+        if($this->cssFile===null)
+        {
+            $file=dirname(__FILE__).DIRECTORY_SEPARATOR.'ddmediapathselector.css';
+            $this->cssFile=Yii::app()->getAssetManager()->publish($file);
+        }
+        parent::init();
+    }
+    public function run()
+    {
+        $this->registerClientScript();
+        $this->render('dDMediaPathSelector', array(
+            'links'=>$this->getLinks(),
+            'formActionId'=>$this->formActionId,
+            'pathFieldId'=>$this->pathFieldId,
+        ));
+    }
+    protected function registerClientScript()
+    {
+        // TODO: publish CSS or JavaScript file here
+        $cs=Yii::app()->clientScript;
+        $cs->registerCssFile($this->cssFile);
+        // $cs->registerScriptFile($jsFile);
+    }
+
+    private function getLinks()
+    {
+        $relativePath = str_replace($this->basePath.'/','',$this->currentPath);
+        if($relativePath==$this->currentPath)
+            $relativePath='';
+        // echo "<li>relativePath: $relativePath";
+        $subDirs = explode('/',$relativePath);
+        if($subDirs==array(''))
+            $subDirs = array();
+        // echo "<h3>subDirs</h3>";
+        // var_dump($subDirs);
+
+        // Init arrays
+        $dirsBreadcrumbs = $dirsBreadcrumbs2 = $links = array();
+
+        foreach($subDirs as $n=>$subDir) {
+            $dirsBreadcrumbs[$n] = $subDir;
+            if(isset($dirsBreadcrumbs[$n-1]))
+                $dirsBreadcrumbs[$n] = $dirsBreadcrumbs[$n-1].'/'.$dirsBreadcrumbs[$n];
+        }
+        // echo "<h3>dirsBreadcrumbs</h3>";
+        // var_dump($dirsBreadcrumbs);
+        foreach($dirsBreadcrumbs as $n=>$subDir) {
+            $dirsBreadcrumbs2[basename($subDir)] = $subDir;
+        }
+        // echo "<h3>dirsBreadcrumbs2</h3>";
+        // var_dump($dirsBreadcrumbs2);
+        $links[] = array(
+            'link'=>CHtml::link(
+                Yii::t('MediaModule.main','Base Path'),
+                array('index')),
+            'subDirs'=>DDMediaDirectory::getSubDirs($this->basePath, $this->showHiddenDirs)
+        );
+        foreach($dirsBreadcrumbs2 as $title=>$subDir) {
+            $links[] = array(
+                'path'=>urlencode($subDir),
+                'link'=>CHtml::link($title,array('index','p'=>urlencode($subDir))),
+                'subDir'=>$title,
+                'subDirs'=>DDMediaDirectory::getSubDirs($this->basePath.'/'.$subDir, $this->showHiddenDirs)
+            );
+        }
+        return $links;
+    }
+}

widgets/ddmediapathselector.css

+table.media-dir-nav { width:0; }
+table.media-dir-nav td { padding: 1px; } 
+table.media-items td.folder img { width: 40px; height: 40px; } 

widgets/views/dDMediaPathSelector.php

+<form id="dirForm" method="get" action="<?php echo Yii::app()->createUrl($formActionId); ?>">
+<input type="hidden" id="r" name="r" value="media" />
+<input type="hidden" id="<?php echo $pathFieldId; ?>" name="<?php echo $pathFieldId; ?>" size="20" />
+<table class="media-dir-nav">
+    <tr valign="top">
+<?php foreach($links as $i=>$link) : ?>
+<?php
+    echo "\t\t".'<td nowrap="nowrap" style="vertical-align:top">'."\n";
+    echo "\t\t\t".$link['link']."<br />\n";
+    if(count($link['subDirs'])>0) {
+        echo "\t\t\t".'<select size="3" onchange="if(jQuery(this).val()!=\'\') {jQuery(\'#p\').val(this.value);jQuery(\'#dirForm\').submit();}">'."\n";
+        // echo '<option value="">'.(isset($link['subDir']) ? $link['subDir'] : '(Base Path)').'</option>';
+        // echo '<option value="">-</option>';
+        foreach($link['subDirs'] as $subDir) {
+            $value='';
+            if(isset($link['path']))
+                $value = $link['path'].'/';
+            echo "\t\t\t\t".'<option value="'.$value.$subDir.'">'.$subDir."</option>\n";
+        }
+        echo "\t\t\t</select>\n";
+    }
+    echo "\t\t</td>\n";
+    if(isset($links[$i+1]))
+        echo "\t\t\t<td style=\"font-weight:bold;padding: 0 3px 0 3px;vertical-align:top\">/</td>\n";
+?>
+<?php endforeach; ?>
+    </tr>
+</table>
+</form>