Source

yii-ddmedia / views / default / index.php

Diff from to

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
 
 <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) {
         echo '<div class="flash-' . $key . '">' . $message . "</div>\n";
 <h2><?php echo str_replace(array($basePath.'/','/'),array('',' / '),$currentPath); ?></h2>
 
 <?php
+/*
 // echo "<li>basePath: $basePath";
 // echo "<li>currentPath: $currentPath";
 $relativePath = str_replace($basePath.'/','',$currentPath);
 // 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; ?>
         <!-- {{{ 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) {
+            // 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':
+            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('MediaModule.main', 'New Name')); ?>');
-                jQuery('#DDMediaAction_p1').val(jQuery('#DDMediaAction_name').val());
+                jQuery('#DDMediaAction_p1').val(selectedItem);
                 jQuery('#DDMediaAction_p1').focus().select();
-                break;
-            case 'copy':
+                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('#nameRowDisplayOnly, #p1Row').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('./'+jQuery('#DDMediaAction_name').val());
+                jQuery('#DDMediaAction_p1').val('./'+selectedItem);
                 jQuery('#DDMediaAction_p1').focus().select();
-                break;
-            case 'move':
+                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('MediaModule.main', 'Destination')); ?>');
-                jQuery('#DDMediaAction_p1').focus().select();
-                break;
-            case 'delete':
+                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('MediaModule.main', 'File to delete')); ?>');
-                break;
-            case 'newdir':
+                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(currentPath);
+                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('MediaModule.main', 'New Directory')); ?>');
                 jQuery('#DDMediaAction_p1').val('').focus().select();
-                break;
-            case 'upload':
+                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(currentPath);
+                jQuery('#DDMediaAction_path').val(jQuery('#path').val());
+                jQuery('#selectedItemsRow').hide();
                 jQuery('#uploadedFileRow').show();
                 jQuery('#DDMediaAction_uploadedFile').focus().select();
-                break;
+                break; // }}} 
         }
         doShowDialog=false;
     } // }}}