fmsystem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fmsystem-commits] [6630] Property: multiuploader


From: Sigurd Nes
Subject: [Fmsystem-commits] [6630] Property: multiuploader
Date: Wed, 24 Nov 2010 09:01:31 +0000

Revision: 6630
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=6630
Author:   sigurdne
Date:     2010-11-24 09:01:29 +0000 (Wed, 24 Nov 2010)
Log Message:
-----------
Property: multiuploader

Modified Paths:
--------------
    trunk/property/inc/class.fileuploader.inc.php
    trunk/property/inc/class.uientity.inc.php
    trunk/property/templates/base/fileuploader.xsl

Modified: trunk/property/inc/class.fileuploader.inc.php
===================================================================
--- trunk/property/inc/class.fileuploader.inc.php       2010-11-23 20:05:32 UTC 
(rev 6629)
+++ trunk/property/inc/class.fileuploader.inc.php       2010-11-24 09:01:29 UTC 
(rev 6630)
@@ -44,215 +44,216 @@
                function __construct()
                {
                        $GLOBALS['phpgw_info']['flags']['xslt_app']             
        = true;
-                       $GLOBALS['phpgw_info']['flags']['noframework']          
= true;
-                       $GLOBALS['phpgw_info']['flags']['no_reset_fonts']       
= true;
+                       $GLOBALS['phpgw_info']['flags']['noframework']          
= true;
+                       $GLOBALS['phpgw_info']['flags']['no_reset_fonts']       
= true;
                }
 
