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_Backup_Grid extends Mage_Adminhtml_Block_Widget_Grid
35: {
36:
37: protected function _construct()
38: {
39: $this->setSaveParametersInSession(true);
40: $this->setId('backupsGrid');
41: $this->setDefaultSort('time', 'desc');
42: }
43:
44: 45: 46:
47: protected function _prepareCollection()
48: {
49: $collection = Mage::getSingleton('backup/fs_collection');
50: $this->setCollection($collection);
51: return parent::_prepareCollection();
52: }
53:
54: 55: 56: 57: 58:
59: protected function _prepareMassaction()
60: {
61: $this->setMassactionIdField('id');
62: $this->getMassactionBlock()->setFormFieldName('ids');
63:
64: $this->getMassactionBlock()->addItem('delete', array(
65: 'label'=> Mage::helper('adminhtml')->__('Delete'),
66: 'url' => $this->getUrl('*/*/massDelete'),
67: 'confirm' => Mage::helper('backup')->__('Are you sure you want to delete the selected backup(s)?')
68: ));
69:
70: return $this;
71: }
72:
73: 74: 75: 76: 77:
78: protected function _prepareColumns()
79: {
80: $url7zip = Mage::helper('adminhtml')->__('The archive can be uncompressed with <a href="%s">%s</a> on Windows systems', 'http://www.7-zip.org/', '7-Zip');
81:
82: $this->addColumn('time', array(
83: 'header' => Mage::helper('backup')->__('Time'),
84: 'index' => 'date_object',
85: 'type' => 'datetime',
86: 'width' => 200
87: ));
88:
89: $this->addColumn('display_name', array(
90: 'header' => Mage::helper('backup')->__('Name'),
91: 'index' => 'display_name',
92: 'filter' => false,
93: 'sortable' => true,
94: 'width' => 350
95: ));
96:
97: $this->addColumn('size', array(
98: 'header' => Mage::helper('backup')->__('Size, Bytes'),
99: 'index' => 'size',
100: 'type' => 'number',
101: 'sortable' => true,
102: 'filter' => false
103: ));
104:
105: $this->addColumn('type', array(
106: 'header' => Mage::helper('backup')->__('Type'),
107: 'type' => 'options',
108: 'options' => Mage::helper('backup')->getBackupTypes(),
109: 'index' => 'type',
110: 'width' => 300
111: ));
112:
113: $this->addColumn('download', array(
114: 'header' => Mage::helper('backup')->__('Download'),
115: 'format' => '<a href="' . $this->getUrl('*/*/download', array('time' => '$time', 'type' => '$type'))
116: . '">$extension</a> <small>('.$url7zip.')</small>',
117: 'index' => 'type',
118: 'sortable' => false,
119: 'filter' => false
120: ));
121:
122: if (Mage::helper('backup')->isRollbackAllowed()){
123: $this->addColumn('action', array(
124: 'header' => Mage::helper('backup')->__('Action'),
125: 'type' => 'action',
126: 'width' => '80px',
127: 'filter' => false,
128: 'sortable' => false,
129: 'actions' => array(array(
130: 'url' => '#',
131: 'caption' => Mage::helper('backup')->__('Rollback'),
132: 'onclick' => 'return backup.rollback(\'$type\', \'$time\');'
133: )),
134: 'index' => 'type',
135: 'sortable' => false
136: ));
137: }
138:
139: return $this;
140: }
141:
142: }
143: