本文整理汇总了PHP中MenusHelper::getMenuLinks方法的典型用法代码示例。如果您正苦于以下问题:PHP MenusHelper::getMenuLinks方法的具体用法?PHP MenusHelper::getMenuLinks怎么用?PHP MenusHelper::getMenuLinks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MenusHelper
的用法示例。
在下文中一共展示了MenusHelper::getMenuLinks方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getGroups
/**
* Method to get the field option groups.
*
* @return array The field option objects as a nested array in groups.
*/
protected function getGroups()
{
// Initialize variables.
$groups = array();
// Initialize some field attributes.
$menuType = (string) $this->element['menu_type'];
$published = $this->element['published'] ? explode(',', (string) $this->element['published']) : array();
$disable = $this->element['disable'] ? explode(',', (string) $this->element['disable']) : array();
$language = $this->element['language'] ? explode(',', (string) $this->element['language']) : array();
// Get the menu items.
$items = \MenusHelper::getMenuLinks($menuType, 0, 0, $published, $language);
// Build group for a specific menu type.
if ($menuType) {
// Initialize the group.
$groups[$menuType] = array();
// Build the options array.
foreach ($items as $link) {
$groups[$menuType][] = Dropdown::option($link->value, $link->text, 'value', 'text', in_array($link->type, $disable));
}
} else {
// Build the groups arrays.
foreach ($items as $menu) {
// Initialize the group.
$groups[$menu->menutype] = array();
// Build the options array.
foreach ($menu->links as $link) {
$groups[$menu->menutype][] = Dropdown::option($link->value, $link->text, 'value', 'text', in_array($link->type, $disable));
}
}
}
// Merge any additional groups in the XML definition.
$groups = array_merge(parent::getGroups(), $groups);
return $groups;
}
示例2: _getGroups
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*/
protected function _getGroups()
{
// Get the attributes
$menuType = (string) $this->_element->attributes()->menu_type;
$published = (string) $this->_element->attributes()->published ? explode(',', (string) $this->_element->attributes()->published) : array();
$disable = (string) $this->_element->attributes()->disable ? explode(',', (string) $this->_element->attributes()->disable) : array();
// Get the com_menus helper
require_once realpath(JPATH_ADMINISTRATOR . '/components/com_menus/helpers/menus.php');
// Get the items
$items = MenusHelper::getMenuLinks($menuType, 0, 0, $published);
// Prepare return value
$groups = array();
// If a menu type was set
if ($menuType) {
$groups[$menuType] = array();
// Loop over links
foreach ($items as $link) {
// Generate an option disabling it if it's the case
$groups[$menuType][] = JHtml::_('select.option', $link->value, $link->text, 'value', 'text', in_array($link->type, $disable));
}
} else {
// Loop over types
foreach ($items as $menu) {
$groups[$menu->menutype] = array();
// Loop over links
foreach ($menu->links as $link) {
// Generate an option disabling it if it's the case
$groups[$menu->menutype][] = JHtml::_('select.option', $link->value, $link->text, 'value', 'text', in_array($link->type, $disable));
}
}
}
// Merge any additional options in the XML definition.
$groups = array_merge(parent::_getGroups(), $groups);
return $groups;
}
示例3: getInput
protected function getInput()
{
$size = (int) $this->def('size');
$multiple = $this->def('multiple', 1);
require_once JPATH_ADMINISTRATOR . '/components/com_menus/helpers/menus.php';
$options = MenusHelper::getMenuLinks();
require_once JPATH_PLUGINS . '/system/nnframework/helpers/html.php';
return nnHtml::selectlist($options, $this->name, $this->value, $this->id, $size, $multiple);
}
示例4: getAssignmentCount
private function getAssignmentCount($id)
{
require_once JPATH_ADMINISTRATOR . '/components/com_menus/helpers/menus.php';
$assignment_count = 0;
$menuTypes = MenusHelper::getMenuLinks();
foreach ($menuTypes as &$type) {
foreach ($type->links as $link) {
if ($link->template_style_id == $id) {
$assignment_count++;
}
}
}
return $assignment_count;
}
示例5: getGroups
/**
* Method to get the field option groups.
*
* @return array The field option objects as a nested array in groups.
*
* @since 1.6
*/
protected function getGroups()
{
$groups = array();
// Initialize some field attributes.
$menuType = (string) $this->element['menu_type'];
$published = $this->element['published'] ? explode(',', (string) $this->element['published']) : array();
$disable = $this->element['disable'] ? explode(',', (string) $this->element['disable']) : array();
$language = $this->element['language'] ? explode(',', (string) $this->element['language']) : array();
// Get the menu items.
$items = MenusHelper::getMenuLinks($menuType, 0, 0, $published, $language);
// Build group for a specific menu type.
if ($menuType) {
// Initialize the group.
$groups[$menuType] = array();
// Build the options array.
foreach ($items as $link) {
/*##mygruz20130718204314 {
It was:
It became:*/
$repeate = $link->level - 1;
if ($repeate > 0) {
$link->text = str_repeat('-', $repeate) . ' ' . $link->text;
}
/*##mygruz20130718204314 } */
$groups[$menuType][] = JHtml::_('select.option', $link->value, $link->text, 'value', 'text', in_array($link->type, $disable));
}
} else {
// Build the groups arrays.
foreach ($items as $menu) {
// Initialize the group.
$groups[$menu->menutype] = array();
// Build the options array.
foreach ($menu->links as $link) {
/*##mygruz20130718204314 {
It was:
It became:*/
$repeate = $link->level - 1;
if ($repeate > 0) {
$link->text = str_repeat('-', $repeate) . ' ' . $link->text;
}
/*##mygruz20130718204314 } */
$groups[$menu->menutype][] = JHtml::_('select.option', $link->value, $link->text, 'value', 'text', in_array($link->type, $disable));
}
}
}
// Merge any additional groups in the XML definition.
$groups = array_merge(parent::getGroups(), $groups);
return $groups;
}
示例6: getMenu
public function getMenu()
{
require_once JPATH_ADMINISTRATOR . '/components/com_menus/helpers/menus.php';
$data = \MenusHelper::getMenuLinks();
$userid = \JFactory::getUser()->id;
$list = [];
foreach ($data as $menu) {
$items = [];
foreach ($menu->links as $link) {
$items[] = ['name' => 'menu[' . $link->value . ']', 'field' => ['id', 'link' . $link->value], 'value' => $link->template_style_id == $this->style_id, 'disabled' => $link->type != 'component' || $link->checked_out && $link->checked_out != $userid, 'label' => str_repeat('—', max(0, $link->level - 1)) . ' ' . $link->text];
}
$group = ['label' => $menu->title ?: $menu->menutype, 'items' => $items];
$list[] = $group;
}
return $list;
}
示例7: getGroupedItems
public function getGroupedItems()
{
$groups = array();
// Get the menu items.
$items = \MenusHelper::getMenuLinks();
// Build the groups arrays.
foreach ($items as $item) {
// Initialize the group.
$groups[$item->menutype] = array();
// Build the options array.
foreach ($item->links as $link) {
$groups[$item->menutype][$link->value] = ['spacing' => str_repeat(' ', $link->level - 1), 'label' => $link->text];
}
}
return $groups;
}
示例8: getInput
function getInput()
{
// Initialize variables.
$groups = array();
$menus = array();
// Initialize some field attributes.
$menuType = (string) $this->element['menu_type'];
$published = $this->element['published'] ? explode(',', (string) $this->element['published']) : array();
$disable = $this->element['disable'] ? explode(',', (string) $this->element['disable']) : array();
// Get the menu items.
$items = MenusHelper::getMenuLinks($menuType, 0, 0, $published);
// Build group for a specific menu type.
if ($menuType) {
// Initialize the group.
$groups[$menuType] = array();
// Build the options array.
foreach ($items as $link) {
$groups[$menuType][] = JHtml::_('select.option', $link->value, $link->text, 'value', 'text', in_array($link->type, $disable));
}
} else {
// Build the groups arrays.
foreach ($items as $menu) {
// Initialize the group.
$groups[$menu->menutype] = array();
// Build the options array.
foreach ($menu->links as $link) {
$groups[$menu->menutype][] = JHtml::_('select.option', $link->value, $link->text, 'value', 'text', in_array($link->type, $disable));
}
}
}
foreach ($groups as $group => $links) {
$menus[] = JHtml::_('select.optgroup', $group);
foreach ($links as $link) {
$menus[] = $link;
}
$menus[] = JHtml::_('select.optgroup', $group);
}
// Create the 'all menus' listing
$temp = new stdClass();
$temp->value = '';
$temp->text = JText::_('JW_DISQUS_SELECT_ALL_MENUS');
// Merge the above
array_unshift($menus, $temp);
// Output
$output = JHTML::_('select.genericlist', $menus, $this->name . '[]', 'class="inputbox" style="width:220px;" multiple="multiple" size="12"', 'value', 'text', $this->value);
return $output;
}
示例9: getInput
protected function getInput()
{
$size = (int) $this->def('size');
$multiple = $this->def('multiple', 1);
require_once JPATH_ADMINISTRATOR . '/components/com_menus/helpers/menus.php';
$options = MenusHelper::getMenuLinks();
require_once JPATH_PLUGINS . '/system/nnframework/helpers/html.php';
foreach ($options as $i => $option) {
$options[$i]->value = 'type.' . $option->menutype;
$options[$i]->text = $option->title;
$options[$i]->level = 0;
$options[$i]->class = 'hidechildren';
$options[$i]->labelclass = 'nav-header';
unset($option->title);
}
return nnHtml::selectlist($options, $this->name, $this->value, $this->id, $size, $multiple);
}
示例10: universalfetchElement
function universalfetchElement($name, $value, &$node)
{
if (version_compare(JVERSION, '1.6.0', 'ge')) {
require_once JPATH_ADMINISTRATOR . '/components/com_menus/helpers/menus.php';
$menus = MenusHelper::getMenuLinks();
foreach ($menus as $menu) {
$node->addChild('option', array('value' => 'optgroup'))->setData($menu->title);
foreach ($menu->links as $link) {
$node->addChild('option', array('value' => $link->value))->setData(' ' . $link->text);
}
}
} else {
require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_menus' . DS . 'helpers' . DS . 'helper.php';
$db =& JFactory::getDBO();
$query = 'SELECT id, parent, name, menutype, type' . ' FROM #__menu WHERE published = 1' . ' ORDER BY menutype, parent, ordering';
$db->setQuery($query);
$menuItems = $db->loadObjectList();
$children = array();
if ($menuItems) {
// first pass - collect children
foreach ($menuItems as $v) {
$pt = $v->parent;
$list = @$children[$pt] ? $children[$pt] : array();
array_push($list, $v);
$children[$pt] = $list;
}
}
$list = JHTML::_('menu.treerecurse', 0, '', array(), $children, 9999, 0, 0);
// assemble into menutype groups
$n = count($list);
$menus = array();
foreach ($list as $k => $v) {
$menus[$v->menutype][] =& $list[$k];
}
foreach ($menus as $k => $menu) {
$node->addChild('option', array('value' => 'optgroup'))->setData($k);
foreach ($menu as $menuitem) {
$node->addChild('option', array('value' => $menuitem->id))->setData(' ' . $menuitem->name);
}
}
}
return parent::universalfetchElement($name, $value, $node);
}
示例11: defined
<?php
/**
* @package Joomla.Administrator
* @subpackage com_templates
*
* @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;
// Initiasile related data.
require_once JPATH_ADMINISTRATOR . '/components/com_menus/helpers/menus.php';
$menuTypes = MenusHelper::getMenuLinks();
$user = JFactory::getUser();
?>
<fieldset class="adminform">
<legend><?php
echo JText::_('COM_TEMPLATES_MENUS_ASSIGNMENT');
?>
</legend>
<label id="jform_menuselect-lbl" for="jform_menuselect"><?php
echo JText::_('JGLOBAL_MENU_SELECTION');
?>
</label>
<button type="button" class="jform-rightbtn" onclick="$$('.chk-menulink').each(function(el) { el.checked = !el.checked; });">
<?php
echo JText::_('JGLOBAL_SELECTION_INVERT_ALL');
?>
</button>
<div class="clr"></div>
示例12: implode
<div id="profile">
<select><?php
echo implode("\n", $select);
?>
</select>
<a class="add" href="#">Add</a>
<a class="rename" href="#">Rename</a>
<a class="remove" href="#">Remove</a>
<a class="assign" href="#">Assign Pages</a>
<div class="items">
<select name="items" size="15" multiple="multiple">
<?php
foreach (MenusHelper::getMenuLinks() as $menu) {
?>
<?php
if (count($menu->links)) {
?>
<optgroup label="<?php
echo $menu->title;
?>
">
<?php
foreach ($menu->links as $link) {
?>
<option value="<?php
echo (int) $link->value;
?>
"><?php
示例13: getMenuItemAssignmentOptions
/**
* Get a list of the menu item assignment options for modules.
*
* @param int $clientId The client id.
*
* @return array
*/
public static function getMenuItemAssignmentOptions($clientId)
{
$options = array();
$options[] = JHtml::_('select.option', '0', JText::_('JALL'));
$options[] = JHtml::_('select.option', '-', JText::_('JNONE'));
if ($clientId != 0) {
return $options;
}
$options[] = JHtml::_('select.option', '-1', JText::_('COM_MODULES_ASSIGNED_VARIES_EXCEPT'));
$options[] = JHtml::_('select.option', '-2', JText::_('COM_MODULES_ASSIGNED_VARIES_ONLY'));
require_once realpath(JPATH_ADMINISTRATOR . '/components/com_menus/helpers/menus.php');
$items = MenusHelper::getMenuLinks();
foreach ($items as $type) {
$options[] = JHtml::_('select.option', '<OPTGROUP>', $type->title);
foreach ($type->links as $item) {
$options[] = JHtml::_('select.option', $item->value, str_repeat('- ', $item->level) . $item->text);
}
$options[] = JHtml::_('select.option', '</OPTGROUP>');
}
return $options;
}
示例14: getGroups
/**
* Method to get the field option groups.
*
* @return array The field option objects as a nested array in groups.
*
* @since 1.6
*/
protected function getGroups()
{
$groups = array();
$menuType = $this->menuType;
// Get the menu items.
$items = MenusHelper::getMenuLinks($menuType, 0, 0, $this->published, $this->language);
// Build group for a specific menu type.
if ($menuType) {
// Initialize the group.
$groups[$menuType] = array();
// Build the options array.
foreach ($items as $link) {
$levelPrefix = str_repeat('- ', max(0, $link->level - 1));
// Displays language code if not set to All
if ($link->language !== '*') {
$lang = ' (' . $link->language . ')';
} else {
$lang = '';
}
$groups[$menuType][] = JHtml::_('select.option', $link->value, $levelPrefix . $link->text . $lang, 'value', 'text', in_array($link->type, $this->disable));
}
} else {
// Build the groups arrays.
foreach ($items as $menu) {
// Initialize the group.
$groups[$menu->menutype] = array();
// Build the options array.
foreach ($menu->links as $link) {
$levelPrefix = str_repeat('- ', $link->level - 1);
// Displays language code if not set to All
if ($link->language !== '*') {
$lang = ' (' . $link->language . ')';
} else {
$lang = '';
}
$groups[$menu->menutype][] = JHtml::_('select.option', $link->value, $levelPrefix . $link->text . $lang, 'value', 'text', in_array($link->type, $this->disable));
}
}
}
// Merge any additional groups in the XML definition.
$groups = array_merge(parent::getGroups(), $groups);
return $groups;
}
示例15: array
<?php
/**
* @package Warp Theme Framework
* @author YOOtheme http://www.yootheme.com
* @copyright Copyright (C) YOOtheme GmbH
* @license http://www.gnu.org/licenses/gpl.html GNU/GPL
*/
// get menu data
require_once $this['path']->path('admin:/components/com_menus/helpers/menus.php');
$menus = \MenusHelper::getMenuLinks();
// get layout data
$layouts = $config->get('layouts', array('default' => array()));
?>
<div id="layout" data-field-name="<?php
echo $name;
?>
">
<p>
Store your modifications in a layout profile and assign it to different pages. The <em>default</em> layout will be used on pages without an assigned layout.
</p>
<p>
<select data-layout-selector class="uk-form-width-small">
<?php
foreach (array_keys($layouts) as $layout) {
?>
<option value="<?php
echo $layout;