1: <?php
2: /**
3: * Magento
4: *
5: * NOTICE OF LICENSE
6: *
7: * This source file is subject to the Open Software License (OSL 3.0)
8: * that is bundled with this package in the file LICENSE.txt.
9: * It is also available through the world-wide-web at this URL:
10: * http://opensource.org/licenses/osl-3.0.php
11: * If you did not receive a copy of the license and are unable to
12: * obtain it through the world-wide-web, please send an email
13: * to license@magentocommerce.com so we can send you a copy immediately.
14: *
15: * DISCLAIMER
16: *
17: * Do not edit or add to this file if you wish to upgrade Magento to newer
18: * versions in the future. If you wish to customize Magento for your
19: * needs please refer to http://www.magentocommerce.com for more information.
20: *
21: * @category Mage
22: * @package Mage_Adminhtml
23: * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24: * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25: */
26:
27:
28: /**
29: * Grid widget massaction single action item
30: *
31: * @category Mage
32: * @package Mage_Adminhtml
33: * @author Magento Core Team <core@magentocommerce.com>
34: */
35: class Mage_Adminhtml_Block_Widget_Grid_Massaction_Item extends Mage_Adminhtml_Block_Widget
36: {
37:
38: protected $_massaction = null;
39:
40: /**
41: * Set parent massaction block
42: *
43: * @param Mage_Adminhtml_Block_Widget_Grid_Massaction_Abstract $massaction
44: * @return Mage_Adminhtml_Block_Widget_Grid_Massaction_Item
45: */
46: public function setMassaction($massaction)
47: {
48: $this->_massaction = $massaction;
49: return $this;
50: }
51:
52: /**
53: * Retrive parent massaction block
54: *
55: * @return Mage_Adminhtml_Block_Widget_Grid_Massaction_Abstract
56: */
57: public function getMassaction()
58: {
59: return $this->_massaction;
60: }
61:
62: /**
63: * Set additional action block for this item
64: *
65: * @param string|Mage_Core_Block_Abstract $block
66: * @return Mage_Adminhtml_Block_Widget_Grid_Massaction_Item
67: */
68: public function setAdditionalActionBlock($block)
69: {
70: if(is_string($block)) {
71: $block = $this->getLayout()->createBlock($block);
72: } elseif (is_array($block)) {
73: $block = $this->_createFromConfig($block);
74: } elseif(!($block instanceof Mage_Core_Block_Abstract)) {
75: Mage::throwException('Unknown block type');
76: }
77:
78: $this->setChild('additional_action', $block);
79: return $this;
80: }
81:
82: protected function _createFromConfig(array $config)
83: {
84: $type = isset($config['type']) ? $config['type'] : 'default';
85: switch($type) {
86: default:
87: $blockClass = 'adminhtml/widget_grid_massaction_item_additional_default';
88: break;
89: }
90:
91: $block = $this->getLayout()->createBlock($blockClass);
92: $block->createFromConfiguration(isset($config['type']) ? $config['config'] : $config);
93: return $block;
94: }
95:
96: /**
97: * Retrive additional action block for this item
98: *
99: * @return Mage_Core_Block_Abstract
100: */
101: public function getAdditionalActionBlock()
102: {
103: return $this->getChild('additional_action');
104: }
105:
106: /**
107: * Retrive additional action block HTML for this item
108: *
109: * @return string
110: */
111: public function getAdditionalActionBlockHtml()
112: {
113: return $this->getChildHtml('additional_action');
114: }
115:
116: }
117: