Skip to content
This repository has been archived by the owner on Apr 24, 2023. It is now read-only.

Commit

Permalink
v1.3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
AlekVolsk committed Aug 13, 2019
1 parent d2c35d8 commit 2f628b0
Show file tree
Hide file tree
Showing 11 changed files with 97 additions and 73 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# 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)

_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
Expand Down
4 changes: 3 additions & 1 deletion README.ru.md
Original file line number Diff line number Diff line change
@@ -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

**Возможности**:

- чтение файлов логов и вывод их содержимого в табличном виде в админке
Expand Down
2 changes: 1 addition & 1 deletion admin/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<config>
<fieldset name="global" label="JGLOBAL_FIELDSET_OPTIONS">
<field name="slen" type="text" label="COM_VLOGS_PRM_STRLEN" class="inputbox" default="32768"/>
<field name="apath" type="fileselect" folder="/" folderonly="true" label="COM_VLOGS_PRM_ARCHPATH" class="inputbox" default="tmp" addfieldpath="/administrator/components/com_vlogs/models/fields"/>
<field name="apath" type="fileselect" folder="/" folderonly="true" label="COM_VLOGS_PRM_ARCHPATH" class="form-control inputbox" default="tmp" addfieldpath="/administrator/components/com_vlogs/models/fields"/>
<field name="delafterarch" type="list" label="COM_VLOGS_PRM_DELAFTERARCH" default="0">
<option value="0">JNO</option>
<option value="1">JYES</option>
Expand Down
2 changes: 1 addition & 1 deletion admin/controllers/items.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ function __construct($config = [])
{
parent::__construct($config);
}
}
}
8 changes: 4 additions & 4 deletions admin/models/ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ protected function ListPHPEL()
}
$html[] = '</tbody></table>';
} else {
$html[] = '<div class="alert">' . JText::_('COM_VLOGS_DATA_EMPTY') . '</div>';
$html[] = '<div class="alert alert-primary">' . JText::_('COM_VLOGS_DATA_EMPTY') . '</div>';
}

$this->printJson(implode('', $html), true, ['count' => $cnt]);
Expand All @@ -162,7 +162,7 @@ public function List()
$this->ListPHPEL();
}
if ($file == '') {
$html = '<div class="alert">' . JText::_('COM_VLOGS_LIST_EMPTY') . '</div>';
$html = '<div class="alert alert-primary">' . JText::_('COM_VLOGS_LIST_EMPTY') . '</div>';
$this->printJson($html, true, ['count' => 0]);
}

Expand Down Expand Up @@ -285,7 +285,7 @@ public function List()
case 'message':
$json = json_decode($dataitem, true);
$json_result = json_last_error() === JSON_ERROR_NONE;
$html[] = '<td>' . ($json_result ? '<p><a onclick="jQuery(this).parent().next(\'pre\').slideToggle(200);" style="cursor:pointer">' . JText::_('COM_VLOGS_COLUMN_MSG_JSON_TITLE') . '</a></p><pre style="display:none">' . print_r($json, true) . '</pre>' : htmlspecialchars($dataitem)) . '</td>';
$html[] = '<td>' . ($json_result ? '<div><a href="javascript:void(0)" onclick="jQuery(this).parent().next(\'pre\').slideToggle(200);" style="cursor:pointer">' . JText::_('COM_VLOGS_COLUMN_MSG_JSON_TITLE') . '</a></div><pre style="display:none">' . print_r($json, true) . '</pre>' : htmlspecialchars($dataitem)) . '</td>';
break;
default:
$html[] = '<td>' . $dataitem . '</td>';
Expand All @@ -296,7 +296,7 @@ public function List()

$html[] = '</tbody></table>';
} else {
$html[] = '<div class="alert">' . JText::_('COM_VLOGS_DATA_EMPTY') . '</div>';
$html[] = '<div class="alert alert-primary">' . JText::_('COM_VLOGS_DATA_EMPTY') . '</div>';
}

$this->printJson(implode('', $html), true, ['count' => $cnt]);
Expand Down
11 changes: 9 additions & 2 deletions admin/models/fields/fileselect.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
Expand Down
97 changes: 56 additions & 41 deletions admin/models/fields/fileselect.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php defined('JPATH_PLATFORM') or die;
/*

/*
Usage:
<field
Expand All @@ -13,8 +13,7 @@ class
showroot="true|false" // show root directori no tree (val 'true'), default 'false'
/>
*/

*/

JFormHelper::loadFieldClass('list');

