Mage_Adminhtml_Block_Media_Uploader Class Reference

Inheritance diagram for Mage_Adminhtml_Block_Media_Uploader:

Mage_Adminhtml_Block_Widget Mage_Adminhtml_Block_Template Mage_Core_Block_Template Mage_Core_Block_Abstract Varien_Object

List of all members.

Public Member Functions

 __construct ()
 getBrowseButtonHtml ()
 getUploadButtonHtml ()
 getDeleteButtonHtml ()
 getJsObjectName ()
 getConfigJson ()
 getConfig ()
 getPostMaxSize ()
 getUploadMaxSize ()
 getDataMaxSize ()
 getDataMaxSizeInBytes ()

Protected Member Functions

 _prepareLayout ()
 _getButtonId ($buttonName)

Protected Attributes

 $_config


Detailed Description

Definition at line 34 of file Uploader.php.


Constructor & Destructor Documentation

__construct (  ) 

Constructor

By default is looking for first argument as array and assignes it as object attributes This behaviour may change in child classes

Reimplemented from Varien_Object.

Definition at line 39 of file Uploader.php.

00040     {
00041         parent::__construct();
00042         $this->setId($this->getId() . '_Uploader');
00043         $this->setTemplate('media/uploader.phtml');
00044         $this->getConfig()->setUrl(Mage::getModel('adminhtml/url')->addSessionParam()->getUrl('*/*/upload'));
00045         $this->getConfig()->setParams(array('form_key' => $this->getFormKey()));
00046         $this->getConfig()->setFileField('file');
00047         $this->getConfig()->setFilters(array(
00048             'images' => array(
00049                 'label' => Mage::helper('adminhtml')->__('Images (.gif, .jpg, .png)'),
00050                 'files' => array('*.gif', '*.jpg', '*.png')
00051             ),
00052             'media' => array(
00053                 'label' => Mage::helper('adminhtml')->__('Media (.avi, .flv, .swf)'),
00054                 'files' => array('*.avi', '*.flv', '*.swf')
00055             ),
00056             'all'    => array(
00057                 'label' => Mage::helper('adminhtml')->__('All Files'),
00058                 'files' => array('*.*')
00059             )
00060         ));
00061     }


Member Function Documentation

_getButtonId ( buttonName  )  [protected]

Definition at line 102 of file Uploader.php.

00103     {
00104         return $this->getHtmlId() . '-' . $buttonName;
00105     }

_prepareLayout (  )  [protected]

Preparing global layout

You can redefine this method in child classes for changin layout

Returns:
Mage_Core_Block_Abstract

Reimplemented from Mage_Core_Block_Abstract.

Definition at line 63 of file Uploader.php.

00064     {
00065         $this->setChild(
00066             'browse_button',
00067             $this->getLayout()->createBlock('adminhtml/widget_button')
00068                 ->addData(array(
00069                     'id'      => $this->_getButtonId('browse'),
00070                     'label'   => Mage::helper('adminhtml')->__('Browse Files...'),
00071                     'type'    => 'button',
00072                     'onclick' => $this->getJsObjectName() . '.browse()'
00073                 ))
00074         );
00075 
00076         $this->setChild(
00077             'upload_button',
00078             $this->getLayout()->createBlock('adminhtml/widget_button')
00079                 ->addData(array(
00080                     'id'      => $this->_getButtonId('upload'),
00081                     'label'   => Mage::helper('adminhtml')->__('Upload Files'),
00082                     'type'    => 'button',
00083                     'onclick' => $this->getJsObjectName() . '.upload()'
00084                 ))
00085         );
00086 
00087         $this->setChild(
00088             'delete_button',
00089             $this->getLayout()->createBlock('adminhtml/widget_button')
00090                 ->addData(array(
00091                     'id'      => '{{id}}-delete',
00092                     'class'   => 'delete',
00093                     'type'    => 'button',
00094                     'label'   => Mage::helper('adminhtml')->__('Remove'),
00095                     'onclick' => $this->getJsObjectName() . '.removeFile(\'{{fileId}}\')'
00096                 ))
00097         );
00098 
00099         return parent::_prepareLayout();
00100     }

getBrowseButtonHtml (  ) 

Definition at line 107 of file Uploader.php.

00108     {
00109         return $this->getChildHtml('browse_button');
00110     }

getConfig (  ) 

Retrive config object

Returns:
Varien_Config

Definition at line 147 of file Uploader.php.

00148     {
00149         if(is_null($this->_config)) {
00150             $this->_config = new Varien_Object();
00151         }
00152 
00153         return $this->_config;
00154     }

getConfigJson (  ) 

Retrive config json

Returns:
string

Definition at line 137 of file Uploader.php.

00138     {
00139         return Zend_Json::encode($this->getConfig()->getData());
00140     }

getDataMaxSize (  ) 

Definition at line 166 of file Uploader.php.

00167     {
00168         return min($this->getPostMaxSize(), $this->getUploadMaxSize());
00169     }

getDataMaxSizeInBytes (  ) 

Definition at line 171 of file Uploader.php.

00172     {
00173         $iniSize = $this->getDataMaxSize();
00174         $size = substr($iniSize, 0, strlen($iniSize)-1);
00175         $parsedSize = 0;
00176         switch (strtolower(substr($iniSize, strlen($iniSize)-1))) {
00177             case 't':
00178                 $parsedSize = $size*(1024*1024*1024*1024);
00179                 break;
00180             case 'g':
00181                 $parsedSize = $size*(1024*1024*1024);
00182                 break;
00183             case 'm':
00184                 $parsedSize = $size*(1024*1024);
00185                 break;
00186             case 'k':
00187                 $parsedSize = $size*1024;
00188                 break;
00189             case 'b':
00190             default:
00191                 $parsedSize = $size;
00192                 break;
00193         }
00194         return $parsedSize;
00195     }

getDeleteButtonHtml (  ) 

Definition at line 117 of file Uploader.php.

00118     {
00119         return $this->getChildHtml('delete_button');
00120     }

getJsObjectName (  ) 

Retrive uploader js object name

Returns:
string

Definition at line 127 of file Uploader.php.

00128     {
00129         return $this->getHtmlId() . 'JsObject';
00130     }

getPostMaxSize (  ) 

Definition at line 156 of file Uploader.php.

00157     {
00158         return ini_get('post_max_size');
00159     }

getUploadButtonHtml (  ) 

Definition at line 112 of file Uploader.php.

00113     {
00114         return $this->getChildHtml('upload_button');
00115     }

getUploadMaxSize (  ) 

Definition at line 161 of file Uploader.php.

00162     {
00163         return ini_get('upload_max_filesize');
00164     }


Member Data Documentation

$_config [protected]

Definition at line 37 of file Uploader.php.


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:22:50 2009 for Magento by  doxygen 1.5.8