1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26:
27: 28: 29: 30: 31: 32: 33:
34: class Mage_Widget_Block_Adminhtml_Widget_Instance_Grid extends Mage_Adminhtml_Block_Widget_Grid
35: {
36: 37: 38: 39:
40: protected function _construct()
41: {
42: parent::_construct();
43: $this->setId('widgetInstanceGrid');
44: $this->setDefaultSort('instance_id');
45: $this->setDefaultDir('ASC');
46: }
47:
48: 49: 50: 51: 52:
53: protected function _prepareCollection()
54: {
55:
56: $collection = Mage::getModel('widget/widget_instance')->getCollection();
57: $this->setCollection($collection);
58: return parent::_prepareCollection();
59: }
60:
61: 62: 63: 64: 65:
66: protected function _prepareColumns()
67: {
68: $this->addColumn('instance_id', array(
69: 'header' => Mage::helper('widget')->__('Widget ID'),
70: 'align' => 'left',
71: 'index' => 'instance_id',
72: ));
73:
74: $this->addColumn('title', array(
75: 'header' => Mage::helper('widget')->__('Widget Instance Title'),
76: 'align' => 'left',
77: 'index' => 'title',
78: ));
79:
80: $this->addColumn('type', array(
81: 'header' => Mage::helper('widget')->__('Type'),
82: 'align' => 'left',
83: 'index' => 'instance_type',
84: 'type' => 'options',
85: 'options' => $this->getTypesOptionsArray()
86: ));
87:
88: $this->addColumn('package_theme', array(
89: 'header' => Mage::helper('widget')->__('Design Package/Theme'),
90: 'align' => 'left',
91: 'index' => 'package_theme',
92: 'type' => 'theme',
93: 'with_empty' => true,
94: ));
95:
96: $this->addColumn('sort_order', array(
97: 'header' => Mage::helper('widget')->__('Sort Order'),
98: 'width' => '100',
99: 'align' => 'center',
100: 'index' => 'sort_order',
101: ));
102:
103: return parent::_prepareColumns();
104: }
105:
106: 107: 108: 109: 110:
111: public function getTypesOptionsArray()
112: {
113: $widgets = array();
114: $widgetsOptionsArr = Mage::getModel('widget/widget_instance')->getWidgetsOptionArray();
115: foreach ($widgetsOptionsArr as $widget) {
116: $widgets[$widget['value']] = $widget['label'];
117: }
118: return $widgets;
119: }
120:
121: 122: 123: 124: 125:
126: public function getPackageThemeOptionsArray()
127: {
128: $packageThemeArray = array();
129: $packageThemeOptions = Mage::getModel('core/design_source_design')
130: ->setIsFullLabel(true)->getAllOptions(false);
131: foreach ($packageThemeOptions as $item) {
132: if (is_array($item['value'])) {
133: foreach ($item['value'] as $valueItem) {
134: $packageThemeArray[$valueItem['value']] = $valueItem['label'];
135: }
136: } else {
137: $packageThemeArray[$item['value']] = $item['label'];
138: }
139: }
140: return $packageThemeArray;
141: }
142:
143: 144: 145: 146: 147:
148: public function getRowUrl($row)
149: {
150: return $this->getUrl('*/*/edit', array('instance_id' => $row->getId()));
151: }
152: }
153: