Mage_Downloadable_Block_Adminhtml_Catalog_Product_Edit_Tab_Downloadable_Samples Class Reference

Inheritance diagram for Mage_Downloadable_Block_Adminhtml_Catalog_Product_Edit_Tab_Downloadable_Samples:

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 ()
 getProduct ()
 isReadonly ()
 getAddButtonHtml ()
 getSampleData ()
 getUsedDefault ()
 getSamplesTitle ()
 getUploadButtonHtml ()
 getConfigJson ()
 getConfig ()

Protected Member Functions

 _prepareLayout ()


Detailed Description

Definition at line 34 of file Samples.php.


Constructor & Destructor Documentation

__construct (  ) 

Class constructor

Reimplemented from Varien_Object.

Definition at line 40 of file Samples.php.

00041     {
00042         parent::__construct();
00043         $this->setTemplate('downloadable/product/edit/downloadable/samples.phtml');
00044     }


Member Function Documentation

_prepareLayout (  )  [protected]

Prepare layout

Reimplemented from Mage_Core_Block_Abstract.

Definition at line 145 of file Samples.php.

00146     {
00147         $this->setChild(
00148             'upload_button',
00149             $this->getLayout()->createBlock('adminhtml/widget_button')
00150                 ->addData(array(
00151                     'id'      => '',
00152                     'label'   => Mage::helper('adminhtml')->__('Upload Files'),
00153                     'type'    => 'button',
00154                     'onclick' => 'Downloadable.massUploadByType(\'samples\')'
00155                 ))
00156         );
00157     }

getAddButtonHtml (  ) 

Retrieve Add Button HTML

Returns:
string

Definition at line 72 of file Samples.php.

00073     {
00074         $addButton = $this->getLayout()->createBlock('adminhtml/widget_button')
00075             ->setData(array(
00076                 'label' => Mage::helper('downloadable')->__('Add New Row'),
00077                 'id' => 'add_sample_item',
00078                 'class' => 'add',
00079             ));
00080         return $addButton->toHtml();
00081     }

getConfig (  ) 

Retrive config object

Returns:
Varien_Config

Definition at line 196 of file Samples.php.

00197     {
00198         if(is_null($this->_config)) {
00199             $this->_config = new Varien_Object();
00200         }
00201 
00202         return $this->_config;
00203     }

getConfigJson (  ) 

Retrive config json

Returns:
string

Definition at line 174 of file Samples.php.

00175     {
00176         $this->getConfig()->setUrl(Mage::getModel('adminhtml/url')->addSessionParam()->getUrl('downloadableadmin/file/upload', array('type' => 'samples', '_secure' => true)));
00177         $this->getConfig()->setParams(array('form_key' => $this->getFormKey()));
00178         $this->getConfig()->setFileField('samples');
00179         $this->getConfig()->setFilters(array(
00180             'all'    => array(
00181                 'label' => Mage::helper('adminhtml')->__('All Files'),
00182                 'files' => array('*.*')
00183             )
00184         ));
00185         $this->getConfig()->setReplaceBrowseWithRemove(true);
00186         $this->getConfig()->setWidth('32');
00187         $this->getConfig()->setHideUploadButton(true);
00188         return Zend_Json::encode($this->getConfig()->getData());
00189     }

getProduct (  ) 

Get model of the product that is being edited

Returns:
Mage_Catalog_Model_Product

Definition at line 51 of file Samples.php.

00052     {
00053         return Mage::registry('current_product');
00054     }

getSampleData (  ) 

Retrieve samples array

Returns:
array

Definition at line 88 of file Samples.php.

00089     {
00090         $samplesArr = array();
00091         $samples = $this->getProduct()->getTypeInstance(true)->getSamples($this->getProduct());
00092         foreach ($samples as $item) {
00093             $tmpSampleItem = array(
00094                 'sample_id' => $item->getId(),
00095                 'title' => $item->getTitle(),
00096                 'sample_url' => $item->getSampleUrl(),
00097                 'sample_type' => $item->getSampleType(),
00098                 'sort_order' => $item->getSortOrder(),
00099             );
00100             $file = Mage::helper('downloadable/file')->getFilePath(
00101                 Mage_Downloadable_Model_Sample::getBasePath(), $item->getSampleFile()
00102             );
00103             if ($item->getSampleFile() && is_file($file)) {
00104                 $tmpSampleItem['file_save'] = array(
00105                     array(
00106                         'file' => $item->getSampleFile(),
00107                         'name' => Mage::helper('downloadable/file')->getFileFromPathFile($item->getSampleFile()),
00108                         'size' => filesize($file),
00109                         'status' => 'old'
00110                     ));
00111             }
00112             if ($this->getProduct() && $item->getStoreTitle()) {
00113                 $tmpSampleItem['store_title'] = $item->getStoreTitle();
00114             }
00115             $samplesArr[] = new Varien_Object($tmpSampleItem);
00116         }
00117 
00118         return $samplesArr;
00119     }

getSamplesTitle (  ) 

Retrieve Default samples title

Returns:
string

Definition at line 136 of file Samples.php.

getUploadButtonHtml (  ) 

Retrieve Upload button HTML

Returns:
string

Definition at line 164 of file Samples.php.

00165     {
00166         return $this->getChild('upload_button')->toHtml();
00167     }

getUsedDefault (  ) 

Check exists defined samples title

Returns:
bool

Definition at line 126 of file Samples.php.

00127     {
00128         return is_null($this->getProduct()->getAttributeDefaultValue('samples_title'));
00129     }

isReadonly (  ) 

Check block is readonly

Returns:
boolean

Definition at line 61 of file Samples.php.

00062     {
00063          return $this->getProduct()->getDownloadableReadonly();
00064     }


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

Generated on Sat Jul 4 17:24:07 2009 for Magento by  doxygen 1.5.8