Commits

Joachim Werner committed c402abb Merge

Comments (0)

Files changed (14)

     public $logTag = 'application.modules.media';
 
     public $baseDir;
+
+    public $tableCssClass;
     
     // getAssetsUrl()
     //    return the URL for this module's assets, performing the publish operation
 
 Download the latest release from [Yii extensions](http://www.yiiframework.com/extension/ddmedia) or from [BitBucket](https://bitbucket.org/jwerner/yii-ddmedia).
 
-Unzip the module under ***protected/modules/ddmedia*** and add the following to your application config:
+Unzip the module under ***protected/modules/media*** and add the following to your application config:
 
 ~~~
 [php]
 return array(
     ...
-    'ddmedia'=>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

     {
         $msg = '';
         $mediaAction = new DDMediaAction;
-        if(isset($_POST['DDMediaAction'])) {
-            $mediaAction->attributes = $_POST['DDMediaAction'];
-            $mediaAction->scenario = $mediaAction->action;
+        // $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");
+            $path = $defaultPath;
+        } else {
+            $path = str_replace($basePath.'/','',$currentPath);
+        }
+        // DEBUG echo "<li>path: $path";
+        $currentPath = DDMediaDirectory::pathToUnix(realpath($basePath.'/'.$path.'/'));
+
+        if(!isset($_POST['DDMediaAction'])) {
+            $mediaAction->selectedItems =' ';
+            $mediaAction->mediaType     = 'file';
+            $mediaAction->path          = $currentPath;
+        } else {
+            $mediaAction->attributes    = $_POST['DDMediaAction'];
+            $mediaAction->scenario      = $mediaAction->action;
+            $mediaAction->path          = $basePath.'/'.$mediaAction->path;
             // DEBUG var_dump($mediaAction->attributes);
             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->oldName,'{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->oldName,'{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->oldName)));
+                            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->oldName,
+                                '{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->name, '{oldName}'=>$mediaAction->oldName)));
+                            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 {
 
             }
         }
-        // $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");
-            $path = $defaultPath;
-        } else {
-            $path = str_replace($basePath.'/','',$currentPath);
-        }
-        // DEBUG echo "<li>path: $path";
-        $currentPath = DDMediaDirectory::pathToUnix(realpath($basePath.'/'.$path.'/'));
-        if(!isset($_POST['DDMediaAction'])) {
-            $mediaAction->name=' ';
-            $mediaAction->mediaType = 'file';
-            $mediaAction->path = $currentPath;
-        }
+
         // DEBUG var_dump(array('basePath'=>$basePath, 'defaultPath'=>$defaultPath, 'GET[path]'=>urldecode($_GET['p']), 'path'=>$path, 'currentPath'=>$currentPath));
         try {
             $dir = new DDMediaDirectory($basePath.'/'.$path);

messages/de/main.php

  * 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',
-  'Item: ' => 'Objekt: ',
-  'Move' => 'Verschieben',
-  'New Directory' => 'Neues Verzeichnis',
-  'New Name' => 'Neuer Name',
-  'Rename' => 'Umbenennen',
-  'Upload' => 'Hochladen',
+  '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',
   'Create New Dir' => 'Neues Verzeichnis anlegen',
   'Date' => 'Datum',
+  'Delete' => 'Löschen',
   'Delete directory {dir}' => 'Verzeichnis {dir} löschen',
   'Delete file {file}' => 'Datei {file} löschen',
+  'Destination' => 'Ziel',
   '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 destination and name:' => 'Geben Sie den neuen Ort und Namen ein:',
+  'Enter the new location:' => 'Geben Sie den neuen Ort ein:',
   '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',
+  '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',
-  'Old Name' => 'Bisheriger 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',
 );