-               function add()
-               {
-                       $upload_target  = phpgw::get_var('upload_target');
-                       $id                             = phpgw::get_var('id');
-
-                       $link_data = array
-                       (
-                               'menuaction'                    => 
$upload_target,
-                               'id'                                    => $id,
-                               'last_loginid'                  => 
phpgw::get_var('last_loginid'),
-                               'last_domain'                   => 
phpgw::get_var('last_domain'),
-                               'sessionphpgwsessid'    => 
phpgw::get_var('sessionphpgwsessid'),
-                               'domain'                                => 
phpgw::get_var('domain')
-                       );
-                               
-                       foreach ($_GET as $varname => $value)
-                       {
-                               if(strpos($varname, '_')===0)
-                               {
-                                       
$link_data[substr($varname,1,strlen($varname)-1)] =  $value;
-                               }
-                       }
-
-                       $upload_url     = $GLOBALS['phpgw']->link('/index.php', 
$link_data);
-
-                       $js_code = self::get_js($upload_url);
-               
-                       
$GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/datatable/assets/skins/sam/datatable.css');
-                       
$GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/fonts/fonts-min.css');
-                       phpgwapi_yui::load_widget('uploader');
-
-                       
$GLOBALS['phpgw']->xslttpl->add_file(array('fileuploader'));
-                       $data = array
-                       (
-                               'js_code' => $js_code,
-                       );
-                       $GLOBALS['phpgw']->xslttpl->set_var('phpgw', 
array('fileuploader' => $data));
+               function add()
+               {
+                       $upload_target  = phpgw::get_var('upload_target');
+                       $id                             = phpgw::get_var('id');
+
+                       $link_data = array
+                       (
+                               'menuaction'                    => 
$upload_target,
+                               'id'                                    => $id,
+                               'last_loginid'                  => 
phpgw::get_var('last_loginid'),
+                               'last_domain'                   => 
phpgw::get_var('last_domain'),
+                               'sessionphpgwsessid'    => 
phpgw::get_var('sessionphpgwsessid'),
+                               'domain'                                => 
phpgw::get_var('domain')
+                       );
+                               
+                       foreach ($_GET as $varname => $value)
+                       {
+                               if(strpos($varname, '_')===0)
+                               {
+                                       
$link_data[substr($varname,1,strlen($varname)-1)] =  $value;
+                               }
+                       }
+
+                       $upload_url     = $GLOBALS['phpgw']->link('/index.php', 
$link_data);
+
+                       $js_code = self::get_js($upload_url);
+               
+                       
$GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/datatable/assets/skins/sam/datatable.css');
+                       
$GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/fonts/fonts-min.css');
+                       phpgwapi_yui::load_widget('uploader');
+
+                       
$GLOBALS['phpgw']->xslttpl->add_file(array('fileuploader'));
+                       $data = array
+                       (
+                               'js_code' => $js_code,
+                       );
+                       $GLOBALS['phpgw']->xslttpl->set_var('phpgw', 
array('fileuploader' => $data));
                }
-
-               
-               static function get_js($upload_url = '')
-               {
-                       $js_code = <<<JS
-                       YAHOO.util.Event.onDOMReady(function () { 
-                       var uiLayer = YAHOO.util.Dom.getRegion('selectLink');
-                       var overlay = YAHOO.util.Dom.get('uploaderOverlay');
-                       YAHOO.util.Dom.setStyle(overlay, 'width', 
uiLayer.right-uiLayer.left + "px");
-                       YAHOO.util.Dom.setStyle(overlay, 'height', 
uiLayer.bottom-uiLayer.top + "px");
-                       });
-
-                       // Custom URL for the uploader swf file (same folder).
-
-                       YAHOO.widget.Uploader.SWFURL = 
"{$GLOBALS['phpgw_info']['server']['webserver_url']}/phpgwapi/js/yahoo/uploader/assets/uploader.swf";
-
-                       // Instantiate the uploader and write it to its 
placeholder div.
-                       var uploader = new YAHOO.widget.Uploader( 
"uploaderOverlay" );
-                       
-                       // Add event listeners to various events on the 
uploader.
-                       // Methods on the uploader should only be called once 
the 
-                       // contentReady event has fired.
-       
-                       uploader.addListener('contentReady', 
handleContentReady);
-                       uploader.addListener('fileSelect', onFileSelect)
-                       uploader.addListener('uploadStart', onUploadStart);
-                       uploader.addListener('uploadProgress', 
onUploadProgress);
-                       uploader.addListener('uploadCancel', onUploadCancel);
-                       uploader.addListener('uploadComplete', 
onUploadComplete);
-                       uploader.addListener('uploadCompleteData', 
onUploadResponse);
-                       uploader.addListener('uploadError', onUploadError);
-                       uploader.addListener('rollOver', handleRollOver);
-                       uploader.addListener('rollOut', handleRollOut);
-                       uploader.addListener('click', handleClick);
-       
-                       // Variable for holding the filelist.
-                       var fileList;
-       
-                       // When the mouse rolls over the uploader, this function
-                       // is called in response to the rollOver event.
-                       // It changes the appearance of the UI element below 
the Flash overlay.
-                       function handleRollOver () {
-                               
YAHOO.util.Dom.setStyle(YAHOO.util.Dom.get('selectLink'), 'color', "#FFFFFF");
-                               
YAHOO.util.Dom.setStyle(YAHOO.util.Dom.get('selectLink'), 'background-color', 
"#000000");
-                       }
-
-                       // On rollOut event, this function is called, which 
changes the appearance of the
-                       // UI element below the Flash layer back to its 
original state.
-                       function handleRollOut () {
-                               
YAHOO.util.Dom.setStyle(YAHOO.util.Dom.get('selectLink'), 'color', "#0000CC");
-                               
YAHOO.util.Dom.setStyle(YAHOO.util.Dom.get('selectLink'), 'background-color', 
"#FFFFFF");
-                       }
-
-                       // When the Flash layer is clicked, the "Browse" dialog 
is invoked.
-                       // The click event handler allows you to do something 
else if you need to.
-                       function handleClick () {
-                       }
-
-                       // When contentReady event is fired, you can call 
methods on the uploader.
-                       function handleContentReady () {
-                           // Allows the uploader to send log messages to 
trace, as well as to YAHOO.log
-                               uploader.setAllowLogging(true);
-
-                               // Allows multiple file selection in "Browse" 
dialog.
-                               uploader.setAllowMultipleFiles(true);
-
-                               // New set of file filters.
-                               var ff = new Array({description:"Images", 
extensions:"*.jpg;*.png;*.gif"},
-                                                  {description:"Videos", 
extensions:"*.avi;*.mov;*.mpg"});
-
-                               // Apply new set of file filters to the 
uploader.
-//                             uploader.setFileFilters(ff);
-                       }
-
-                       // Actually uploads the files. In this case,
-                       // uploadAll() is used for automated queueing and 
upload 
-                       // of all files on the list.
-                       // You can manage the queue on your own and use 
"upload" instead,
-                       // if you need to modify the properties of the request 
for each
-                       // individual file.
-                       function upload() {
-                               if (fileList != null) {
-                                       
uploader.setSimUploadLimit(parseInt(document.getElementById("simulUploads").value));
-                                       uploader.uploadAll("{$upload_url}", 
"POST", null, "Filedata");
-                               }       
-                       }
-
-                       // Fired when the user selects files in the "Browse" 
dialog
-                       // and clicks "Ok".
-                       function onFileSelect(event) {
-                               if('fileList' in event && event.fileList != 
null) {
-                                       fileList = event.fileList;
-                                       createDataTable(fileList);
-                               }
-                       }
-
-                       function createDataTable(entries) {
-                         rowCounter = 0;
-                         this.fileIdHash = {};
-                         this.dataArr = [];
-                         for(var i in entries) {
-                            var entry = entries[i];
-                                entry["progress"] = "<div 
style='height:5px;width:100px;background-color:#CCC;'></div>";
-                            dataArr.unshift(entry);
-                         }
-
-                         for (var j = 0; j < dataArr.length; j++) {
-                           this.fileIdHash[dataArr[j].id] = j;
-                         }
-
-                           var myColumnDefs = [
-                               {key:"name", label: "File Name", 
sortable:false},
-                               {key:"size", label: "Size", sortable:false},
-                               {key:"progress", label: "Upload progress", 
sortable:false}
-                           ];
-
-                       this.myDataSource = new YAHOO.util.DataSource(dataArr);
-                       this.myDataSource.responseType = 
YAHOO.util.DataSource.TYPE_JSARRAY;
-                       this.myDataSource.responseSchema = {
-                       fields: ["id","name","created","modified","type", 
"size", "progress"]
-               };
-
-                       this.singleSelectDataTable = new 
YAHOO.widget.DataTable("dataTableContainer",
-                                  myColumnDefs, this.myDataSource, {
-                                      caption:"Files To Upload",
-                                      selectionMode:"single"
-                                  });
-                       }
-
-                       // Do something on each file's upload start.
-                       function onUploadStart(event) {
-                       
-                       }
-
-                       // Do something on each file's upload progress event.
-                       function onUploadProgress(event) {
-                               rowNum = fileIdHash[event["id"]];
-                               prog = 
Math.round(100*(event["bytesLoaded"]/event["bytesTotal"]));
-                               progbar = "<div 
style='height:5px;width:100px;background-color:#CCC;'><div 
style='height:5px;background-color:#F00;width:" + prog + "px;'></div></div>";
-                               singleSelectDataTable.updateRow(rowNum, {name: 
dataArr[rowNum]["name"], size: dataArr[rowNum]["size"], progress: progbar});    
 
-                       }
-
-                       // Do something when each file's upload is complete.
-                       function onUploadComplete(event) {
-                               rowNum = fileIdHash[event["id"]];
-                               prog = 
Math.round(100*(event["bytesLoaded"]/event["bytesTotal"]));
-                               progbar = "<div 
style='height:5px;width:100px;background-color:#CCC;'><div 
style='height:5px;background-color:#F00;width:100px;'></div></div>";
-                               singleSelectDataTable.updateRow(rowNum, {name: 
dataArr[rowNum]["name"], size: dataArr[rowNum]["size"], progress: progbar});
-                       }
-
-                       // Do something if a file upload throws an error.
-                       // (When uploadAll() is used, the Uploader will
-                       // attempt to continue uploading.
-                       function onUploadError(event) {
-
-                       }
-
-                       // Do something if an upload is cancelled.
-                       function onUploadCancel(event) {
-
-                       }
-
-                       // Do something when data is received back from the 
server.
-                       function onUploadResponse(event) {
-
-                       }
-JS;
-                       return $js_code;
-               }
+
+               
+               static function get_js($upload_url = '')
+               {
+                       $js_code = <<<JS
+                       YAHOO.util.Event.onDOMReady(function () { 
+                       var uiLayer = YAHOO.util.Dom.getRegion('selectLink');
+                       var overlay = YAHOO.util.Dom.get('uploaderOverlay');
+                       YAHOO.util.Dom.setStyle(overlay, 'width', 
uiLayer.right-uiLayer.left + "px");
+                       YAHOO.util.Dom.setStyle(overlay, 'height', 
uiLayer.bottom-uiLayer.top + "px");
+                       });
+
+                       // Custom URL for the uploader swf file (same folder).
+
+                       YAHOO.widget.Uploader.SWFURL = 
"{$GLOBALS['phpgw_info']['server']['webserver_url']}/phpgwapi/js/yahoo/uploader/assets/uploader.swf";
+
+                       // Instantiate the uploader and write it to its 
placeholder div.
+                       var uploader = new YAHOO.widget.Uploader( 
"uploaderOverlay" );
+                       
+                       // Add event listeners to various events on the 
uploader.
+                       // Methods on the uploader should only be called once 
the 
+                       // contentReady event has fired.
+       
+                       uploader.addListener('contentReady', 
handleContentReady);
+                       uploader.addListener('fileSelect', onFileSelect)
+                       uploader.addListener('uploadStart', onUploadStart);
+                       uploader.addListener('uploadProgress', 
onUploadProgress);
+                       uploader.addListener('uploadCancel', onUploadCancel);
+                       uploader.addListener('uploadComplete', 
onUploadComplete);
+                       uploader.addListener('uploadCompleteData', 
onUploadResponse);
+                       uploader.addListener('uploadError', onUploadError);
+                       uploader.addListener('rollOver', handleRollOver);
+                       uploader.addListener('rollOut', handleRollOut);
+                       uploader.addListener('click', handleClick);
+       
+                       // Variable for holding the filelist.
+                       var fileList;
+       
+                       // When the mouse rolls over the uploader, this function
+                       // is called in response to the rollOver event.
+                       // It changes the appearance of the UI element below 
the Flash overlay.
+                       function handleRollOver () {
+                               
YAHOO.util.Dom.setStyle(YAHOO.util.Dom.get('selectLink'), 'color', "#FFFFFF");
+                               
YAHOO.util.Dom.setStyle(YAHOO.util.Dom.get('selectLink'), 'background-color', 
"#000000");
+                       }
+
+                       // On rollOut event, this function is called, which 
changes the appearance of the
+                       // UI element below the Flash layer back to its 
original state.
+                       function handleRollOut () {
+                               
YAHOO.util.Dom.setStyle(YAHOO.util.Dom.get('selectLink'), 'color', "#0000CC");
+                               
YAHOO.util.Dom.setStyle(YAHOO.util.Dom.get('selectLink'), 'background-color', 
"#FFFFFF");
+                       }
+
+                       // When the Flash layer is clicked, the "Browse" dialog 
is invoked.
+                       // The click event handler allows you to do something 
else if you need to.
+                       function handleClick () {
+                       }
+
+                       // When contentReady event is fired, you can call 
methods on the uploader.
+                       function handleContentReady () {
+                           // Allows the uploader to send log messages to 
trace, as well as to YAHOO.log
+                               uploader.setAllowLogging(true);
+
+                               // Allows multiple file selection in "Browse" 
dialog.
+                               uploader.setAllowMultipleFiles(true);
+
+                               // New set of file filters.
+                               var ff = new Array({description:"Images", 
extensions:"*.jpg;*.png;*.gif"},
+                                                  {description:"Videos", 
extensions:"*.avi;*.mov;*.mpg"});
+
+                               // Apply new set of file filters to the 
uploader.
+//                             uploader.setFileFilters(ff);
+                       }
+
+                       // Actually uploads the files. In this case,
+                       // uploadAll() is used for automated queueing and 
upload 
+                       // of all files on the list.
+                       // You can manage the queue on your own and use 
"upload" instead,
+                       // if you need to modify the properties of the request 
for each
+                       // individual file.
+                       function upload() {
+                               if (fileList != null) {
+//                                     
uploader.setSimUploadLimit(parseInt(document.getElementById("simulUploads").value));
+                                       uploader.setSimUploadLimit(1);
+                                       uploader.uploadAll("{$upload_url}", 
"POST", null, "Filedata");
+                               }       
+                       }
+
+                       // Fired when the user selects files in the "Browse" 
dialog
+                       // and clicks "Ok".
+                       function onFileSelect(event) {
+                               if('fileList' in event && event.fileList != 
null) {
+                                       fileList = event.fileList;
+                                       createDataTable(fileList);
+                               }
+                       }
+
+                       function createDataTable(entries) {
+                         rowCounter = 0;
+                         this.fileIdHash = {};
+                         this.dataArr = [];
+                         for(var i in entries) {
+                            var entry = entries[i];
+                                entry["progress"] = "<div 
style='height:5px;width:100px;background-color:#CCC;'></div>";
+                            dataArr.unshift(entry);
+                         }
+
+                         for (var j = 0; j < dataArr.length; j++) {
+                           this.fileIdHash[dataArr[j].id] = j;
+                         }
+
+                           var myColumnDefs = [
+                               {key:"name", label: "File Name", 
sortable:false},
+                               {key:"size", label: "Size", sortable:false},
+                               {key:"progress", label: "Upload progress", 
sortable:false}
+                           ];
+
+                       this.myDataSource = new YAHOO.util.DataSource(dataArr);
+                       this.myDataSource.responseType = 
YAHOO.util.DataSource.TYPE_JSARRAY;
+                       this.myDataSource.responseSchema = {
+                       fields: ["id","name","created","modified","type", 
"size", "progress"]
+               };
+
+                       this.singleSelectDataTable = new 
YAHOO.widget.DataTable("dataTableContainer",
+                                  myColumnDefs, this.myDataSource, {
+                                      caption:"Files To Upload",
+                                      selectionMode:"single"
+                                  });
+                       }
+
+                       // Do something on each file's upload start.
+                       function onUploadStart(event) {
+                       
+                       }
+
+                       // Do something on each file's upload progress event.
+                       function onUploadProgress(event) {
+                               rowNum = fileIdHash[event["id"]];
+                               prog = 
Math.round(100*(event["bytesLoaded"]/event["bytesTotal"]));
+                               progbar = "<div 
style='height:5px;width:100px;background-color:#CCC;'><div 
style='height:5px;background-color:#F00;width:" + prog + "px;'></div></div>";
+                               singleSelectDataTable.updateRow(rowNum, {name: 
dataArr[rowNum]["name"], size: dataArr[rowNum]["size"], progress: progbar});    
 
+                       }
+
+                       // Do something when each file's upload is complete.
+                       function onUploadComplete(event) {
+                               rowNum = fileIdHash[event["id"]];
+                               prog = 
Math.round(100*(event["bytesLoaded"]/event["bytesTotal"]));
+                               progbar = "<div 
style='height:5px;width:100px;background-color:#CCC;'><div 
style='height:5px;background-color:#F00;width:100px;'></div></div>";
+                               singleSelectDataTable.updateRow(rowNum, {name: 
dataArr[rowNum]["name"], size: dataArr[rowNum]["size"], progress: progbar});
+                       }
+
+                       // Do something if a file upload throws an error.
+                       // (When uploadAll() is used, the Uploader will
+                       // attempt to continue uploading.
+                       function onUploadError(event) {
+
+                       }
+
+                       // Do something if an upload is cancelled.
+                       function onUploadCancel(event) {
+
+                       }
+
+                       // Do something when data is received back from the 
server.
+                       function onUploadResponse(event) {
+
+                       }
+JS;
+                       return $js_code;
+               }
  }

