- md5
- 581791a6ca387cb1ec7f9bd0fa07c6b9
- sha1
- fb4612de809baaab674c91fcc32dba68640b608b
- sha256
- fc77c67a034bdf89841d2098a969da2a0abb1668f512805c698ce6f1a01ba85d
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
<?php
/**
* @package Joomla.Administrator
* @subpackage com_menus
*
* @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* The HTML Menus Menu Items View.
*
* @since 1.6
*/
class MenusViewItems extends JViewLegacy
{
/**
* @var array
*/
protected $f_levels;
/**
* @var mixed
*/
protected $items;
/**
* @var JPagination
*/
protected $pagination;
/**
* @var JObject
*/
protected $state;
/**
* Display the view
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return void
*
* @since 1.6
*/
public function display($tpl = null)
{
$lang = JFactory::getLanguage();
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
$this->state = $this->get('State');
$this->filterForm = $this->get('FilterForm');
$this->activeFilters = $this->get('ActiveFilters');
MenusHelper::addSubmenu('items');
// Check for errors.
if (count($errors = $this->get('Errors')))
{
JError::raiseError(500, implode("\n", $errors));
return false;
}
$this->ordering = array();
// Preprocess the list of items to find ordering divisions.
foreach ($this->items as $item)
{
$this->ordering[$item->parent_id][] = $item->id;
// Item type text
switch ($item->type)
{
case 'url':
$value = JText::_('COM_MENUS_TYPE_EXTERNAL_URL');
break;
case 'alias':
$value = JText::_('COM_MENUS_TYPE_ALIAS');
break;
case 'separator':
$value = JText::_('COM_MENUS_TYPE_SEPARATOR');
break;
case 'heading':
$value = JText::_('COM_MENUS_TYPE_HEADING');
break;
case 'component':
default:
// Load language
$lang->load($item->componentname . '.sys', JPATH_ADMINISTRATOR, null, false, true)
|| $lang->load($item->componentname . '.sys', JPATH_ADMINISTRATOR . '/components/' . $item->componentname, null, false, true);
if (!empty($item->componentname))
{
$value = JText::_($item->componentname);
$vars = null;
parse_str($item->link, $vars);
if (isset($vars['view']))
{
// Attempt to load the view xml file.
$file = JPATH_SITE . '/components/' . $item->componentname . '/views/' . $vars['view'] . '/metadata.xml';
if (!is_file($file))
{
$file = JPATH_SITE . '/components/' . $item->componentname . '/view/' . $vars['view'] . '/metadata.xml';
}
if (is_file($file) && $xml = simplexml_load_file($file))
{
// Look for the first view node off of the root node.
if ($view = $xml->xpath('view[1]'))
{
if (!empty($view[0]['title']))
{
$vars['layout'] = isset($vars['layout']) ? $vars['layout'] : 'default';
// Attempt to load the layout xml file.
// If Alternative Menu Item, get template folder for layout file
if (strpos($vars['layout'], ':') > 0)
{
// Use template folder for layout file
$temp = explode(':', $vars['layout']);
$file = JPATH_SITE . '/templates/' . $temp[0] . '/html/' . $item->componentname . '/' . $vars['view'] . '/' . $temp[1] . '.xml';
// Load template language file
$lang->load('tpl_' . $temp[0] . '.sys', JPATH_SITE, null, false, true)
|| $lang->load('tpl_' . $temp[0] . '.sys', JPATH_SITE . '/templates/' . $temp[0], null, false, true);
}
else
{
// Get XML file from component folder for standard layouts
$file = JPATH_SITE . '/components/' . $item->componentname . '/views/' . $vars['view'] . '/tmpl/' . $vars['layout'] . '.xml';
if (!file_exists($file))
{
$file = JPATH_SITE . '/components/' . $item->componentname . '/view/' . $vars['view'] . '/tmpl/' . $vars['layout'] . '.xml';
}
}
if (is_file($file) && $xml = simplexml_load_file($file))
{
// Look for the first view node off of the root node.
if ($layout = $xml->xpath('layout[1]'))
{
if (!empty($layout[0]['title']))
{
$value .= ' » ' . JText::_(trim((string) $layout[0]['title']));
}
}
if (!empty($layout[0]->message[0]))
{
$item->item_type_desc = JText::_(trim((string) $layout[0]->message[0]));
}
}
}
}
unset($xml);
}
else
{
// Special case for absent views
$value .= ' » ' . $vars['view'];
}
}
}
else
{
if (preg_match("/^index.php\?option=([a-zA-Z\-0-9_]*)/", $item->link, $result))
{
$value = JText::sprintf('COM_MENUS_TYPE_UNEXISTING', $result[1]);
}
else
{
$value = JText::_('COM_MENUS_TYPE_UNKNOWN');
}
}
break;
}
$item->item_type = $value;
}
// Levels filter.
$options = array();
$options[] = JHtml::_('select.option', '1', JText::_('J1'));
$options[] = JHtml::_('select.option', '2', JText::_('J2'));
$options[] = JHtml::_('select.option', '3', JText::_('J3'));
$options[] = JHtml::_('select.option', '4', JText::_('J4'));
$options[] = JHtml::_('select.option', '5', JText::_('J5'));
$options[] = JHtml::_('select.option', '6', JText::_('J6'));
$options[] = JHtml::_('select.option', '7', JText::_('J7'));
$options[] = JHtml::_('select.option', '8', JText::_('J8'));
$options[] = JHtml::_('select.option', '9', JText::_('J9'));
$options[] = JHtml::_('select.option', '10', JText::_('J10'));
$this->f_levels = $options;
$this->addToolbar();
$this->sidebar = JHtmlSidebar::render();
// Allow a system plugin to insert dynamic menu types to the list shown in menus:
JEventDispatcher::getInstance()->trigger('onBeforeRenderMenuItems', array($this));
parent::display($tpl);
}
/**
* Add the page title and toolbar.
*
* @return void
*
* @since 1.6
*/
protected function addToolbar()
{
$canDo = JHelperContent::getActions('com_menus');
$user = JFactory::getUser();
// Get the toolbar object instance
$bar = JToolBar::getInstance('toolbar');
JToolbarHelper::title(JText::_('COM_MENUS_VIEW_ITEMS_TITLE'), 'list menumgr');
if ($canDo->get('core.create'))
{
JToolbarHelper::addNew('item.add');
}
if ($canDo->get('core.edit'))
{
JToolbarHelper::editList('item.edit');
}
if ($canDo->get('core.edit.state'))
{
JToolbarHelper::publish('items.publish', 'JTOOLBAR_PUBLISH', true);
JToolbarHelper::unpublish('items.unpublish', 'JTOOLBAR_UNPUBLISH', true);
}
if (JFactory::getUser()->authorise('core.admin'))
{
JToolbarHelper::checkin('items.checkin', 'JTOOLBAR_CHECKIN', true);
}
if ($canDo->get('core.edit.state'))
{
JToolbarHelper::makeDefault('items.setDefault', 'COM_MENUS_TOOLBAR_SET_HOME');
}
if (JFactory::getUser()->authorise('core.admin'))
{
JToolbarHelper::custom('items.rebuild', 'refresh.png', 'refresh_f2.png', 'JToolbar_Rebuild', false);
}
// Add a batch button
if ($user->authorise('core.create', 'com_menus')
&& $user->authorise('core.edit', 'com_menus')
&& $user->authorise('core.edit.state', 'com_menus'))
{
$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');
}
if ($this->state->get('filter.published') == -2 && $canDo->get('core.delete'))
{
JToolbarHelper::deleteList('', 'items.delete', 'JTOOLBAR_EMPTY_TRASH');
}
elseif ($canDo->get('core.edit.state'))
{
JToolbarHelper::trash('items.trash');
}
JToolbarHelper::help('JHELP_MENUS_MENU_ITEM_MANAGER');
}
/**
* 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.lft' => JText::_('JGRID_HEADING_ORDERING'),
'a.published' => JText::_('JSTATUS'),
'a.title' => JText::_('JGLOBAL_TITLE'),
'a.home' => JText::_('COM_MENUS_HEADING_HOME'),
'a.access' => JText::_('JGRID_HEADING_ACCESS'),
'association' => JText::_('COM_MENUS_HEADING_ASSOCIATION'),
'language' => JText::_('JGRID_HEADING_LANGUAGE'),
'a.id' => JText::_('JGRID_HEADING_ID')
);
}
}
The same content is in 8 releases, Joomla 3.4.4-rc to 3.4.8. See them all, or every version of this file.