Path

ez projects / ezmultiupload / forum / general / enhancement: user selectabl...


Enhancement: User selectable upload-location

You need to be logged in to post messages in the forums. New users may register here.

Russell Michell

Member since:
07 April 2008

Posts: 15

Wednesday 17 March 2010 2:29:56 am

I try to keep all user-uploaded images in the 'Media' folder. Using this otherwise excellent extension however, I can upload images in the same virtual-dir where ezmultiupload is invoked, but nowhere else.

What would be excellent is to integrate it with ezoe, so you can upload an image or multiple images wherever you invoke ezoe's image-add/upload dialogue. It would allow to select more than one file *and* ask you where you'd like to store it.

Otherwise this is a great extension - so thank you :-)

Russ

Russell Michell, Wellington, New Zealand.
We're building! http://www.theruss.com/blog/
I'm on Twitter: http://twitter.com/therussdotcom

Believe nothing, consider everything.

Up

Russell Michell

Member since:
07 April 2008

Posts: 15

Thursday 18 March 2010 1:37:09 am

Hi again,

I have now modified my version of this extension to allow user-selectable upload locations (needs proper testing but works fine for my purposes using eZ4.1.3)

Via an ini setting it will now allow either the default action - the current-location being the automatic file upload location or a user-selectable upload location.

New Files:




ezmultiupload_userselect.js




Modified Files:




ezmultiupload.tpl


ezmultiupload.ini.append.php


design.ini.append.php




ezmultiupload_userselect.js



/*


The <select> menu of alternative upload destinations in ezmultiupload.tpl is hidden by default. Reveal it:


*/


function multiUploadRevealMenu()


{


       // The <select> menu is hidden until the button is clicked:


       var menu = document.getElementById('userSelectionMenu');


       menu.style.visibility = 'visible';


       return false;


}


/*


Takes a user-selected alternative upload location, changes the upload button href accordingly and redirects


*/


function multiUploadChangeNodeID()


{


       var menu = document.getElementById('userSelectionMenu');


       var butn = document.getElementById('userSelectionButn');


       var selection = menu.options[menu.options.selectedIndex].value;


 

       // Get current node_id appended to button's href attribute by default and change it:


       var href_data = butn.href.split('/');


       node_id = href_data[href_data.length-1];


       href_data.pop();


       href_data.push(selection);


 

       // Change the node_id and redirect:


       window.location.href = href_data.join('/');


       return false;


}




diff for ezmultiupload.tpl



Index: extension/ezmultiupload/design/standard/templates/parts/websitetoolbar/ezmultiupload.tpl


===================================================================


--- extension/ezmultiupload/design/standard/templates/parts/websitetoolbar/ezmultiupload.tpl   (revision 2501)


+++ extension/ezmultiupload/design/standard/templates/parts/websitetoolbar/ezmultiupload.tpl   (revision 2505)


@@ -1,7 +1,29 @@


