Mage_Adminhtml_Block_Widget_Grid_Massaction_Abstract Class Reference

Inheritance diagram for Mage_Adminhtml_Block_Widget_Grid_Massaction_Abstract:

Mage_Adminhtml_Block_Widget Mage_Adminhtml_Block_Template Mage_Core_Block_Template Mage_Core_Block_Abstract Varien_Object Mage_Adminhtml_Block_Widget_Grid_Massaction

List of all members.

Public Member Functions

 __construct ()
 addItem ($itemId, array $item)
 getItem ($itemId)
 getItems ()
 getItemsJson ()
 getCount ()
 isAvailable ()
 getFormFieldName ()
 getFormFieldNameInternal ()
 getJsObjectName ()
 getGridJsObjectName ()
 getSelectedJson ()
 getSelected ()
 getApplyButtonHtml ()
 getJavaScript ()
 getGridIdsJson ()
 getHtmlId ()

Protected Attributes

 $_items = array()


Detailed Description

Definition at line 34 of file Abstract.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 43 of file Abstract.php.

00044     {
00045         parent::__construct();
00046         $this->setTemplate('widget/grid/massaction.phtml');
00047         $this->setErrorText(Mage::helper('catalog')->jsQuoteEscape(Mage::helper('catalog')->__('Please select  items')));
00048     }


Member Function Documentation

addItem ( itemId,
array item 
)

Add new massaction item

$item = array( 'label' => string, 'complete' => string, // Only for ajax enabled grid (optional) 'url' => string, 'confirm' => string, // text of confirmation of this action (optional) 'additional' => string|array|Mage_Core_Block_Abstract // (optional) );

Parameters:
string $itemId
array $item
Returns:
Mage_Adminhtml_Block_Widget_Grid_Massaction_Abstract

Definition at line 65 of file Abstract.php.

00066     {
00067         $this->_items[$itemId] =  $this->getLayout()->createBlock('adminhtml/widget_grid_massaction_item')
00068             ->setData($item)
00069             ->setMassaction($this)
00070             ->setId($itemId);
00071 
00072         if($this->_items[$itemId]->getAdditional()) {
00073             $this->_items[$itemId]->setAdditionalActionBlock($this->_items[$itemId]->getAdditional());
00074             $this->_items[$itemId]->unsAdditional();
00075         }
00076 
00077         return $this;
00078     }

getApplyButtonHtml (  ) 

Retrive apply button html

Returns:
string

Definition at line 217 of file Abstract.php.

00218     {
00219         return $this->getButtonHtml($this->__('Submit'), $this->getJsObjectName() . ".apply()");
00220     }

getCount (  ) 

Retrive massaction items count

Returns:
integer

Definition at line 125 of file Abstract.php.

00126     {
00127         return sizeof($this->_items);
00128     }

getFormFieldName (  ) 

Retrive global form field name for all massaction items

Returns:
string

Definition at line 145 of file Abstract.php.

00146     {
00147         return ($this->getData('form_field_name') ? $this->getData('form_field_name') : 'massaction');
00148     }

getFormFieldNameInternal (  ) 

Retrive form field name for internal use. Based on $this->getFormFieldName()

Returns:
string

Definition at line 155 of file Abstract.php.

00156     {
00157         return  'internal_' . $this->getFormFieldName();
00158     }

getGridIdsJson (  ) 

Definition at line 232 of file Abstract.php.

00233     {
00234         $gridIds = $this->getParentBlock()->getCollection()->getAllIds();
00235 
00236         if(!empty($gridIds)) {
00237             return join(",", $gridIds);
00238             //return Zend_Json::encode($gridIds);
00239         }
00240         return '';
00241         //return '[]';
00242     }

getGridJsObjectName (  ) 

Retrive grid block js object name

Returns:
string

Definition at line 175 of file Abstract.php.

00176     {
00177         return $this->getParentBlock()->getJsObjectName();
00178     }

getHtmlId (  ) 

Reimplemented from Mage_Adminhtml_Block_Widget.

Definition at line 244 of file Abstract.php.

00245     {
00246         return $this->getParentBlock()->getHtmlId() . '_massaction';
00247     }

getItem ( itemId  ) 

Retrive massaction item with id $itemId

Parameters:
string $itemId
Returns:
Mage_Adminhtml_Block_Widget_Grid_Massaction_Item

Definition at line 86 of file Abstract.php.

00087     {
00088         if(isset($this->_items[$itemId])) {
00089             return $this->_items[$itemId];
00090         }
00091 
00092         return null;
00093     }

getItems (  ) 

Retrive massaction items

Returns:
array

Definition at line 100 of file Abstract.php.

00101     {
00102         return $this->_items;
00103     }

getItemsJson (  ) 

Retrive massaction items JSON

Returns:
string

Definition at line 110 of file Abstract.php.

00111     {
00112         $result = array();
00113         foreach ($this->getItems() as $itemId=>$item) {
00114             $result[$itemId] = $item->toArray();
00115         }
00116 
00117         return Zend_Json::encode($result);
00118     }

getJavaScript (  ) 

Definition at line 222 of file Abstract.php.

00223     {
00224         return "
00225                 var {$this->getJsObjectName()} = new varienGridMassaction('{$this->getHtmlId()}', {$this->getGridJsObjectName()}, '{$this->getSelectedJson()}', '{$this->getFormFieldNameInternal()}', '{$this->getFormFieldName()}');
00226                 {$this->getJsObjectName()}.setItems({$this->getItemsJson()});
00227                 {$this->getJsObjectName()}.setGridIds('{$this->getGridIdsJson()}');
00228                 ". ($this->getUseAjax() ? "{$this->getJsObjectName()}.setUseAjax(true);" : '') .
00229                 "{$this->getJsObjectName()}.errorText = '{$this->getErrorText()}';";
00230     }

getJsObjectName (  ) 

Retrive massaction block js object name

Returns:
string

Definition at line 165 of file Abstract.php.

00166     {
00167         return $this->getHtmlId() . 'JsObject';
00168     }

getSelected (  ) 

Retrive array of selected checkboxes

Returns:
array

Definition at line 202 of file Abstract.php.

00203     {
00204         if($selected = $this->getRequest()->getParam($this->getFormFieldNameInternal())) {
00205             $selected = explode(',', $selected);
00206             return $selected;
00207         } else {
00208             return array();
00209         }
00210     }

getSelectedJson (  ) 

Retrive JSON string of selected checkboxes

Returns:
string

Definition at line 185 of file Abstract.php.

00186     {
00187         if($selected = $this->getRequest()->getParam($this->getFormFieldNameInternal())) {
00188             $selected = explode(',', $selected);
00189             return join(',', $selected);
00190 //            return Zend_Json::encode($selected);
00191         } else {
00192             return '';
00193 //            return '[]';
00194         }
00195     }

isAvailable (  ) 

Checks are massactions available

Returns:
boolean

Definition at line 135 of file Abstract.php.

00136     {
00137         return $this->getCount() > 0 && $this->getParentBlock()->getMassactionIdField();
00138     }


Member Data Documentation

$_items = array() [protected]

Definition at line 41 of file Abstract.php.


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

Generated on Sat Jul 4 17:23:09 2009 for Magento by  doxygen 1.5.8