Expand All @@ -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 = '<ul id="' . $this->uid . '" class="av-folderlist level-0' . '">';
$subdir = $this->showdir($dir, $folderOnly, $showRoot, $level + 1, $ef);
$name = substr(strrchr($dir, DIRECTORY_SEPARATOR), 1);
Expand All @@ -54,36 +53,40 @@ 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 .= '<ul' . ((int)$level == 0 ? ' id="' . $this->uid . '"' : '') . ' class="' . ((int)$level == 0 ? 'av-folderlist ' : '') . 'level-' . (int)$level . '">';
if (!($folderOnly && !$folders) || !(!$folders || !$files)) {
$html .= '<ul' . ((int) $level == 0 ? ' id="' . $this->uid . '"' : '') . ' class="' . ((int) $level == 0 ? 'av-folderlist ' : '') . 'level-' . (int) $level . '">';
}

sort($folders);
sort($files);

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 .= '<li class="av-folderlist-item av-folderlist-dir">' . ($subdir ? '<span class="av-folderlist-tree"></span>' : '') . '<span class="av-folderlist-label" path="' . $fpath . '">' . $name . '</span>' . $subdir . '</li>';
}

if (!$folderOnly)
foreach ($files as $name) {
$fpath = $dir . DIRECTORY_SEPARATOR . $name;
$fpath = str_replace($ef, '', $fpath);
$ext = substr(strrchr($name, '.'), 1);
$html .= '<li class="av-folderlist-item av-folderlist-file' . ($ext ? ' av-folderlist-file-' . $ext : '') . '"><span class="av-folderlist-label" path="' . $fpath . '">' . $name . '</span></li>';
}
$fpath = $dir . DIRECTORY_SEPARATOR . $name;
$fpath = str_replace('\\', '/', str_replace($ef, '', $fpath));
$ext = substr(strrchr($name, '.'), 1);
$html .= '<li class="av-folderlist-item av-folderlist-file' . ($ext ? ' av-folderlist-file-' . $ext : '') . '"><span class="av-folderlist-label" path="' . $fpath . '">' . $name . '</span></li>';
}

if (!($folderOnly && !$folders) || !(!$folders || !$files))
if (!($folderOnly && !$folders) || !(!$folders || !$files)) {
$html .= '</ul>';
}

unset($folders, $files, $fpath, $ext);
}
}
Expand All @@ -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');
Expand All @@ -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 = '<div class="field-wrapper">';

// input
$html .= '<div class="input-append" style="position:relative;">';
$html .= '<div class="btn-group input-append" style="position:relative;">';
$html .= '<input type="text" name="' . $this->name . '" id="' . $this->id . '"' . ($this->class ? ' class="' . $this->class . '"' : '') . ' value="' . $this->value . '" placeholder="' . JText::_('Select file or folder') . '" readonly ' . ($this->required ? 'required' : '') . '/>';
if (!$this->readonly)
$html .= '<a class="btn btn-primary" onclick="javascript:jQuery(\'#' . $this->uid . 'modal\').toggle();"><span class="icon-folder"></span></a>';
$html .= '<button id="' . $this->uid . 'btn" class="btn btn-primary" type="button"><span class="icon-folder"></span></button>';

// modal
$html .= '<div id="' . $this->uid . 'modal" class="av-modal">';
$html .= $this->showdir(JPATH_ROOT . DIRECTORY_SEPARATOR . $folder, $folderOnly, $showRoot);
$html .= '</div>';
$html .= '</div>';

// script

