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: * Adminhtml alert queue grid block action item renderer
29: *
30: * @category Mage
31: * @package Mage_Adminhtml
32: * @author Magento Core Team <core@magentocommerce.com>
33: */
34:
35: class Mage_Adminhtml_Block_Sales_Reorder_Renderer_Action
36: extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
37: {
38: /**
39: * Array to store all options data
40: *
41: * @var array
42: */
43: protected $_actions = array();
44:
45: public function render(Varien_Object $row)
46: {
47: $this->_actions = array();
48: if (Mage::helper('sales/reorder')->canReorder($row)) {
49: $reorderAction = array(
50: '@' => array('href' => $this->getUrl('*/sales_order_create/reorder', array('order_id'=>$row->getId()))),
51: '#' => Mage::helper('sales')->__('Reorder')
52: );
53: $this->addToActions($reorderAction);
54: }
55: Mage::dispatchEvent('adminhtml_customer_orders_add_action_renderer', array('renderer' => $this, 'row' => $row));
56: return $this->_actionsToHtml();
57: }
58:
59: protected function _getEscapedValue($value)
60: {
61: return addcslashes(htmlspecialchars($value),'\\\'');
62: }
63:
64: /**
65: * Render options array as a HTML string
66: *
67: * @param array $actions
68: * @return string
69: */
70: protected function _actionsToHtml(array $actions = array())
71: {
72: $html = array();
73: $attributesObject = new Varien_Object();
74:
75: if (empty($actions)) {
76: $actions = $this->_actions;
77: }
78:
79: foreach ($actions as $action) {
80: $attributesObject->setData($action['@']);
81: $html[] = '<a ' . $attributesObject->serialize() . '>' . $action['#'] . '</a>';
82: }
83: return implode($html, '<span class="separator">|</span>');
84: }
85:
86: /**
87: * Add one action array to all options data storage
88: *
89: * @param array $actionArray
90: * @return void
91: */
92: public function addToActions($actionArray)
93: {
94: $this->_actions[] = $actionArray;
95: }
96: }
97: