Your IP : 216.73.216.85


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

<?php
/********************************************************************
Product     : Eyesite
Date		: 7 May 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\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Toolbar\ToolbarHelper;

class EyesiteViewMain extends HtmlView
{
function display($tpl = null)
{
	LAE_helper::addSubMenu('main');
	LAE_helper::viewStart();
	ToolBarHelper::title('Eyesite: '.Text::_('COM_EYESITE_STATUS'), 'lad.png');
	ToolBarHelper::custom('scan_now', 'search.png', 'search.png', Text::_('COM_EYESITE_TOOLBAR_SCAN_NOW'), false);
	echo '<form method="post" name="adminForm" id="adminForm" class="form-horizontal lad-filterform">';
	echo HTMLHelper::_('form.token');
	echo '<input type="hidden" name="option" value="com_eyesite">';
	echo '<input type="hidden" name="task" value="">';

// create the state filter list

	$app = Factory::getApplication();
	$filter_state = $app->getUserStateFromRequest('com_eyesite.filter_state','filter_state',-1);
	$state_array[-1] = Text::_('COM_EYESITE_STATE_FILTER_ALL');
	$state_array[LAE_STATE_NEW] = Text::_('COM_EYESITE_STATE_FILTER_NEW');
	$state_array[LAE_STATE_CHANGED] = Text::_('COM_EYESITE_STATE_FILTER_CHANGED');
	$state_array[LAE_STATE_DELETED] = Text::_('COM_EYESITE_STATE_FILTER_DELETED');
	$state_list = LAE_helper::make_list('filter_state', $filter_state, $state_array, 'ladj-change-submit');
	echo '<div class="lad-filterform-right">'.Text::_('COM_EYESITE_STATE_FILTER_LABEL').' '.$state_list.'</div>';

// div for the Ajax data

	echo '<div id="ajax_response"></div><hr>';

// get the list of outstanding changes

	$data_model = $this->getModel('data');
	$rows = $data_model->getList();
	$numrows = count($rows);
	if ($numrows == 0)
		{
		echo '</form><br>';
		LAE_helper::viewEnd();
		return;
		}
	$pagination = $data_model->getPagination();

	echo '<table class="table table-striped">';
	echo '<thead><tr>';
	echo '<th>'.Text::_('COM_EYESITE_CHANGES_STATE').'</th>';
    echo '<th>'.Text::_('COM_EYESITE_CHANGES_FILE').'</th>';
	echo '<th>'.Text::_('COM_EYESITE_DETAILS').'</th>';
	echo '</tr></thead>';
	echo '<tbody>';
    
    $root_len = strlen(JPATH_ROOT);

	for ($i=0; $i < $numrows; $i++) 
		{
		$row = $rows[$i];
		$state = LAE_helper::state_text($row->state);
		switch ($row->state)
			{
			case LAE_STATE_NEW:
				$icon = '<span class="ey-icon icon-asterisk lad-list-icon" style="color:red"></span> ';
				$info_text = Text::_('COM_EYESITE_SCANNER_NEW_DATE').': '.$row->datetime.', '.Text::_('COM_EYESITE_SCANNER_SIZE').': '.self::format_size($row->filesize);
				break;
			case LAE_STATE_CHANGED:
				$icon = '<span class="ey-icon icon-refresh lad-list-icon" style="color:orange"></span> ';
				$info_text = Text::_('COM_EYESITE_SCANNER_ORIG_DATE').': '.$row->datetime.', '.Text::_('COM_EYESITE_SCANNER_SIZE').': '.self::format_size($row->filesize).'<br>'.
					Text::_('COM_EYESITE_SCANNER_NEW_DATE').': '.$row->new_datetime.', '.Text::_('COM_EYESITE_SCANNER_SIZE').': '.self::format_size($row->new_filesize);
				break;
			case LAE_STATE_DELETED:
				$icon = '<span class="ey-icon icon-trash lad-list-icon" style="color:black"></span> ';
				$info_text = Text::_('COM_EYESITE_SCANNER_ORIG_DATE').': '.$row->datetime.', '.Text::_('COM_EYESITE_SCANNER_SIZE').': '.self::format_size($row->filesize);
				break;
			default:
				$info_text = '';
			}
			
        $filepath = $row->filepath;
        if (substr($filepath,0,$root_len) == JPATH_ROOT)
            $filepath = substr($filepath, $root_len);
		echo "<tr>";
        echo '<td>'.$icon.$state.'</td>';
        echo '<td class="lad-break-word">'.$filepath.'</td>';
		echo '<td>'.$info_text.'</td>';
		echo "</tr>\n";
	}
	echo '</tbody>';
    echo '<tfoot><tr><td colspan="3">'.$pagination->getListFooter().'</td></tr></tfoot>';
	echo '</table></form>';
	LAE_helper::viewEnd();
}

//-------------------------------------------------------------------------------
// Format a file size
//
static function format_size($bytes)
{
	if ($bytes >= 1073741824)
		return number_format($bytes / 1073741824, 2).' GB';
	if ($bytes >= 1048576)
		return number_format($bytes / 1048576, 2).' MB';
	if ($bytes >= 1024)
		return number_format($bytes / 1024, 2).' KB';
	return $bytes;
}
  
}