You've already forked joomla_test
first commit
This commit is contained in:
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
@ -0,0 +1,107 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_menus
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('JPATH_BASE') or die;
|
||||
|
||||
JFormHelper::loadFieldClass('list');
|
||||
|
||||
/**
|
||||
* Form Field class for the Joomla Framework.
|
||||
*
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_menus
|
||||
* @since 1.6
|
||||
*/
|
||||
class JFormFieldMenuOrdering extends JFormFieldList
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.7
|
||||
*/
|
||||
protected $type = 'MenuOrdering';
|
||||
|
||||
/**
|
||||
* Method to get the list of siblings in a menu.
|
||||
* The method requires that parent be set.
|
||||
*
|
||||
* @return array The field option objects or false if the parent field has not been set
|
||||
* @since 1.7
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
$options = array();
|
||||
|
||||
// Get the parent
|
||||
$parent_id = $this->form->getValue('parent_id', 0);
|
||||
if (empty($parent_id))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
$db = JFactory::getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select('a.id AS value, a.title AS text')
|
||||
->from('#__menu AS a')
|
||||
|
||||
->where('a.published >= 0')
|
||||
->where('a.parent_id =' . (int) $parent_id);
|
||||
if ($menuType = $this->form->getValue('menutype'))
|
||||
{
|
||||
$query->where('a.menutype = ' . $db->quote($menuType));
|
||||
}
|
||||
else
|
||||
{
|
||||
$query->where('a.menutype != ' . $db->quote(''));
|
||||
}
|
||||
|
||||
$query->order('a.lft ASC');
|
||||
|
||||
// Get the options.
|
||||
$db->setQuery($query);
|
||||
|
||||
try
|
||||
{
|
||||
$options = $db->loadObjectList();
|
||||
}
|
||||
catch (RuntimeException $e)
|
||||
{
|
||||
JError::raiseWarning(500, $e->getMessage());
|
||||
}
|
||||
|
||||
$options = array_merge(
|
||||
array(array('value' => '-1', 'text' => JText::_('COM_MENUS_ITEM_FIELD_ORDERING_VALUE_FIRST'))),
|
||||
$options,
|
||||
array(array('value' => '-2', 'text' => JText::_('COM_MENUS_ITEM_FIELD_ORDERING_VALUE_LAST')))
|
||||
);
|
||||
|
||||
// Merge any additional options in the XML definition.
|
||||
$options = array_merge(parent::getOptions(), $options);
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the field input markup
|
||||
*
|
||||
* @return string The field input markup.
|
||||
* @since 1.7
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
if ($this->form->getValue('id', 0) == 0)
|
||||
{
|
||||
return '<span class="readonly">' . JText::_('COM_MENUS_ITEM_FIELD_ORDERING_TEXT') . '</span>';
|
||||
}
|
||||
else
|
||||
{
|
||||
return parent::getInput();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_menus
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('JPATH_BASE') or die;
|
||||
|
||||
JFormHelper::loadFieldClass('list');
|
||||
|
||||
/**
|
||||
* Form Field class for the Joomla Framework.
|
||||
*
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_menus
|
||||
* @since 1.6
|
||||
*/
|
||||
class JFormFieldMenuParent extends JFormFieldList
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $type = 'MenuParent';
|
||||
|
||||
/**
|
||||
* Method to get the field options.
|
||||
*
|
||||
* @return array The field option objects.
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
$options = array();
|
||||
|
||||
$db = JFactory::getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select('a.id AS value, a.title AS text, a.level')
|
||||
->from('#__menu AS a')
|
||||
->join('LEFT', $db->quoteName('#__menu') . ' AS b ON a.lft > b.lft AND a.rgt < b.rgt');
|
||||
|
||||
if ($menuType = $this->form->getValue('menutype'))
|
||||
{
|
||||
$query->where('a.menutype = ' . $db->quote($menuType));
|
||||
}
|
||||
else
|
||||
{
|
||||
$query->where('a.menutype != ' . $db->quote(''));
|
||||
}
|
||||
|
||||
// Prevent parenting to children of this item.
|
||||
if ($id = $this->form->getValue('id'))
|
||||
{
|
||||
$query->join('LEFT', $db->quoteName('#__menu') . ' AS p ON p.id = ' . (int) $id)
|
||||
->where('NOT(a.lft >= p.lft AND a.rgt <= p.rgt)');
|
||||
}
|
||||
|
||||
$query->where('a.published != -2')
|
||||
->group('a.id, a.title, a.level, a.lft, a.rgt, a.menutype, a.parent_id, a.published')
|
||||
->order('a.lft ASC');
|
||||
|
||||
// Get the options.
|
||||
$db->setQuery($query);
|
||||
|
||||
try
|
||||
{
|
||||
$options = $db->loadObjectList();
|
||||
}
|
||||
catch (RuntimeException $e)
|
||||
{
|
||||
JError::raiseWarning(500, $e->getMessage());
|
||||
}
|
||||
|
||||
// Pad the option text with spaces using depth level as a multiplier.
|
||||
for ($i = 0, $n = count($options); $i < $n; $i++)
|
||||
{
|
||||
$options[$i]->text = str_repeat('- ', $options[$i]->level) . $options[$i]->text;
|
||||
}
|
||||
|
||||
// Merge any additional options in the XML definition.
|
||||
$options = array_merge(parent::getOptions(), $options);
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_menus
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('JPATH_BASE') or die;
|
||||
|
||||
JFormHelper::loadFieldClass('list');
|
||||
|
||||
/**
|
||||
* Form Field class for the Joomla Framework.
|
||||
*
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_menus
|
||||
* @since 1.6
|
||||
*/
|
||||
class JFormFieldMenutype extends JFormFieldList
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $type = 'menutype';
|
||||
|
||||
/**
|
||||
* Method to get the field input markup.
|
||||
*
|
||||
* @return string The field input markup.
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
$html = array();
|
||||
$recordId = (int) $this->form->getValue('id');
|
||||
$size = ($v = $this->element['size']) ? ' size="'.$v.'"' : '';
|
||||
$class = ($v = $this->element['class']) ? ' class="'.$v.'"' : 'class="text_area"';
|
||||
|
||||
// Get a reverse lookup of the base link URL to Title
|
||||
$model = JModelLegacy::getInstance('menutypes', 'menusModel');
|
||||
$rlu = $model->getReverseLookup();
|
||||
|
||||
switch ($this->value)
|
||||
{
|
||||
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;
|
||||
|
||||
default:
|
||||
$link = $this->form->getValue('link');
|
||||
// Clean the link back to the option, view and layout
|
||||
$value = JText::_(JArrayHelper::getValue($rlu, MenusHelper::getLinkKey($link)));
|
||||
break;
|
||||
}
|
||||
// Load the javascript and css
|
||||
JHtml::_('behavior.framework');
|
||||
JHtml::_('behavior.modal');
|
||||
|
||||
$html[] = '<span class="input-append"><input type="text" readonly="readonly" disabled="disabled" value="'.$value.'"'.$size.$class.' /><a class="btn btn-primary" onclick="SqueezeBox.fromElement(this, {handler:\'iframe\', size: {x: 600, y: 450}, url:\''.JRoute::_('index.php?option=com_menus&view=menutypes&tmpl=component&recordId='.$recordId).'\'})"><i class="icon-list icon-white"></i> '.JText::_('JSELECT').'</a></span>';
|
||||
$html[] = '<input class="input-small" type="hidden" name="' . $this->name . '" value="'.htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '" />';
|
||||
|
||||
return implode("\n", $html);
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
218
administrator/components/com_menus/models/forms/item.xml
Normal file
218
administrator/components/com_menus/models/forms/item.xml
Normal file
@ -0,0 +1,218 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<form>
|
||||
<fieldset>
|
||||
<field
|
||||
name="id"
|
||||
type="text"
|
||||
class="readonly"
|
||||
label="JGLOBAL_FIELD_ID_LABEL"
|
||||
description ="JGLOBAL_FIELD_ID_DESC"
|
||||
default="0"
|
||||
filter="int"
|
||||
readonly="true"/>
|
||||
|
||||
<field
|
||||
name="title"
|
||||
type="text"
|
||||
label="COM_MENUS_ITEM_FIELD_TITLE_LABEL"
|
||||
description="COM_MENUS_ITEM_FIELD_TITLE_DESC"
|
||||
class="inputbox"
|
||||
size="40"
|
||||
required="true"/>
|
||||
|
||||
<field
|
||||
name="alias"
|
||||
type="alias"
|
||||
label="JFIELD_ALIAS_LABEL"
|
||||
description="JFIELD_ALIAS_DESC"
|
||||
class="inputbox"
|
||||
size="40"/>
|
||||
|
||||
<field name="aliastip"
|
||||
type="spacer"
|
||||
label="COM_MENUS_TIP_ALIAS_LABEL"/>
|
||||
|
||||
<field
|
||||
name="note"
|
||||
type="text"
|
||||
label="JFIELD_NOTE_LABEL"
|
||||
description="COM_MENUS_ITEM_FIELD_NOTE_DESC"
|
||||
class="inputbox"
|
||||
size="40"/>
|
||||
|
||||
<field
|
||||
name="link"
|
||||
type="link"
|
||||
label="COM_MENUS_ITEM_FIELD_LINK_LABEL"
|
||||
description="COM_MENUS_ITEM_FIELD_LINK_DESC"
|
||||
readonly="true"
|
||||
class="inputbox"
|
||||
size="50"/>
|
||||
|
||||
<field
|
||||
name="menutype"
|
||||
type="menu"
|
||||
label="COM_MENUS_ITEM_FIELD_ASSIGNED_LABEL"
|
||||
description="COM_MENUS_ITEM_FIELD_ASSIGNED_DESC"
|
||||
class="inputbox"
|
||||
required="true"
|
||||
size="1" />
|
||||
|
||||
<field
|
||||
name="type"
|
||||
type="menutype"
|
||||
label="COM_MENUS_ITEM_FIELD_TYPE_LABEL"
|
||||
description="COM_MENUS_ITEM_FIELD_TYPE_DESC"
|
||||
class="inputbox input-medium"
|
||||
required="true"
|
||||
size="40" />
|
||||
|
||||
<field
|
||||
name="published"
|
||||
type="radio"
|
||||
class="btn-group"
|
||||
id="published"
|
||||
label="JSTATUS"
|
||||
description="JFIELD_PUBLISHED_DESC"
|
||||
size="1"
|
||||
default="1"
|
||||
filter="integer">
|
||||
<option
|
||||
value="1">
|
||||
JPUBLISHED</option>
|
||||
<option
|
||||
value="0">
|
||||
JUNPUBLISHED</option>
|
||||
|
||||
<option
|
||||
value="-2">
|
||||
JTRASHED</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="parent_id"
|
||||
type="menuparent"
|
||||
label="COM_MENUS_ITEM_FIELD_PARENT_LABEL"
|
||||
description="COM_MENUS_ITEM_FIELD_PARENT_DESC"
|
||||
default="1"
|
||||
filter="int"
|
||||
class="inputbox"
|
||||
size="1">
|
||||
<option
|
||||
value="1">COM_MENUS_ITEM_ROOT</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="menuordering"
|
||||
type="menuordering"
|
||||
label="COM_MENUS_ITEM_FIELD_ORDERING_LABEL"
|
||||
description="COM_MENUS_ITEM_FIELD_ORDERING_DESC"
|
||||
filter="int"
|
||||
class="inputbox"
|
||||
size="1">
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="component_id"
|
||||
type="hidden"
|
||||
filter="int" />
|
||||
|
||||
<field
|
||||
name="ordering"
|
||||
type="ordering"
|
||||
label="JFIELD_ORDERING_LABEL"
|
||||
description="JFIELD_ORDERING_DESC"
|
||||
filter="int"
|
||||
class="inputbox"/>
|
||||
|
||||
<field
|
||||
name="browserNav"
|
||||
type="list"
|
||||
label="COM_MENUS_ITEM_FIELD_BROWSERNAV_LABEL"
|
||||
description="COM_MENUS_ITEM_FIELD_BROWSERNAV_DESC"
|
||||
default="Parent"
|
||||
filter="int"
|
||||
class="inputbox">
|
||||
<option value="0">COM_MENUS_FIELD_VALUE_PARENT</option>
|
||||
<option value="1">COM_MENUS_FIELD_VALUE_NEW_WITH_NAV</option>
|
||||
<option value="2">COM_MENUS_FIELD_VALUE_NEW_WITHOUT_NAV</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="access"
|
||||
type="accesslevel"
|
||||
id="access"
|
||||
class="inputbox"
|
||||
label="JFIELD_ACCESS_LABEL"
|
||||
description="JFIELD_ACCESS_DESC"
|
||||
default="1"
|
||||
filter="integer"/>
|
||||
|
||||
|
||||
<field
|
||||
name="template_style_id"
|
||||
type="templatestyle"
|
||||
label="COM_MENUS_ITEM_FIELD_TEMPLATE_LABEL"
|
||||
description="COM_MENUS_ITEM_FIELD_TEMPLATE_DESC"
|
||||
filter="int"
|
||||
class="inputbox">
|
||||
<option value="0">JOPTION_USE_DEFAULT</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="home"
|
||||
type="radio"
|
||||
label="COM_MENUS_ITEM_FIELD_HOME_LABEL"
|
||||
description="COM_MENUS_ITEM_FIELD_HOME_DESC"
|
||||
default="0"
|
||||
class="btn-group"
|
||||
filter="integer">
|
||||
<option
|
||||
value="0">JNO</option>
|
||||
<option
|
||||
value="1">JYES</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="language"
|
||||
type="contentlanguage"
|
||||
label="JFIELD_LANGUAGE_LABEL"
|
||||
description="COM_MENUS_ITEM_FIELD_LANGUAGE_DESC"
|
||||
class="inputbox">
|
||||
<option value="*">JALL</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="path"
|
||||
type="hidden"
|
||||
filter="unset"/>
|
||||
|
||||
<field
|
||||
name="level"
|
||||
type="hidden"
|
||||
filter="unset"/>
|
||||
|
||||
<field
|
||||
name="checked_out"
|
||||
type="hidden"
|
||||
filter="unset"/>
|
||||
|
||||
<field
|
||||
name="checked_out_time"
|
||||
type="hidden"
|
||||
filter="unset"/>
|
||||
|
||||
<field
|
||||
name="lft"
|
||||
type="hidden"
|
||||
filter="unset"/>
|
||||
|
||||
<field
|
||||
name="rgt"
|
||||
type="hidden"
|
||||
filter="unset"/>
|
||||
</fieldset>
|
||||
|
||||
<fields name="params">
|
||||
</fields>
|
||||
</form>
|
@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<form>
|
||||
<!-- Add fields to the request variables for the layout. -->
|
||||
|
||||
<fields name="params">
|
||||
|
||||
<fieldset name="aliasoptions">
|
||||
<field name="aliasoptions" type="menuitem"
|
||||
description="COM_MENUS_ITEM_FIELD_ALIAS_MENU_DESC"
|
||||
label="COM_MENUS_ITEM_FIELD_ALIAS_MENU_LABEL"
|
||||
required="true" />
|
||||
</fieldset>
|
||||
|
||||
<fieldset name="menu-options"
|
||||
label="COM_MENUS_LINKTYPE_OPTIONS_LABEL"
|
||||
>
|
||||
|
||||
<field name="menu-anchor_title" type="text"
|
||||
label="COM_MENUS_ITEM_FIELD_ANCHOR_TITLE_LABEL"
|
||||
description="COM_MENUS_ITEM_FIELD_ANCHOR_TITLE_DESC" />
|
||||
|
||||
<field name="menu-anchor_css" type="text"
|
||||
label="COM_MENUS_ITEM_FIELD_ANCHOR_CSS_LABEL"
|
||||
description="COM_MENUS_ITEM_FIELD_ANCHOR_CSS_DESC" />
|
||||
|
||||
<field name="menu_image" type="media"
|
||||
label="COM_MENUS_ITEM_FIELD_MENU_IMAGE_LABEL"
|
||||
description="COM_MENUS_ITEM_FIELD_MENU_IMAGE_DESC" />
|
||||
|
||||
<field name="menu_text" type="radio" class="btn-group"
|
||||
label="COM_MENUS_ITEM_FIELD_MENU_TEXT_LABEL"
|
||||
description="COM_MENUS_ITEM_FIELD_MENU_TEXT_DESC"
|
||||
default="1" filter="integer"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
|
||||
</fieldset>
|
||||
</fields>
|
||||
<help key="JHELP_MENUS_MENU_ITEM_MENU_ITEM_ALIAS" />
|
||||
</form>
|
@ -0,0 +1,100 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<form>
|
||||
<fields name="params" label="COM_MENUS_LINKTYPE_OPTIONS_LABEL"
|
||||
>
|
||||
<fieldset name="menu-options"
|
||||
label="COM_MENUS_LINKTYPE_OPTIONS_LABEL"
|
||||
>
|
||||
|
||||
<field name="menu-anchor_title" type="text"
|
||||
label="COM_MENUS_ITEM_FIELD_ANCHOR_TITLE_LABEL"
|
||||
description="COM_MENUS_ITEM_FIELD_ANCHOR_TITLE_DESC" />
|
||||
|
||||
<field name="menu-anchor_css" type="text"
|
||||
label="COM_MENUS_ITEM_FIELD_ANCHOR_CSS_LABEL"
|
||||
description="COM_MENUS_ITEM_FIELD_ANCHOR_CSS_DESC" />
|
||||
|
||||
<field name="menu_image" type="media"
|
||||
label="COM_MENUS_ITEM_FIELD_MENU_IMAGE_LABEL"
|
||||
description="COM_MENUS_ITEM_FIELD_MENU_IMAGE_DESC" />
|
||||
|
||||
<field name="menu_text" type="radio"
|
||||
class="btn-group"
|
||||
label="COM_MENUS_ITEM_FIELD_MENU_TEXT_LABEL"
|
||||
description="COM_MENUS_ITEM_FIELD_MENU_TEXT_DESC"
|
||||
default="1" filter="integer"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
|
||||
</fieldset>
|
||||
|
||||
<fieldset name="page-options"
|
||||
label="COM_MENUS_PAGE_OPTIONS_LABEL"
|
||||
>
|
||||
|
||||
|
||||
<field name="page_title" type="text"
|
||||
label="COM_MENUS_ITEM_FIELD_PAGE_TITLE_LABEL"
|
||||
description="COM_MENUS_ITEM_FIELD_PAGE_TITLE_DESC" />
|
||||
|
||||
<field name="show_page_heading" type="radio"
|
||||
class="btn-group"
|
||||
label="COM_MENUS_ITEM_FIELD_SHOW_PAGE_HEADING_LABEL"
|
||||
description="COM_MENUS_ITEM_FIELD_SHOW_PAGE_HEADING_DESC"
|
||||
default="0" filter="integer"
|
||||
>
|
||||
<option value="0" class="no">JNO</option>
|
||||
<option value="1" class="yes">JYES</option>
|
||||
</field>
|
||||
|
||||
<field name="page_heading" type="text"
|
||||
label="COM_MENUS_ITEM_FIELD_PAGE_HEADING_LABEL"
|
||||
description="COM_MENUS_ITEM_FIELD_PAGE_HEADING_DESC" />
|
||||
|
||||
<field name="pageclass_sfx" type="text"
|
||||
label="COM_MENUS_ITEM_FIELD_PAGE_CLASS_LABEL"
|
||||
description="COM_MENUS_ITEM_FIELD_PAGE_CLASS_DESC" />
|
||||
|
||||
|
||||
</fieldset>
|
||||
|
||||
<fieldset name="metadata" label="JGLOBAL_FIELDSET_METADATA_OPTIONS"
|
||||
>
|
||||
<field name="menu-meta_description" type="textarea"
|
||||
label="JFIELD_META_DESCRIPTION_LABEL" description="JFIELD_META_DESCRIPTION_DESC"
|
||||
rows="3" cols="40" />
|
||||
|
||||
<field name="menu-meta_keywords" type="textarea"
|
||||
label="JFIELD_META_KEYWORDS_LABEL" description="JFIELD_META_KEYWORDS_DESC"
|
||||
rows="3" cols="40" />
|
||||
|
||||
<field name="robots"
|
||||
type="list"
|
||||
label="JFIELD_METADATA_ROBOTS_LABEL"
|
||||
description="JFIELD_METADATA_ROBOTS_DESC"
|
||||
>
|
||||
<option value="">JGLOBAL_USE_GLOBAL</option>
|
||||
<option value="index, follow">JGLOBAL_INDEX_FOLLOW</option>
|
||||
<option value="noindex, follow">JGLOBAL_NOINDEX_FOLLOW</option>
|
||||
<option value="index, nofollow">JGLOBAL_INDEX_NOFOLLOW</option>
|
||||
<option value="noindex, nofollow">JGLOBAL_NOINDEX_NOFOLLOW</option>
|
||||
</field>
|
||||
|
||||
<field name="secure" type="list"
|
||||
class="btn-group"
|
||||
label="COM_MENUS_ITEM_FIELD_SECURE_LABEL" description="COM_MENUS_ITEM_FIELD_SECURE_DESC"
|
||||
default="0" filter="integer"
|
||||
>
|
||||
<option value="-1">JOFF</option>
|
||||
<option value="1">JON</option>
|
||||
<option value="0">COM_MENUS_FIELD_VALUE_IGNORE
|
||||
</option>
|
||||
|
||||
</field>
|
||||
</fieldset>
|
||||
|
||||
</fields>
|
||||
|
||||
</form>
|
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<form>
|
||||
<fields name="params">
|
||||
<fieldset name="menu-options"
|
||||
label="COM_MENUS_LINKTYPE_OPTIONS_LABEL"
|
||||
>
|
||||
</fieldset>
|
||||
</fields>
|
||||
<help key="JHELP_MENUS_MENU_ITEM_MENU_ITEM_HEADING" />
|
||||
</form>
|
@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<form>
|
||||
<fields name="params">
|
||||
<fieldset name="menu-options"
|
||||
label="COM_MENUS_LINKTYPE_OPTIONS_LABEL"
|
||||
>
|
||||
|
||||
<field name="menu_image" type="media"
|
||||
label="COM_MENUS_ITEM_FIELD_MENU_IMAGE_LABEL"
|
||||
description="COM_MENUS_ITEM_FIELD_MENU_IMAGE_DESC" />
|
||||
|
||||
<field name="menu_text" type="radio" class="btn-group"
|
||||
label="COM_MENUS_ITEM_FIELD_MENU_TEXT_LABEL"
|
||||
description="COM_MENUS_ITEM_FIELD_MENU_TEXT_DESC"
|
||||
default="1" filter="integer"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
|
||||
</fieldset>
|
||||
</fields>
|
||||
<help key="JHELP_MENUS_MENU_ITEM_TEXT_SEPARATOR" />
|
||||
</form>
|
31
administrator/components/com_menus/models/forms/item_url.xml
Normal file
31
administrator/components/com_menus/models/forms/item_url.xml
Normal file
@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<form>
|
||||
<fields name="params">
|
||||
<fieldset name="menu-options" label="COM_MENUS_LINKTYPE_OPTIONS_LABEL"
|
||||
>
|
||||
|
||||
<field name="menu-anchor_title"
|
||||
type="text" label="COM_MENUS_ITEM_FIELD_ANCHOR_TITLE_LABEL"
|
||||
description="COM_MENUS_ITEM_FIELD_ANCHOR_TITLE_DESC" />
|
||||
|
||||
<field name="menu-anchor_css"
|
||||
type="text" label="COM_MENUS_ITEM_FIELD_ANCHOR_CSS_LABEL"
|
||||
description="COM_MENUS_ITEM_FIELD_ANCHOR_CSS_DESC" />
|
||||
|
||||
<field name="menu_image" type="media"
|
||||
label="COM_MENUS_ITEM_FIELD_MENU_IMAGE_LABEL"
|
||||
description="COM_MENUS_ITEM_FIELD_MENU_IMAGE_DESC" />
|
||||
|
||||
<field name="menu_text" type="radio" class="btn-group"
|
||||
label="COM_MENUS_ITEM_FIELD_MENU_TEXT_LABEL"
|
||||
description="COM_MENUS_ITEM_FIELD_MENU_TEXT_DESC"
|
||||
default="1" filter="integer"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
|
||||
</fieldset>
|
||||
</fields>
|
||||
<help key="JHELP_MENUS_MENU_ITEM_EXTERNAL_URL" />
|
||||
</form>
|
45
administrator/components/com_menus/models/forms/menu.xml
Normal file
45
administrator/components/com_menus/models/forms/menu.xml
Normal file
@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<form>
|
||||
<fieldset>
|
||||
<field
|
||||
id="id"
|
||||
name="id"
|
||||
type="hidden"
|
||||
default="0"
|
||||
filter="int"
|
||||
readonly="true"/>
|
||||
|
||||
<field
|
||||
id="menutype"
|
||||
name="menutype"
|
||||
type="text"
|
||||
label="COM_MENUS_MENU_MENUTYPE_LABEL"
|
||||
description="COM_MENUS_MENU_MENUTYPE_DESC"
|
||||
class="inputbox"
|
||||
size="30"
|
||||
maxlength="24"
|
||||
required="true" />
|
||||
|
||||
<field
|
||||
id="title"
|
||||
name="title"
|
||||
type="text"
|
||||
label="JGLOBAL_TITLE"
|
||||
description="COM_MENUS_MENU_TITLE_DESC"
|
||||
class="inputbox"
|
||||
size="30"
|
||||
maxlength="48"
|
||||
required="true" />
|
||||
|
||||
<field
|
||||
id="menudescription"
|
||||
name="description"
|
||||
type="text"
|
||||
label="JGLOBAL_DESCRIPTION"
|
||||
description="COM_MENUS_MENU_DESCRIPTION_DESC"
|
||||
class="inputbox"
|
||||
size="30"
|
||||
maxlength="255" />
|
||||
|
||||
</fieldset>
|
||||
</form>
|
1
administrator/components/com_menus/models/index.html
Normal file
1
administrator/components/com_menus/models/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
1515
administrator/components/com_menus/models/item.php
Normal file
1515
administrator/components/com_menus/models/item.php
Normal file
File diff suppressed because it is too large
Load Diff
313
administrator/components/com_menus/models/items.php
Normal file
313
administrator/components/com_menus/models/items.php
Normal file
@ -0,0 +1,313 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_menus
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* Menu Item List Model for Menus.
|
||||
*
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_menus
|
||||
* @since 1.6
|
||||
*/
|
||||
class MenusModelItems extends JModelList
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array An optional associative array of configuration settings.
|
||||
* @see JController
|
||||
* @since 1.6
|
||||
*/
|
||||
public function __construct($config = array())
|
||||
{
|
||||
if (empty($config['filter_fields']))
|
||||
{
|
||||
$config['filter_fields'] = array(
|
||||
'id', 'a.id',
|
||||
'menutype', 'a.menutype',
|
||||
'title', 'a.title',
|
||||
'alias', 'a.alias',
|
||||
'published', 'a.published',
|
||||
'access', 'a.access', 'access_level',
|
||||
'language', 'a.language',
|
||||
'checked_out', 'a.checked_out',
|
||||
'checked_out_time', 'a.checked_out_time',
|
||||
'lft', 'a.lft',
|
||||
'rgt', 'a.rgt',
|
||||
'level', 'a.level',
|
||||
'path', 'a.path',
|
||||
'client_id', 'a.client_id',
|
||||
'home', 'a.home',
|
||||
);
|
||||
|
||||
$app = JFactory::getApplication();
|
||||
$assoc = isset($app->item_associations) ? $app->item_associations : 0;
|
||||
if ($assoc)
|
||||
{
|
||||
$config['filter_fields'][] = 'association';
|
||||
}
|
||||
}
|
||||
|
||||
parent::__construct($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to auto-populate the model state.
|
||||
*
|
||||
* Note. Calling getState in this method will result in recursion.
|
||||
*
|
||||
* @return void
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function populateState($ordering = null, $direction = null)
|
||||
{
|
||||
$app = JFactory::getApplication('administrator');
|
||||
|
||||
$search = $this->getUserStateFromRequest($this->context . '.search', 'filter_search');
|
||||
$this->setState('filter.search', $search);
|
||||
|
||||
$published = $this->getUserStateFromRequest($this->context . '.published', 'filter_published', '');
|
||||
$this->setState('filter.published', $published);
|
||||
|
||||
$access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int');
|
||||
$this->setState('filter.access', $access);
|
||||
|
||||
$parentId = $this->getUserStateFromRequest($this->context . '.filter.parent_id', 'filter_parent_id', 0, 'int');
|
||||
$this->setState('filter.parent_id', $parentId);
|
||||
|
||||
$level = $this->getUserStateFromRequest($this->context . '.filter.level', 'filter_level', 0, 'int');
|
||||
$this->setState('filter.level', $level);
|
||||
|
||||
$menuType = $app->input->getString('menutype', null);
|
||||
if ($menuType)
|
||||
{
|
||||
if ($menuType != $app->getUserState($this->context . '.filter.menutype'))
|
||||
{
|
||||
$app->setUserState($this->context . '.filter.menutype', $menuType);
|
||||
$app->input->set('limitstart', 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$menuType = $app->getUserState($this->context . '.filter.menutype');
|
||||
|
||||
if (!$menuType)
|
||||
{
|
||||
$menuType = $this->getDefaultMenuType();
|
||||
}
|
||||
}
|
||||
|
||||
$this->setState('filter.menutype', $menuType);
|
||||
|
||||
$language = $this->getUserStateFromRequest($this->context . '.filter.language', 'filter_language', '');
|
||||
$this->setState('filter.language', $language);
|
||||
|
||||
// Component parameters.
|
||||
$params = JComponentHelper::getParams('com_menus');
|
||||
$this->setState('params', $params);
|
||||
|
||||
// List state information.
|
||||
parent::populateState('a.lft', 'asc');
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a store id based on model configuration state.
|
||||
*
|
||||
* This is necessary because the model is used by the component and
|
||||
* different modules that might need different sets of data or different
|
||||
* ordering requirements.
|
||||
*
|
||||
* @param string $id A prefix for the store id.
|
||||
*
|
||||
* @return string A store id.
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function getStoreId($id = '')
|
||||
{
|
||||
// Compile the store id.
|
||||
$id .= ':' . $this->getState('filter.access');
|
||||
$id .= ':' . $this->getState('filter.published');
|
||||
$id .= ':' . $this->getState('filter.language');
|
||||
$id .= ':' . $this->getState('filter.search');
|
||||
$id .= ':' . $this->getState('filter.parent_id');
|
||||
$id .= ':' . $this->getState('filter.menutype');
|
||||
|
||||
return parent::getStoreId($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the default menu type.
|
||||
*
|
||||
* In the absence of better information, this is the first menu ordered by title.
|
||||
*
|
||||
* @return string The default menu type
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function getDefaultMenuType()
|
||||
{
|
||||
// Create a new query object.
|
||||
$db = $this->getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select('menutype')
|
||||
->from('#__menu_types')
|
||||
->order('title');
|
||||
$db->setQuery($query, 0, 1);
|
||||
$menuType = $db->loadResult();
|
||||
|
||||
return $menuType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds an SQL query to load the list data.
|
||||
*
|
||||
* @return JDatabaseQuery A query object.
|
||||
*/
|
||||
protected function getListQuery()
|
||||
{
|
||||
// Create a new query object.
|
||||
$db = $this->getDbo();
|
||||
$query = $db->getQuery(true);
|
||||
$user = JFactory::getUser();
|
||||
$app = JFactory::getApplication();
|
||||
|
||||
// Select all fields from the table.
|
||||
$query->select(
|
||||
$this->getState(
|
||||
'list.select',
|
||||
$db->quoteName(
|
||||
array('a.id', 'a.menutype', 'a.title', 'a.alias', 'a.note', 'a.path', 'a.link', 'a.type', 'a.parent_id', 'a.level', 'a.published', 'a.component_id', 'a.checked_out', 'a.checked_out_time', 'a.browserNav', 'a.access', 'a.img', 'a.template_style_id', 'a.params', 'a.lft', 'a.rgt', 'a.home', 'a.language', 'a.client_id'),
|
||||
array(null, null, null, null, null, null, null, null, null, null, 'apublished', null, null, null, null, null, null, null, null, null, null, null, null, null)
|
||||
)
|
||||
)
|
||||
);
|
||||
$query->select(
|
||||
'CASE a.type' .
|
||||
' WHEN ' . $db->quote('component') . ' THEN a.published+2*(e.enabled-1) ' .
|
||||
' WHEN ' . $db->quote('url') . ' THEN a.published+2 ' .
|
||||
' WHEN ' . $db->quote('alias') . ' THEN a.published+4 ' .
|
||||
' WHEN ' . $db->quote('separator') . ' THEN a.published+6 ' .
|
||||
' WHEN ' . $db->quote('heading') . ' THEN a.published+8 ' .
|
||||
' END AS published'
|
||||
);
|
||||
$query->from($db->quoteName('#__menu') . ' AS a');
|
||||
|
||||
// Join over the language
|
||||
$query->select('l.title AS language_title, l.image as image')
|
||||
->join('LEFT', $db->quoteName('#__languages') . ' AS l ON l.lang_code = a.language');
|
||||
|
||||
// Join over the users.
|
||||
$query->select('u.name AS editor')
|
||||
->join('LEFT', $db->quoteName('#__users') . ' AS u ON u.id = a.checked_out');
|
||||
|
||||
//Join over components
|
||||
$query->select('c.element AS componentname')
|
||||
->join('LEFT', $db->quoteName('#__extensions') . ' AS c ON c.extension_id = a.component_id');
|
||||
|
||||
// Join over the asset groups.
|
||||
$query->select('ag.title AS access_level')
|
||||
->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access');
|
||||
|
||||
// Join over the associations.
|
||||
$assoc = isset($app->item_associations) ? $app->item_associations : 0;
|
||||
if ($assoc)
|
||||
{
|
||||
$query->select('COUNT(asso2.id)>1 as association')
|
||||
->join('LEFT', '#__associations AS asso ON asso.id = a.id AND asso.context=' . $db->quote('com_menus.item'))
|
||||
->join('LEFT', '#__associations AS asso2 ON asso2.key = asso.key')
|
||||
->group('a.id');
|
||||
}
|
||||
|
||||
// Join over the extensions
|
||||
$query->select('e.name AS name')
|
||||
->join('LEFT', '#__extensions AS e ON e.extension_id = a.component_id');
|
||||
|
||||
// Exclude the root category.
|
||||
$query->where('a.id > 1')
|
||||
->where('a.client_id = 0');
|
||||
|
||||
// Filter on the published state.
|
||||
$published = $this->getState('filter.published');
|
||||
if (is_numeric($published))
|
||||
{
|
||||
$query->where('a.published = ' . (int) $published);
|
||||
}
|
||||
elseif ($published === '')
|
||||
{
|
||||
$query->where('(a.published IN (0, 1))');
|
||||
}
|
||||
|
||||
// Filter by search in title, alias or id
|
||||
if ($search = trim($this->getState('filter.search')))
|
||||
{
|
||||
if (stripos($search, 'id:') === 0)
|
||||
{
|
||||
$query->where('a.id = ' . (int) substr($search, 3));
|
||||
}
|
||||
elseif (stripos($search, 'link:') === 0)
|
||||
{
|
||||
if ($search = substr($search, 5))
|
||||
{
|
||||
$search = $db->quote('%' . $db->escape($search, true) . '%');
|
||||
$query->where('a.link LIKE ' . $search);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$search = $db->quote('%' . $db->escape($search, true) . '%');
|
||||
$query->where('(' . 'a.title LIKE ' . $search . ' OR a.alias LIKE ' . $search . ' OR a.note LIKE ' . $search . ')');
|
||||
}
|
||||
}
|
||||
|
||||
// Filter the items over the parent id if set.
|
||||
$parentId = $this->getState('filter.parent_id');
|
||||
if (!empty($parentId))
|
||||
{
|
||||
$query->where('p.id = ' . (int) $parentId);
|
||||
}
|
||||
|
||||
// Filter the items over the menu id if set.
|
||||
$menuType = $this->getState('filter.menutype');
|
||||
if (!empty($menuType))
|
||||
{
|
||||
$query->where('a.menutype = ' . $db->quote($menuType));
|
||||
}
|
||||
|
||||
// Filter on the access level.
|
||||
if ($access = $this->getState('filter.access'))
|
||||
{
|
||||
$query->where('a.access = ' . (int) $access);
|
||||
}
|
||||
|
||||
// Implement View Level Access
|
||||
if (!$user->authorise('core.admin'))
|
||||
{
|
||||
$groups = implode(',', $user->getAuthorisedViewLevels());
|
||||
$query->where('a.access IN (' . $groups . ')');
|
||||
}
|
||||
|
||||
// Filter on the level.
|
||||
if ($level = $this->getState('filter.level'))
|
||||
{
|
||||
$query->where('a.level <= ' . (int) $level);
|
||||
}
|
||||
|
||||
// Filter on the language.
|
||||
if ($language = $this->getState('filter.language'))
|
||||
{
|
||||
$query->where('a.language = ' . $db->quote($language));
|
||||
}
|
||||
|
||||
// Add the list ordering clause.
|
||||
$query->order($db->escape($this->getState('list.ordering', 'a.lft')) . ' ' . $db->escape($this->getState('list.direction', 'ASC')));
|
||||
|
||||
//echo nl2br(str_replace('#__','jos_',(string)$query)).'<hr/>';
|
||||
return $query;
|
||||
}
|
||||
}
|
296
administrator/components/com_menus/models/menu.php
Normal file
296
administrator/components/com_menus/models/menu.php
Normal file
@ -0,0 +1,296 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_menus
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* Menu Item Model for Menus.
|
||||
*
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_menus
|
||||
* @since 1.6
|
||||
*/
|
||||
class MenusModelMenu extends JModelForm
|
||||
{
|
||||
/**
|
||||
* @var string The prefix to use with controller messages.
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $text_prefix = 'COM_MENUS_MENU';
|
||||
|
||||
/**
|
||||
* Model context string.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_context = 'com_menus.menu';
|
||||
|
||||
/**
|
||||
* Method to test whether a record can be deleted.
|
||||
*
|
||||
* @param object A record object.
|
||||
*
|
||||
* @return boolean True if allowed to delete the record. Defaults to the permission set in the component.
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function canDelete($record)
|
||||
{
|
||||
$user = JFactory::getUser();
|
||||
|
||||
return $user->authorise('core.delete', 'com_menus.menu.' . (int) $record->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to test whether a record can be deleted.
|
||||
*
|
||||
* @param object A record object.
|
||||
*
|
||||
* @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component.
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function canEditState($record)
|
||||
{
|
||||
$user = JFactory::getUser();
|
||||
|
||||
return $user->authorise('core.edit.state', 'com_menus.menu.' . (int) $record->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a Table object, always creating it
|
||||
*
|
||||
* @param type The table type to instantiate
|
||||
* @param string A prefix for the table class name. Optional.
|
||||
* @param array Configuration array for model. Optional.
|
||||
* @return JTable A database object
|
||||
*/
|
||||
public function getTable($type = 'MenuType', $prefix = 'JTable', $config = array())
|
||||
{
|
||||
return JTable::getInstance($type, $prefix, $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to auto-populate the model state.
|
||||
*
|
||||
* Note. Calling getState in this method will result in recursion.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function populateState()
|
||||
{
|
||||
$app = JFactory::getApplication('administrator');
|
||||
|
||||
// Load the User state.
|
||||
$id = $app->input->getInt('id');
|
||||
$this->setState('menu.id', $id);
|
||||
|
||||
// Load the parameters.
|
||||
$params = JComponentHelper::getParams('com_menus');
|
||||
$this->setState('params', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a menu item.
|
||||
*
|
||||
* @param integer The id of the menu item to get.
|
||||
*
|
||||
* @return mixed Menu item data object on success, false on failure.
|
||||
*/
|
||||
public function &getItem($itemId = null)
|
||||
{
|
||||
$itemId = (!empty($itemId)) ? $itemId : (int) $this->getState('menu.id');
|
||||
$false = false;
|
||||
|
||||
// Get a menu item row instance.
|
||||
$table = $this->getTable();
|
||||
|
||||
// Attempt to load the row.
|
||||
$return = $table->load($itemId);
|
||||
|
||||
// Check for a table object error.
|
||||
if ($return === false && $table->getError())
|
||||
{
|
||||
$this->setError($table->getError());
|
||||
return $false;
|
||||
}
|
||||
|
||||
$properties = $table->getProperties(1);
|
||||
$value = JArrayHelper::toObject($properties, 'JObject');
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the menu item form.
|
||||
*
|
||||
* @param array $data Data for the form.
|
||||
* @param boolean $loadData True if the form is to load its own data (default case), false if not.
|
||||
* @return JForm A JForm object on success, false on failure
|
||||
* @since 1.6
|
||||
*/
|
||||
public function getForm($data = array(), $loadData = true)
|
||||
{
|
||||
// Get the form.
|
||||
$form = $this->loadForm('com_menus.menu', 'menu', array('control' => 'jform', 'load_data' => $loadData));
|
||||
if (empty($form))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the data that should be injected in the form.
|
||||
*
|
||||
* @return mixed The data for the form.
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function loadFormData()
|
||||
{
|
||||
// Check the session for previously entered form data.
|
||||
$data = JFactory::getApplication()->getUserState('com_menus.edit.menu.data', array());
|
||||
|
||||
if (empty($data))
|
||||
{
|
||||
$data = $this->getItem();
|
||||
}
|
||||
|
||||
$this->preprocessData('com_menus.menu', $data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to save the form data.
|
||||
*
|
||||
* @param array The form data.
|
||||
* @return boolean True on success.
|
||||
*/
|
||||
public function save($data)
|
||||
{
|
||||
$id = (!empty($data['id'])) ? $data['id'] : (int) $this->getState('menu.id');
|
||||
|
||||
// Get a row instance.
|
||||
$table = $this->getTable();
|
||||
|
||||
// Load the row if saving an existing item.
|
||||
if ($id > 0)
|
||||
{
|
||||
$table->load($id);
|
||||
}
|
||||
|
||||
// Bind the data.
|
||||
if (!$table->bind($data))
|
||||
{
|
||||
$this->setError($table->getError());
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check the data.
|
||||
if (!$table->check())
|
||||
{
|
||||
$this->setError($table->getError());
|
||||
return false;
|
||||
}
|
||||
|
||||
// Store the data.
|
||||
if (!$table->store())
|
||||
{
|
||||
$this->setError($table->getError());
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->setState('menu.id', $table->id);
|
||||
|
||||
// Clean the cache
|
||||
$this->cleanCache();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to delete groups.
|
||||
*
|
||||
* @param array An array of item ids.
|
||||
* @return boolean Returns true on success, false on failure.
|
||||
*/
|
||||
public function delete($itemIds)
|
||||
{
|
||||
// Sanitize the ids.
|
||||
$itemIds = (array) $itemIds;
|
||||
JArrayHelper::toInteger($itemIds);
|
||||
|
||||
// Get a group row instance.
|
||||
$table = $this->getTable();
|
||||
|
||||
// Iterate the items to delete each one.
|
||||
foreach ($itemIds as $itemId)
|
||||
{
|
||||
// TODO: Delete the menu associations - Menu items and Modules
|
||||
|
||||
if (!$table->delete($itemId))
|
||||
{
|
||||
$this->setError($table->getError());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Clean the cache
|
||||
$this->cleanCache();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of all mod_mainmenu modules and collates them by menutype
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function &getModules()
|
||||
{
|
||||
$db = $this->getDbo();
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->from('#__modules as a')
|
||||
->select('a.id, a.title, a.params, a.position')
|
||||
->where('module = ' . $db->quote('mod_menu'))
|
||||
->select('ag.title AS access_title')
|
||||
->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access');
|
||||
$db->setQuery($query);
|
||||
|
||||
$modules = $db->loadObjectList();
|
||||
|
||||
$result = array();
|
||||
|
||||
foreach ($modules as &$module)
|
||||
{
|
||||
$params = new JRegistry;
|
||||
$params->loadString($module->params);
|
||||
|
||||
$menuType = $params->get('menutype');
|
||||
if (!isset($result[$menuType]))
|
||||
{
|
||||
$result[$menuType] = array();
|
||||
}
|
||||
$result[$menuType][] = & $module;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom clean cache method
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function cleanCache($group = null, $client_id = 0)
|
||||
{
|
||||
parent::cleanCache('com_modules');
|
||||
parent::cleanCache('mod_menu');
|
||||
}
|
||||
}
|
235
administrator/components/com_menus/models/menus.php
Normal file
235
administrator/components/com_menus/models/menus.php
Normal file
@ -0,0 +1,235 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_menus
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* Menu List Model for Menus.
|
||||
*
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_menus
|
||||
* @since 1.6
|
||||
*/
|
||||
class MenusModelMenus extends JModelList
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array An optional associative array of configuration settings.
|
||||
*
|
||||
* @see JController
|
||||
* @since 1.6
|
||||
*/
|
||||
public function __construct($config = array())
|
||||
{
|
||||
if (empty($config['filter_fields']))
|
||||
{
|
||||
$config['filter_fields'] = array(
|
||||
'id', 'a.id',
|
||||
'title', 'a.title',
|
||||
'menutype', 'a.menutype',
|
||||
);
|
||||
}
|
||||
|
||||
parent::__construct($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides the getItems method to attach additional metrics to the list.
|
||||
*
|
||||
* @return mixed An array of data items on success, false on failure.
|
||||
*
|
||||
* @since 1.6.1
|
||||
*/
|
||||
public function getItems()
|
||||
{
|
||||
// Get a storage key.
|
||||
$store = $this->getStoreId('getItems');
|
||||
|
||||
// Try to load the data from internal storage.
|
||||
if (!empty($this->cache[$store]))
|
||||
{
|
||||
return $this->cache[$store];
|
||||
}
|
||||
|
||||
// Load the list items.
|
||||
$items = parent::getItems();
|
||||
|
||||
// If emtpy or an error, just return.
|
||||
if (empty($items))
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
// Getting the following metric by joins is WAY TOO SLOW.
|
||||
// Faster to do three queries for very large menu trees.
|
||||
|
||||
// Get the menu types of menus in the list.
|
||||
$db = $this->getDbo();
|
||||
$menuTypes = JArrayHelper::getColumn($items, 'menutype');
|
||||
|
||||
// Quote the strings.
|
||||
$menuTypes = implode(
|
||||
',',
|
||||
array_map(array($db, 'quote'), $menuTypes)
|
||||
);
|
||||
|
||||
// Get the published menu counts.
|
||||
$query = $db->getQuery(true)
|
||||
->select('m.menutype, COUNT(DISTINCT m.id) AS count_published')
|
||||
->from('#__menu AS m')
|
||||
->where('m.published = 1')
|
||||
->where('m.menutype IN (' . $menuTypes . ')')
|
||||
->group('m.menutype');
|
||||
|
||||
$db->setQuery($query);
|
||||
|
||||
try
|
||||
{
|
||||
$countPublished = $db->loadAssocList('menutype', 'count_published');
|
||||
}
|
||||
catch (RuntimeException $e)
|
||||
{
|
||||
$this->setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get the unpublished menu counts.
|
||||
$query->clear('where')
|
||||
->where('m.published = 0')
|
||||
->where('m.menutype IN (' . $menuTypes . ')');
|
||||
$db->setQuery($query);
|
||||
|
||||
try
|
||||
{
|
||||
$countUnpublished = $db->loadAssocList('menutype', 'count_published');
|
||||
}
|
||||
catch (RuntimeException $e)
|
||||
{
|
||||
$this->setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get the trashed menu counts.
|
||||
$query->clear('where')
|
||||
->where('m.published = -2')
|
||||
->where('m.menutype IN (' . $menuTypes . ')');
|
||||
$db->setQuery($query);
|
||||
|
||||
try
|
||||
{
|
||||
$countTrashed = $db->loadAssocList('menutype', 'count_published');
|
||||
}
|
||||
catch (RuntimeException $e)
|
||||
{
|
||||
$this->setError($e->getMessage);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Inject the values back into the array.
|
||||
foreach ($items as $item)
|
||||
{
|
||||
$item->count_published = isset($countPublished[$item->menutype]) ? $countPublished[$item->menutype] : 0;
|
||||
$item->count_unpublished = isset($countUnpublished[$item->menutype]) ? $countUnpublished[$item->menutype] : 0;
|
||||
$item->count_trashed = isset($countTrashed[$item->menutype]) ? $countTrashed[$item->menutype] : 0;
|
||||
}
|
||||
|
||||
// Add the items to the internal cache.
|
||||
$this->cache[$store] = $items;
|
||||
|
||||
return $this->cache[$store];
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to build an SQL query to load the list data.
|
||||
*
|
||||
* @return string An SQL query
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function getListQuery()
|
||||
{
|
||||
// Create a new query object.
|
||||
$db = $this->getDbo();
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Select all fields from the table.
|
||||
$query->select($this->getState('list.select', 'a.*'))
|
||||
->from($db->quoteName('#__menu_types') . ' AS a')
|
||||
|
||||
->group('a.id, a.menutype, a.title, a.description');
|
||||
|
||||
// Filter by search in title or menutype
|
||||
if ($search = trim($this->getState('filter.search')))
|
||||
{
|
||||
$search = $db->quote('%' . $db->escape($search, true) . '%');
|
||||
$query->where('(' . 'a.title LIKE ' . $search . ' OR a.menutype LIKE ' . $search . ')');
|
||||
}
|
||||
|
||||
// Add the list ordering clause.
|
||||
$query->order($db->escape($this->getState('list.ordering', 'a.id')) . ' ' . $db->escape($this->getState('list.direction', 'ASC')));
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to auto-populate the model state.
|
||||
*
|
||||
* Note. Calling getState in this method will result in recursion.
|
||||
*
|
||||
* @param string $ordering An optional ordering field.
|
||||
* @param string $direction An optional direction (asc|desc).
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function populateState($ordering = null, $direction = null)
|
||||
{
|
||||
$search = $this->getUserStateFromRequest($this->context . '.search', 'filter_search');
|
||||
$this->setState('filter.search', $search);
|
||||
|
||||
// List state information.
|
||||
parent::populateState('a.id', 'asc');
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the extension id of the core mod_menu module.
|
||||
*
|
||||
* @return integer
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
public function getModMenuId()
|
||||
{
|
||||
$db = $this->getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select('e.extension_id')
|
||||
->from('#__extensions AS e')
|
||||
->where('e.type = ' . $db->quote('module'))
|
||||
->where('e.element = ' . $db->quote('mod_menu'))
|
||||
->where('e.client_id = 0');
|
||||
$db->setQuery($query);
|
||||
|
||||
return $db->loadResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of all mod_mainmenu modules and collates them by menutype
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function &getModules()
|
||||
{
|
||||
$model = JModelLegacy::getInstance('Menu', 'MenusModel', array('ignore_request' => true));
|
||||
$result = & $model->getModules();
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
431
administrator/components/com_menus/models/menutypes.php
Normal file
431
administrator/components/com_menus/models/menutypes.php
Normal file
@ -0,0 +1,431 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_menus
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
jimport('joomla.filesystem.folder');
|
||||
|
||||
/**
|
||||
* Menu Item Types Model for Menus.
|
||||
*
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_menus
|
||||
* @since 1.6
|
||||
*/
|
||||
class MenusModelMenutypes extends JModelLegacy
|
||||
{
|
||||
/**
|
||||
* A reverse lookup of the base link URL to Title
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $rlu = array();
|
||||
|
||||
/**
|
||||
* Method to get the reverse lookup of the base link URL to Title
|
||||
*
|
||||
* @return array Array of reverse lookup of the base link URL to Title
|
||||
* @since 1.6
|
||||
*/
|
||||
public function getReverseLookup()
|
||||
{
|
||||
if (empty($this->rlu))
|
||||
{
|
||||
$this->getTypeOptions();
|
||||
}
|
||||
return $this->rlu;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the available menu item type options.
|
||||
*
|
||||
* @return array Array of groups with menu item types.
|
||||
* @since 1.6
|
||||
*/
|
||||
public function getTypeOptions()
|
||||
{
|
||||
jimport('joomla.filesystem.file');
|
||||
|
||||
$lang = JFactory::getLanguage();
|
||||
$list = array();
|
||||
|
||||
// Get the list of components.
|
||||
$db = JFactory::getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select('name, element AS ' . $db->quoteName('option'))
|
||||
->from('#__extensions')
|
||||
->where('type = ' . $db->quote('component'))
|
||||
->where('enabled = 1')
|
||||
->order('name ASC');
|
||||
$db->setQuery($query);
|
||||
$components = $db->loadObjectList();
|
||||
|
||||
foreach ($components as $component)
|
||||
{
|
||||
if ($options = $this->getTypeOptionsByComponent($component->option))
|
||||
{
|
||||
$list[$component->name] = $options;
|
||||
|
||||
// Create the reverse lookup for link-to-name.
|
||||
foreach ($options as $option)
|
||||
{
|
||||
if (isset($option->request))
|
||||
{
|
||||
$this->addReverseLookupUrl($option);
|
||||
|
||||
if (isset($option->request['option']))
|
||||
{
|
||||
$lang->load($option->request['option'].'.sys', JPATH_ADMINISTRATOR, null, false, false)
|
||||
|| $lang->load($option->request['option'].'.sys', JPATH_ADMINISTRATOR.'/components/'.$option->request['option'], null, false, false)
|
||||
|| $lang->load($option->request['option'].'.sys', JPATH_ADMINISTRATOR, $lang->getDefault(), false, false)
|
||||
|| $lang->load($option->request['option'].'.sys', JPATH_ADMINISTRATOR.'/components/'.$option->request['option'], $lang->getDefault(), false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Allow a system plugin to insert dynamic menu types to the list shown in menus:
|
||||
JDispatcher::getInstance()->trigger('onAfterGetMenuTypeOptions', array(&$list, $this));
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to create the reverse lookup for link-to-name.
|
||||
* (can be used from onAfterGetMenuTypeOptions handlers)
|
||||
*
|
||||
* @param $option JObject with request array or string and title public variables
|
||||
*
|
||||
* @return void
|
||||
* @since 3.1
|
||||
*/
|
||||
public function addReverseLookupUrl($option)
|
||||
{
|
||||
$this->rlu[MenusHelper::getLinkKey($option->request)] = $option->get('title');
|
||||
}
|
||||
|
||||
protected function getTypeOptionsByComponent($component)
|
||||
{
|
||||
$options = array();
|
||||
|
||||
$mainXML = JPATH_SITE.'/components/'.$component.'/metadata.xml';
|
||||
|
||||
if (is_file($mainXML))
|
||||
{
|
||||
$options = $this->getTypeOptionsFromXML($mainXML, $component);
|
||||
}
|
||||
|
||||
if (empty($options))
|
||||
{
|
||||
$options = $this->getTypeOptionsFromMVC($component);
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
protected function getTypeOptionsFromXML($file, $component)
|
||||
{
|
||||
$options = array();
|
||||
|
||||
// Attempt to load the xml file.
|
||||
if (!$xml = simplexml_load_file($file))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Look for the first menu node off of the root node.
|
||||
if (!$menu = $xml->xpath('menu[1]'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$menu = $menu[0];
|
||||
}
|
||||
|
||||
// If we have no options to parse, just add the base component to the list of options.
|
||||
if (!empty($menu['options']) && $menu['options'] == 'none')
|
||||
{
|
||||
// Create the menu option for the component.
|
||||
$o = new JObject;
|
||||
$o->title = (string) $menu['name'];
|
||||
$o->description = (string) $menu['msg'];
|
||||
$o->request = array('option' => $component);
|
||||
|
||||
$options[] = $o;
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
// Look for the first options node off of the menu node.
|
||||
if (!$optionsNode = $menu->xpath('options[1]'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$optionsNode = $optionsNode[0];
|
||||
}
|
||||
|
||||
// Make sure the options node has children.
|
||||
if (!$children = $optionsNode->children())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Process each child as an option.
|
||||
foreach ($children as $child)
|
||||
{
|
||||
if ($child->getName() == 'option')
|
||||
{
|
||||
// Create the menu option for the component.
|
||||
$o = new JObject;
|
||||
$o->title = (string) $child['name'];
|
||||
$o->description = (string) $child['msg'];
|
||||
$o->request = array('option' => $component, (string) $optionsNode['var'] => (string) $child['value']);
|
||||
|
||||
$options[] = $o;
|
||||
}
|
||||
elseif ($child->getName() == 'default')
|
||||
{
|
||||
// Create the menu option for the component.
|
||||
$o = new JObject;
|
||||
$o->title = (string) $child['name'];
|
||||
$o->description = (string) $child['msg'];
|
||||
$o->request = array('option' => $component);
|
||||
|
||||
$options[] = $o;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
protected function getTypeOptionsFromMVC($component)
|
||||
{
|
||||
$options = array();
|
||||
|
||||
// Get the views for this component.
|
||||
$path = JPATH_SITE . '/components/' . $component . '/views';
|
||||
|
||||
if (is_dir($path))
|
||||
{
|
||||
$views = JFolder::folders($path);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($views as $view)
|
||||
{
|
||||
// Ignore private views.
|
||||
if (strpos($view, '_') !== 0)
|
||||
{
|
||||
// Determine if a metadata file exists for the view.
|
||||
$file = $path.'/'.$view.'/metadata.xml';
|
||||
|
||||
if (is_file($file))
|
||||
{
|
||||
// Attempt to load the xml file.
|
||||
if ($xml = simplexml_load_file($file))
|
||||
{
|
||||
// Look for the first view node off of the root node.
|
||||
if ($menu = $xml->xpath('view[1]'))
|
||||
{
|
||||
$menu = $menu[0];
|
||||
|
||||
// If the view is hidden from the menu, discard it and move on to the next view.
|
||||
if (!empty($menu['hidden']) && $menu['hidden'] == 'true')
|
||||
{
|
||||
unset($xml);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Do we have an options node or should we process layouts?
|
||||
// Look for the first options node off of the menu node.
|
||||
if ($optionsNode = $menu->xpath('options[1]'))
|
||||
{
|
||||
$optionsNode = $optionsNode[0];
|
||||
|
||||
// Make sure the options node has children.
|
||||
if ($children = $optionsNode->children())
|
||||
{
|
||||
// Process each child as an option.
|
||||
foreach ($children as $child)
|
||||
{
|
||||
if ($child->getName() == 'option')
|
||||
{
|
||||
// Create the menu option for the component.
|
||||
$o = new JObject;
|
||||
$o->title = (string) $child['name'];
|
||||
$o->description = (string) $child['msg'];
|
||||
$o->request = array('option' => $component, 'view' => $view, (string) $optionsNode['var'] => (string) $child['value']);
|
||||
|
||||
$options[] = $o;
|
||||
}
|
||||
elseif ($child->getName() == 'default')
|
||||
{
|
||||
// Create the menu option for the component.
|
||||
$o = new JObject;
|
||||
$o->title = (string) $child['name'];
|
||||
$o->description = (string) $child['msg'];
|
||||
$o->request = array('option' => $component, 'view' => $view);
|
||||
|
||||
$options[] = $o;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$options = array_merge($options, (array) $this->getTypeOptionsFromLayouts($component, $view));
|
||||
}
|
||||
}
|
||||
unset($xml);
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
$options = array_merge($options, (array) $this->getTypeOptionsFromLayouts($component, $view));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
protected function getTypeOptionsFromLayouts($component, $view)
|
||||
{
|
||||
$options = array();
|
||||
$layouts = array();
|
||||
$layoutNames = array();
|
||||
$lang = JFactory::getLanguage();
|
||||
|
||||
// Get the layouts from the view folder.
|
||||
$path = JPATH_SITE . '/components/' . $component . '/views/' . $view . '/tmpl';
|
||||
if (is_dir($path))
|
||||
{
|
||||
$layouts = array_merge($layouts, JFolder::files($path, '.xml$', false, true));
|
||||
}
|
||||
else
|
||||
{
|
||||
return $options;
|
||||
}
|
||||
|
||||
// build list of standard layout names
|
||||
foreach ($layouts as $layout)
|
||||
{
|
||||
// Ignore private layouts.
|
||||
if (strpos(basename($layout), '_') === false)
|
||||
{
|
||||
// Get the layout name.
|
||||
$layoutNames[] = basename($layout, '.xml');
|
||||
}
|
||||
}
|
||||
|
||||
// get the template layouts
|
||||
// TODO: This should only search one template -- the current template for this item (default of specified)
|
||||
$folders = JFolder::folders(JPATH_SITE . '/templates', '', false, true);
|
||||
// Array to hold association between template file names and templates
|
||||
$templateName = array();
|
||||
foreach ($folders as $folder)
|
||||
{
|
||||
if (is_dir($folder . '/html/' . $component . '/' . $view))
|
||||
{
|
||||
$template = basename($folder);
|
||||
$lang->load('tpl_'.$template.'.sys', JPATH_SITE, null, false, false)
|
||||
|| $lang->load('tpl_'.$template.'.sys', JPATH_SITE.'/templates/'.$template, null, false, false)
|
||||
|| $lang->load('tpl_'.$template.'.sys', JPATH_SITE, $lang->getDefault(), false, false)
|
||||
|| $lang->load('tpl_'.$template.'.sys', JPATH_SITE.'/templates/'.$template, $lang->getDefault(), false, false);
|
||||
|
||||
$templateLayouts = JFolder::files($folder . '/html/' . $component . '/' . $view, '.xml$', false, true);
|
||||
|
||||
foreach ($templateLayouts as $layout)
|
||||
{
|
||||
// Get the layout name.
|
||||
$templateLayoutName = basename($layout, '.xml');
|
||||
|
||||
// add to the list only if it is not a standard layout
|
||||
if (array_search($templateLayoutName, $layoutNames) === false)
|
||||
{
|
||||
$layouts[] = $layout;
|
||||
// Set template name array so we can get the right template for the layout
|
||||
$templateName[$layout] = basename($folder);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Process the found layouts.
|
||||
foreach ($layouts as $layout)
|
||||
{
|
||||
// Ignore private layouts.
|
||||
if (strpos(basename($layout), '_') === false)
|
||||
{
|
||||
$file = $layout;
|
||||
// Get the layout name.
|
||||
$layout = basename($layout, '.xml');
|
||||
|
||||
// Create the menu option for the layout.
|
||||
$o = new JObject;
|
||||
$o->title = ucfirst($layout);
|
||||
$o->description = '';
|
||||
$o->request = array('option' => $component, 'view' => $view);
|
||||
|
||||
// Only add the layout request argument if not the default layout.
|
||||
if ($layout != 'default')
|
||||
{
|
||||
// If the template is set, add in format template:layout so we save the template name
|
||||
$o->request['layout'] = (isset($templateName[$file])) ? $templateName[$file] . ':' . $layout : $layout;
|
||||
}
|
||||
|
||||
// Load layout metadata if it exists.
|
||||
if (is_file($file))
|
||||
{
|
||||
// Attempt to load the xml file.
|
||||
if ($xml = simplexml_load_file($file))
|
||||
{
|
||||
// Look for the first view node off of the root node.
|
||||
if ($menu = $xml->xpath('layout[1]'))
|
||||
{
|
||||
$menu = $menu[0];
|
||||
|
||||
// If the view is hidden from the menu, discard it and move on to the next view.
|
||||
if (!empty($menu['hidden']) && $menu['hidden'] == 'true')
|
||||
{
|
||||
unset($xml);
|
||||
unset($o);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Populate the title and description if they exist.
|
||||
if (!empty($menu['title']))
|
||||
{
|
||||
$o->title = trim((string) $menu['title']);
|
||||
}
|
||||
|
||||
if (!empty($menu->message[0]))
|
||||
{
|
||||
$o->description = trim((string) $menu->message[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add the layout to the options array.
|
||||
$options[] = $o;
|
||||
}
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user