Actions

API15

JHTMLBehavior/uploader

From Joomla! Documentation

< API15:JHTMLBehavior
Revision as of 17:21, 22 March 2010 by Doxiki (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.

[Edit Descripton]

Description:JHTMLBehavior/uploader

Contents

Syntax

uploader($id='file-upload', $params=array())
Parameter Name Default Value Description
$id 'file-upload'
$params array()

Defined in

libraries/joomla/html/html/behavior.php

Importing

jimport( 'joomla.html.html.behavior' );

Source Body

function uploader($id='file-upload', $params = array())
{
        JHTML::script('swf.js' );
        JHTML::script('uploader.js' );
 
        static $uploaders;
 
        if (!isset($uploaders)) {
                $uploaders = array();
        }
 
        if (isset($uploaders[$id]) && ($uploaders[$id])) {
                return;
        }
 
        // Setup options object
        $opt['url']                                     = (isset($params['targetURL'])) ? $params['targetURL'] : null ;
        $opt['swf']                                     = (isset($params['swf'])) ? $params['swf'] : JURI::root(true).'/media/system/swf/uploader.swf';
        $opt['multiple']                        = (isset($params['multiple']) && !($params['multiple'])) ? '\\false' : '\\true';
        $opt['queued']                          = (isset($params['queued']) && !($params['queued'])) ? '\\false' : '\\true';
        $opt['queueList']                       = (isset($params['queueList'])) ? $params['queueList'] : 'upload-queue';
        $opt['instantStart']            = (isset($params['instantStart']) && ($params['instantStart'])) ? '\\true' : '\\false';
        $opt['allowDuplicates']         = (isset($params['allowDuplicates']) && !($params['allowDuplicates'])) ? '\\false' : '\\true';
        $opt['limitSize']                       = (isset($params['limitSize']) && ($params['limitSize'])) ? (int)$params['limitSize'] : null;
        $opt['limitFiles']                      = (isset($params['limitFiles']) && ($params['limitFiles'])) ? (int)$params['limitFiles'] : null;
        $opt['optionFxDuration']        = (isset($params['optionFxDuration'])) ? (int)$params['optionFxDuration'] : null;
        $opt['container']                       = (isset($params['container'])) ? '\\$('.$params['container'].')' : '\\$(\''.$id.'\').getParent()';
        $opt['types']                           = (isset($params['types'])) ?'\\'.$params['types'] : '\\{\'All Files (*.*)\': \'*.*\'}';
 
 
        // Optional functions
        $opt['createReplacement']       = (isset($params['createReplacement'])) ? '\\'.$params['createReplacement'] : null;
        $opt['onComplete']                      = (isset($params['onComplete'])) ? '\\'.$params['onComplete'] : null;
        $opt['onAllComplete']           = (isset($params['onAllComplete'])) ? '\\'.$params['onAllComplete'] : null;
 
/*  types: Object with (description: extension) pairs, default: Images (*.jpg; *.jpeg; *.gif; *.png)
*/
 
        $options = JHTMLBehavior::_getJSObject($opt);
 
        // Attach tooltips to document
        $document =& JFactory::getDocument();
        $uploaderInit = 'sBrowseCaption=\''.JText::_('Browse Files', true).'\';
                        sRemoveToolTip=\''.JText::_('Remove from queue', true).'\';
                        window.addEvent(\'load\', function(){
                        var Uploader = new FancyUpload($(\''.$id.'\'), '.$options.');
                        $(\'upload-clear\').adopt(new Element(\'input\', { type: \'button\', events: { click: Uploader.clearList.bind(Uploader, [false])}, value: \''.JText::_('Clear Completed').'\' }));                              });';
        $document->addScriptDeclaration($uploaderInit);
 
        // Set static array
        $uploaders[$id] = true;
        return;
}

[Edit See Also] SeeAlso:JHTMLBehavior/uploader

Examples

<CodeExamplesForm />