- {if and(


-           or( ezini( 'MultiUploadSettings', 'AvailableSubtreeNode', 'ezmultiupload.ini' )|contains( $current_node.node_id ),


-               ezini( 'MultiUploadSettings', 'AvailableClasses', 'ezmultiupload.ini' )|contains( $current_node.class_identifier ) ) ,


+{def


+      $ezMultiAvailableSubTreeNode = ezini( 'MultiUploadSettings', 'AvailableSubtreeNode', 'ezmultiupload.ini' )


+      $ezMultiAvailableClasses = ezini( 'MultiUploadSettings', 'AvailableClasses', 'ezmultiupload.ini' )


+      $ezMultiUploadLocation = ezini( 'MultiUploadSettings', 'UploadLocation', 'ezmultiupload.ini' )


+      $ezMultiUploadLocationNodeID = ezini( 'MultiUploadSettings', 'UploadLocationNodeID', 'ezmultiupload.ini' )


+      $ezMultiUploadLocationNodeDepth = ezini( 'MultiUploadSettings', 'UploadLocationNodeDepth', 'ezmultiupload.ini' )


+   $mediaLocations = fetch('content','list',hash(


+              'parent_node_id',$ezMultiUploadLocationNodeID,


+              'depth',$ezMultiUploadLocationNodeDepth,


+              'class_filter_type','include',


+              'class_filter_array',$ezMultiAvailableClasses


+      ))


+}


+


+{if and(


+           or( $ezMultiAvailableSubTreeNode|contains( $current_node.node_id ),$ezMultiAvailableClasses |contains( $current_node.class_identifier ) ) ,


            and( $content_object.can_create, $is_container)


         )}


-   <a href={concat("/ezmultiupload/upload/",$current_node.node_id)|ezurl} title="{'Multiupload'|i18n('extension/ezmultiupload')}"><img src={"ezwt-icon-upload.gif"|ezimage} alt="{'Multiupload'|i18n('extension/ezmultiupload')}" /></a>


+


+          <a id="userSelectionButn" onclick="multiUploadRevealMenu(); return false;" href={concat("/ezmultiupload/upload/",$current_node.node_id)|ezurl} title="{'Multiupload'|i18n('extension/ezmultiupload')}"><img src={"ezwt-icon-upload.gif"|ezimage} alt="{'Multiupload'|i18n('extension/ezmultiupload')}" /></a>


+              {* decide where to upload stuff to *}


+              {if eq($ezMultiUploadLocation,'selection')}


+                      <select id="userSelectionMenu" style="visibility:hidden" onchange="multiUploadChangeNodeID()">


+                              {foreach $mediaLocations as $item}


+                                      <option value="{$item.node_id}">{concat('&nbsp;'|repeat($item.depth),$item.object.name)} ({$item.depth})</option>


+                              {/foreach}


+                      </select>


+              {/else}


  {/if}




diff for ezmultiupload.ini.append.php




Index: extension/ezmultiupload/settings/ezmultiupload.ini.append.php


===================================================================


--- extension/ezmultiupload/settings/ezmultiupload.ini.append.php      (revision 2501)


+++ extension/ezmultiupload/settings/ezmultiupload.ini.append.php      (revision 2505)


@@ -7,6 +7,18 @@


 

 AvailableSubtreeNode[]


 

+# Use default/original ezmultiupload behaviour or user-selected upload destination ('default' or 'selection')


+UploadLocation=selection


+


+# The node_id whose child nodes should be displayed in the <select> menu


+# e.g. use UploadLocationNodeID=43 and UploadLocationNodeDepth=5 to fetch:


+# - All class types listed in AvailableClasses[] array (above)


+# - All objects under the node_id 43 (Media)


+# - All objects to a depth of 5


+


+UploadLocationNodeID=43


+UploadLocationNodeDepth=5


+


 MultiuploadHandlers[]


 

 [FileTypeSettings_folder]


@@ -15,6 +27,10 @@


 FileType[]=*.flv


 FileType[]=*.xap


 FileType[]=*.doc


+FileType[]=*.xls


+FileType[]=*.pdf


+FileType[]=*.txt


+FileType[]=*.csv


 

 [FileTypeSettings_gallery]


 FileType[]




diff for design.ini.append.php




Index: extension/ezmultiupload/settings/design.ini.append.php


===================================================================


--- extension/ezmultiupload/settings/design.ini.append.php     (revision 2501)


+++ extension/ezmultiupload/settings/design.ini.append.php     (revision 2505)


@@ -5,4 +5,8 @@


 

 [StylesheetSettings]


 CSSFileList[]=ezmultiupload.css


-*/ ?>


\ No newline at end of file


+


+[JavaScriptSettings]


+JavaScriptList[]=ezmultiupload_userselect.js


+


+*/ ?>




Cheers
Russ

Russell Michell, Wellington, New Zealand.
We're building! http://www.theruss.com/blog/
I'm on Twitter: http://twitter.com/therussdotcom

Believe nothing, consider everything.

Up

You need to be logged in to post messages in the forums. New users may register here.