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_Adminhtml_Block_Poll_Grid extends Mage_Adminhtml_Block_Widget_Grid
35: {
36:
37: public function __construct()
38: {
39: parent::__construct();
40: $this->setId('pollGrid');
41: $this->setDefaultSort('poll_title');
42: $this->setDefaultDir('ASC');
43: $this->setSaveParametersInSession(true);
44: }
45:
46: protected function _prepareCollection()
47: {
48: $collection = Mage::getModel('poll/poll')->getCollection();
49: $this->setCollection($collection);
50: parent::_prepareCollection();
51:
52: if (!Mage::app()->isSingleStoreMode()) {
53: $this->getCollection()->addStoreData();
54: }
55:
56: return $this;
57: }
58:
59: protected function _prepareColumns()
60: {
61: $this->addColumn('poll_id', array(
62: 'header' => Mage::helper('poll')->__('ID'),
63: 'align' =>'right',
64: 'width' => '50px',
65: 'index' => 'poll_id',
66: ));
67:
68: $this->addColumn('poll_title', array(
69: 'header' => Mage::helper('poll')->__('Poll Question'),
70: 'align' =>'left',
71: 'index' => 'poll_title',
72: ));
73:
74: $this->addColumn('votes_count', array(
75: 'header' => Mage::helper('poll')->__('Number of Responses'),
76: 'width' => '50px',
77: 'type' => 'number',
78: 'index' => 'votes_count',
79: ));
80:
81: $this->addColumn('date_posted', array(
82: 'header' => Mage::helper('poll')->__('Date Posted'),
83: 'align' => 'left',
84: 'width' => '120px',
85: 'type' => 'datetime',
86: 'index' => 'date_posted',
87: 'format' => Mage::app()->getLocale()->getDateFormat()
88: ));
89:
90: $this->addColumn('date_closed', array(
91: 'header' => Mage::helper('poll')->__('Date Closed'),
92: 'align' => 'left',
93: 'width' => '120px',
94: 'type' => 'datetime',
95: 'default' => '--',
96: 'index' => 'date_closed',
97: 'format' => Mage::app()->getLocale()->getDateFormat()
98: ));
99:
100: if (!Mage::app()->isSingleStoreMode()) {
101: $this->addColumn('visible_in', array(
102: 'header' => Mage::helper('review')->__('Visible In'),
103: 'index' => 'stores',
104: 'type' => 'store',
105: 'store_view' => true,
106: 'sortable' => false,
107: ));
108: }
109:
110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122:
123: $this->addColumn('closed', array(
124: 'header' => Mage::helper('poll')->__('Status'),
125: 'align' => 'left',
126: 'width' => '80px',
127: 'index' => 'closed',
128: 'type' => 'options',
129: 'options' => array(
130: 1 => Mage::helper('poll')->__('Closed'),
131: 0 => Mage::helper('poll')->__('Open')
132: ),
133: ));
134:
135: return parent::_prepareColumns();
136: }
137:
138: public function getRowUrl($row)
139: {
140: return $this->getUrl('*/*/edit', array('id' => $row->getId()));
141: }
142:
143: }
144: