| Current Path : /home/juvelize/martine/administrator/components/com_jhackguard/views/ondemandscans/ |
| Current File : /home/juvelize/martine/administrator/components/com_jhackguard/views/ondemandscans/view.html.php |
<?php
/**
* @version 2.0.0
* @package com_jhackguard
* @copyright Copyright (C) 2013. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @author Valeri Markov <val@jhackguard.com> - http://www.jhackguard.com/
*/
// No direct access
defined('_JEXEC') or die;
jimport('joomla.application.component.view');
/**
* View class for a list of Jhackguard.
*/
class JhackguardViewOndemandscans extends JViewLegacy
{
protected $items;
protected $pagination;
protected $state;
/**
* Display the view
*/
public function display($tpl = null)
{
$this->state = $this->get('State');
// Check for errors.
if (count($errors = $this->get('Errors'))) {
throw new Exception(implode("\n", $errors));
}
JhackguardHelper::addSubmenu('ondemandscans');
$this->addToolbar();
$this->sidebar = JHtmlSidebar::render();
parent::display($tpl);
}
/**
* Add the page title and toolbar.
*
* @since 1.6
*/
protected function addToolbar()
{
require_once JPATH_COMPONENT.'/helpers/jhackguard.php';
$state = $this->get('State');
$canDo = JhackguardHelper::getActions($state->get('filter.category_id'));
JToolBarHelper::title(JText::_('COM_JHACKGUARD_TITLE_ONDEMANDSCANS'), 'ondemandscans.png');
//Check if the form exists before showing the add/edit buttons
$formPath = JPATH_COMPONENT_ADMINISTRATOR.'/views/ondemandscan';
if (file_exists($formPath)) {
if ($canDo->get('core.create')) {
JToolBarHelper::addNew('ondemandscan.add','JTOOLBAR_NEW');
}
if ($canDo->get('core.edit') && isset($this->items[0])) {
JToolBarHelper::editList('ondemandscan.edit','JTOOLBAR_EDIT');
}
}
if ($canDo->get('core.edit.state')) {
if (isset($this->items[0]->state)) {
JToolBarHelper::divider();
JToolBarHelper::custom('ondemandscans.publish', 'publish.png', 'publish_f2.png','JTOOLBAR_PUBLISH', true);
JToolBarHelper::custom('ondemandscans.unpublish', 'unpublish.png', 'unpublish_f2.png', 'JTOOLBAR_UNPUBLISH', true);
} else if (isset($this->items[0])) {
//If this component does not use state then show a direct delete button as we can not trash
JToolBarHelper::deleteList('', 'ondemandscans.delete','JTOOLBAR_DELETE');
}
if (isset($this->items[0]->state)) {
JToolBarHelper::divider();
JToolBarHelper::archiveList('ondemandscans.archive','JTOOLBAR_ARCHIVE');
}
if (isset($this->items[0]->checked_out)) {
JToolBarHelper::custom('ondemandscans.checkin', 'checkin.png', 'checkin_f2.png', 'JTOOLBAR_CHECKIN', true);
}
}
//Show trash and delete for components that uses the state field
if (isset($this->items[0]->state)) {
if ($state->get('filter.state') == -2 && $canDo->get('core.delete')) {
JToolBarHelper::deleteList('', 'ondemandscans.delete','JTOOLBAR_EMPTY_TRASH');
JToolBarHelper::divider();
} else if ($canDo->get('core.edit.state')) {
JToolBarHelper::trash('ondemandscans.trash','JTOOLBAR_TRASH');
JToolBarHelper::divider();
}
}
if ($canDo->get('core.admin')) {
JToolBarHelper::preferences('com_jhackguard');
}
//Set sidebar action - New in 3.0
JHtmlSidebar::setAction('index.php?option=com_jhackguard&view=ondemandscans');
$this->extra_sidebar = '';
//
}
protected function getSortFields()
{
return array(
'a.id' => JText::_('JGRID_HEADING_ID'),
'a.severity' => JText::_('COM_JHACKGUARD_LOGS_SEVERITY'),
'a.ip_address' => JText::_('COM_JHACKGUARD_LOGS_IP_ADDRESS'),
'a.message' => JText::_('COM_JHACKGUARD_LOGS_MESSAGE'),
'a.time' => JText::_('COM_JHACKGUARD_LOGS_TIME'),
);
}
}