Version Notes
Initial release.
Download this release
Release Info
Developer | Jukka Viljala |
Extension | Rockwells_LogViewer |
Version | 0.1.0 |
Comparing to | |
See all releases |
Version 0.1.0
- app/code/community/Rockwells/LogViewer/Block/Adminhtml/Viewer.php +30 -0
- app/code/community/Rockwells/LogViewer/Block/Adminhtml/Viewer/Edit/Form.php +38 -0
- app/code/community/Rockwells/LogViewer/Block/Adminhtml/Viewer/Grid.php +100 -0
- app/code/community/Rockwells/LogViewer/Block/Adminhtml/Viewer/View.php +50 -0
- app/code/community/Rockwells/LogViewer/Helper/Data.php +43 -0
- app/code/community/Rockwells/LogViewer/controllers/Adminhtml/IndexController.php +78 -0
- app/code/community/Rockwells/LogViewer/etc/config.xml +83 -0
- app/design/adminhtml/default/default/layout/logviewer/logviewer.xml +27 -0
- app/etc/modules/Rockwells_LogViewer.xml +9 -0
- app/locale/en_US/Rockwells_LogViewer.csv +23 -0
- package.xml +18 -0
- skin/adminhtml/default/default/logviewer/linedtextarea.css +58 -0
- skin/adminhtml/default/default/logviewer/linedtextarea.js +102 -0
- skin/adminhtml/default/default/logviewer/load.js +4 -0
app/code/community/Rockwells/LogViewer/Block/Adminhtml/Viewer.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Rockwells_LogViewer_Block_Adminhtml_Viewer extends Mage_Adminhtml_Block_Widget_Grid_Container {
|
4 |
+
|
5 |
+
public function __construct() {
|
6 |
+
$this->_blockGroup = 'logviewer';
|
7 |
+
$this->_controller = 'adminhtml_viewer';
|
8 |
+
$this->_headerText = Mage::helper('logviewer')->__('Log Files');
|
9 |
+
parent::__construct();
|
10 |
+
}
|
11 |
+
|
12 |
+
protected function _prepareLayout() {
|
13 |
+
$this->removeButton('add');
|
14 |
+
return parent::_prepareLayout();
|
15 |
+
}
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Returns the CSS class for the header
|
19 |
+
*
|
20 |
+
* Usually 'icon-head' and a more precise class is returned. We return
|
21 |
+
* only an empty string to avoid spacing on the left of the header as we
|
22 |
+
* don't have an icon.
|
23 |
+
*
|
24 |
+
* @return string
|
25 |
+
*/
|
26 |
+
public function getHeaderCssClass() {
|
27 |
+
return '';
|
28 |
+
}
|
29 |
+
|
30 |
+
}
|
app/code/community/Rockwells/LogViewer/Block/Adminhtml/Viewer/Edit/Form.php
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Rockwells_LogViewer_Block_Adminhtml_Viewer_Edit_Form extends Mage_Adminhtml_Block_Widget_Form {
|
4 |
+
|
5 |
+
protected function _prepareForm() {
|
6 |
+
$form = new Varien_Data_Form(array(
|
7 |
+
'id' => 'view_form',
|
8 |
+
));
|
9 |
+
|
10 |
+
$fieldset = $form->addFieldset('view_file', array());
|
11 |
+
|
12 |
+
$textarea = $fieldset->addField('log-contents', 'textarea', array(
|
13 |
+
'label' => Mage::helper('logviewer')->__('File Contents'),
|
14 |
+
'name' => 'log-contents',
|
15 |
+
'readonly' => 'readonly',
|
16 |
+
'style' => 'width:98%;height:52em;font-family:courier new;',
|
17 |
+
));
|
18 |
+
$textarea->setCols(10000);
|
19 |
+
|
20 |
+
$path = Mage::getBaseDir('log') . DS . Mage::registry('log_file');
|
21 |
+
restore_error_handler();
|
22 |
+
$contents = file_get_contents($path);
|
23 |
+
if ($contents === false) {
|
24 |
+
$err = error_get_last();
|
25 |
+
if (!empty($err)) {
|
26 |
+
$contents = Mage::helper('logviewer')->__('Error reading file: %s', $err['message']);
|
27 |
+
} else {
|
28 |
+
$contents = Mage::helper('logviewer')->__('Error reading file.');
|
29 |
+
}
|
30 |
+
}
|
31 |
+
|
32 |
+
$form->setUseContainer(true);
|
33 |
+
$form->setValues(array('log-contents' => $contents));
|
34 |
+
$this->setForm($form);
|
35 |
+
return parent::_prepareForm();
|
36 |
+
}
|
37 |
+
|
38 |
+
}
|
app/code/community/Rockwells/LogViewer/Block/Adminhtml/Viewer/Grid.php
ADDED
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Rockwells_LogViewer_Block_Adminhtml_Viewer_Grid extends Mage_Adminhtml_Block_Widget_Grid {
|
4 |
+
|
5 |
+
/* @var $_helper Rockwells_LogViewer_Helper_Data */
|
6 |
+
protected $_helper;
|
7 |
+
|
8 |
+
public function __construct() {
|
9 |
+
parent::__construct();
|
10 |
+
$this->_helper = Mage::helper('logviewer');
|
11 |
+
|
12 |
+
$this->setId('logviewer_grid');
|
13 |
+
$this->_filterVisibility = false;
|
14 |
+
$this->_pagerVisibility = false;
|
15 |
+
$this->_defaultSort = 'filesize';
|
16 |
+
$this->_defaultDir = 'desc';
|
17 |
+
}
|
18 |
+
|
19 |
+
protected function _prepareCollection() {
|
20 |
+
$sort = $this->getParam('sort', $this->_defaultSort);
|
21 |
+
$dir = $this->getParam('dir', $this->_defaultDir);
|
22 |
+
$files = $this->_helper->getLogFiles();
|
23 |
+
if (isset($sort) && !empty($files) && isset($files[0][$sort])) {
|
24 |
+
usort($files, function($a, $b) use ($sort, $dir) {
|
25 |
+
$a = $a[$sort];
|
26 |
+
$b = $b[$sort];
|
27 |
+
if (is_numeric($a)) {
|
28 |
+
return ($dir == 'asc' ? $a - $b : $b - $a);
|
29 |
+
} else {
|
30 |
+
return ($dir == 'asc' ? strcmp($a, $b) : -strcmp($a, $b));
|
31 |
+
}
|
32 |
+
});
|
33 |
+
}
|
34 |
+
$collection = new Varien_Data_Collection();
|
35 |
+
foreach ($files as $file) {
|
36 |
+
$item = new Varien_Object();
|
37 |
+
$item->setIdFieldName('filename');
|
38 |
+
$item->setFilename($file['filename']);
|
39 |
+
$item->setFilesize($this->_helper->humanFilesize($file['filesize']));
|
40 |
+
$item->setLines($file['lines']);
|
41 |
+
$collection->addItem($item);
|
42 |
+
}
|
43 |
+
$this->setCollection($collection);
|
44 |
+
return parent::_prepareCollection();
|
45 |
+
}
|
46 |
+
|
47 |
+
protected function _prepareMassaction() {
|
48 |
+
$this->setMassactionIdField('filename');
|
49 |
+
$this->getMassactionBlock()->setFormFieldName('files');
|
50 |
+
$this->getMassactionBlock()->addItem('files', array(
|
51 |
+
'label' => $this->_helper->__('Empty'),
|
52 |
+
'url' => $this->getUrl('*/*/massEmpty'),
|
53 |
+
'confirm' => $this->_helper->__('Are you sure you want to do this?')
|
54 |
+
));
|
55 |
+
return $this;
|
56 |
+
}
|
57 |
+
|
58 |
+
protected function _prepareColumns() {
|
59 |
+
$this->addColumn('filename', array(
|
60 |
+
'header' => $this->_helper->__('File Name'),
|
61 |
+
'index' => 'filename',
|
62 |
+
'sortable' => true,
|
63 |
+
));
|
64 |
+
$this->addColumn('filesize', array(
|
65 |
+
'header' => $this->_helper->__('File Size'),
|
66 |
+
'index' => 'filesize',
|
67 |
+
'sortable' => true,
|
68 |
+
));
|
69 |
+
$this->addColumn('lines', array(
|
70 |
+
'header' => $this->_helper->__('Lines'),
|
71 |
+
'index' => 'lines',
|
72 |
+
'sortable' => true,
|
73 |
+
));
|
74 |
+
$this->addColumn('action',
|
75 |
+
array(
|
76 |
+
'header' => $this->_helper->__('Action'),
|
77 |
+
'width' => '50px',
|
78 |
+
'type' => 'action',
|
79 |
+
'getter' => 'getFilename',
|
80 |
+
'actions' => array(
|
81 |
+
array(
|
82 |
+
'caption' => $this->_helper->__('View'),
|
83 |
+
'url' => array(
|
84 |
+
'base' => '*/*/view',
|
85 |
+
),
|
86 |
+
'field' => 'file'
|
87 |
+
)
|
88 |
+
),
|
89 |
+
'filter' => false,
|
90 |
+
'sortable' => false,
|
91 |
+
));
|
92 |
+
return parent::_prepareColumns();
|
93 |
+
}
|
94 |
+
|
95 |
+
public function getRowUrl($row) {
|
96 |
+
return $this->getUrl('*/*/view', array(
|
97 |
+
'file' => $row->getFilename(),
|
98 |
+
));
|
99 |
+
}
|
100 |
+
}
|
app/code/community/Rockwells/LogViewer/Block/Adminhtml/Viewer/View.php
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Rockwells_LogViewer_Block_Adminhtml_Viewer_View extends Mage_Adminhtml_Block_Widget_Form_Container {
|
4 |
+
|
5 |
+
/* @var $_helper Rockwells_LogViewer_Helper_Data */
|
6 |
+
protected $_helper;
|
7 |
+
|
8 |
+
public function __construct() {
|
9 |
+
parent::__construct();
|
10 |
+
$this->_helper = Mage::helper('logviewer');
|
11 |
+
|
12 |
+
$this->_objectId = 'file';
|
13 |
+
$this->_blockGroup = 'logviewer';
|
14 |
+
$this->_controller = 'adminhtml_viewer';
|
15 |
+
$this->_removeButton('save');
|
16 |
+
$this->_removeButton('reset');
|
17 |
+
$this->_addButton('empty', array(
|
18 |
+
'label' => $this->_helper->__('Empty File'),
|
19 |
+
'class' => 'delete',
|
20 |
+
'onclick' => 'deleteConfirm(\''. Mage::helper('adminhtml')->__('Are you sure you want to do this?')
|
21 |
+
.'\', \'' . $this->getDeleteUrl() . '\')',
|
22 |
+
));
|
23 |
+
|
24 |
+
$file = $this->getRequest()->getParam($this->_objectId);
|
25 |
+
Mage::register('log_file', $file);
|
26 |
+
}
|
27 |
+
|
28 |
+
public function getDeleteUrl() {
|
29 |
+
return $this->getUrl('*/*/empty', array($this->_objectId => $this->getRequest()->getParam($this->_objectId)));
|
30 |
+
}
|
31 |
+
|
32 |
+
public function getHeaderText(){
|
33 |
+
$file = $this->getRequest()->getParam($this->_objectId);
|
34 |
+
return sprintf($this->_helper->__('Viewing file: %s'), $file);
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Returns the CSS class for the header
|
39 |
+
*
|
40 |
+
* Usually 'icon-head' and a more precise class is returned. We return
|
41 |
+
* only an empty string to avoid spacing on the left of the header as we
|
42 |
+
* don't have an icon.
|
43 |
+
*
|
44 |
+
* @return string
|
45 |
+
*/
|
46 |
+
public function getHeaderCssClass() {
|
47 |
+
return '';
|
48 |
+
}
|
49 |
+
|
50 |
+
}
|
app/code/community/Rockwells/LogViewer/Helper/Data.php
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Rockwells_LogViewer_Helper_Data extends Mage_Core_Helper_Abstract {
|
4 |
+
|
5 |
+
public function getLogFiles() {
|
6 |
+
$dir = Mage::getBaseDir('log') . DS;
|
7 |
+
$files = scandir($dir);
|
8 |
+
$useWc = PHP_OS != 'WINNT';
|
9 |
+
$collection = array();
|
10 |
+
foreach ($files as $file) {
|
11 |
+
if ($file == '.' || $file == '..') {
|
12 |
+
continue;
|
13 |
+
}
|
14 |
+
$path = "$dir$file";
|
15 |
+
if (is_dir($path)) {
|
16 |
+
continue;
|
17 |
+
}
|
18 |
+
$lines = 0;
|
19 |
+
if ($useWc) {
|
20 |
+
$lines = intval(exec('wc -l ' . escapeshellarg($path)));
|
21 |
+
} else {
|
22 |
+
$fh = fopen($path, 'rb');
|
23 |
+
while (!feof($fh)) {
|
24 |
+
$lines += substr_count(fread($fh, 8192), "\n");
|
25 |
+
}
|
26 |
+
fclose($fh);
|
27 |
+
}
|
28 |
+
$collection[] = array(
|
29 |
+
'filename' => $file,
|
30 |
+
'filesize' => filesize($path),
|
31 |
+
'lines' => $lines,
|
32 |
+
);
|
33 |
+
}
|
34 |
+
return $collection;
|
35 |
+
}
|
36 |
+
|
37 |
+
public function humanFilesize($bytes, $decimals = 2) {
|
38 |
+
$size = array('B','kB','MB','GB','TB','PB','EB','ZB','YB');
|
39 |
+
$factor = floor((strlen($bytes) - 1) / 3);
|
40 |
+
return sprintf("%.{$decimals}f %s", $bytes / pow(1024, $factor), $size[$factor]);
|
41 |
+
}
|
42 |
+
|
43 |
+
}
|
app/code/community/Rockwells/LogViewer/controllers/Adminhtml/IndexController.php
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Rockwells_LogViewer_Adminhtml_IndexController extends Mage_Adminhtml_Controller_Action {
|
4 |
+
|
5 |
+
/* @var $_helper Rockwells_LogViewer_Helper_Data */
|
6 |
+
protected $_helper;
|
7 |
+
|
8 |
+
public function _construct() {
|
9 |
+
parent::_construct();
|
10 |
+
$this->_helper = Mage::helper('logviewer');
|
11 |
+
}
|
12 |
+
|
13 |
+
public function indexAction() {
|
14 |
+
$this->_title($this->_helper->__('System'))->_title($this->_helper->__('Log Viewer'));
|
15 |
+
$this->loadLayout()->_setActiveMenu('system');
|
16 |
+
$this->renderLayout();
|
17 |
+
}
|
18 |
+
|
19 |
+
public function viewAction() {
|
20 |
+
$this->_title($this->_helper->__('System'))->_title($this->_helper->__('Log Viewer'))->_title($this->_helper->__('View Log'));
|
21 |
+
$this->loadLayout()->_setActiveMenu('system');
|
22 |
+
$this->renderLayout();
|
23 |
+
}
|
24 |
+
|
25 |
+
protected function _emptyFile($file) {
|
26 |
+
$path = Mage::getBaseDir('log') . DS . $file;
|
27 |
+
$fh = fopen($path, 'r+');
|
28 |
+
if ($fh === false) {
|
29 |
+
$err = error_get_last();
|
30 |
+
if (!empty($err)) {
|
31 |
+
throw new Exception($this->_helper->__('Error emptying file: %s', $err['message']));
|
32 |
+
}
|
33 |
+
throw new Exception($this->_helper->__('Error emptying file.'));
|
34 |
+
}
|
35 |
+
ftruncate($fh, 0);
|
36 |
+
fclose($fh);
|
37 |
+
return $this;
|
38 |
+
}
|
39 |
+
|
40 |
+
public function emptyAction() {
|
41 |
+
restore_error_handler();
|
42 |
+
$file = $this->getRequest()->getParam('file');
|
43 |
+
try {
|
44 |
+
$this->_emptyFile($file);
|
45 |
+
Mage::getSingleton('adminhtml/session')->addSuccess($this->_helper->__('The file has been emptied.'));
|
46 |
+
$this->_redirect('*/*/');
|
47 |
+
} catch (Exception $e) {
|
48 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
49 |
+
$this->_redirect('*/*/view', array('file' => $file));
|
50 |
+
}
|
51 |
+
}
|
52 |
+
|
53 |
+
public function massEmptyAction() {
|
54 |
+
$files = $this->getRequest()->getParam('files');
|
55 |
+
if (empty($files) || empty($files[0])) {
|
56 |
+
Mage::getSingleton('adminhtml/session')->addNotice($this->_helper->__('No files selected.'));
|
57 |
+
} else {
|
58 |
+
$errors = array();
|
59 |
+
for ($i = 0; $i < count($files); $i++) {
|
60 |
+
$file = $files[$i];
|
61 |
+
try {
|
62 |
+
$this->_emptyFile($file);
|
63 |
+
} catch (Exception $e) {
|
64 |
+
unset($files[$i]);
|
65 |
+
$errors[] = $file;
|
66 |
+
}
|
67 |
+
}
|
68 |
+
$success = sprintf($this->_helper->__('Emptied files:<br /> * %s', implode($this->_helper->__('<br /> * '), $files)));
|
69 |
+
Mage::getSingleton('adminhtml/session')->addSuccess($success);
|
70 |
+
if (!empty($errors)) {
|
71 |
+
$error = sprintf($this->_helper->__('Could not empty files:<br /> * %s', implode($this->_helper->__('<br /> * '), $errors)));
|
72 |
+
Mage::getSingleton('adminhtml/session')->addError($error);
|
73 |
+
}
|
74 |
+
}
|
75 |
+
$this->_redirect('*/*/');
|
76 |
+
}
|
77 |
+
|
78 |
+
}
|
app/code/community/Rockwells/LogViewer/etc/config.xml
ADDED
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" ?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Rockwells_LogViewer>
|
5 |
+
<version>0.1.0</version>
|
6 |
+
</Rockwells_LogViewer>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<models>
|
10 |
+
<logviewer>
|
11 |
+
<class>Rockwells_LogViewer_Model</class>
|
12 |
+
</logviewer>
|
13 |
+
</models>
|
14 |
+
<blocks>
|
15 |
+
<logviewer>
|
16 |
+
<class>Rockwells_LogViewer_Block</class>
|
17 |
+
</logviewer>
|
18 |
+
</blocks>
|
19 |
+
<helpers>
|
20 |
+
<logviewer>
|
21 |
+
<class>Rockwells_LogViewer_Helper</class>
|
22 |
+
</logviewer>
|
23 |
+
</helpers>
|
24 |
+
</global>
|
25 |
+
<admin>
|
26 |
+
<routers>
|
27 |
+
<logviewer>
|
28 |
+
<use>admin</use>
|
29 |
+
<args>
|
30 |
+
<module>Rockwells_LogViewer</module>
|
31 |
+
<frontName>logviewer</frontName>
|
32 |
+
</args>
|
33 |
+
</logviewer>
|
34 |
+
</routers>
|
35 |
+
</admin>
|
36 |
+
<adminhtml>
|
37 |
+
<translate>
|
38 |
+
<modules>
|
39 |
+
<logviewer>
|
40 |
+
<files>
|
41 |
+
<default>Rockwells_LogViewer.csv</default>
|
42 |
+
</files>
|
43 |
+
</logviewer>
|
44 |
+
</modules>
|
45 |
+
</translate>
|
46 |
+
<layout>
|
47 |
+
<updates>
|
48 |
+
<logviewer>
|
49 |
+
<file>logviewer/logviewer.xml</file>
|
50 |
+
</logviewer>
|
51 |
+
</updates>
|
52 |
+
</layout>
|
53 |
+
<menu>
|
54 |
+
<system>
|
55 |
+
<children>
|
56 |
+
<logviewer translate="title" module="logviewer">
|
57 |
+
<title>Log Viewer</title>
|
58 |
+
<action>logviewer/adminhtml_index</action>
|
59 |
+
</logviewer>
|
60 |
+
</children>
|
61 |
+
</system>
|
62 |
+
</menu>
|
63 |
+
<acl>
|
64 |
+
<resources>
|
65 |
+
<admin>
|
66 |
+
<children>
|
67 |
+
<system>
|
68 |
+
<children>
|
69 |
+
<config>
|
70 |
+
<children>
|
71 |
+
<logviewer>
|
72 |
+
<title>Log Viewer</title>
|
73 |
+
</logviewer>
|
74 |
+
</children>
|
75 |
+
</config>
|
76 |
+
</children>
|
77 |
+
</system>
|
78 |
+
</children>
|
79 |
+
</admin>
|
80 |
+
</resources>
|
81 |
+
</acl>
|
82 |
+
</adminhtml>
|
83 |
+
</config>
|
app/design/adminhtml/default/default/layout/logviewer/logviewer.xml
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<layout>
|
3 |
+
<logviewer_adminhtml_index_index>
|
4 |
+
<reference name="content">
|
5 |
+
<block type="logviewer/adminhtml_viewer" name="logviewer.viewer" />
|
6 |
+
</reference>
|
7 |
+
</logviewer_adminhtml_index_index>
|
8 |
+
<logviewer_adminhtml_index_view>
|
9 |
+
<reference name="head">
|
10 |
+
<action method="addItem">
|
11 |
+
<type>skin_css</type>
|
12 |
+
<name>logviewer/linedtextarea.css</name>
|
13 |
+
</action>
|
14 |
+
<action method="addItem">
|
15 |
+
<type>skin_js</type>
|
16 |
+
<name>logviewer/linedtextarea.js</name>
|
17 |
+
</action>
|
18 |
+
<action method="addItem">
|
19 |
+
<type>skin_js</type>
|
20 |
+
<name>logviewer/load.js</name>
|
21 |
+
</action>
|
22 |
+
</reference>
|
23 |
+
<reference name="content">
|
24 |
+
<block type="logviewer/adminhtml_viewer_view" name="logviewer.view" />
|
25 |
+
</reference>
|
26 |
+
</logviewer_adminhtml_index_view>
|
27 |
+
</layout>
|
app/etc/modules/Rockwells_LogViewer.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Rockwells_LogViewer>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
</Rockwells_LogViewer>
|
8 |
+
</modules>
|
9 |
+
</config>
|
app/locale/en_US/Rockwells_LogViewer.csv
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"File Contents","File Contents"
|
2 |
+
"Empty","Empty"
|
3 |
+
"Are you sure you want to do this?","Are you sure you want to do this?"
|
4 |
+
"File Name","File Name"
|
5 |
+
"File Size","File Size"
|
6 |
+
"Lines","Lines"
|
7 |
+
"Action","Action"
|
8 |
+
"View","View"
|
9 |
+
"View Log","View Log"
|
10 |
+
"Empty File","Empty File"
|
11 |
+
"Are you sure you want to do this?","Are you sure you want to do this?"
|
12 |
+
"Viewing file: %s","Viewing file: %s"
|
13 |
+
"Log Files","Log Files"
|
14 |
+
"Log Viewer","Log Viewer"
|
15 |
+
"Error reading file: %s","Error reading file: %s"
|
16 |
+
"Error emptying file.","Error emptying file."
|
17 |
+
"Error emptying file: %s","Error emptying file: %s"
|
18 |
+
"Error emptying file.","Error emptying file."
|
19 |
+
"The file has been emptied.","The file has been emptied."
|
20 |
+
"No files selected.","No files selected."
|
21 |
+
"Emptied files:<br /> * %s","Emptied files:<br /> * %s"
|
22 |
+
"Could not empty files:<br /> * %s","Could not empty files:<br /> * %s"
|
23 |
+
"<br /> * ","<br /> * "
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Rockwells_LogViewer</name>
|
4 |
+
<version>0.1.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://opensource.org/licenses/mit-license.php">MIT License (MIT)</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Backend viewer for log files.</summary>
|
10 |
+
<description>Provides way to view log files in the Magento backend. All files in the /var/log directory can be viewed and emptied if desired.</description>
|
11 |
+
<notes>Initial release.</notes>
|
12 |
+
<authors><author><name>Jukka Viljala</name><user>murkeli</user><email>murkelius@gmail.com</email></author></authors>
|
13 |
+
<date>2015-03-13</date>
|
14 |
+
<time>21:41:58</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="Rockwells"><dir name="LogViewer"><dir name="Block"><dir name="Adminhtml"><dir name="Viewer"><dir name="Edit"><file name="Form.php" hash="f329c2f1d50683d15c5d22a01139aba8"/></dir><file name="Grid.php" hash="6e436266633a5f0ba12953b2b65570ec"/><file name="View.php" hash="d1891de15029897f9ca307c09aad4ad7"/></dir><file name="Viewer.php" hash="f659d3b810b7f276261bdf7d07e87563"/></dir></dir><dir name="Helper"><file name="Data.php" hash="f73a99ff5af3f2863b6039c706c249f2"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="IndexController.php" hash="0c90479f83c0fc4b7e6ecf8003d09bc1"/></dir></dir><dir name="etc"><file name="config.xml" hash="876ef0e98060fdfd75a02349947c209f"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="logviewer"><file name="logviewer.xml" hash="ed4cb78b3fbf51e9f9f30d5e72c72fe3"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Rockwells_LogViewer.xml" hash="20cefafd2c0d57a51e980a62054418be"/></dir></target><target name="magelocale"><dir name="en_US"><file name="Rockwells_LogViewer.csv" hash="beab09c3b3d0d978f5533feaf09ea4a2"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="logviewer"><file name="linedtextarea.css" hash="2e594409a47f046919afc51fda73440c"/><file name="linedtextarea.js" hash="074669b1ac7f01b582216011a7a043de"/><file name="load.js" hash="975098b892ed0131038978066a35c09e"/></dir></dir></dir></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.6.0.0</min><max>1.9.1.0</max></package></required></dependencies>
|
18 |
+
</package>
|
skin/adminhtml/default/default/logviewer/linedtextarea.css
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* jQuery Lined Textarea Plugin
|
3 |
+
* http://alan.blog-city.com/jquerylinedtextarea.htm
|
4 |
+
*
|
5 |
+
* Copyright (c) 2010 Alan Williamson
|
6 |
+
*
|
7 |
+
* Released under the MIT License:
|
8 |
+
* http://www.opensource.org/licenses/mit-license.php
|
9 |
+
*
|
10 |
+
*/
|
11 |
+
|
12 |
+
.linedwrap {
|
13 |
+
border: 1px solid #c0c0c0;
|
14 |
+
padding: 3px;
|
15 |
+
}
|
16 |
+
|
17 |
+
.linedtextarea {
|
18 |
+
padding: 0px;
|
19 |
+
margin: 0px;
|
20 |
+
}
|
21 |
+
|
22 |
+
.linedtextarea textarea, .linedwrap .codelines .lineno {
|
23 |
+
font-size: 10pt;
|
24 |
+
font-family: monospace;
|
25 |
+
line-height: normal !important;
|
26 |
+
}
|
27 |
+
|
28 |
+
.linedtextarea textarea {
|
29 |
+
padding-right:0.3em;
|
30 |
+
padding-top:0.3em;
|
31 |
+
border: 0;
|
32 |
+
}
|
33 |
+
|
34 |
+
.linedwrap .lines {
|
35 |
+
margin-top: 0px;
|
36 |
+
width: 50px;
|
37 |
+
float: left;
|
38 |
+
overflow: hidden;
|
39 |
+
border-right: 1px solid #c0c0c0;
|
40 |
+
margin-right: 10px;
|
41 |
+
}
|
42 |
+
|
43 |
+
.linedwrap .codelines {
|
44 |
+
padding-top: 5px;
|
45 |
+
}
|
46 |
+
|
47 |
+
.linedwrap .codelines .lineno {
|
48 |
+
color:#AAAAAA;
|
49 |
+
padding-right: 0.5em;
|
50 |
+
padding-top: 0.0em;
|
51 |
+
text-align: right;
|
52 |
+
white-space: nowrap;
|
53 |
+
}
|
54 |
+
|
55 |
+
.linedwrap .codelines .lineselect {
|
56 |
+
color: red;
|
57 |
+
font-weight: bold;
|
58 |
+
}
|
skin/adminhtml/default/default/logviewer/linedtextarea.js
ADDED
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* Displays line numbers in a textbox.
|
3 |
+
*
|
4 |
+
* Usage:
|
5 |
+
* $("id").linedtextarea();
|
6 |
+
* $$("selector").each(function(element) {
|
7 |
+
* element.linedtextarea();
|
8 |
+
* });
|
9 |
+
*
|
10 |
+
* Converted to Prototype.js from http://alan.blog-city.com/jquerylinedtextarea.htm
|
11 |
+
*/
|
12 |
+
(function() {
|
13 |
+
|
14 |
+
/*
|
15 |
+
* Helper function to make sure the line numbers are always
|
16 |
+
* kept up to the current system
|
17 |
+
*/
|
18 |
+
var fillOutLines = function(codeLines, h, lineNo) {
|
19 |
+
while ((codeLines.measure("height") - h) <= 0) {
|
20 |
+
codeLines.insert("<div class='lineno' id='lineno-" + lineNo + "'>" + lineNo + "</div>");
|
21 |
+
lineNo++;
|
22 |
+
}
|
23 |
+
return lineNo;
|
24 |
+
};
|
25 |
+
|
26 |
+
var LinedTextarea = {
|
27 |
+
linedtextarea: function(element) {
|
28 |
+
element = $(element);
|
29 |
+
var lineNo = 1;
|
30 |
+
/* Turn off the wrapping of as we don't want to screw up the line numbers */
|
31 |
+
element.writeAttribute("wrap", "off");
|
32 |
+
element.setStyle({resize: "none"});
|
33 |
+
var originalTextAreaWidth = element.measure("border-box-width");
|
34 |
+
|
35 |
+
/* Wrap the text area in the elements we need */
|
36 |
+
Element.wrap(element, "div", { 'class': "linedtextarea" });
|
37 |
+
var linedTextAreaDiv = element.up().wrap("div", {
|
38 |
+
'class': "linedwrap",
|
39 |
+
style: "width:" + originalTextAreaWidth + "px",
|
40 |
+
});
|
41 |
+
var linedWrapDiv = linedTextAreaDiv.up();
|
42 |
+
|
43 |
+
var linesDiv = new Element("div", {
|
44 |
+
'class': "lines",
|
45 |
+
style: "width:50px;height:" + (element.measure("height") + 6) + "px;",
|
46 |
+
});
|
47 |
+
var codeLinesDiv = new Element("div", { 'class': "codelines" });
|
48 |
+
linesDiv.insert(codeLinesDiv);
|
49 |
+
|
50 |
+
linedTextAreaDiv.insert({ top: linesDiv });
|
51 |
+
|
52 |
+
/* Draw the number bar; filling it out where necessary */
|
53 |
+
lineNo = fillOutLines(codeLinesDiv, linesDiv.measure("height"), 1);
|
54 |
+
|
55 |
+
/* Set the width */
|
56 |
+
var sidebarWidth = linesDiv.measure("border-box-width");
|
57 |
+
var paddingHorizontal = linedWrapDiv.measure("border-left") +
|
58 |
+
linedWrapDiv.measure("border-right") +
|
59 |
+
linedWrapDiv.measure("padding-left") +
|
60 |
+
linedWrapDiv.measure("padding-right");
|
61 |
+
var linedWrapDivNewWidth = originalTextAreaWidth - paddingHorizontal;
|
62 |
+
var textareaNewWidth = originalTextAreaWidth - sidebarWidth - paddingHorizontal - 20;
|
63 |
+
|
64 |
+
element.setStyle({ width: textareaNewWidth + "px" });
|
65 |
+
linedWrapDiv.setStyle({ width: linedWrapDivNewWidth + "px" });
|
66 |
+
|
67 |
+
/* React to the scroll event */
|
68 |
+
element.observe("scroll", function() {
|
69 |
+
//var domTextArea = $(this)[0];
|
70 |
+
var scrollTop = element.scrollTop;
|
71 |
+
var clientHeight = element.clientHeight;
|
72 |
+
codeLinesDiv.setStyle({'margin-top': (-1 * scrollTop) + "px"});
|
73 |
+
lineNo = fillOutLines(codeLinesDiv, scrollTop + clientHeight, lineNo);
|
74 |
+
});
|
75 |
+
|
76 |
+
/* Should the textarea get resized outside of our control */
|
77 |
+
element.observe("resize", function() {
|
78 |
+
linesDiv.height(element.clientHeight + 6);
|
79 |
+
});
|
80 |
+
|
81 |
+
var selectionChange = function() {
|
82 |
+
if (element.selectionStart !== undefined && element.selectionStart >= 0) {
|
83 |
+
var start = element.selectionStart;
|
84 |
+
var end = element.selectionEnd;
|
85 |
+
var firstLine = element.value.substr(0, start).split("\n").length;
|
86 |
+
var lastLine = firstLine + element.value.substr(start, end - start).split("\n").length;
|
87 |
+
$$(".lineselect").each(function(elem) {
|
88 |
+
elem.removeClassName("lineselect");
|
89 |
+
});
|
90 |
+
for (var line = firstLine; line < lastLine; line++) {
|
91 |
+
$("lineno-" + line).addClassName("lineselect");
|
92 |
+
}
|
93 |
+
}
|
94 |
+
};
|
95 |
+
element.observe("keyup", selectionChange);
|
96 |
+
element.observe("click", selectionChange);
|
97 |
+
element.observe("focus", selectionChange);
|
98 |
+
},
|
99 |
+
};
|
100 |
+
|
101 |
+
Element.addMethods(LinedTextarea);
|
102 |
+
})();
|
skin/adminhtml/default/default/logviewer/load.js
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
document.observe("dom:loaded", function(){
|
3 |
+
$("log-contents").linedtextarea();
|
4 |
+
});
|