/** * Method to get the field input markup. * * @return string The field input markup. * @since 1.6 */ protected function getInput() { // Initialise variables. $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 = JModel::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; 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[] = '<input type="text" readonly="readonly" disabled="disabled" value="' . $value . '"' . $size . $class . ' />'; $html[] = '<input type="button" value="' . JText::_('JSELECT') . '" onclick="SqueezeBox.fromElement(this, {handler:\'iframe\', size: {x: 600, y: 450}, url:\'' . JRoute::_('index.php?option=com_menus&view=menutypes&tmpl=component&recordId=' . $recordId) . '\'})" />'; $html[] = '<input type="hidden" name="' . $this->name . '" value="' . htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '" />'; return implode("\n", $html); }
/** * Method to display a view. * * @param boolean If true, the view output will be cached * @param array An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}. * * @return JController This object to support chaining. * @since 1.5 */ public function display($cachable = false, $urlparams = false) { require_once JPATH_COMPONENT . '/helpers/menus.php'; // Load the submenu. MenusHelper::addSubmenu(JRequest::getCmd('view')); $view = JRequest::getCmd('view', 'menus'); $layout = JRequest::getCmd('layout', 'default'); $id = JRequest::getInt('id'); // Check for edit form. if ($view == 'menu' && $layout == 'edit' && !$this->checkEditId('com_menus.edit.menu', $id)) { // Somehow the person just went to the form - we don't allow that. $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id)); $this->setMessage($this->getError(), 'error'); $this->setRedirect(JRoute::_('index.php?option=com_menus&view=menus', false)); return false; } elseif ($view == 'item' && $layout == 'edit' && !$this->checkEditId('com_menus.edit.item', $id)) { // Somehow the person just went to the form - we don't allow that. $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id)); $this->setMessage($this->getError(), 'error'); $this->setRedirect(JRoute::_('index.php?option=com_menus&view=items', false)); return false; } parent::display(); return $this; }
/** * Method to get the available menu item type options. * * @return array Array of groups with menu item types. * @since 1.6 */ public function getTypeOptions() { // Initialise variables. $lang = Lang::getRoot(); $list = array(); // Get the list of components. $db = App::get('db'); $query = $db->getQuery(true); $query->select('name, element AS ' . $db->qn('option')); $query->from('#__extensions'); $query->where('type = ' . $db->q('component')); $query->where('enabled = 1'); $query->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->rlu[MenusHelper::getLinkKey($option->request)] = $option->get('title'); if (isset($option->request['option'])) { $lang->load($option->request['option'] . '.sys', PATH_APP, null, false, true) || $lang->load($option->request['option'] . '.sys', PATH_CORE . '/components/' . $option->request['option'] . '/admin', null, false, true); } } } } } return $list; }
/** * 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'); // Initialise variables. $lang = JFactory::getLanguage(); $list = array(); // Get the list of components. $db = JFactory::getDBO(); $query = $db->getQuery(true); $query->select('name, element AS ' . $db->qn('option')); $query->from('#__extensions'); $query->where('type = ' . $db->q('component')); $query->where('enabled = 1'); $query->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->rlu[MenusHelper::getLinkKey($option->request)] = $option->get('title'); 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); } } } } } return $list; }
/** * Generate the markup to display the item associations * * @param int $itemid The menu item id * * @return string * * @since 3.0 * * @throws Exception If there is an error on the query */ public static function association($itemid) { // Defaults $html = ''; // Get the associations if ($associations = MenusHelper::getAssociations($itemid)) { // Get the associated menu items $db = JFactory::getDbo(); $query = $db->getQuery(true)->select('m.id, m.title')->select('l.sef as lang_sef')->select('mt.title as menu_title')->from('#__menu as m')->join('LEFT', '#__menu_types as mt ON mt.menutype=m.menutype')->where('m.id IN (' . implode(',', array_values($associations)) . ')')->join('LEFT', '#__languages as l ON m.language=l.lang_code')->select('l.image')->select('l.title as language_title'); $db->setQuery($query); try { $items = $db->loadObjectList('id'); } catch (runtimeException $e) { throw new Exception($e->getMessage(), 500); } // Construct html if ($items) { foreach ($items as &$item) { $text = strtoupper($item->lang_sef); $url = JRoute::_('index.php?option=com_menus&task=item.edit&id=' . (int) $item->id); $tooltipParts = array(JHtml::_('image', 'mod_languages/' . $item->image . '.gif', $item->language_title, array('title' => $item->language_title), true), $item->title, '(' . $item->menu_title . ')'); $class = 'hasTooltip label label-association label-' . $item->lang_sef; $item->link = JHtml::_('tooltip', implode(' ', $tooltipParts), null, null, $text, $url, null, $class); } } $html = JLayoutHelper::render('joomla.content.associations', $items); } return $html; }
/** * @param int $itemid The menu item id */ static function association($itemid) { // Get the associations $associations = MenusHelper::getAssociations($itemid); // Get the associated menu items $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('m.*'); $query->select('mt.title as menu_title'); $query->from('#__menu as m'); $query->leftJoin('#__menu_types as mt ON mt.menutype=m.menutype'); $query->where('m.id IN (' . implode(',', array_values($associations)) . ')'); $query->leftJoin('#__languages as l ON m.language=l.lang_code'); $query->select('l.image'); $query->select('l.title as language_title'); $db->setQuery($query); $items = $db->loadObjectList('id'); // Check for a database error. if ($error = $db->getErrorMsg()) { JError::raiseWarning(500, $error); return false; } // Construct html $text = array(); foreach ($associations as $tag => $associated) { if ($associated != $itemid) { $text[] = JText::sprintf('COM_MENUS_TIP_ASSOCIATED_LANGUAGE', JHtml::_('image', 'mod_languages/' . $items[$associated]->image . '.gif', $items[$associated]->language_title, array('title' => $items[$associated]->language_title), true), $items[$associated]->title, $items[$associated]->menu_title); } } return JHtml::_('tooltip', implode('<br />', $text), JText::_('COM_MENUS_TIP_ASSOCIATION'), 'menu/icon-16-links.png'); }
/** * 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; }
/** * Add the page title and toolbar. * * @since 1.6 */ protected function addToolbar() { JRequest::setVar('hidemainmenu', true); $user = JFactory::getUser(); $isNew = $this->item->id == 0; $canDo = MenusHelper::getActions($this->state->get('filter.parent_id')); JToolBarHelper::title(JText::_($isNew ? 'COM_MENUS_VIEW_NEW_MENU_TITLE' : 'COM_MENUS_VIEW_EDIT_MENU_TITLE'), 'menu.png'); // If a new item, can save the item. Allow users with edit permissions to apply changes to prevent returning to grid. if ($isNew && $canDo->get('core.create')) { if ($canDo->get('core.edit')) { JToolBarHelper::apply('menu.apply'); } JToolBarHelper::save('menu.save'); } // If user can edit, can save the item. if (!$isNew && $canDo->get('core.edit')) { JToolBarHelper::apply('menu.apply'); JToolBarHelper::save('menu.save'); } // If the user can create new items, allow them to see Save & New if ($canDo->get('core.create')) { JToolBarHelper::save2new('menu.save2new'); } if ($isNew) { JToolBarHelper::cancel('menu.cancel'); } else { JToolBarHelper::cancel('menu.cancel', 'JTOOLBAR_CLOSE'); } JToolBarHelper::divider(); JToolBarHelper::help('JHELP_MENUS_MENU_MANAGER_EDIT'); }
/** * Add the page title and toolbar. * * @since 1.6 */ protected function addToolbar() { JRequest::setVar('hidemainmenu', true); $user = JFactory::getUser(); $isNew = $this->item->id == 0; $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id')); $canDo = MenusHelper::getActions($this->state->get('filter.parent_id')); JToolBarHelper::title(JText::_($isNew ? 'COM_MENUS_VIEW_NEW_ITEM_TITLE' : 'COM_MENUS_VIEW_EDIT_ITEM_TITLE'), 'menu-add'); // If a new item, can save the item. Allow users with edit permissions to apply changes to prevent returning to grid. if ($isNew && $canDo->get('core.create')) { if ($canDo->get('core.edit')) { JToolBarHelper::apply('adminitem.apply'); } JToolBarHelper::save('adminitem.save'); } // If not checked out, can save the item. if (!$isNew && !$checkedOut && $canDo->get('core.edit')) { JToolBarHelper::apply('adminitem.apply'); JToolBarHelper::save('adminitem.save'); } // If the user can create new items, allow them to see Save & New if ($canDo->get('core.create')) { JToolBarHelper::save2new('adminitem.save2new'); } // If an existing item, can save to a copy only if we have create rights. if (!$isNew && $canDo->get('core.create')) { JToolBarHelper::save2copy('adminitem.save2copy'); } if ($isNew) { JToolBarHelper::cancel('adminitem.cancel'); } else { JToolBarHelper::cancel('adminitem.cancel', 'JTOOLBAR_CLOSE'); } }
/** * 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; }
public function links() { if (!CakePlugin::loaded('Menus')) { CakePlugin::load('Menus'); } App::uses('View', 'View'); App::uses('AppHelper', 'View/Helper'); App::uses('MenusHelper', 'Menus.View/Helper'); $Menus = new MenusHelper(new View()); $Link = ClassRegistry::init('Menus.Link'); $links = $Link->find('all', array('fields' => array('id', 'title', 'link'))); $count = 0; foreach ($links as $link) { if (!strstr($link['Link']['link'], 'controller:')) { continue; } if (strstr($link['Link']['link'], 'plugin:')) { continue; } $url = $Menus->linkStringToArray($link['Link']['link']); if (isset($this->_controllerMap[$url['controller']])) { $url['plugin'] = $this->_controllerMap[$url['controller']]; $linkString = $Menus->urlToLinkString($url); $Link->id = $link['Link']['id']; $this->out(__('Updating Link %s', $Link->id)); $this->warn(__('- %s', $link['Link']['link'])); $this->success(__('+ %s', $linkString), 2); $Link->saveField('link', $linkString, false); $count++; } } $this->out(__('Links updated: %d rows', $count)); }
/** * Generate the markup to display the item associations * * @param int $itemid The menu item id * * @return string * * @since 3.0 * * @throws Exception If there is an error on the query */ public static function association($itemid) { // Defaults $html = ''; // Get the associations if ($associations = MenusHelper::getAssociations($itemid)) { // Get the associated menu items $db = JFactory::getDbo(); $query = $db->getQuery(true)->select('m.id, m.title')->select('l.sef as lang_sef, l.lang_code')->select('mt.title as menu_title')->from('#__menu as m')->join('LEFT', '#__menu_types as mt ON mt.menutype=m.menutype')->where('m.id IN (' . implode(',', array_values($associations)) . ')')->join('LEFT', '#__languages as l ON m.language=l.lang_code')->select('l.image')->select('l.title as language_title'); $db->setQuery($query); try { $items = $db->loadObjectList('id'); } catch (runtimeException $e) { throw new Exception($e->getMessage(), 500); } // Construct html if ($items) { foreach ($items as &$item) { $text = strtoupper($item->lang_sef); $url = JRoute::_('index.php?option=com_menus&task=item.edit&id=' . (int) $item->id); $tooltip = $item->title . '<br />' . JText::sprintf('COM_MENUS_MENU_SPRINTF', $item->menu_title); $classes = 'hasPopover label label-association label-' . $item->lang_sef; $item->link = '<a href="' . $url . '" title="' . $item->language_title . '" class="' . $classes . '" data-content="' . $tooltip . '" data-placement="top">' . $text . '</a>'; } } JHtml::_('bootstrap.popover'); $html = JLayoutHelper::render('joomla.content.associations', $items); } return $html; }
/** * Return list of menus. * * @return array * @throws \RuntimeException */ public function getMenus() { static $items; if ($items === null) { require_once JPATH_ADMINISTRATOR . '/components/com_menus/helpers/menus.php'; $items = (array) \MenusHelper::getMenuTypes(); } return $items; }
public static function getList(&$params) { $user = JFactory::getUser(); $lang = JFactory::getLanguage(); $app = JFactory::getApplication(); $menu = $app->getMenu(); // Get menu home items $homes = array(); foreach ($menu->getMenu() as $item) { if ($item->home) { $homes[$item->language] = $item; } } // Load associations $assoc = isset($app->menu_associations) ? $app->menu_associations : 0; if ($assoc) { $active = $menu->getActive(); if ($active) { $associations = MenusHelper::getAssociations($active->id); } } $levels = $user->getAuthorisedViewLevels(); $languages = JLanguageHelper::getLanguages(); // Filter allowed languages foreach ($languages as $i => &$language) { // Do not display language without frontend UI if (!JLanguage::exists($language->lang_code)) { unset($languages[$i]); } elseif (!isset($homes[$language->lang_code])) { unset($languages[$i]); } elseif (isset($language->access) && $language->access && !in_array($language->access, $levels)) { unset($languages[$i]); } else { $language->active = $language->lang_code == $lang->getTag(); if ($app->getLanguageFilter()) { if (isset($associations[$language->lang_code]) && $menu->getItem($associations[$language->lang_code])) { $itemid = $associations[$language->lang_code]; if ($app->getCfg('sef') == '1') { $language->link = JRoute::_('index.php?lang=' . $language->sef . '&Itemid=' . $itemid); } else { $language->link = 'index.php?lang=' . $language->sef . '&Itemid=' . $itemid; } } else { if ($app->getCfg('sef') == '1') { $itemid = isset($homes[$language->lang_code]) ? $homes[$language->lang_code]->id : $homes['*']->id; $language->link = JRoute::_('index.php?lang=' . $language->sef . '&Itemid=' . $itemid); } else { $language->link = 'index.php?lang=' . $language->sef; } } } else { $language->link = JRoute::_('&Itemid=' . $homes['*']->id); } } } return $languages; }
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); }
/** * Fetch a calendar element * * @param string $name Element name * @param string $value Element value * @param object &$node XMLElement node object containing the settings for the element * @param string $control_name Control name * @return string */ public function fetchElement($name, $value, &$node, $control_name) { require_once PATH_CORE . '/components/com_menus/admin/helpers/menus.php'; $menuTypes = \MenusHelper::getMenuTypes(); foreach ($menuTypes as $menutype) { $options[] = Builder\Select::option($menutype, $menutype); } array_unshift($options, Builder\Select::option(\App::get('language')->txt('JOPTION_SELECT_MENU'))); return Builder\Select::genericlist($options, $control_name . '[' . $name . ']', array('id' => $control_name . $name, 'list.attr' => 'class="inputbox"', 'list.select' => $value)); }
public function fetchElement($name, $value, &$node, $control_name) { require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_menus' . DS . 'helpers' . DS . 'menus.php'; $menuTypes = MenusHelper::getMenuTypes(); foreach ($menuTypes as $menutype) { $options[] = JHtml::_('select.option', $menutype, $menutype); } array_unshift($options, JHtml::_('select.option', '', JText::_('JOPTION_SELECT_MENU'))); return JHtml::_('select.genericlist', $options, $control_name . '[' . $name . ']', array('id' => $control_name . $name, 'list.attr' => 'class="inputbox"', 'list.select' => $value)); }
function fetchElement($name, $value, &$node, $control_name) { $db =& JFactory::getDBO(); require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_menus' . DS . 'helpers' . DS . 'helper.php'; $menuTypes = MenusHelper::getMenuTypes(); foreach ($menuTypes as $menutype) { $options[] = JHTML::_('select.option', $menutype, $menutype); } array_unshift($options, JHTML::_('select.option', '', '- ' . JText::_('Select Menu') . ' -')); return JHTML::_('select.genericlist', $options, '' . $control_name . '[' . $name . ']', 'class="inputbox"', 'value', 'text', $value, $control_name . $name); }
/** * Fetch a html for a list of menus * * @param string $name Element name * @param string $value Element value * @param JXMLElement &$node JXMLElement node object containing the settings for the element * @param string $control_name Control name * * @return string * * @deprecated 12.1 Use JFormFieldMenu::getOptions instead * @since 11.1 */ public function fetchElement($name, $value, &$node, $control_name) { // Deprecation warning. JLog::add('JElementMenu::fetchElement() is deprecated.', JLog::WARNING, 'deprecated'); require_once JPATH_ADMINISTRATOR . '/components/com_menus/helpers/menus.php'; $menuTypes = MenusHelper::getMenuTypes(); foreach ($menuTypes as $menutype) { $options[] = JHtml::_('select.option', $menutype, $menutype); } array_unshift($options, JHtml::_('select.option', '', JText::_('JOPTION_SELECT_MENU'))); return JHtml::_('select.genericlist', $options, $control_name . '[' . $name . ']', array('id' => $control_name . $name, 'list.attr' => 'class="inputbox"', 'list.select' => $value)); }
function universalfetchElement($name, $value, &$node) { if (version_compare(JVERSION, '1.6.0', 'ge')) { require_once JPATH_ADMINISTRATOR . '/components/com_menus/helpers/menus.php'; } else { require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_menus' . DS . 'helpers' . DS . 'helper.php'; } $menuTypes = MenusHelper::getMenuTypes(); foreach ($menuTypes as $menutype) { $node->addChild('option', array('value' => $menutype))->setData(ucfirst($menutype)); } return parent::universalfetchElement($name, $value, $node); }
public static function getList(&$params) { $lang = JFactory::getLanguage(); $languages = JLanguageHelper::getLanguages(); $db = JFactory::getDBO(); $app = JFactory::getApplication(); $query = $db->getQuery(true); $query->select('id'); $query->select('language'); $query->from($db->nameQuote('#__menu')); $query->where('home=1'); $db->setQuery($query); $homes = $db->loadObjectList('language'); if ($app->get('menu_associations', 0)) { $menu = $app->getMenu(); $active = $menu->getActive(); if ($active) { $associations = MenusHelper::getAssociations($active->id); } } foreach ($languages as $i => &$language) { // Do not display language without frontend UI if (!JLanguage::exists($language->lang_code)) { unset($languages[$i]); } elseif (!isset($homes[$language->lang_code])) { unset($languages[$i]); } else { $language->active = $language->lang_code == $lang->getTag(); if ($app->getLanguageFilter()) { if (isset($associations[$language->lang_code]) && $menu->getItem($associations[$language->lang_code])) { $itemid = $associations[$language->lang_code]; if ($app->getCfg('sef') == '1') { $language->link = JRoute::_('index.php?lang=' . $language->sef . '&Itemid=' . $itemid); } else { $language->link = 'index.php?lang=' . $language->sef . '&Itemid=' . $itemid; } } else { if ($app->getCfg('sef') == '1') { $itemid = isset($homes[$language->lang_code]) ? $homes[$language->lang_code]->id : $homes['*']->id; $language->link = JRoute::_('index.php?lang=' . $language->sef . '&Itemid=' . $itemid); } else { $language->link = 'index.php?lang=' . $language->sef; } } } else { $language->link = JRoute::_('&Itemid=' . $homes['*']->id); } } } return $languages; }
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; }
/** * 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; }
function fetchElement() { if (version_compare(JVERSION, '1.6.0', 'ge')) { require_once JPATH_ADMINISTRATOR . '/components/com_menus/helpers/menus.php'; } else { require_once JPATH_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_menus' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'helper.php'; } $options = MenusHelper::getMenuTypes(); for ($i = 0; $i < count($options); $i++) { $this->_xml->addChild('option', htmlspecialchars(ucfirst($options[$i])))->addAttribute('value', $options[$i]); } $this->_value = $this->_form->get($this->_name, $this->_default); $html = parent::fetchElement(); return $html; }
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; }
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; }
/** * 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) { $this->items = $this->get('Items'); $this->modules = $this->get('Modules'); $this->pagination = $this->get('Pagination'); $this->state = $this->get('State'); MenusHelper::addSubmenu('menus'); // 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. * * @since 1.6 */ protected function addToolbar() { $input = JFactory::getApplication()->input; $input->set('hidemainmenu', true); $user = JFactory::getUser(); $isNew = $this->item->id == 0; $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id')); $canDo = MenusHelper::getActions($this->state->get('filter.parent_id')); JToolbarHelper::title(JText::_($isNew ? 'COM_MENUS_VIEW_NEW_ITEM_TITLE' : 'COM_MENUS_VIEW_EDIT_ITEM_TITLE'), 'menu-add'); // If a new item, can save the item. Allow users with edit permissions to apply changes to prevent returning to grid. if ($isNew && $canDo->get('core.create')) { if ($canDo->get('core.edit')) { JToolbarHelper::apply('item.apply'); } JToolbarHelper::save('item.save'); } // If not checked out, can save the item. if (!$isNew && !$checkedOut && $canDo->get('core.edit')) { JToolbarHelper::apply('item.apply'); JToolbarHelper::save('item.save'); } // If the user can create new items, allow them to see Save & New if ($canDo->get('core.create')) { JToolbarHelper::save2new('item.save2new'); } // If an existing item, can save to a copy only if we have create rights. if (!$isNew && $canDo->get('core.create')) { JToolbarHelper::save2copy('item.save2copy'); } if ($isNew) { JToolbarHelper::cancel('item.cancel'); } else { JToolbarHelper::cancel('item.cancel', 'JTOOLBAR_CLOSE'); } JToolbarHelper::divider(); // Get the help information for the menu item. $lang = JFactory::getLanguage(); $help = $this->get('Help'); if ($lang->hasKey($help->url)) { $debug = $lang->setDebug(false); $url = JText::_($help->url); $lang->setDebug($debug); } else { $url = $help->url; } JToolbarHelper::help($help->key, $help->local, $url); }
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; }
function fetchElement($name, $value, &$node, $control_name) { $class = $node->attributes('class') ? 'class="' . $node->attributes('class') . '"' : 'class="inputbox"'; $db =& JFactory::getDBO(); require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_menus' . DS . 'helpers' . DS . 'helper.php'; $menuTypes = MenusHelper::getMenuTypes(); if (null == $value || !isset($value) || !in_array($value, $menuTypes)) { $value = $menuTypes[0]; } foreach ($menuTypes as $menutype) { $options[] = JHTML::_('select.option', $menutype, $menutype); } array_unshift($options, JHTML::_('select.option', '', '- ' . JText::_('Select Menu') . ' -')); include_once 'selectbox.php'; $selectbox = new JElementSelectBox(); return $selectbox->fetchElement($name, $value, $node, $control_name, $options); }