2014-04-08 12:32:59 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2016-12-01 07:21:47 +00:00
|
|
|
* @package Joomla.Administrator
|
|
|
|
* @subpackage Weblinks
|
2014-04-08 12:32:59 +00:00
|
|
|
*
|
2017-02-13 16:20:35 +00:00
|
|
|
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
|
2014-04-08 12:32:59 +00:00
|
|
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
|
|
|
defined('_JEXEC') or die;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* View class for a list of weblinks.
|
|
|
|
*
|
2014-12-04 19:43:05 +00:00
|
|
|
* @since 1.5
|
2014-04-08 12:32:59 +00:00
|
|
|
*/
|
|
|
|
class WeblinksViewWeblinks extends JViewLegacy
|
|
|
|
{
|
|
|
|
protected $items;
|
|
|
|
|
|
|
|
protected $pagination;
|
|
|
|
|
|
|
|
protected $state;
|
|
|
|
|
|
|
|
/**
|
2016-07-03 10:04:21 +00:00
|
|
|
* Display the view.
|
2014-04-08 12:32:59 +00:00
|
|
|
*
|
2016-07-03 10:04:21 +00:00
|
|
|
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
|
|
|
|
*
|
|
|
|
* @return mixed A string if successful, otherwise an Error object.
|
2014-04-08 12:32:59 +00:00
|
|
|
*/
|
|
|
|
public function display($tpl = null)
|
|
|
|
{
|
2016-06-28 09:45:18 +00:00
|
|
|
$this->state = $this->get('State');
|
|
|
|
$this->items = $this->get('Items');
|
|
|
|
$this->pagination = $this->get('Pagination');
|
|
|
|
$this->filterForm = $this->get('FilterForm');
|
|
|
|
$this->activeFilters = $this->get('ActiveFilters');
|
2014-04-08 12:32:59 +00:00
|
|
|
|
|
|
|
WeblinksHelper::addSubmenu('weblinks');
|
|
|
|
|
|
|
|
// Check for errors.
|
|
|
|
if (count($errors = $this->get('Errors')))
|
|
|
|
{
|
|
|
|
JError::raiseError(500, implode("\n", $errors));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->addToolbar();
|
|
|
|
$this->sidebar = JHtmlSidebar::render();
|
|
|
|
parent::display($tpl);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add the page title and toolbar.
|
|
|
|
*
|
2016-07-03 10:04:21 +00:00
|
|
|
* @return void
|
|
|
|
*
|
2014-04-08 12:32:59 +00:00
|
|
|
* @since 1.6
|
|
|
|
*/
|
|
|
|
protected function addToolbar()
|
|
|
|
{
|
|
|
|
require_once JPATH_COMPONENT . '/helpers/weblinks.php';
|
|
|
|
|
2015-02-18 01:20:59 +00:00
|
|
|
$state = $this->get('State');
|
|
|
|
$canDo = JHelperContent::getActions('com_weblinks', 'category', $state->get('filter.category_id'));
|
|
|
|
$user = JFactory::getUser();
|
2014-04-08 12:32:59 +00:00
|
|
|
|
|
|
|
// Get the toolbar object instance
|
|
|
|
$bar = JToolBar::getInstance('toolbar');
|
|
|
|
|
|
|
|
JToolbarHelper::title(JText::_('COM_WEBLINKS_MANAGER_WEBLINKS'), 'link weblinks');
|
2015-02-18 01:20:59 +00:00
|
|
|
|
2014-04-08 12:32:59 +00:00
|
|
|
if (count($user->getAuthorisedCategories('com_weblinks', 'core.create')) > 0)
|
|
|
|
{
|
|
|
|
JToolbarHelper::addNew('weblink.add');
|
|
|
|
}
|
2015-02-18 01:20:59 +00:00
|
|
|
|
2016-08-07 01:08:21 +00:00
|
|
|
if ($canDo->get('core.edit') || $canDo->get('core.edit.own'))
|
2014-04-08 12:32:59 +00:00
|
|
|
{
|
|
|
|
JToolbarHelper::editList('weblink.edit');
|
|
|
|
}
|
|
|
|
|
2015-02-18 01:20:59 +00:00
|
|
|
if ($canDo->get('core.edit.state'))
|
|
|
|
{
|
2014-04-08 12:32:59 +00:00
|
|
|
JToolbarHelper::publish('weblinks.publish', 'JTOOLBAR_PUBLISH', true);
|
|
|
|
JToolbarHelper::unpublish('weblinks.unpublish', 'JTOOLBAR_UNPUBLISH', true);
|
|
|
|
|
|
|
|
JToolbarHelper::archiveList('weblinks.archive');
|
|
|
|
JToolbarHelper::checkin('weblinks.checkin');
|
|
|
|
}
|
2015-02-18 01:20:59 +00:00
|
|
|
|
2016-06-28 09:45:18 +00:00
|
|
|
if ($state->get('filter.published') == -2 && $canDo->get('core.delete'))
|
2014-04-08 12:32:59 +00:00
|
|
|
{
|
2016-01-28 07:08:09 +00:00
|
|
|
JToolbarHelper::deleteList('JGLOBAL_CONFIRM_DELETE', 'weblinks.delete', 'JTOOLBAR_EMPTY_TRASH');
|
2015-02-18 01:20:59 +00:00
|
|
|
}
|
|
|
|
elseif ($canDo->get('core.edit.state'))
|
2014-04-08 12:32:59 +00:00
|
|
|
{
|
|
|
|
JToolbarHelper::trash('weblinks.trash');
|
|
|
|
}
|
2015-02-18 01:20:59 +00:00
|
|
|
|
2014-04-08 12:32:59 +00:00
|
|
|
// Add a batch button
|
2015-02-18 01:20:59 +00:00
|
|
|
if ($user->authorise('core.create', 'com_weblinks') && $user->authorise('core.edit', 'com_weblinks')
|
|
|
|
&& $user->authorise('core.edit.state', 'com_weblinks'))
|
2014-04-08 12:32:59 +00:00
|
|
|
{
|
|
|
|
JHtml::_('bootstrap.modal', 'collapseModal');
|
|
|
|
$title = JText::_('JTOOLBAR_BATCH');
|
|
|
|
|
|
|
|
// Instantiate a new JLayoutFile instance and render the batch button
|
|
|
|
$layout = new JLayoutFile('joomla.toolbar.batch');
|
|
|
|
|
|
|
|
$dhtml = $layout->render(array('title' => $title));
|
|
|
|
$bar->appendButton('Custom', $dhtml, 'batch');
|
|
|
|
}
|
2015-02-18 01:20:59 +00:00
|
|
|
|
2015-06-30 08:56:01 +00:00
|
|
|
if ($user->authorise('core.admin', 'com_weblinks') || $user->authorise('core.options', 'com_weblinks'))
|
2014-04-08 12:32:59 +00:00
|
|
|
{
|
|
|
|
JToolbarHelper::preferences('com_weblinks');
|
|
|
|
}
|
|
|
|
|
|
|
|
JToolbarHelper::help('JHELP_COMPONENTS_WEBLINKS_LINKS');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns an array of fields the table can be sorted by
|
|
|
|
*
|
|
|
|
* @return array Array containing the field name to sort by as the key and display text as value
|
|
|
|
*
|
|
|
|
* @since 3.0
|
|
|
|
*/
|
|
|
|
protected function getSortFields()
|
|
|
|
{
|
|
|
|
return array(
|
|
|
|
'a.ordering' => JText::_('JGRID_HEADING_ORDERING'),
|
|
|
|
'a.state' => JText::_('JSTATUS'),
|
|
|
|
'a.title' => JText::_('JGLOBAL_TITLE'),
|
|
|
|
'a.access' => JText::_('JGRID_HEADING_ACCESS'),
|
|
|
|
'a.hits' => JText::_('JGLOBAL_HITS'),
|
|
|
|
'a.language' => JText::_('JGRID_HEADING_LANGUAGE'),
|
|
|
|
'a.id' => JText::_('JGRID_HEADING_ID')
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|