Your IP : 216.73.216.85


Current Path : /home/smartconb/www/armencom33/administrator/components/com_eyesite/views/history/
Upload File :
Current File : /home/smartconb/www/armencom33/administrator/components/com_eyesite/views/history/view.html.php

<?php
/********************************************************************
Product     : Eyesite
Date		: 11 January 2024
Copyright	: Les Arbres Design 2009-2024
Contact	    : https://www.lesarbresdesign.info
Licence     : GNU General Public License
*********************************************************************/
defined('_JEXEC') or die('Restricted access');

use Joomla\CMS\MVC\View\HtmlView;
use Joomla\CMS\Form\Form;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Toolbar\ToolbarHelper;

class EyesiteViewHistory extends HtmlView
{

//-------------------------------------------------------------------------------
// Show the history list
//
function display($tpl = null)
{
	LAE_helper::addSubMenu('history');
	LAE_helper::viewStart();
	ToolBarHelper::title('Eyesite: '.Text::_('COM_EYESITE_HISTORY'), 'lad.png');
	ToolBarHelper::deleteList('', 'history_delete');
	ToolBarHelper::cancel('cancel_to_main','JTOOLBAR_CLOSE');

// get the current filters	
		
	$app = Factory::getApplication();
	$search = $app->getUserStateFromRequest('com_eyesite.history_search','search','','string');
	$history_filter = $app->getUserStateFromRequest('com_eyesite.history_filter','history_filter',0);
	$filter_array = [0 => Text::_('JALL'), 1 => Text::_('COM_EYESITE_SCANNER_STARTING'), 2 => Text::_('COM_EYESITE_NEW_CHANGES'),
		3 => Text::_('COM_EYESITE_SCANNER_NO_NEW'), 4 => Text::_('COM_EYESITE_ERRORS'), 5 => Text::_('COM_EYESITE_CONFIGURATION'),
		6 => Text::_('COM_EYESITE_UPDATES')];
	$filter_list = LAE_helper::make_list('history_filter', $history_filter, $filter_array, 'ladj-change-submit');
    
	echo '<form method="post" name="adminForm" id="adminForm" class="lad-filterform">';
	echo HTMLHelper::_('form.token');
	echo '<input type="hidden" name="option" value="com_eyesite">';
	echo '<input type="hidden" name="task" value="history_list">';
	echo '<input type="hidden" name="boxchecked" value="0">';
	HTMLHelper::_('bootstrap.popover', 'span.hasPopover', ['trigger' => 'hover focus']);
	echo '<div>&nbsp;<div class="lad-filterform-left">'; 
	$icon = '<span class="icon-search lad-list-icon"></span>';
	echo '<span class="hasPopover" title="'.Text::_('JSEARCH_FILTER').'" '.LAE_BS_DATA_CONTENT.'="'.Text::_('COM_EYESITE_SEARCH_DESC').'">'.$icon.'</span>';
    echo ' <input type="text" class="form-control lad-input-inline input-large" name="search" id="search" value="'.$search.'">';
    echo ' <button type="button" class="btn btn-primary ladj-click-submit">'.Text::_('COM_EYESITE_GO').'</button>';
	echo '</div>'; 
	echo '<div class="lad-filterform-right">'; 
	echo $filter_list;
    echo ' <button type="button" class="btn btn-primary ladj-click-submit" data-task="history_reset">'.Text::_('JSEARCH_RESET').'</button>';
	echo '</div></div>';

// get the history list

	$history_model = $this->getModel('history');
	$rows = $history_model->getList();
	$numrows = count($rows);
	if ($numrows == 0)
		{
		echo '</form><br><div class="ey-info">'.Text::_('COM_EYESITE_NO_ITEMS').'</div>';
		LAE_helper::viewEnd();
		return;
		}
	$pagination = $history_model->getPagination();
?>
	<table class="table table-striped"><thead><tr>
		<th style="text-align:center;width:20px"><input type="checkbox" name="toggle" value="" class="form-check-input ladj-check-all"></th>
		<th><?php echo Text::_('COM_EYESITE_DATE_TIME'); ?></th>
		<th style="text-align:center" colspan="2"><?php echo Text::_('COM_EYESITE_EVENT'); ?></th>
		<th><?php echo Text::_('COM_EYESITE_SUMMARY'); ?></th>
	</tr></thead>
	<tbody>
<?php
	for ($i=0; $i < $numrows; $i++) 
		{
		$row = $rows[$i];
		$datetime = $row->datetime;
		if ($row->details != '')
			$datetime = "<a href=index.php?option=com_eyesite&task=history_item&id=$row->id>$row->datetime</a>";
		$icon = self::history_icon($row->state);
        $event = self::history_text($row->state);
		$checked = HTMLHelper::_('grid.id', $i, $row->id );
		$summary = mb_strimwidth($row->summary, 0, 90, " ...");
		echo '<tr>';
		echo '<td style="text-align:center">'.$checked.'</td>';
		echo '<td>'.$datetime.'</td>';
		echo '<td style="text-align:center">'.$icon.'</td>';
		echo '<td>'.$event.'</td>';
		echo '<td>'.$summary.'</td>';
		echo "</tr>";
		}
	echo '<tbody><tfoot><tr><td colspan="5">'.$pagination->getListFooter().'</td></tr></tfoot>';
	echo '</table></form>';
	LAE_helper::viewEnd();
}

//-------------------------------------------------------------------------------
// Edit a single history record
//
function edit($tpl = null)
{
	LAE_helper::addSubMenu('history');
	LAE_helper::viewStart();
	ToolBarHelper::title('Eyesite: '.Text::_('COM_EYESITE_HISTORY').': '.Text::_('COM_EYESITE_DETAILS'), 'lad.png');
	ToolBarHelper::save('history_save');
	ToolBarHelper::cancel('cancel_to_history_list','JTOOLBAR_CLOSE');

	echo '<form method="post" name="adminForm" id="adminForm" class="form-horizontal">';
	echo HTMLHelper::_('form.token');
	echo '<input type="hidden" name="option" value="com_eyesite">';
	echo '<input type="hidden" name="task" value="">';
	echo '<input type="hidden" name="id" value="'.$this->history_data->id.'">';

	$form = Form::getInstance('history_form', LAE_FORMS_PATH.'/history.xml');
    $this->history_data->_state_text = self::history_text($this->history_data->state);

// these two items contain serialised arrays - we need to format them into readable text

	if (($this->history_data->state == LAE_HISTORY_UPDATE_EXTENSION) || ($this->history_data->state == LAE_HISTORY_NEW_EXTENSION))
		{
		$xml_array = unserialize($this->history_data->details);
		$this->history_data->details = '<pre>';
		foreach ($xml_array as $extension)
			{
			$filepath = $extension['filepath'];
			unset($extension['filepath']);
			$text = print_r($extension,true);
			$this->history_data->details .= $filepath.substr($text,5); // replace "Array" with the file path
			$this->history_data->details .= "\n";
			}
		$this->history_data->details .= '</pre>';
		}
    $form->bind($this->history_data);
	echo $form->renderFieldset('main');  
	echo '<div class="lad-break-word">'.$this->history_data->details.'</div>';
	echo '</form>';
	LAE_helper::viewEnd();
}

//-------------------------------------------------------------------------------
// Get the icon for a history item
//
static function history_icon($state)
{
	switch ($state)
		{
		case LAE_HISTORY_SCAN_STARTED:    return '<span class="icon-arrow-right-4 lad-list-icon" style="color:green"></span>';
		case LAE_HISTORY_SCAN_NO_CHANGES: return '<span class="icon-checkmark lad-list-icon" style="color:green"></span>';
		case LAE_HISTORY_SCAN_CHANGES:    return '<span class="icon-checkmark lad-list-icon" style="color:orange"></span>';
		case LAE_HISTORY_SCAN_ERROR:      return '<span class="icon-warning-2 lad-list-icon" style="color:red"></span>';
		case LAE_HISTORY_ACCEPT:          return '<span class="icon-circle lad-list-icon" style="color:green"></span>';
		case LAE_HISTORY_REJECT:          return '<span class="icon-circle lad-list-icon" style="color:red"></span>';
		case LAE_HISTORY_ACCEPT_ALL:      return '<span class="icon-circle lad-list-icon" style="color:green"></span>';
		case LAE_HISTORY_REJECT_ALL:      return '<span class="icon-circle lad-list-icon" style="color:red"></span>';
		case LAE_HISTORY_SCAN_NOT_STARTED:return '<span class="icon-warning-2 lad-list-icon" style="color:red"></span>';
		case LAE_HISTORY_EMAIL_OK:        return '<span class="icon-mail lad-list-icon" style="color:green"></span>';
		case LAE_HISTORY_EMAIL_FAILED:    return '<span class="icon-mail lad-list-icon" style="color:red"></span>';
		case LAE_HISTORY_SCAN_EXCEPTION:  return '<span class="icon-warning-2 lad-list-icon" style="color:red"></span>';
		case LAE_HISTORY_CONFIG_CHANGE:   return '<span class="icon-cog lad-list-icon" style="color:#1e88e5"></span>';
		case LAE_HISTORY_INFO:            return '<span class="icon-info-circle lad-list-icon" style="color:#1e88e5"></span>';
		case LAE_HISTORY_UPDATE_JOOMLA:   return '<span class="icon-joomla lad-list-icon" style="color:brown"></span>';
		case LAE_HISTORY_UPDATE_EXTENSION:return '<span class="icon-puzzle lad-list-icon" style="color:brown"></span>';
		case LAE_HISTORY_NEW_EXTENSION:   return '<span class="icon-puzzle lad-list-icon" style="color:orange"></span>';
		default:                          return '';
		}
}

//-------------------------------------------------------------------------------
// Get the text for a history item
//
static function history_text($state)
{
	switch ($state)
		{
		case LAE_HISTORY_SCAN_STARTED:     return Text::_('COM_EYESITE_SCANNER_STARTING');
		case LAE_HISTORY_SCAN_NO_CHANGES:  return Text::_('COM_EYESITE_SCANNER_COMPLETE');	// "Scan completed"
		case LAE_HISTORY_SCAN_CHANGES:     return Text::_('COM_EYESITE_SCANNER_COMPLETE');	// "Scan completed"
		case LAE_HISTORY_SCAN_ERROR:       return Text::_('COM_EYESITE_SCAN_ERROR');
		case LAE_HISTORY_ACCEPT:           return Text::_('COM_EYESITE_TOOLBAR_ACCEPT');
		case LAE_HISTORY_REJECT:           return Text::_('COM_EYESITE_TOOLBAR_REJECT');
		case LAE_HISTORY_ACCEPT_ALL:       return Text::_('COM_EYESITE_TOOLBAR_ACCEPT_ALL');
		case LAE_HISTORY_REJECT_ALL:       return Text::_('COM_EYESITE_TOOLBAR_REJECT_ALL');
        case LAE_HISTORY_SCAN_NOT_STARTED: return Text::_('COM_EYESITE_SCANNER_NOT_STARTED');
        case LAE_HISTORY_EMAIL_FAILED:     return Text::_('COM_EYESITE_EMAIL_SEND_FAILED');
        case LAE_HISTORY_EMAIL_OK:         return Text::_('COM_EYESITE_EMAIL_SENT');
        case LAE_HISTORY_SCAN_EXCEPTION:   return Text::_('COM_EYESITE_SCAN_ERROR');
		case LAE_HISTORY_CONFIG_CHANGE:    return Text::_('COM_EYESITE_CONFIGURATION');
		case LAE_HISTORY_INFO:             return Text::_('INFO');
		case LAE_HISTORY_UPDATE_JOOMLA:    return Text::_('COM_EYESITE_UPDATED');
		case LAE_HISTORY_UPDATE_EXTENSION: return Text::_('COM_EYESITE_UPDATED');
		case LAE_HISTORY_NEW_EXTENSION:    return Text::_('COM_EYESITE_ADDED');
		}
	return '';
}

}