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_XmlConnect_Block_Adminhtml_Template_Grid extends Mage_Adminhtml_Block_Widget_Grid
35: {
36: 37: 38:
39: public function __construct()
40: {
41: parent::__construct();
42: $this->setId('app_template_grid');
43: $this->setDefaultSort('created_at');
44: $this->setDefaultDir('ASC');
45: $this->setSaveParametersInSession(true);
46: }
47:
48: 49: 50: 51: 52:
53: protected function _prepareCollection()
54: {
55: $collection = Mage::getModel('xmlconnect/template')->getCollection();
56: $this->setCollection($collection);
57: return parent::_prepareCollection();
58: }
59:
60: 61: 62: 63: 64:
65: protected function _prepareColumns()
66: {
67: $this->addColumn('template_id', array(
68: 'header' => $this->__('ID'),
69: 'align' => 'center',
70: 'index' => 'template_id',
71: 'width' => '40px'
72: ));
73:
74: $this->addColumn('name', array(
75: 'header' => $this->__('Template Name'),
76: 'align' => 'left',
77: 'index' => 'main_table.name',
78: 'renderer' => 'xmlconnect/adminhtml_template_grid_renderer_name',
79: 'escape' => true
80: ));
81:
82: $this->addColumn('created_at', array(
83: 'header' => $this->__('Date Created'),
84: 'align' => 'left',
85: 'index' => 'created_at',
86: 'type' => 'datetime'
87: ));
88:
89: $this->addColumn('modified_at', array(
90: 'header' => $this->__('Date Updated'),
91: 'align' => 'left',
92: 'index' => 'modified_at',
93: 'type' => 'datetime'
94: ));
95:
96: $this->addColumn('app_code', array(
97: 'header' => $this->__('Application'),
98: 'index' => 'app.code',
99: 'type' => 'options',
100: 'align' => 'left',
101: 'options' => Mage::helper('xmlconnect')->getApplications(),
102: 'renderer' => 'xmlconnect/adminhtml_template_grid_renderer_application',
103: 'escape' => true
104: ));
105:
106: $this->addColumn('push_title', array(
107: 'header' => $this->__('Push Title'),
108: 'type' => 'text',
109: 'align' => 'left',
110: 'index' => 'push_title',
111: 'escape' => true
112: ));
113:
114: $this->addColumn('message_title', array(
115: 'header' => $this->__('Message Title'),
116: 'type' => 'text',
117: 'align' => 'left',
118: 'index' => 'message_title',
119: 'escape' => true
120: ));
121:
122: $this->addColumn('action', array(
123: 'header' => $this->__('Action'),
124: 'type' => 'action',
125: 'getter' => 'getId',
126: 'actions' => array(
127: array(
128: 'caption' => $this->__('Preview'),
129: 'url' => array(
130: 'base' => '*/*/previewTemplate'
131: ),
132: 'popup' => true,
133: 'field' => 'id'
134: ),
135: array(
136: 'caption' => $this->__('Queue Message'),
137: 'url' => array(
138: 'base' => '*/*/queueMessage',
139: ),
140: 'field' => 'template_id'
141: ),
142: ),
143: 'filter' => false,
144: 'sortable' => false,
145: ));
146:
147: return parent::_prepareColumns();
148: }
149:
150: 151: 152: 153: 154: 155:
156: public function getRowUrl($row)
157: {
158: return $this->getUrl('*/*/editTemplate', array('id' => $row->getId()));
159: }
160: }
161: