From 2f628b0df22333a89425536da8e76e41a1dfe2e4 Mon Sep 17 00:00:00 2001 From: AlekVolsk Date: Tue, 13 Aug 2019 15:17:08 +0400 Subject: [PATCH] v1.3.8 --- README.md | 4 +- README.ru.md | 4 +- admin/config.xml | 2 +- admin/controllers/items.php | 2 +- admin/models/ajax.php | 8 +-- admin/models/fields/fileselect.css | 11 +++- admin/models/fields/fileselect.php | 97 +++++++++++++++++------------- admin/views/items/tmpl/default.php | 12 ++-- admin/views/items/view.html.php | 26 ++++---- admin/vlogs.php | 2 +- vlogs.xml | 2 +- 11 files changed, 97 insertions(+), 73 deletions(-) diff --git a/README.md b/README.md index d34c78a..acc4859 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # View logs -![Version](https://img.shields.io/badge/VERSION-1.3.7-0366d6.svg?style=for-the-badge) +![Version](https://img.shields.io/badge/VERSION-1.3.4-0366d6.svg?style=for-the-badge) ![Joomla](https://img.shields.io/badge/joomla-3.2+-1A3867.svg?style=for-the-badge) ![Php](https://img.shields.io/badge/php-5.6+-8892BF.svg?style=for-the-badge) @@ -8,6 +8,8 @@ _description in Russian [here](README.ru.md)_ ## Component view the saved logs of core and extensions Joomla +### Powered by Joomla!4 + **Scope**: - reading log files and displaying their contents in a tabular form in the admin panel diff --git a/README.ru.md b/README.ru.md index 90a9fb6..6965ec8 100644 --- a/README.ru.md +++ b/README.ru.md @@ -1,11 +1,13 @@ # View logs -![Version](https://img.shields.io/badge/VERSION-1.3.7-0366d6.svg?style=for-the-badge) +![Version](https://img.shields.io/badge/VERSION-1.3.8-0366d6.svg?style=for-the-badge) ![Joomla](https://img.shields.io/badge/joomla-3.2+-1A3867.svg?style=for-the-badge) ![Php](https://img.shields.io/badge/php-5.6+-8892BF.svg?style=for-the-badge) ## Компонент просмотра сохраненных логов ядра и расширений Joomla +### Работает на Joomla!4 + **Возможности**: - чтение файлов логов и вывод их содержимого в табличном виде в админке diff --git a/admin/config.xml b/admin/config.xml index 26a29d6..9b83aca 100644 --- a/admin/config.xml +++ b/admin/config.xml @@ -2,7 +2,7 @@
- + diff --git a/admin/controllers/items.php b/admin/controllers/items.php index 3e314cf..92358bd 100644 --- a/admin/controllers/items.php +++ b/admin/controllers/items.php @@ -6,4 +6,4 @@ function __construct($config = []) { parent::__construct($config); } -} \ No newline at end of file +} diff --git a/admin/models/ajax.php b/admin/models/ajax.php index de8d2fb..7cfed5e 100644 --- a/admin/models/ajax.php +++ b/admin/models/ajax.php @@ -148,7 +148,7 @@ protected function ListPHPEL() } $html[] = ''; } else { - $html[] = '
' . JText::_('COM_VLOGS_DATA_EMPTY') . '
'; + $html[] = '
' . JText::_('COM_VLOGS_DATA_EMPTY') . '
'; } $this->printJson(implode('', $html), true, ['count' => $cnt]); @@ -162,7 +162,7 @@ public function List() $this->ListPHPEL(); } if ($file == '') { - $html = '
' . JText::_('COM_VLOGS_LIST_EMPTY') . '
'; + $html = '
' . JText::_('COM_VLOGS_LIST_EMPTY') . '
'; $this->printJson($html, true, ['count' => 0]); } @@ -285,7 +285,7 @@ public function List() case 'message': $json = json_decode($dataitem, true); $json_result = json_last_error() === JSON_ERROR_NONE; - $html[] = '' . ($json_result ? '

' . JText::_('COM_VLOGS_COLUMN_MSG_JSON_TITLE') . '

' . print_r($json, true) . '
' : htmlspecialchars($dataitem)) . ''; + $html[] = '' . ($json_result ? '
' . print_r($json, true) . '
' : htmlspecialchars($dataitem)) . ''; break; default: $html[] = '' . $dataitem . ''; @@ -296,7 +296,7 @@ public function List() $html[] = ''; } else { - $html[] = '
' . JText::_('COM_VLOGS_DATA_EMPTY') . '
'; + $html[] = '
' . JText::_('COM_VLOGS_DATA_EMPTY') . '
'; } $this->printJson(implode('', $html), true, ['count' => $cnt]); diff --git a/admin/models/fields/fileselect.css b/admin/models/fields/fileselect.css index 2439657..995cea4 100644 --- a/admin/models/fields/fileselect.css +++ b/admin/models/fields/fileselect.css @@ -11,10 +11,15 @@ z-index: 1; } +.av-modal.open { + display: block; +} + .av-folderlist { display: inline-block; box-sizing: border-box; margin: 0; + padding: 0; width: 100%; max-width: 100%; max-height: 250px; @@ -57,7 +62,8 @@ line-height: 21px; } -.av-folderlist .av-folderlist-item:before, .av-folderlist .av-folderlist-item:after { +.av-folderlist .av-folderlist-item:before, +.av-folderlist .av-folderlist-item:after { content: ''; display: table; } @@ -79,7 +85,8 @@ cursor: pointer; } -.av-folderlist .av-folderlist-tree:before, .av-folderlist .av-folderlist-tree:after { +.av-folderlist .av-folderlist-tree:before, +.av-folderlist .av-folderlist-tree:after { content: ''; position: absolute; top: 6px; diff --git a/admin/models/fields/fileselect.php b/admin/models/fields/fileselect.php index 8408d1a..df9148d 100644 --- a/admin/models/fields/fileselect.php +++ b/admin/models/fields/fileselect.php @@ -1,6 +1,6 @@ - */ - +*/ JFormHelper::loadFieldClass('list'); @@ -33,14 +32,14 @@ protected function showdir( $ef = '' // do not use!!! ) { $html = ''; - if ((int)$level == 0) { + if ((int) $level == 0) { $dir = realpath($dir); $ef = ($showRoot ? realpath($dir . DIRECTORY_SEPARATOR . '..') . DIRECTORY_SEPARATOR : $dir . DIRECTORY_SEPARATOR); } if (!file_exists($dir)) return ''; - if ($showRoot && (int)$level == 0) { + if ($showRoot && (int) $level == 0) { $html = '
    '; $subdir = $this->showdir($dir, $folderOnly, $showRoot, $level + 1, $ef); $name = substr(strrchr($dir, DIRECTORY_SEPARATOR), 1); @@ -54,15 +53,17 @@ protected function showdir( $folders = array(); $files = array(); - foreach ($list as $name) + foreach ($list as $name) { if (is_dir($dir . DIRECTORY_SEPARATOR . $name)) { - $folders[] = $name; - } else { - $files[] = $name; + $folders[] = $name; + } else { + $files[] = $name; + } } - if (!($folderOnly && !$folders) || !(!$folders || !$files)) - $html .= ''; + if (!($folderOnly && !$folders) || !(!$folders || !$files)) { + $html .= ''; + } sort($folders); sort($files); @@ -70,20 +71,22 @@ protected function showdir( foreach ($folders as $name) { $fpath = $dir . DIRECTORY_SEPARATOR . $name; $subdir = $this->showdir($fpath, $folderOnly, $showRoot, $level + 1, $ef); - $fpath = str_replace($ef, '', $fpath); + $fpath = str_replace('\\', '/', str_replace($ef, '', $fpath)); $html .= '
  • ' . ($subdir ? '' : '') . '' . $name . '' . $subdir . '
  • '; } if (!$folderOnly) foreach ($files as $name) { - $fpath = $dir . DIRECTORY_SEPARATOR . $name; - $fpath = str_replace($ef, '', $fpath); - $ext = substr(strrchr($name, '.'), 1); - $html .= '
  • ' . $name . '
  • '; - } + $fpath = $dir . DIRECTORY_SEPARATOR . $name; + $fpath = str_replace('\\', '/', str_replace($ef, '', $fpath)); + $ext = substr(strrchr($name, '.'), 1); + $html .= '
  • ' . $name . '
  • '; + } - if (!($folderOnly && !$folders) || !(!$folders || !$files)) + if (!($folderOnly && !$folders) || !(!$folders || !$files)) { $html .= '
'; + } + unset($folders, $files, $fpath, $ext); } } @@ -94,11 +97,10 @@ protected function showdir( protected function getInput() { - // include jq && css - JHtml::_('jquery.framework', false, null, false); + // include css $path = str_replace('\\', '/', str_replace(JPATH_ROOT . DIRECTORY_SEPARATOR, '', __DIR__)); JHtml::_('stylesheet', $path . DIRECTORY_SEPARATOR . 'fileselect.css'); - + // get attributes $folder = $this->getAttribute('folder'); $folder = ($folder && file_exists(realpath(JPATH_ROOT . DIRECTORY_SEPARATOR . $folder)) ? $folder : 'images'); @@ -108,46 +110,59 @@ protected function getInput() $showRoot = $this->getAttribute('showroot'); $showRoot = ($showRoot && (strtolower($showRoot) === 'true' || strtolower($showRoot) === 'showroot') ? true : false); - + // get uniq id $this->uid = uniqid('avfl'); - + // make html $html = '
'; - + // input - $html .= '
'; + $html .= '
'; $html .= 'class ? ' class="' . $this->class . '"' : '') . ' value="' . $this->value . '" placeholder="' . JText::_('Select file or folder') . '" readonly ' . ($this->required ? 'required' : '') . '/>'; if (!$this->readonly) - $html .= ''; - + $html .= ''; + // modal $html .= '
'; $html .= $this->showdir(JPATH_ROOT . DIRECTORY_SEPARATOR . $folder, $folderOnly, $showRoot); $html .= '
'; $html .= '
'; - - // script + $html .= ""; + $html .= '
'; return $html; diff --git a/admin/views/items/tmpl/default.php b/admin/views/items/tmpl/default.php index aa8c0f7..c857682 100644 --- a/admin/views/items/tmpl/default.php +++ b/admin/views/items/tmpl/default.php @@ -1,21 +1,19 @@ - +
- +
- + - +
addStyleDeclaration(".com_vlogs pre {box-sizing:border-box;max-width:100%;width:100%;}"); +JFactory::getDocument()->addStyleDeclaration(".com_vlogs pre {box-sizing:border-box;margin-top:10px;padding:10px;max-width:100%;width:100%;border:1px solid #ddd;background-color:#fefefe;} .com_vlogs .table td, .com_vlogs .table th {vertical-align:top;}"); JFactory::getDocument()->addScriptDeclaration(" document.addEventListener('DOMContentLoaded', function() diff --git a/admin/views/items/view.html.php b/admin/views/items/view.html.php index d99fd5a..44265c9 100644 --- a/admin/views/items/view.html.php +++ b/admin/views/items/view.html.php @@ -9,21 +9,21 @@ public function display($tpl = null) $this->items = $this->get('Items'); - JHtml::script('media/system/js/core.js', [], ['options' => ['version' => 'auto']]); + JHtmlBehavior::core(); JToolBarHelper::title(JText::_('COM_VLOGS'), 'health'); - $custom_button_html = ''; - JToolBar::getInstance('toolbar')->appendButton('Custom', $custom_button_html, 'custom'); + if (count($this->items)) { + $custom_button_html = ''; + JToolBar::getInstance('toolbar')->appendButton('Custom', $custom_button_html, 'custom'); - $custom_button_html = ''; - JToolBar::getInstance('toolbar')->appendButton('Custom', $custom_button_html, 'custom'); + $custom_button_html = ''; + JToolBar::getInstance('toolbar')->appendButton('Custom', $custom_button_html, 'custom'); - if (count($this->items)) { $custom_button_html = ''; JToolBar::getInstance('toolbar')->appendButton('Custom', $custom_button_html, 'custom'); @@ -39,14 +39,14 @@ public function display($tpl = null) } } - $custom_button_html = '' . JText::_('COM_VLOGS_COUNT_ITEMS_VIEW') . ' 0'; - JToolBar::getInstance('toolbar')->appendButton('Custom', $custom_button_html, 'options'); - $canDo = JHelperContent::getActions('com_vlogs'); if ($canDo->get('core.admin')) { JToolBarHelper::preferences('com_vlogs'); } + $custom_button_html = '' . JText::_('COM_VLOGS_COUNT_ITEMS_VIEW') . ' 0'; + JToolBar::getInstance('toolbar')->appendButton('Custom', $custom_button_html, 'options'); + parent::display($tpl); } } diff --git a/admin/vlogs.php b/admin/vlogs.php index 8ca680b..a6a43e0 100644 --- a/admin/vlogs.php +++ b/admin/vlogs.php @@ -1,4 +1,4 @@ -https://alekvolsk.pw © 2019 Aleksey A. Morozov. All right reserved. GNU General Public License version 3 or later; see http://www.gnu.org/licenses/gpl-3.0.txt - 1.3.7 + 1.3.8 COM_VLOGS_DESC August 2019