Modified: trunk/property/inc/class.uientity.inc.php
===================================================================
--- trunk/property/inc/class.uientity.inc.php   2010-11-23 20:05:32 UTC (rev 
6629)
+++ trunk/property/inc/class.uientity.inc.php   2010-11-24 09:01:29 UTC (rev 
6630)
@@ -152,6 +152,9 @@
                function addfiles()
                {
                        $GLOBALS['phpgw_info']['flags']['xslt_app'] = false;
+                       $GLOBALS['phpgw_info']['flags']['noframework'] = true;
+                       $GLOBALS['phpgw_info']['flags']['nofooter'] = true;
+
                        $id                             = phpgw::get_var('id', 
'int');
                        $jasperfile             = phpgw::get_var('jasperfile', 
'bool');
 

Modified: trunk/property/templates/base/fileuploader.xsl
===================================================================
--- trunk/property/templates/base/fileuploader.xsl      2010-11-23 20:05:32 UTC 
(rev 6629)
+++ trunk/property/templates/base/fileuploader.xsl      2010-11-24 09:01:29 UTC 
(rev 6630)
@@ -3,6 +3,7 @@
                        <h2><xsl:value-of select="php:function('lang', 
'fileuploader')" /></h2>
                </div>
 
+<!--
                <style>
                        #selectFilesLink a, #uploadFilesLink a, #clearFilesLink 
