DigitalPianism_ReportsViewer - Version 0.0.4

Version Notes

- Fix display date issue.

Download this release

Release Info

Developer Digital Pianism
Extension DigitalPianism_ReportsViewer
Version 0.0.4
Comparing to
See all releases


Version 0.0.4

app/code/community/DigitalPianism/ReportsViewer/Block/Adminhtml/Reportsviewer.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Class DigitalPianism_Reportsviewer_Block_Adminhtml_Reportsviewer
5
+ */
6
+ class DigitalPianism_Reportsviewer_Block_Adminhtml_Reportsviewer extends Mage_Adminhtml_Block_Widget_Grid_Container
7
+ {
8
+ /**
9
+ * Constructor
10
+ */
11
+ public function __construct()
12
+ {
13
+ $this->_controller = 'adminhtml_reportsviewer';
14
+ $this->_blockGroup = 'reportsviewer';
15
+ $this->_headerText = Mage::helper('reportsviewer')->__('Reports Viewer');
16
+ parent::__construct();
17
+ $this->setTemplate('digitalpianism/reportsviewer/list.phtml');
18
+ }
19
+
20
+ /**
21
+ * Prepare the layout
22
+ */
23
+ protected function _prepareLayout()
24
+ {
25
+ // Add the grid
26
+ $this->setChild('grid', $this->getLayout()->createBlock('reportsviewer/adminhtml_reportsviewer_grid', 'reportsviewer.grid'));
27
+ return parent::_prepareLayout();
28
+ }
29
+
30
+ /**
31
+ * Getter for the grid HTML
32
+ */
33
+ public function getGridHtml()
34
+ {
35
+ return $this->getChildHtml('grid');
36
+ }
37
+
38
+ }
app/code/community/DigitalPianism/ReportsViewer/Block/Adminhtml/Reportsviewer/Grid.php ADDED
@@ -0,0 +1,185 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Class DigitalPianism_Reportsviewer_Block_Adminhtml_Reportsviewer_Grid
5
+ * This is the block representing the grid of reports
6
+ */
7
+ class DigitalPianism_Reportsviewer_Block_Adminhtml_Reportsviewer_Grid extends Mage_Adminhtml_Block_Widget_Grid
8
+ {
9
+ /**
10
+ * Constructor the grid
11
+ */
12
+ public function __construct()
13
+ {
14
+ parent::__construct();
15
+ $this->setId('reportsviewerGrid');
16
+ $this->setDefaultSort('report_id');
17
+ $this->setDefaultDir('ASC');
18
+ $this->setSaveParametersInSession(true);
19
+ }
20
+
21
+ /**
22
+ * Prepare the collection to display in the grid
23
+ */
24
+ protected function _prepareCollection()
25
+ {
26
+ // Create a collection
27
+ $collection = new Varien_Data_Collection();
28
+
29
+ // Add the reports from the var folder to the collection
30
+ $reportFolder = Mage::getBaseDir('var') . '/report';
31
+
32
+ // If the report folder is a directory
33
+ if (is_dir($reportFolder))
34
+ {
35
+ // And if we can read it
36
+ if ($dh = opendir($reportFolder))
37
+ {
38
+ // We loop through its readable files
39
+ while (($file = readdir($dh)) !== false)
40
+ {
41
+ // Except "." and ".."
42
+ if ($file != "." && $file != "..")
43
+ {
44
+ // For each file we create a new object
45
+ $newItem = new Varien_Object();
46
+ // Set some data
47
+ $newItem->setReportId($file);
48
+ $newItem->setFile($reportFolder . "/" . $file);
49
+ // Set the date properly
50
+ $dateAdded = Mage::getModel('core/date')->date(null,filemtime($reportFolder . "/" . $file));
51
+ $newItem->setAdded($dateAdded);
52
+
53
+ // Get the content of the file
54
+ $content = file_get_contents($reportFolder . "/" . $file);
55
+ // Decode it
56
+ $content = unserialize($content);
57
+ // Loop through the array
58
+ foreach ($content as $key => $value)
59
+ {
60
+ // Value with key = 0 is always the error message
61
+ if (!$key)
62
+ {
63
+ $newItem->setError($value);
64
+ }
65
+ elseif ($key == "url")
66
+ {
67
+ $newItem->setUrl($value);
68
+ }
69
+ elseif ($key == "script_name")
70
+ {
71
+ $newItem->setScriptName($value);
72
+ }
73
+ elseif ($key == "skin")
74
+ {
75
+ $newItem->setSkin($value);
76
+ }
77
+ }
78
+ // Once the data are set, we add the object to the collection
79
+ $collection->addItem($newItem);
80
+ }
81
+ }
82
+ // We close the folder
83
+ closedir($dh);
84
+ }
85
+ }
86
+
87
+ // We set the collection of the grid
88
+ $this->setCollection($collection);
89
+ return parent::_prepareCollection();
90
+ }
91
+
92
+ /**
93
+ * Prepare the columns of the grid
94
+ */
95
+ protected function _prepareColumns()
96
+ {
97
+ $this->addColumn('report_id', array(
98
+ 'header' => Mage::helper('reportsviewer')->__('Report #'),
99
+ 'align' => 'right',
100
+ 'width' => '50px',
101
+ 'index' => 'report_id',
102
+ ));
103
+
104
+ $this->addColumn('error', array(
105
+ 'header' => Mage::helper('reportsviewer')->__('Error'),
106
+ 'align' => 'right',
107
+ 'index' => 'error',
108
+ ));
109
+
110
+ $this->addColumn('url', array(
111
+ 'header' => Mage::helper('reportsviewer')->__('URL'),
112
+ 'align' => 'right',
113
+ 'index' => 'url',
114
+ ));
115
+
116
+ $this->addColumn('script_name', array(
117
+ 'header' => Mage::helper('reportsviewer')->__('Script Name'),
118
+ 'align' => 'right',
119
+ 'index' => 'script_name',
120
+ ));
121
+
122
+ $this->addColumn('skin', array(
123
+ 'header' => Mage::helper('reportsviewer')->__('Skin'),
124
+ 'align' => 'right',
125
+ 'index' => 'skin',
126
+ ));
127
+
128
+ $this->addColumn('file', array(
129
+ 'header' => Mage::helper('reportsviewer')->__('File'),
130
+ 'align' => 'right',
131
+ 'index' => 'file',
132
+ ));
133
+
134
+ $this->addColumn('added', array(
135
+ 'header' => Mage::helper('reportsviewer')->__('Created At'),
136
+ 'index' => 'added',
137
+ 'width' => '140px',
138
+ 'type' => 'datetime',
139
+ 'gmtoffset' => true,
140
+ 'default' => ' -- '
141
+ ));
142
+
143
+ // Here we use a custom renderer to be able to display what we want
144
+ $this->addColumn('action', array(
145
+ 'header' => Mage::helper('reportsviewer')->__('Action'),
146
+ 'index' => 'stores',
147
+ 'sortable' => false,
148
+ 'filter' => false,
149
+ 'width' => '160',
150
+ 'is_system' => true,
151
+ 'renderer' => 'DigitalPianism_ReportsViewer_Block_Adminhtml_Template_Grid_Renderer_Action'
152
+ ));
153
+
154
+ return parent::_prepareColumns();
155
+ }
156
+
157
+ /**
158
+ * Prepare mass actions
159
+ */
160
+ protected function _prepareMassaction()
161
+ {
162
+ $this->setMassactionIdField('report_id');
163
+ $this->getMassactionBlock()->setFormFieldName('reportsviewer');
164
+
165
+ // Delete action
166
+ $this->getMassactionBlock()->addItem('delete', array(
167
+ 'label' => Mage::helper('reportsviewer')->__('Delete'),
168
+ 'url' => $this->getUrl('*/*/massDelete'),
169
+ 'confirm' => Mage::helper('reportsviewer')->__('Are you sure?')
170
+ ));
171
+
172
+ return $this;
173
+ }
174
+
175
+ /**
176
+ * Getter for the row URL
177
+ * @param $row
178
+ * @return string
179
+ */
180
+ public function getRowUrl($row)
181
+ {
182
+ return $this->getUrl('*/*/view', array('id' => $row->getData('report_id')));
183
+ }
184
+
185
+ }
app/code/community/DigitalPianism/ReportsViewer/Block/Adminhtml/Reportsviewer/View.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Class DigitalPianism_Reportsviewer_Block_Adminhtml_Reportsviewer_View
5
+ * This is the view page parent block
6
+ */
7
+ class DigitalPianism_Reportsviewer_Block_Adminhtml_Reportsviewer_View extends Mage_Adminhtml_Block_Widget_Form_Container
8
+ {
9
+ /**
10
+ * Constructor for the Edit page
11
+ */
12
+ public function __construct()
13
+ {
14
+ parent::__construct();
15
+ $this->_objectId = 'id';
16
+ $this->_blockGroup = 'reportsviewer';
17
+ $this->_controller = 'adminhtml_reportsviewer';
18
+ $this->_mode = 'view';
19
+ $this->_updateButton('delete', 'label', Mage::helper('reportsviewer')->__('Delete Report File'));
20
+ // Remove the save button as we do not deal with editable data
21
+ $this->_removeButton('save');
22
+ }
23
+
24
+ /**
25
+ * @return mixed
26
+ */
27
+ protected function _prepareLayout()
28
+ {
29
+ if ($this->_blockGroup && $this->_controller && $this->_mode) {
30
+ // Here we set the form block
31
+ $this->setChild('form', $this->getLayout()->createBlock('reportsviewer/adminhtml_reportsviewer_view_form'));
32
+ }
33
+ return parent::_prepareLayout();
34
+ }
35
+
36
+ /**
37
+ * Getter for the header text
38
+ */
39
+ public function getHeaderText()
40
+ {
41
+ return Mage::helper('reportsviewer')->__('Viewing Report');
42
+ }
43
+
44
+ }
app/code/community/DigitalPianism/ReportsViewer/Block/Adminhtml/Reportsviewer/View/Form.php ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Class DigitalPianism_ReportsViewer_Block_Adminhtml_Reportsviewer_View_Form
5
+ * This is the form block to view the report data
6
+ */
7
+ class FactoryX_ReportsViewer_Block_Adminhtml_Reportsviewer_View_Form extends Mage_Adminhtml_Block_Widget_Form
8
+ {
9
+ /**
10
+ * Prepare the form of the edit reportsviewer page
11
+ */
12
+ protected function _prepareForm()
13
+ {
14
+ // Create a new form
15
+ $form = new Varien_Data_Form(array(
16
+ 'id' => 'view_form',
17
+ 'method' => 'post',
18
+ 'enctype' => 'multipart/form-data'
19
+ )
20
+ );
21
+
22
+ // Create a fieldset
23
+ $fieldset = $form->addFieldset('reports_form', array(
24
+ 'legend' => Mage::helper('reportsviewer')->__('General Information'),
25
+ 'class' => 'fieldset-wide'
26
+ )
27
+ );
28
+
29
+ // We retrieve the data from the registered data set in the controller
30
+ if (Mage::registry('report_data'))
31
+ {
32
+ $data = Mage::registry('report_data')->getData();
33
+ }
34
+
35
+ // Field for the report_id of the report
36
+ $fieldset->addField('report_id', 'text', array(
37
+ 'label' => Mage::helper('reportsviewer')->__('Report #'),
38
+ 'disabled' => true,
39
+ 'name' => 'report_id'
40
+ ));
41
+
42
+ // Field for the error of the report
43
+ $fieldset->addField('error', 'textarea', array(
44
+ 'label' => Mage::helper('reportsviewer')->__('Error'),
45
+ 'disabled' => true,
46
+ 'name' => 'error'
47
+ ));
48
+
49
+ // Field for the trace of the report
50
+ $fieldset->addField('trace', 'textarea', array(
51
+ 'label' => Mage::helper('reportsviewer')->__('Trace'),
52
+ 'disabled' => true,
53
+ 'name' => 'trace'
54
+ ));
55
+
56
+ // Field for the URL
57
+ $fieldset->addField('url', 'text', array(
58
+ 'label' => Mage::helper('reportsviewer')->__('URL'),
59
+ 'disabled' => true,
60
+ 'name' => 'url'
61
+ )
62
+ );
63
+
64
+ // Field for the skin
65
+ $fieldset->addField('skin', 'text', array(
66
+ 'label' => Mage::helper('reportsviewer')->__('Skin'),
67
+ 'disabled' => true,
68
+ 'name' => 'skin'
69
+ )
70
+ );
71
+
72
+ // Field for the script_name
73
+ $fieldset->addField('script_name', 'text', array(
74
+ 'label' => Mage::helper('reportsviewer')->__('Script Name'),
75
+ 'disabled' => true,
76
+ 'name' => 'script_name'
77
+ )
78
+ );
79
+
80
+ // Format the timestamp date to a viewable date
81
+ $data['added'] = Mage::getModel('core/date')->date(null,$data['added']);
82
+
83
+ // Field for the added date
84
+ $fieldset->addField('added', 'text', array(
85
+ 'label' => Mage::helper('reportsviewer')->__('Created At'),
86
+ 'disabled' => true,
87
+ 'name' => 'added'
88
+ )
89
+ );
90
+
91
+ $form->setUseContainer(true);
92
+ // We fill the form based on the retrieved data
93
+ $form->setValues($data);
94
+ $this->setForm($form);
95
+
96
+ return parent::_prepareForm();
97
+ }
98
+
99
+ }
app/code/community/DigitalPianism/ReportsViewer/Block/Adminhtml/Template/Grid/Renderer/Action.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Adminhtml reports viewer templates grid block action item renderer
4
+ *
5
+ * @category DigitalPianism
6
+ * @package DigitalPianism_ReportsViewer
7
+ * @author Digital Pianism Team <contact@digital-pianism.com>
8
+ */
9
+
10
+ class DigitalPianism_ReportsViewer_Block_Adminhtml_Template_Grid_Renderer_Action extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Action {
11
+
12
+ /**
13
+ * @param Varien_Object $row
14
+ * @return string
15
+ */
16
+ public function render(Varien_Object $row)
17
+ {
18
+ // for href actions
19
+ $actions[] = array(
20
+ '@' => array(
21
+ 'href' => $this->getUrl("*/*/view", array('id' => $row->getData('report_id')))
22
+ ),
23
+ '#' => Mage::helper('reportsviewer')->__('View Details')
24
+ );
25
+
26
+ return $this->_actionsToHtml($actions);
27
+ }
28
+
29
+ /**
30
+ * @param $value
31
+ * @return string
32
+ */
33
+ protected function _getEscapedValue($value)
34
+ {
35
+ return addcslashes(htmlspecialchars($value),'\\\'');
36
+ }
37
+
38
+ /**
39
+ * @param array $actions
40
+ * @return string
41
+ */
42
+ protected function _actionsToHtml(array $actions)
43
+ {
44
+ //Mage::helper('reportsviewer')->log(sprintf("%s->actions=%s", __METHOD__, print_r($actions, true)) );
45
+ $html = array();
46
+ $attributesObject = new Varien_Object();
47
+ foreach ($actions as $action) {
48
+ $attributesObject->setData($action['@']);
49
+ $html[] = '<a ' . $attributesObject->serialize() . '>' . $action['#'] . '</a>';
50
+ }
51
+ return implode(' <span class="separator">&nbsp;|&nbsp;</span> ', $html);
52
+ }
53
+
54
+ }
app/code/community/DigitalPianism/ReportsViewer/Helper/Data.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Class DigitalPianism_ReportsViewer_Helper_Data
5
+ */
6
+ class DigitalPianism_ReportsViewer_Helper_Data extends Mage_Core_Helper_Abstract
7
+ {
8
+ // Protected log file name
9
+ protected $_logFileName = 'digitalpianism_reportsviewer.log';
10
+
11
+ /**
12
+ * Log data to a custom file
13
+ * @param string|object|array data to log
14
+ */
15
+ public function log($data)
16
+ {
17
+ Mage::log($data, null, $this->_logFileName);
18
+ }
19
+
20
+ }
app/code/community/DigitalPianism/ReportsViewer/controllers/Adminhtml/ReportsviewerController.php ADDED
@@ -0,0 +1,172 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Class DigitalPianism_ReportsViewer_Adminhtml_ReportsviewerController
5
+ */
6
+ class DigitalPianism_ReportsViewer_Adminhtml_ReportsviewerController extends Mage_Adminhtml_Controller_Action
7
+ {
8
+
9
+ /**
10
+ * Check the ACL permission
11
+ * @return mixed
12
+ */
13
+ protected function _isAllowed()
14
+ {
15
+ return Mage::getSingleton('admin/session')->isAllowed('system/tools/reportsviewer');
16
+ }
17
+
18
+ /**
19
+ * Initialization
20
+ * @return $this
21
+ */
22
+ protected function _initAction()
23
+ {
24
+ $this->loadLayout()->_setActiveMenu('system/tools/reportsviewer');
25
+
26
+ return $this;
27
+ }
28
+
29
+ /**
30
+ * This is the action used to display the grid
31
+ */
32
+ public function indexAction()
33
+ {
34
+ try {
35
+ $this->_initAction()->renderLayout();
36
+ }
37
+ catch(Exception $ex) {
38
+ Mage::helper('reportsviewer')->log(sprintf("%s->error=%s", __METHOD__, print_r($ex, true)), Zend_Log::DEBUG );
39
+ }
40
+ }
41
+
42
+ /**
43
+ * This is called when deleting an item from its edit page
44
+ */
45
+ public function deleteAction() {
46
+ // We first retrieve the ID
47
+ $reportId = (int) $this->getRequest()->getParam('id');
48
+ // Set the location of the report
49
+ $reportFolder = Mage::getBaseDir('var') . '/report';
50
+
51
+ if ($reportId)
52
+ {
53
+ try {
54
+ // We physically (so to say) delete the file
55
+ unlink($reportFolder . "/" . $reportId);
56
+ // Success message
57
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('reportsviewer')->__('Report was successfully deleted'));
58
+ $this->_redirect('*/*/');
59
+ } catch (Exception $e) {
60
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
61
+ $this->_redirect('*/*/view', array('id' => $this->getRequest()->getParam('id')));
62
+ }
63
+ }
64
+ // Redirection to the grid
65
+ $this->_redirect('*/*/');
66
+ }
67
+
68
+ /**
69
+ * This is called when we mass delete items from the grid
70
+ */
71
+ public function massDeleteAction()
72
+ {
73
+ // We get the IDs of the items that need to be deleted
74
+ $reportIds = $this->getRequest()->getParam('reportsviewer');
75
+ // Set the location of the reports
76
+ $reportFolder = Mage::getBaseDir('var') . '/report';
77
+
78
+ if (!is_array($reportIds))
79
+ {
80
+ // Display an error if the parameter is not an array
81
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('reportsviewer')->__('Please select report(s)'));
82
+ }
83
+ else
84
+ {
85
+ try {
86
+ // Loop through the reports IDs
87
+ foreach($reportIds as $reportId)
88
+ {
89
+ // Delete them manually
90
+ unlink($reportFolder . "/" . $reportId);
91
+ }
92
+ // Success message
93
+ Mage::getSingleton('adminhtml/session')->addSuccess(
94
+ Mage::helper('reportsviewer')->__(
95
+ 'Total of %d report(s) were successfully deleted', count($reportIds)
96
+ )
97
+ );
98
+ } catch (Exception $e) {
99
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
100
+ }
101
+ }
102
+ // Redirection to the grid
103
+ $this->_redirect('*/*/index');
104
+ }
105
+
106
+ /**
107
+ * This is the action used to view the details of a report
108
+ */
109
+ public function viewAction()
110
+ {
111
+ // We first retrieve the report ID
112
+ $id = $this->getRequest()->getParam('id');
113
+
114
+ // This is the location of the reports
115
+ $reportFolder = Mage::getBaseDir('var') . '/report';
116
+
117
+ // Then we create a new Object
118
+ $model = new Varien_Object();
119
+ // Set some data
120
+ $model->setReportId($id);
121
+ $model->setFile($reportFolder . "/" . $id);
122
+ $model->setAdded(filemtime($reportFolder . "/" . $id));
123
+
124
+ // Retrieve the content from the file
125
+ $content = file_get_contents($reportFolder . "/" . $id);
126
+ // Decode it
127
+ $content = unserialize($content);
128
+ // Loop through the content array
129
+ foreach ($content as $key => $value)
130
+ {
131
+ // The value with the key = 0 of the array is always the error message
132
+ if (!$key)
133
+ {
134
+ $model->setError($value);
135
+ }
136
+ elseif ($key == "url")
137
+ {
138
+ $model->setUrl($value);
139
+ }
140
+ elseif ($key == "script_name")
141
+ {
142
+ $model->setScriptName($value);
143
+ }
144
+ elseif ($key == "skin")
145
+ {
146
+ $model->setSkin($value);
147
+ }
148
+ else
149
+ {
150
+ // The trace has the key = 1, we do it last
151
+ $model->setTrace($value);
152
+ }
153
+ }
154
+
155
+ // Register the data so we can use it in the form
156
+ Mage::register('report_data', $model);
157
+
158
+ // Layout loading / rendering
159
+ $this->loadLayout();
160
+ $this->_setActiveMenu('system/tools/reportsviewer');
161
+
162
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
163
+
164
+ $this->_addContent($this->getLayout()->createBlock('reportsviewer/adminhtml_reportsviewer_view'));
165
+
166
+ $this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
167
+
168
+
169
+ $this->renderLayout();
170
+ }
171
+
172
+ }
app/code/community/DigitalPianism/ReportsViewer/etc/adminhtml.xml ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" ?>
2
+ <config>
3
+ <menu>
4
+ <!-- System Menu -->
5
+ <system>
6
+ <children>
7
+ <!-- Tools Item -->
8
+ <tools>
9
+ <children>
10
+ <!-- Submenu -->
11
+ <reportsviewer translate="title" module="reportsviewer">
12
+ <title>Reports Viewer</title>
13
+ <sort_order>10</sort_order>
14
+ <action>reportsviewer_admin/adminhtml_reportsviewer/index</action>
15
+ </reportsviewer>
16
+ </children>
17
+ </tools>
18
+ </children>
19
+ </system>
20
+ </menu>
21
+
22
+ <acl>
23
+ <resources>
24
+ <all>
25
+ <title>Allow Everything</title>
26
+ </all>
27
+ <admin>
28
+ <children>
29
+ <!-- System Menu -->
30
+ <system>
31
+ <children>
32
+ <!-- Tools item -->
33
+ <tools>
34
+ <children>
35
+ <!-- Submenu -->
36
+ <reportsviewer>
37
+ <title>Reports Viewer</title>
38
+ <sort_order>20</sort_order>
39
+ </reportsviewer>
40
+ </children>
41
+ </tools>
42
+ </children>
43
+ </system>
44
+ </children>
45
+ </admin>
46
+ </resources>
47
+ </acl>
48
+ </config>
app/code/community/DigitalPianism/ReportsViewer/etc/config.xml ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <DigitalPianism_ReportsViewer>
5
+ <version>0.0.4</version>
6
+ </DigitalPianism_ReportsViewer>
7
+ </modules>
8
+
9
+ <admin>
10
+ <routers>
11
+ <!-- Admin route -->
12
+ <reportsviewer_admin>
13
+ <use>admin</use>
14
+ <args>
15
+ <module>DigitalPianism_ReportsViewer</module>
16
+ <frontName>reportsviewer_admin</frontName>
17
+ </args>
18
+ </reportsviewer_admin>
19
+ </routers>
20
+ </admin>
21
+
22
+ <adminhtml>
23
+ <layout>
24
+ <updates>
25
+ <!-- Backend layout update -->
26
+ <reportsviewer module="DigitalPianism_ReportsViewer">
27
+ <file>digitalpianism/reportsviewer.xml</file>
28
+ </reportsviewer>
29
+ </updates>
30
+ </layout>
31
+ </adminhtml>
32
+
33
+ <global>
34
+ <helpers>
35
+ <!-- Helper declaration -->
36
+ <reportsviewer>
37
+ <class>DigitalPianism_ReportsViewer_Helper</class>
38
+ </reportsviewer>
39
+ </helpers>
40
+ <blocks>
41
+ <!-- Block declaration -->
42
+ <reportsviewer>
43
+ <class>DigitalPianism_ReportsViewer_Block</class>
44
+ </reportsviewer>
45
+ </blocks>
46
+
47
+ </global>
48
+ </config>
app/design/adminhtml/default/default/layout/digitalpianism/reportsviewer.xml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <!-- Grid handle -->
4
+ <reportsviewer_admin_adminhtml_reportsviewer_index>
5
+ <update handle="editor" />
6
+ <reference name="content">
7
+ <!-- Grid parent block -->
8
+ <block type="reportsviewer/adminhtml_reportsviewer" name="reportsviewer" />
9
+ </reference>
10
+ </reportsviewer_admin_adminhtml_reportsviewer_index>
11
+ <!-- View handle -->
12
+ <reportsviewer_admin_adminhtml_reportsviewer_view>
13
+ <update handle="editor" />
14
+ </reportsviewer_admin_adminhtml_reportsviewer_view>
15
+ </layout>
app/design/adminhtml/default/default/template/digitalpianism/reportsviewer/list.phtml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This is the grid template that displays the list of reports
4
+ */
5
+ ?>
6
+ <div class="content-header">
7
+ <table cellspacing="0">
8
+ <tr>
9
+ <td><h3 class="icon-head head-reportsviewer"><?php echo Mage::helper('reportsviewer')->__('Reports Viewer') ?></h3></td>
10
+ </tr>
11
+ </table>
12
+ </div>
13
+ <div>
14
+ <?php echo $this->getGridHtml() ?>
15
+ </div>
app/etc/modules/DigitalPianism_ReportsViewer.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <DigitalPianism_ReportsViewer>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </DigitalPianism_ReportsViewer>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>DigitalPianism_ReportsViewer</name>
4
+ <version>0.0.4</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>This module improves the way the category images are managed via the admin.</summary>
10
+ <description>&lt;h2&gt;Description&lt;/h2&gt;&#xD;
11
+ &lt;p&gt;Ever been annoyed by the way Magento handles the error reports ? Having to manually check the var/reports folder and decode the content of the report could be painful, that's why we developped this new module.&lt;/p&gt;&#xD;
12
+ &lt;p&gt;With this extension, you will be able to view and delete the Magento error reports from the backend. No more FTP and no more serialized value to read, the Error Reports Viewer module does everything for you.&#xD;
13
+ &#xD;
14
+ &lt;h2&gt;Reports List&lt;/h2&gt;&#xD;
15
+ &lt;p&gt;Install the module, clear your cache and go to System &gt; Tools &gt; Reports Viewer&lt;/p&gt;&#xD;
16
+ &lt;p&gt;Here you will have the list of all the reports that are in your var/reports folder.&lt;/p&gt;&#xD;
17
+ &lt;p&gt;This list includes the following data:&lt;/p&gt;&#xD;
18
+ &lt;ul&gt;&#xD;
19
+ &lt;li&gt;Report ID&lt;/li&gt;&#xD;
20
+ &lt;li&gt;Error message&lt;/li&gt;&#xD;
21
+ &lt;li&gt;URL&lt;/li&gt;&#xD;
22
+ &lt;li&gt;Script Name&lt;/li&gt;&#xD;
23
+ &lt;li&gt;Skin&lt;/li&gt;&#xD;
24
+ &lt;li&gt;Report File Path&lt;/li&gt;&#xD;
25
+ &lt;li&gt;Creation date&lt;/li&gt;&#xD;
26
+ &lt;/ul&gt;&#xD;
27
+ &#xD;
28
+ &lt;p&gt;From this grid, you have the possibility to mass delete reports (reports will be deleted from the var/reports folder) using the mass action dropdown.&lt;/p&gt;&#xD;
29
+ &#xD;
30
+ &lt;h2&gt;View Report Details&lt;/h2&gt;&#xD;
31
+ &#xD;
32
+ &lt;p&gt;The only data not included in the grid is the trace.&lt;/p&gt;&#xD;
33
+ &lt;p&gt;So when you click the "view details" link or if you click directly on the row, you will get access to a page that displays all the data of the grid PLUS the trace of the report.&lt;/p&gt;&#xD;
34
+ &lt;p&gt;From this page, you can also delete a report.&lt;/p&gt;</description>
35
+ <notes>- Fix display date issue.</notes>
36
+ <authors><author><name>Digital Pianism</name><user>digitalpianism</user><email>contact@digital-pianism.com</email></author></authors>
37
+ <date>2015-08-12</date>
38
+ <time>11:06:36</time>
39
+ <contents><target name="magecommunity"><dir name="DigitalPianism"><dir name="ReportsViewer"><dir name="Block"><dir name="Adminhtml"><dir name="Reportsviewer"><file name="Grid.php" hash="175cb6e707be5c3079c75fc49f4ebf38"/><dir name="View"><file name="Form.php" hash="398b46d47682fb842fd385f13afa6f4b"/></dir><file name="View.php" hash="c234f392f8c3d030d27740ba8036715e"/></dir><file name="Reportsviewer.php" hash="df899cc86e9fdaf9d90ceed175125fab"/><dir name="Template"><dir name="Grid"><dir name="Renderer"><file name="Action.php" hash="ab39437238ad1c8e22f8dd3746865679"/></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="8320b9bdaedd283e702c745a03fbe1f1"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="ReportsviewerController.php" hash="f5ba6ae65f5f5440ae966e2aee8c2dcc"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="b460c9d10c922c26c1bbf121933992a5"/><file name="config.xml" hash="c861e6c48024f85a2ca1e8c670c75f09"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="DigitalPianism_ReportsViewer.xml" hash="bc4370b8f8905113dcf26afbbbd062c6"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="digitalpianism"><file name="reportsviewer.xml" hash="28618a433f486b05eb74a102803afe67"/></dir></dir><dir name="template"><dir name="digitalpianism"><dir name="reportsviewer"><file name="list.phtml" hash="933186d1346fe7e17e6fbfc3c3770abc"/></dir></dir></dir></dir></dir></dir></target></contents>
40
+ <compatible/>
41
+ <dependencies><required><php><min>4.1.0</min><max>6.0.0</max></php></required></dependencies>
42
+ </package>