messages/en/main.php

   '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' => '',

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 (
+  '(Batch Action)' => '',
+  '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' => '',
+  'IconDelete' => '',
+  'IconMove' => '',
+  'IconRename' => '',
+  'Item: ' => '',
+  'Media Browser' => '',
+  'Media Type' => '',
+  'Move' => '',
+  'Move directory {dir}' => '',
+  'Move file {file} to another location' => '',
+  'Name' => '',
+  'New Dest. and Name' => '',
+  'New Directory' => '',
+  'New Name' => '',
+  'Parameter 1' => '',
+  'Path' => '',
+  'Rename' => '',
+  'Rename directory {dir}' => '',
+  'Rename file {file}' => '',
+  'Select a file to be uploaded:' => '',
+  'Selected Items' => '',
+  'Selected Items (old)' => '',
+  '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/DDMediaAction.php

 {
     // {{{ *** Members ***
     public $path;
-    public $name;
-    public $multipleNames;
-    public $oldName;
+    public $selectedItems;
+    public $selectedItemsOld;
     public $mediaType;
     public $action;
     public $p1;
         return array(
             array('path, mediaType, action','required'),
             array('action','checkActionParams'),
-            array('name, multipleNames, oldName, p1', 'safe'),
+            array('selectedItems, selectedItemsOld, p1', 'safe'),
             array('uploadedFile','file','on'=>'upload'),
         );
     } // }}}
     public function attributeLabels()
     {
         return array(
-            'path'          => Yii::t('main','Path'),
-            'name'          => Yii::t('main','Name'),
-            'multipleNames' => Yii::t('main','Multiple Selection'),
-            'oldName'       => Yii::t('main','Old Name'),
-            '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
         $result = false;
         switch($this->action)
         {
-            case 'rename':
-                $src = $this->path;
-                $dest = dirname($this->path).'/'.$this->p1;
-                if($this->isWindows()) {
-                    $src    = DDMediaDirectory::pathToWindows($src);
-                    $dest   = DDMediaDirectory::pathToWindows($dest);
+            case 'rename': // {{{ 
+                $result = true;
+                $items = preg_split('/^\R$/', $this->selectedItems, -1, PREG_SPLIT_NO_EMPTY);
+                foreach($items as $srcItem) {
+                    $src = $this->path.'/'.$srcItem;
+                    $dest = $this->path.'/'.$this->p1;
+                    if($this->isWindows()) {
+                        $src    = DDMediaDirectory::pathToWindows($src);
+                        $dest   = DDMediaDirectory::pathToWindows($dest);
+                    }
+                    $result = $result && @rename($src, $dest);
                 }
-                $result = @rename($src, $dest);
-                break;
-            case 'copy':
-                $src = $this->path;
-                $dest = dirname($this->path).'/'.$this->p1;
-                if($this->isWindows()) {
-                    $src    = DDMediaDirectory::pathToWindows($src);
-                    $dest   = DDMediaDirectory::pathToWindows($dest);
+                $this->selectedItemsOld = join(', ', preg_split('/^\R$/', $this->selectedItems, -1, PREG_SPLIT_NO_EMPTY) );
+                break; // }}} 
+            case 'copy': // {{{
+                $result = true;
+                $items = preg_split('/^\R$/', $this->selectedItems, -1, PREG_SPLIT_NO_EMPTY);
+                foreach($items as $srcItem) {
+                    $src = $this->path.'/'.$srcItem;
+                    $dest = $this->path.'/'.$this->p1;
+                    if($this->isWindows()) {
+                        $src    = DDMediaDirectory::pathToWindows($src);
+                        $dest   = DDMediaDirectory::pathToWindows($dest);
+                    }
+                    $result = $result && $this->rcopy($src, $dest);
                 }
-                $result = $this->rcopy($src, $dest);
-                break;
-            case 'delete':
-                $path = $this->path;
-                if($this->isWindows()) {
-                    $path    = DDMediaDirectory::pathToWindows($path);
+                $this->selectedItemsOld = join(', ', preg_split('/^\R$/', $this->selectedItems, -1, PREG_SPLIT_NO_EMPTY) );
+                break; // }}} 
+            case 'delete': // {{{
+                $result = true;
+                $items = explode("\n", $this->selectedItems);
+                foreach($items as $srcItem) {
+                    $path = $this->path.'/'.$srcItem;
+                    if($this->isWindows()) {
+                        $path    = DDMediaDirectory::pathToUnix($path);
+                    }
+                    $result0 = DDMediaDirectory::rrmdir($path);
+                    $result = $result && $result0;
                 }
-                //echo "<li>path: $path";
-                if(is_file($this->path))
-                    $result = @unlink($path);
-                else
-                    $result = DDMediaDirectory::rrmdir($path);
-                break;
-            case 'move':
-                $src    = $this->path;
-                $dest   = dirname($this->path).'/'.$this->p1;
-                if($this->isWindows()) {
-                    $src    = DDMediaDirectory::pathToWindows($src);
-                    $dest   = DDMediaDirectory::pathToWindows($dest);
+                break; // }}}
+            case 'move': // {{{ 
+                $result = true;
+                $items = explode("\n", $this->selectedItems);
+                foreach($items as $srcItem) {
+                    $src    = $this->path.'/'.$srcItem;
+                    $dest   = realpath($this->path.'/'.$this->p1).'/'.$srcItem;
+                    if($this->isWindows()) {
+                        $src    = DDMediaDirectory::pathToWindows($src);
+                        $dest   = DDMediaDirectory::pathToWindows($dest);
+                    }
+                    $result = $result && @rename($src, $dest);
                 }
-                $result = rename($src, $dest);
-                break;
-            case 'upload':
+                break; // }}} 
+            case 'upload': // {{{ 
+                var_dump($this->attributes);
                 $this->uploadedFile=CUploadedFile::getInstance($this,'uploadedFile');
-                $fileName = $this->oldName = $this->uploadedFile->name;
+                $fileName = $this->selectedItemsOld = $this->uploadedFile->name;
                 // Check if file already exists?
                 $filePathAndName = $this->path.'/'.basename($fileName);
                 $i=0;
                 while(is_file($filePathAndName.$add))
                     $add = '.'.(++$i+1);
                 $result = $this->uploadedFile->saveAs($this->path.'/'.basename($fileName).$add);
-                if($this->oldName!==basename($fileName).$add)
-                    $this->name = basename($fileName).$add;
-                break;
-            case 'newdir':
+                $this->selectedItems = $this->path.'/'.basename($fileName).$add;
+                break; // }}} 
+            case 'newdir': // {{{ 
                 $newDir = $this->path.'/'.$this->p1;
                 if(!is_dir($newDir))
                     $result = @mkdir($newDir, 0770);
-                break;
+                if(is_dir($newDir))
+                    $result = true;
+                break; // }}} 
         }
         return $result;
     } // }}}
     {
         return strtoupper(substr(php_uname('s'), 0, 3)) === 'WIN';
     } // }}} 
-    // removes files and non-empty directories
-    public function rrmdir($dir) 
+    // {{{ removes files and non-empty directories
+    public static function rrmdir($dir) 
     {
-        if (is_dir($dir)) {
+        echo "<li>dir: ".$dir;
+        echo "<li>realpath(dir): ".realpath($dir);
+        if (is_dir(realpath($dir.'/'))) {
+            echo " is dir";
             $files = scandir($dir);
-            foreach ($files as $file)
-                if ($file != "." && $file != "..") $this->rrmdir("$dir/$file");
+            foreach ($files as $file) {
+                if ($file != "." && $file != "..") {
+                    echo "<li>file: $dir/$file".
+                        $this->rrmdir("$dir/$file");
+                }
+            }
             rmdir($dir);
+        } else {
+            echo " is not a dir";
+            if (file_exists($dir)) {
+                unlink($dir);
+            }
         }
-        else if (file_exists($dir)) unlink($dir);
         return true;
-    }
-    
-    // copies files and non-empty directories
+    } // }}} 
+    // {{{ copies files and non-empty directories
     public function rcopy($src, $dst) 
     {
         if (file_exists($dst)) $this->rrmdir($dst);
         }
         else if (file_exists($src)) copy($src, $dst);
         return true;
-    }
+    } // }}}
 }

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_dir($dir)) { 
-            $objects = scandir($dir); 
+        if (!is_file($dir)) { 
+            $objects = @scandir($dir); 
+            if($objects===false)
+                return false;
             foreach ($objects as $object) { 
                 if ($object != "." && $object != "..") { 
                     if (filetype($dir."/".$object) == "dir") self::rrmdir($dir."/".$object); else unlink($dir."/".$object);
             } 
             reset($objects); 
             rmdir($dir); 
-        } 
+        } else {
+            return @unlink($dir);
+        }
         return !is_dir($dir);
     } // }}} 
     // }}} End Methods

views/default/_mediaAction.php

     <?php echo CHtml::activeHiddenField($model,'mediaType') ?>
     <?php echo CHtml::activeHiddenField($model,'action'); ?>
  
-    <?php echo CHtml::activeHiddenField($model,'oldName') ?>
+    <?php echo CHtml::activeHiddenField($model,'selectedItemsOld') ?>
 
-    <div class="simple" id="nameRow" style="display:none">
-        <?php echo CHtml::activeLabel($model,'name'); ?>
-        <?php echo CHtml::activeTextField($model,'name') ?>
-    </div>
- 
-    <div class="simple" id="multipleNamesRow" style="display:none">
-        <?php echo CHtml::activeLabel($model,'multipleNames'); ?>
-        <?php echo CHtml::activeTextArea($model,'multipleNames', array( 'rows'=>5 )) ?>
-    </div>
- 
-    <div class="simple" id="nameRowDisplayOnly" style="display:none">
-        <?php echo CHtml::activeLabel($model,'name'); ?>
-        <?php //echo CHtml::activeHiddenField($model,'name') ?>
-        <span id="selectedItemName"></span>
+    <div class="simple" id="selectedItemsRow">
+        <?php echo CHtml::activeLabel($model,'selectedItems'); ?>
+        <?php echo CHtml::activeTextArea($model,'selectedItems', array( 'cols'=>40, 'rows'=>5 )) ?>
     </div>
  
     <div class="simple" id="p1Row" style="display:none">

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; }
+div.ui-dialog form div.simple textarea#DDMediaAction_selectedItems { font-size:smaller; }
 // -->
 </style>
 <?php
     //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
+echo "<li>basePath: ".$basePath; 
+echo "<li>path: ".$path; 
+echo "<li>currentPath: ".$currentPath; 
+ */
+?>
 
 <?php
     foreach(Yii::app()->user->getFlashes() as $key => $message) {
 <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; ?>
         <!-- {{{ Batch Selection Row -->
         <tr>
             <td colspan="7">
-                <input type="text" name="path" value="<?php echo $path; ?>" size="20" />
+                &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="">(Batch Action)</option>
-                    <option value="move">Move</option>
-                    <option value="delete">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>
     var doBatchJob=false;
     var doShowDialog=false;
     var selectedItems=[];
-    function toggleAll(toggle)
+    function toggleAll(toggle) // {{{ 
     {
         $('.chSelectedItems').each( function() {
             if(this.checked)
             else
                 this.checked=true;
         });
-    }
+    } // }}} 
+    // {{{ collectChSelectedItems
     function collectChSelectedItems()
     {
         selectedItems = [];
                 selectedItems.push( this.value );
             }
         });
-        jQuery('#DDMediaAction_multipleNames').val(selectedItems.join("\n"));
-    }
+        console.log('selectedItems: ' + selectedItems.join("; "));
+        jQuery('#DDMediaAction_selectedItems, #DDMediaAction_selectedItemsOld').val(selectedItems.join("\n"));
+    } // }}} 
     // {{{ selectMedia
     function selectMedia(mediaType, path, name)
     {
         else
             doShowDialog=true;
         jQuery('#DDMediaAction_mediaType').val(mediaType);
-        jQuery('#DDMediaAction_path').val(path);
-        jQuery('#DDMediaAction_name, #DDMediaAction_oldName').val(name);
+        jQuery('#DDMediaAction_path').val(jQuery('#path').val());
+        jQuery('#DDMediaAction_selectedItems, #DDMediaAction_selectedItemsOld').val(name);
         selectedItem = name;
     } // }}} 
     // {{{ showDialog
     function showDialog(action)
     {
+        console.log('doShowDialog : ' + doShowDialog);
+        console.log('doBatchJob   : ' + doBatchJob);
         if(doShowDialog==false)
             return;
         jQuery('#mydialog').dialog('open');
         if(doBatchJob==false) {
-            jQuery('#mydialog').dialog({title:'<?php echo CHtml::encode(Yii::t('main', 'Item: ')); ?>'+selectedItem /* +' &rArr; '+action */ });
+            // Single file
+            jQuery('#mydialog').dialog({title:'<?php echo CHtml::encode(Yii::t('MediaModule.main', 'Item: ')); ?>'+selectedItem /* +' &rArr; '+action */ });
+            jQuery('#DDMediaAction_selectedItems, #DDMediaAction_selectedItemsOld').val(selectedItem);
         } else {
-            jQuery('#mydialog').dialog({title:'Multiple Selection'});
+            // Multiple files - batch job
+            collectChSelectedItems();
+            jQuery('#mydialog').dialog({title:'<?php echo CHtml::encode(Yii::t('MediaModule.main','Multiple Selection')); ?>'});
             jQuery('#batchAction').val('');
         }
         jQuery('#DDMediaAction_action').val(action);
         jQuery('#mediaActionSubmitButton').val('Submit');
         jQuery('.msg').html('').hide();
-        jQuery('#selectedItemName').html(selectedItem);
-        jQuery('#nameRow, #multipleNamesRow, #nameRowDisplayOnly, #p1Row, #uploadedFileRow').hide();
+        jQuery('#p1Row, #uploadedFileRow').hide();
         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();
+            case 'rename': // {{{ 
+                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('#DDMediaAction_p1').val(jQuery('#DDMediaAction_name').val());
+                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('#nameRowDisplayOnly, #p1Row').show();
-                jQuery('label[for=DDMediaAction_p1]').html('<?php echo CHtml::encode(Yii::t('main', 'New Dest. and Name')); ?>');
-                jQuery('#DDMediaAction_p1').val('./'+jQuery('#DDMediaAction_name').val());
+                break; // }}} 
+            case 'copy': // {{{ 
+                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('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();
+                break; // }}} 
+            case 'move': // {{{
+                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('#nameRowDisplayOnly, #p1Row').show();
                     jQuery('#DDMediaAction_p1').val('./'+selectedItem);
                 } else {
-                    jQuery('#multipleNamesRow, #p1Row').show();
                     jQuery('#DDMediaAction_p1').val('./');
                 }
-                jQuery('label[for=DDMediaAction_p1]').html('<?php echo CHtml::encode(Yii::t('main', 'Destination')); ?>');
-                jQuery('#DDMediaAction_p1').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('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('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')); ?>');
-                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('#DDMediaAction_path').val(currentPath);
+                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('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('#DDMediaAction_path').val(currentPath);
+                break; // }}} 
+            case 'upload': // {{{ 
+                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();
                 jQuery('#DDMediaAction_uploadedFile').focus().select();
-                break;
+                break; // }}} 
         }
         doShowDialog=false;
     } // }}} 

views/default/textPreview.php

-<pre style="font-family:'Courier New';font-size:8pt;">
+<pre style="font-family:'Courier New';font-size:8pt;height:400px;overflow:auto;">
 <?php echo file_get_contents($path); ?>
 </pre>

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>
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.