$html .= "<script>
jQuery(function(){
document.addEventListener('DOMContentLoaded', function() {
jQuery('#" . $this->uid . " .av-folderlist-tree').click(function() {
jQuery(this).parent().toggleClass('open');
document.getElementById('" . $this->uid . "btn').addEventListener('click', function(e) {
document.getElementById('" . $this->uid . "modal').classList.toggle('open');
});
jQuery('#" . $this->uid . " .av-folderlist-label').click(function() {
var list = jQuery(this).closest('.av-folderlist');
list.find('.av-folderlist-label').removeClass('selected');
jQuery('#" . $this->id . "').val(jQuery(this).attr('path'));
jQuery(this).addClass('selected');
document.querySelectorAll('#" . $this->uid . " .av-folderlist-tree').forEach(function(el) {
el.addEventListener('click', function(e) {
e.target.parentNode.classList.toggle('open');
});
});
jQuery('#" . $this->uid . " .av-folderlist-label').dblclick(function() {
jQuery(this).prev().click();
document.querySelectorAll('#" . $this->uid . " .av-folderlist-label').forEach(function(el) {
el.addEventListener('click', function(e) {
var
target = e.target;
list = e.target.closest('.av-folderlist');
list.querySelectorAll('.av-folderlist-label').forEach(function(elm) {
elm.classList.remove('selected');
});
document.getElementById('" . $this->id . "').value = target.getAttribute('path');
target.classList.add('selected');
if (!target.parentNode.classList.contains('open')) {
target.parentNode.classList.add('open');
}
});
});
});
</script>";

$html .= '</div>';

return $html;
Expand Down
12 changes: 5 additions & 7 deletions admin/views/items/tmpl/default.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
<?php defined('_JEXEC') or die;

?>
<?php defined('_JEXEC') or die; ?>

<form action="<?php echo JRoute::_('index.php?option=com_vlogs&view=items'); ?>" method="post" name="adminForm" id="adminForm">
<div id="j-main-container">

<div id="view_items_list"></div>

<input type="hidden" name="task" value="" />
<?php echo JHtml::_('form.token'); ?>

</div>
</form>

<?php

JFactory::getDocument()->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()
Expand Down
26 changes: 13 additions & 13 deletions admin/views/items/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '<select id="view_select_files" style="margin-bottom:0">';
foreach ($this->items as $item) {
$custom_button_html .= '<option value="' . $item . '">' . $item . '</option>';
}
$custom_button_html .= '</select>';
JToolBar::getInstance('toolbar')->appendButton('Custom', $custom_button_html, 'custom');
if (count($this->items)) {
$custom_button_html = '<select id="view_select_files" class="form-control" style="margin-bottom:0">';
foreach ($this->items as $item) {
$custom_button_html .= '<option value="' . $item . '">' . $item . '</option>';
}
$custom_button_html .= '</select>';
JToolBar::getInstance('toolbar')->appendButton('Custom', $custom_button_html, 'custom');

$custom_button_html = '<button id="view_refresh_file" type="button" class="btn btn-small"><span class="icon-refresh"></span>' . JText::_('COM_VLOGS_REFRESH_BUTTON') . '</button>';
JToolBar::getInstance('toolbar')->appendButton('Custom', $custom_button_html, 'custom');
$custom_button_html = '<button id="view_refresh_file" type="button" class="btn btn-small"><span class="icon-refresh"></span>' . JText::_('COM_VLOGS_REFRESH_BUTTON') . '</button>';
JToolBar::getInstance('toolbar')->appendButton('Custom', $custom_button_html, 'custom');

if (count($this->items)) {
$custom_button_html = '<button id="view_download_file" type="button" class="btn btn-small"><span class="icon-download"></span>' . JText::_('COM_VLOGS_DOWNLOAD_BUTTON') . '</button>';
JToolBar::getInstance('toolbar')->appendButton('Custom', $custom_button_html, 'custom');

Expand All @@ -39,14 +39,14 @@ public function display($tpl = null)
}
}

$custom_button_html = '<span style="display:inline-block;padding:0 15px;font-size:12px;line-height:25.5px;border:1px solid #d6e9c6;border-radius:3px;background-color:#dff0d8;color:#3c763d;">' . JText::_('COM_VLOGS_COUNT_ITEMS_VIEW') . ' <span id="view_count_items">0</span></span>';
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 = '<span style="display:inline-flex;align-items:center;padding:0 15px;' . (JVersion::MAJOR_VERSION < 4 ? 'font-size:12px;line-height:25.5px;' : '') . 'border:1px solid #d6e9c6;border-radius:3px;background-color:#dff0d8;color:#3c763d;">' . JText::_('COM_VLOGS_COUNT_ITEMS_VIEW') . '&nbsp;<span id="view_count_items">0</span></span>';
JToolBar::getInstance('toolbar')->appendButton('Custom', $custom_button_html, 'options');

parent::display($tpl);
}
}
2 changes: 1 addition & 1 deletion admin/vlogs.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php defined( '_JEXEC' ) or die;
<?php defined('_JEXEC') or die;
/*
* @package com_vlogs
* @copyright Copyright (C) 2019 Aleksey A. Morozov (AlekVolsk). All rights reserved.
Expand Down
2 changes: 1 addition & 1 deletion vlogs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<authorUrl>https://alekvolsk.pw</authorUrl>
<copyright>© 2019 Aleksey A. Morozov. All right reserved.</copyright>
<license>GNU General Public License version 3 or later; see http://www.gnu.org/licenses/gpl-3.0.txt</license>
<version>1.3.7</version>
<version>1.3.8</version>
<description>COM_VLOGS_DESC</description>
<creationDate>August 2019</creationDate>
<administration>
Expand Down

0 comments on commit 2f628b0

Please sign in to comment.