a {
                                color: #0000CC;
@@ -19,15 +20,28 @@
                                background-color: #000000;
                        }
                </style>
-
+-->
                <div id="uiElements" style="display:inline;">
                        <div id="uploaderContainer">
                                <div id="uploaderOverlay" 
style="position:absolute; z-index:2"></div>
-                               <div id="selectFilesLink" style="z-index:1"><a 
id="selectLink" href="#">Select Files</a></div>
+                               <div id="selectFilesLink" style="z-index:1">
+                                       <input id="selectLink" type="button" 
name="selectLink" title="">
+                                               <xsl:attribute name="value">
+                                                       <xsl:value-of 
select="php:function('lang', 'Select Files')" />
+                                               </xsl:attribute>
+                                       </input>
+                               </div>
                        </div>
-                       <div id="uploadFilesLink"><a id="uploadLink" 
onClick="upload(); return false;" href="#">Upload Files</a></div>
+                       <div id="uploadFilesLink">
+                                       <input id="uploadLink" type="button" 
name="uploadLink" title="" onClick="upload(); return false;">
+                                               <xsl:attribute name="value">
+                                                       <xsl:value-of 
select="php:function('lang', 'Upload Files')" />
+                                               </xsl:attribute>
+                                       </input>
+                       </div>
                </div>
 
+<!--
                <div id="simUploads"> Number of simultaneous uploads:
                        <select id="simulUploads">
                                <option value="1">1</option>
@@ -36,7 +50,7 @@
                                <option value="4">4</option>
                        </select>
                </div>
-
+-->
                <div id="dataTableContainer"></div>
                <script type="text/javascript">
                        <xsl:value-of select="js_code"/>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]