diff --git a/wire/modules/Process/ProcessLogger/ProcessLogger.module b/wire/modules/Process/ProcessLogger/ProcessLogger.module
index 7cb0a3b7..ef465051 100644
--- a/wire/modules/Process/ProcessLogger/ProcessLogger.module
+++ b/wire/modules/Process/ProcessLogger/ProcessLogger.module
@@ -3,7 +3,7 @@
/**
* ProcessWire Logger (Logs Viewer)
*
- * ProcessWire 3.x, Copyright 2019 by Ryan Cramer
+ * ProcessWire 3.x, Copyright 2023 by Ryan Cramer
* https://processwire.com
*
* @method string formatLogText($text, $logName = '')
@@ -52,7 +52,7 @@ class ProcessLogger extends Process {
$options['itemLabel2'] = 'when';
$options['add'] = false;
$options['edit'] = 'view/{name}/';
- $options['items'] = $this->wire('log')->getLogs(true);
+ $options['items'] = $this->wire()->log->getLogs(true);
$options['sort'] = false;
foreach($options['items'] as $key => $item) {
@@ -78,12 +78,14 @@ class ProcessLogger extends Process {
$this->_x('Entries', 'th'),
$this->_x('Size', 'th'),
));
- $logs = $this->wire('log')->getLogs();
+ $logs = $this->wire()->log->getLogs();
foreach($logs as $log) {
+ $logName = $log['name'];
+ if(ctype_digit($logName)) $logName = " $logName";
$table->row(array(
- $log['name'] => "./view/$log[name]/",
+ $logName => "./view/$log[name]/",
"$log[modified] " . wireRelativeTimeStr($log['modified']),
- $this->wire('log')->getTotalEntries($log['name']),
+ $this->wire()->log->getTotalEntries($log['name']),
"$log[size] " . wireBytesStr($log['size'])
));
}
@@ -101,42 +103,46 @@ class ProcessLogger extends Process {
protected function processAction($action, $name) {
- if(!$this->wire('input')->post("submit_$action")) {
+ $log = $this->wire()->log;
+ $input = $this->wire()->input;
+ $session = $this->wire()->session;
+
+ if(!$input->post("submit_$action")) {
throw new WireException("Action missing submit");
}
- if($action != 'download' && !$this->wire('user')->hasPermission('logs-edit')) {
+ if($action != 'download' && !$this->wire()->user->hasPermission('logs-edit')) {
throw new WirePermissionException("You don't have permission to execute that action");
}
switch($action) {
case 'delete':
- if($this->wire('log')->delete($name)) $this->message(sprintf($this->_('Deleted log: %s'), $name));
- $this->wire('session')->redirect($this->wire('page')->url);
+ if($log->delete($name)) $this->message(sprintf($this->_('Deleted log: %s'), $name));
+ $session->location($this->wire()->page->url);
break;
case 'prune':
- $days = (int) $this->wire('input')->post('prune_days');
- $qty = $this->wire('log')->prune($name, $days);
+ $days = (int) $input->post('prune_days');
+ $qty = $log->prune($name, $days);
$this->message(sprintf($this->_('Pruned "%s" log file (now contains %d entries)'), $name, $qty));
- $this->wire('session')->redirect('./');
+ $session->location('./');
break;
case 'download':
- $filename = $this->wire('log')->getFilename($name);
+ $filename = $log->getFilename($name);
if(file_exists($filename)) wireSendFile($filename, array('forceDownload' => true));
break;
case 'add':
- $text = $this->wire('sanitizer')->text($this->wire('input')->post('add_text'));
+ $text = $this->wire()->sanitizer->text($input->post('add_text'));
if(strlen($text)) {
- $this->wire('log')->save($name, $text);
+ $log->save($name, $text);
$this->message(sprintf($this->_('Saved new log entry to "%s"'), $name));
} else {
$this->error($this->_('Log entry text was blank'));
}
- $this->wire('session')->redirect('./');
+ $session->location('./');
break;
}
}
@@ -155,7 +161,7 @@ class ProcessLogger extends Process {
$logs = $log->getLogs();
if(!isset($logs[$name])) {
$this->error(sprintf('Unknown log: %s', $name));
- $session->redirect('../');
+ $session->location('../');
}
$action = $input->post('action');
if($action) $this->processAction($action, $name);
@@ -277,6 +283,7 @@ class ProcessLogger extends Process {
$f->showIf = 'action=prune';
$fieldset->add($f);
+ /** @var InputfieldSubmit $f */
$f = $modules->get('InputfieldSubmit');
$f->value = $this->_('Burn this log now (permanently delete)');
$f->icon = 'fire';
@@ -284,6 +291,7 @@ class ProcessLogger extends Process {
$f->showIf = 'action=delete';
$fieldset->add($f);
+ /** @var InputfieldSubmit $f */
$f = $modules->get('InputfieldSubmit');
$f->value = $this->_('Add this log entry');
$f->icon = 'leaf';
@@ -351,11 +359,10 @@ class ProcessLogger extends Process {
protected function renderLog(array $items, $name, $time = 0) {
- /** @var Sanitizer $sanitizer */
- $sanitizer = $this->wire('sanitizer');
+ $sanitizer = $this->wire()->sanitizer;
/** @var MarkupAdminDataTable $table */
- $table = $this->wire('modules')->get('MarkupAdminDataTable');
+ $table = $this->wire()->modules->get('MarkupAdminDataTable');
$table->setSortable(false);
$table->setEncodeEntities(false);
$templateItem = reset($items);
@@ -387,7 +394,7 @@ class ProcessLogger extends Process {
}
if(strpos($entry['text'], '&') !== false) {
- $entry['text'] = $this->wire('sanitizer')->unentities($entry['text']);
+ $entry['text'] = $sanitizer->unentities($entry['text']);
}
foreach($entry as $key => $value) {
@@ -415,6 +422,7 @@ class ProcessLogger extends Process {
$table->row($row);
}
+ /** @var LogEntriesArray $entries */
$entries = $this->wire(new LogEntriesArray());
if(count($items)) {
@@ -427,7 +435,7 @@ class ProcessLogger extends Process {
$entries->setStart($start);
$entries->setTotal($total);
/** @var MarkupPagerNav $pager */
- $pager = $this->wire('modules')->get('MarkupPagerNav');
+ $pager = $this->wire()->modules->get('MarkupPagerNav');
$options = array('baseUrl' => "../$name/");
$pagerOut = $pager->render($entries, $options);
$pagerHeadline = $entries->getPaginationString();
@@ -474,7 +482,7 @@ class ProcessLogger extends Process {
$url = preg_replace('{^https?://[^/]+}', '', $url);
}
- $config = $this->wire('config');
+ $config = $this->wire()->config;
$rootUrl = $config->urls->root;
$adminUrl = $config->urls->admin;
$isAdmin = false;
@@ -509,7 +517,7 @@ class ProcessLogger extends Process {
*/
protected function ___formatLogText($text, $logName = '') {
- $config = $this->wire('config');
+ $config = $this->wire()->config;
// shorten paths
foreach(array('site', 'wire') as $name) {
@@ -565,4 +573,3 @@ class ProcessLogger extends Process {
}
}
-