AAAAPKT>\jhOmenus/default.phpnuW+Aget('id'); $listOrder = $this->escape($this->state->get('list.ordering')); $listDirn = $this->escape($this->state->get('list.direction')); ?>
items as $i => $item) : $canCreate = $user->authorise('core.create', 'com_menus'); $canEdit = $user->authorise('core.edit', 'com_menus'); $canChange = $user->authorise('core.edit.state', 'com_menus'); ?>
id); ?> escape($item->title); ?>

( id).' title='.$this->escape($item->description).'">'. $this->escape($item->menutype).''; ?>) escape($item->menutype)?>)

count_published; ?> count_unpublished; ?> count_trashed; ?> id; ?>
pagination->getListFooter(); ?>
PKT>\Vmenus/index.htmlnuW+A PKT>\)menus/.htaccessnuW+A Order allow,deny Deny from all PKT>\) .htaccessnuW+A Order allow,deny Deny from all PKT>\)menu/.htaccessnuW+A Order allow,deny Deny from all PKT>\cu $$ menu/edit.phpnuW+A PKT>\Vmenu/index.htmlnuW+A PKT>\Vitem/index.htmlnuW+A PKT>\)item/.htaccessnuW+A Order allow,deny Deny from all PKT>\ӂe e item/edit_options.phpnuW+A form->getFieldsets('request'); if (!empty($fieldSets)) { $fieldSet = array_shift($fieldSets); $label = !empty($fieldSet->label) ? $fieldSet->label : 'COM_MENUS_'.$fieldSet->name.'_FIELDSET_LABEL'; echo JHtml::_('sliders.panel', JText::_($label), 'request-options'); if (isset($fieldSet->description) && trim($fieldSet->description)) : echo '

'.$this->escape(JText::_($fieldSet->description)).'

'; endif; ?>
form->getFieldsets('params'); foreach ($fieldSets as $name => $fieldSet) : $label = !empty($fieldSet->label) ? $fieldSet->label : 'COM_MENUS_'.$name.'_FIELDSET_LABEL'; echo JHtml::_('sliders.panel', JText::_($label), $name.'-options'); if (isset($fieldSet->description) && trim($fieldSet->description)) : echo '

'.$this->escape(JText::_($fieldSet->description)).'

'; endif; ?>
form->getFieldsets('associations'); foreach ($fieldSets as $name => $fieldSet) : $label = !empty($fieldSet->label) ? $fieldSet->label : 'COM_MENUS_'.$name.'_FIELDSET_LABEL'; echo JHtml::_('sliders.panel', JText::_($label), $name.'-options'); if (isset($fieldSet->description) && trim($fieldSet->description)) : echo '

'.$this->escape(JText::_($fieldSet->description)).'

'; endif; ?>
PKT>\,X(( item/edit.phpnuW+A PKT>\Vitems/index.htmlnuW+A PKT>\)items/.htaccessnuW+A Order allow,deny Deny from all PKT>\R `,`,items/default.phpnuW+Aget('id'); $listOrder = $this->escape($this->state->get('list.ordering')); $listDirn = $this->escape($this->state->get('list.direction')); $ordering = ($listOrder == 'a.lft'); $canOrder = $user->authorise('core.edit.state', 'com_menus'); $saveOrder = ($listOrder == 'a.lft' && $listDirn == 'asc'); ?>
menu_associations) ? $app->menu_associations : 0; if ($assoc): ?> items as $i => $item) : $orderkey = array_search($item->id, $this->ordering[$item->parent_id]); $canCreate = $user->authorise('core.create', 'com_menus'); $canEdit = $user->authorise('core.edit', 'com_menus'); $canCheckin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out==$user->get('id')|| $item->checked_out==0; $canChange = $user->authorise('core.edit.state', 'com_menus') && $canCheckin; ?> menu_associations) ? $app->menu_associations : 0; if ($assoc): ?>
items, 'filesave.png', 'items.saveorder'); ?>
id); ?> |—', $item->level-1) ?> checked_out) : ?> editor, $item->checked_out_time, 'items.', $canCheckin); ?> escape($item->title); ?> escape($item->title); ?>

|—', $item->level-1) ?> type !='url') : ?> note)) : ?> escape($item->alias));?> escape($item->alias), $this->escape($item->note));?> type =='url' && $item->note) : ?> escape($item->note));?>

published, $i, $canChange, 'cb'); ?> pagination->orderUpIcon($i, isset($this->ordering[$item->parent_id][$orderkey - 1]), 'items.orderup', 'JLIB_HTML_MOVE_UP', $ordering); ?> pagination->orderDownIcon($i, $this->pagination->total, isset($this->ordering[$item->parent_id][$orderkey + 1]), 'items.orderdown', 'JLIB_HTML_MOVE_DOWN', $ordering); ?> class="text-area-order" title="title; ?> order" /> escape($item->access_level); ?> escape($item->item_type); ?> type == 'component') : ?> language=='*' || $item->home=='0'):?> home, $i, 'items.', ($item->language != '*' || !$item->home) && $canChange);?> image.'.gif', $item->language_title, array('title'=>JText::sprintf('COM_MENUS_GRID_UNSET_LANGUAGE', $item->language_title)), true);?> image.'.gif', $item->language_title, array('title'=>$item->language_title), true);?> association):?> id);?> language==''):?> language=='*'):?> language_title ? $this->escape($item->language_title) : JText::_('JUNDEFINED'); ?> id; ?>
pagination->getListFooter(); ?>
authorize('core.create', 'com_menus') || $user->authorize('core.edit', 'com_menus')) : ?> loadTemplate('batch'); ?>
PKT>\V index.htmlnuW+A PKA>\3hhcontroller.phpnuW+AcheckEditId('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; } } PKA>\- views/item/view.html.phpnuW+Aform = $this->get('Form'); $this->item = $this->get('Item'); $this->modules = $this->get('Modules'); $this->state = $this->get('State'); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } parent::display($tpl); $this->addToolbar(); } /** * 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('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); } } PKA>\dk;views/item/tmpl/edit.phpnuW+A
  • form->getLabel('type'); ?> form->getInput('type'); ?>
  • form->getLabel('title'); ?> form->getInput('title'); ?>
  • item->type =='url'): ?> form->setFieldAttribute('link', 'readonly', 'false');?>
  • form->getLabel('link'); ?> form->getInput('link'); ?>
  • item->type == 'alias'): ?>
  • form->getLabel('aliastip'); ?>
  • item->type !='url'): ?>
  • form->getLabel('alias'); ?> form->getInput('alias'); ?>
  • form->getLabel('note'); ?> form->getInput('note'); ?>
  • item->type !=='url'): ?>
  • form->getLabel('link'); ?> form->getInput('link'); ?>
  • form->getLabel('published'); ?> form->getInput('published'); ?>
  • form->getLabel('access'); ?> form->getInput('access'); ?>
  • form->getLabel('menutype'); ?> form->getInput('menutype'); ?>
  • form->getLabel('parent_id'); ?> form->getInput('parent_id'); ?>
  • form->getLabel('menuordering'); ?> form->getInput('menuordering'); ?>
  • form->getLabel('browserNav'); ?> form->getInput('browserNav'); ?>
  • item->type == 'component') : ?>
  • form->getLabel('home'); ?> form->getInput('home'); ?>
  • form->getLabel('language'); ?> form->getInput('language'); ?>
  • form->getLabel('template_style_id'); ?> form->getInput('template_style_id'); ?>
  • form->getLabel('id'); ?> form->getInput('id'); ?>
item->id); ?> loadTemplate('options'); ?>
modules)) : ?>
loadTemplate('modules'); ?>
form->getInput('component_id'); ?>
PKA>\ Yt views/item/tmpl/edit_modules.phpnuW+A modules as $i => &$module) : ?> menuid)) : ?> except || $module->menuid < 0) : ?>
id.'&tmpl=component&view=module&layout=modal' ; ?> escape($module->title), $this->escape($module->access_title), $this->escape($module->position)); ?> menuid)) : ?> except):?> menuid > 0) : ?> menuid < 0) : ?>
PKA>\)views/item/tmpl/.htaccessnuW+A Order allow,deny Deny from all PKA>\Vviews/item/tmpl/index.htmlnuW+A PKA>\ /g g views/item/tmpl/edit_options.phpnuW+A form->getFieldsets('request'); if (!empty($fieldSets)) { $fieldSet = array_shift($fieldSets); $label = !empty($fieldSet->label) ? $fieldSet->label : 'COM_MENUS_'.$fieldSet->name.'_FIELDSET_LABEL'; echo JHtml::_('sliders.panel', JText::_($label), 'request-options'); if (isset($fieldSet->description) && trim($fieldSet->description)) : echo '

'.$this->escape(JText::_($fieldSet->description)).'

'; endif; ?>
form->getFieldsets('params'); foreach ($fieldSets as $name => $fieldSet) : $label = !empty($fieldSet->label) ? $fieldSet->label : 'COM_MENUS_'.$name.'_FIELDSET_LABEL'; echo JHtml::_('sliders.panel', JText::_($label), $name.'-options'); if (isset($fieldSet->description) && trim($fieldSet->description)) : echo '

'.$this->escape(JText::_($fieldSet->description)).'

'; endif; ?>
form->getFieldsets('associations'); foreach ($fieldSets as $name => $fieldSet) : $label = !empty($fieldSet->label) ? $fieldSet->label : 'COM_MENUS_'.$name.'_FIELDSET_LABEL'; echo JHtml::_('sliders.panel', JText::_($label), $name.'-options'); if (isset($fieldSet->description) && trim($fieldSet->description)) : echo '

'.$this->escape(JText::_($fieldSet->description)).'

'; endif; ?>
PKA>\Vviews/item/index.htmlnuW+A PKA>\)views/item/.htaccessnuW+A Order allow,deny Deny from all PKA>\)views/.htaccessnuW+A Order allow,deny Deny from all PKA>\Vviews/menus/tmpl/index.htmlnuW+A PKA>\views/menus/tmpl/default.phpnuW+Aget('id'); $listOrder = $this->escape($this->state->get('list.ordering')); $listDirn = $this->escape($this->state->get('list.direction')); $modMenuId = (int) $this->get('ModMenuId'); ?>
items as $i => $item) : $canCreate = $user->authorise('core.create', 'com_menus'); $canEdit = $user->authorise('core.edit', 'com_menus'); $canChange = $user->authorise('core.edit.state', 'com_menus'); ?>
pagination->getListFooter(); ?>
id); ?> escape($item->title); ?>

( id).' title='.$this->escape($item->description).'">'. $this->escape($item->menutype).''; ?>) escape($item->menutype)?>)

count_published; ?> count_unpublished; ?> count_trashed; ?> modules[$item->menutype])) : ?> id; ?>
PKA>\)views/menus/tmpl/.htaccessnuW+A Order allow,deny Deny from all PKA>\Vviews/menus/index.htmlnuW+A PKA>\)views/menus/.htaccessnuW+A Order allow,deny Deny from all PKA>\20views/menus/view.html.phpnuW+Aitems = $this->get('Items'); $this->modules = $this->get('Modules'); $this->pagination = $this->get('Pagination'); $this->state = $this->get('State'); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } parent::display($tpl); $this->addToolbar(); } /** * Add the page title and toolbar. * * @since 1.6 */ protected function addToolbar() { require_once JPATH_COMPONENT.'/helpers/menus.php'; $canDo = MenusHelper::getActions($this->state->get('filter.parent_id')); JToolBarHelper::title(JText::_('COM_MENUS_VIEW_MENUS_TITLE'), 'menumgr.png'); if ($canDo->get('core.create')) { JToolBarHelper::addNew('menu.add'); } if ($canDo->get('core.edit')) { JToolBarHelper::editList('menu.edit'); } if ($canDo->get('core.delete')) { JToolBarHelper::divider(); JToolBarHelper::deleteList('', 'menus.delete'); } JToolBarHelper::custom('menus.rebuild', 'refresh.png', 'refresh_f2.png', 'JTOOLBAR_REBUILD', false); if ($canDo->get('core.admin')) { JToolBarHelper::divider(); JToolBarHelper::preferences('com_menus'); } JToolBarHelper::divider(); JToolBarHelper::help('JHELP_MENUS_MENU_MANAGER'); } } PKA>\Vviews/items/index.htmlnuW+A PKA>\"views/items/tmpl/default_batch.phpnuW+Astate->get('filter.published'); ?>

= 0) : ?>
PKA>\Vviews/items/tmpl/index.htmlnuW+A PKA>\i;))views/items/tmpl/default.phpnuW+Aget('id'); $listOrder = $this->escape($this->state->get('list.ordering')); $listDirn = $this->escape($this->state->get('list.direction')); $ordering = ($listOrder == 'a.lft'); $canOrder = $user->authorise('core.edit.state', 'com_menus'); $saveOrder = ($listOrder == 'a.lft' && $listDirn == 'asc'); ?>
menu_associations) ? $app->menu_associations : 0; if ($assoc): ?> items as $i => $item) : $orderkey = array_search($item->id, $this->ordering[$item->parent_id]); $canCreate = $user->authorise('core.create', 'com_menus'); $canEdit = $user->authorise('core.edit', 'com_menus'); $canCheckin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out==$user->get('id')|| $item->checked_out==0; $canChange = $user->authorise('core.edit.state', 'com_menus') && $canCheckin; ?> menu_associations) ? $app->menu_associations : 0; if ($assoc): ?>
items, 'filesave.png', 'items.saveorder'); ?>
pagination->getListFooter(); ?>
id); ?> |—', $item->level-1) ?> checked_out) : ?> editor, $item->checked_out_time, 'items.', $canCheckin); ?> escape($item->title); ?> escape($item->title); ?>

|—', $item->level-1) ?> type !='url') : ?> note)) : ?> escape($item->alias));?> escape($item->alias), $this->escape($item->note));?> type =='url' && $item->note) : ?> escape($item->note));?>

published, $i, $canChange, 'cb'); ?> pagination->orderUpIcon($i, isset($this->ordering[$item->parent_id][$orderkey - 1]), 'items.orderup', 'JLIB_HTML_MOVE_UP', $ordering); ?> pagination->orderDownIcon($i, $this->pagination->total, isset($this->ordering[$item->parent_id][$orderkey + 1]), 'items.orderdown', 'JLIB_HTML_MOVE_DOWN', $ordering); ?> class="text-area-order" /> escape($item->access_level); ?> escape($item->item_type); ?> type == 'component') : ?> language=='*' || $item->home=='0'):?> home, $i, 'items.', ($item->language != '*' || !$item->home) && $canChange);?> image.'.gif', $item->language_title, array('title'=>JText::sprintf('COM_MENUS_GRID_UNSET_LANGUAGE', $item->language_title)), true);?> image.'.gif', $item->language_title, array('title'=>$item->language_title), true);?> association):?> id);?> language==''):?> language=='*'):?> language_title ? $this->escape($item->language_title) : JText::_('JUNDEFINED'); ?> id; ?>
authorize('core.create', 'com_menus') && $user->authorize('core.edit', 'com_menus') && $user->authorize('core.edit.state', 'com_menus')) : ?> loadTemplate('batch'); ?>
PKA>\)views/items/tmpl/.htaccessnuW+A Order allow,deny Deny from all PKA>\)views/items/.htaccessnuW+A Order allow,deny Deny from all PKA>\ҴǦviews/items/view.html.phpnuW+Aitems = $this->get('Items'); $this->pagination = $this->get('Pagination'); $this->state = $this->get('State'); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } $this->ordering = array(); // Preprocess the list of items to find ordering divisions. foreach ($this->items as $item) { $this->ordering[$item->parent_id][] = $item->id; // item type text switch ($item->type) { case 'url': $value = JText::_('COM_MENUS_TYPE_EXTERNAL_URL'); break; case 'alias': $value = JText::_('COM_MENUS_TYPE_ALIAS'); break; case 'separator': $value = JText::_('COM_MENUS_TYPE_SEPARATOR'); break; case 'component': default: // load language $lang->load($item->componentname . '.sys', JPATH_ADMINISTRATOR, null, false, true) || $lang->load($item->componentname . '.sys', JPATH_ADMINISTRATOR . '/components/' . $item->componentname, null, false, true); if (!empty($item->componentname)) { $value = JText::_($item->componentname); $vars = null; parse_str($item->link, $vars); if (isset($vars['view'])) { // Attempt to load the view xml file. $file = JPATH_SITE.'/components/'.$item->componentname.'/views/'.$vars['view'].'/metadata.xml'; if (JFile::exists($file) && $xml = simplexml_load_file($file)) { // Look for the first view node off of the root node. if ($view = $xml->xpath('view[1]')) { if (!empty($view[0]['title'])) { $vars['layout'] = isset($vars['layout']) ? $vars['layout'] : 'default'; // Attempt to load the layout xml file. // If Alternative Menu Item, get template folder for layout file if (strpos($vars['layout'], ':') > 0) { // Use template folder for layout file $temp = explode(':', $vars['layout']); $file = JPATH_SITE.'/templates/'.$temp[0].'/html/'.$item->componentname.'/'.$vars['view'].'/'.$temp[1].'.xml'; // Load template language file $lang->load('tpl_' . $temp[0] . '.sys', JPATH_SITE, null, false, true) || $lang->load('tpl_' . $temp[0] . '.sys', JPATH_SITE . '/templates/' . $temp[0], null, false, true); } else { // Get XML file from component folder for standard layouts $file = JPATH_SITE.'/components/'.$item->componentname.'/views/'.$vars['view'].'/tmpl/'.$vars['layout'].'.xml'; } if (JFile::exists($file) && $xml = simplexml_load_file($file)) { // Look for the first view node off of the root node. if ($layout = $xml->xpath('layout[1]')) { if (!empty($layout[0]['title'])) { $value .= ' » ' . JText::_(trim((string) $layout[0]['title'])); } } if (!empty($layout[0]->message[0])) { $item->item_type_desc = JText::_(trim((string) $layout[0]->message[0])); } } } } unset($xml); } else { // Special case for absent views $value .= ' » ' . JText::_($item->componentname.'_'.$vars['view'].'_VIEW_DEFAULT_TITLE'); } } } else { if (preg_match("/^index.php\?option=([a-zA-Z\-0-9_]*)/", $item->link, $result)) { $value = JText::sprintf('COM_MENUS_TYPE_UNEXISTING', $result[1]); } else { $value = JText::_('COM_MENUS_TYPE_UNKNOWN'); } } break; } $item->item_type = $value; } // Levels filter. $options = array(); $options[] = JHtml::_('select.option', '1', JText::_('J1')); $options[] = JHtml::_('select.option', '2', JText::_('J2')); $options[] = JHtml::_('select.option', '3', JText::_('J3')); $options[] = JHtml::_('select.option', '4', JText::_('J4')); $options[] = JHtml::_('select.option', '5', JText::_('J5')); $options[] = JHtml::_('select.option', '6', JText::_('J6')); $options[] = JHtml::_('select.option', '7', JText::_('J7')); $options[] = JHtml::_('select.option', '8', JText::_('J8')); $options[] = JHtml::_('select.option', '9', JText::_('J9')); $options[] = JHtml::_('select.option', '10', JText::_('J10')); $this->f_levels = $options; parent::display($tpl); $this->addToolbar(); } /** * Add the page title and toolbar. * * @since 1.6 */ protected function addToolbar() { require_once JPATH_COMPONENT.'/helpers/menus.php'; $canDo = MenusHelper::getActions($this->state->get('filter.parent_id')); JToolBarHelper::title(JText::_('COM_MENUS_VIEW_ITEMS_TITLE'), 'menumgr.png'); if ($canDo->get('core.create')) { JToolBarHelper::addNew('item.add'); } if ($canDo->get('core.edit')) { JToolBarHelper::editList('item.edit'); } if ($canDo->get('core.edit.state')) { JToolBarHelper::divider(); JToolBarHelper::publish('items.publish', 'JTOOLBAR_PUBLISH', true); JToolBarHelper::unpublish('items.unpublish', 'JTOOLBAR_UNPUBLISH', true); } if (JFactory::getUser()->authorise('core.admin')) { JToolBarHelper::divider(); JToolBarHelper::checkin('items.checkin', 'JTOOLBAR_CHECKIN', true); } if ($this->state->get('filter.published') == -2 && $canDo->get('core.delete')) { JToolBarHelper::deleteList('', 'items.delete', 'JTOOLBAR_EMPTY_TRASH'); } elseif ($canDo->get('core.edit.state')) { JToolBarHelper::trash('items.trash'); } if ($canDo->get('core.edit.state')) { JToolBarHelper::makeDefault('items.setDefault', 'COM_MENUS_TOOLBAR_SET_HOME'); JToolBarHelper::divider(); } if (JFactory::getUser()->authorise('core.admin')) { JToolBarHelper::custom('items.rebuild', 'refresh.png', 'refresh_f2.png', 'JToolbar_Rebuild', false); JToolBarHelper::divider(); } JToolBarHelper::help('JHELP_MENUS_MENU_ITEM_MANAGER'); } } PKA>\wtWviews/menutypes/index.htmlnuW+APKA>\)views/menutypes/.htaccessnuW+A Order allow,deny Deny from all PKA>\#H views/menutypes/tmpl/default.phpnuW+A PKA>\)views/menutypes/tmpl/.htaccessnuW+A Order allow,deny Deny from all PKA>\wtWviews/menutypes/tmpl/index.htmlnuW+APKA>\m??views/menutypes/view.html.phpnuW+ArecordId = JRequest::getInt('recordId'); $this->types = $this->get('TypeOptions'); parent::display($tpl); } } PKA>\Vviews/index.htmlnuW+A PKA>\)views/menu/.htaccessnuW+A Order allow,deny Deny from all PKA>\)views/menu/tmpl/.htaccessnuW+A Order allow,deny Deny from all PKA>\nAviews/menu/tmpl/edit.phpnuW+A
  • form->getLabel('title'); ?> form->getInput('title'); ?>
  • form->getLabel('menutype'); ?> form->getInput('menutype'); ?>
  • form->getLabel('description'); ?> form->getInput('description'); ?>
PKA>\Vviews/menu/tmpl/index.htmlnuW+A PKA>\Vviews/menu/index.htmlnuW+A PKA>\views/menu/view.html.phpnuW+Aform = $this->get('Form'); $this->item = $this->get('Item'); $this->state = $this->get('State'); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } parent::display($tpl); $this->addToolbar(); } /** * 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'); } } PKA>\)controllers/.htaccessnuW+A Order allow,deny Deny from all PKA>\Vcontrollers/index.htmlnuW+A PKA>\controllers/menu.phpnuW+AsetRedirect(JRoute::_('index.php?option=com_menus&view=menus', false)); } /** * Method to save a menu item. * * @return void */ public function save($key = null, $urlVar = null) { // Check for request forgeries. JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); // Initialise variables. $app = JFactory::getApplication(); $data = JRequest::getVar('jform', array(), 'post', 'array'); $context = 'com_menus.edit.menu'; $task = $this->getTask(); $recordId = JRequest::getInt('id'); if (!$this->checkEditId($context, $recordId)) { // Somehow the person just went to the form and saved it - we don't allow that. $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $recordId)); $this->setMessage($this->getError(), 'error'); $this->setRedirect(JRoute::_('index.php?option='.$this->option.'&view='.$this->view_list.$this->getRedirectToListAppend(), false)); return false; } // Make sure we are not trying to modify an administrator menu. if ((isset($data['client_id']) && $data['client_id'] == 1) || strtolower($data['menutype']) == 'menu' || strtolower($data['menutype']) == 'main') { JError::raiseNotice(0, JText::_('COM_MENUS_MENU_TYPE_NOT_ALLOWED')); // Redirect back to the edit screen. $this->setRedirect(JRoute::_('index.php?option=com_menus&view=menu&layout=edit', false)); return false; } // Populate the row id from the session. $data['id'] = $recordId; // Get the model and attempt to validate the posted data. $model = $this->getModel('Menu'); $form = $model->getForm(); if (!$form) { JError::raiseError(500, $model->getError()); return false; } $data = $model->validate($form, $data); // Check for validation errors. if ($data === false) { // Get the validation messages. $errors = $model->getErrors(); // Push up to three validation messages out to the user. for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++) { if ($errors[$i] instanceof Exception) { $app->enqueueMessage($errors[$i]->getMessage(), 'warning'); } else { $app->enqueueMessage($errors[$i], 'warning'); } } // Save the data in the session. $app->setUserState('com_menus.edit.menu.data', $data); // Redirect back to the edit screen. $this->setRedirect(JRoute::_('index.php?option=com_menus&view=menu&layout=edit', false)); return false; } // Attempt to save the data. if (!$model->save($data)) { // Save the data in the session. $app->setUserState('com_menus.edit.menu.data', $data); // Redirect back to the edit screen. $this->setMessage(JText::sprintf('JLIB_APPLICATION_ERROR_SAVE_FAILED', $model->getError()), 'warning'); $this->setRedirect(JRoute::_('index.php?option=com_menus&view=menu&layout=edit', false)); return false; } $this->setMessage(JText::_('COM_MENUS_MENU_SAVE_SUCCESS')); // Redirect the user and adjust session state based on the chosen task. switch ($task) { case 'apply': // Set the record data in the session. $recordId = $model->getState($this->context.'.id'); $this->holdEditId($context, $recordId); // Redirect back to the edit screen. $this->setRedirect(JRoute::_('index.php?option=com_menus&view=menu&layout=edit'.$this->getRedirectToItemAppend($recordId), false)); break; case 'save2new': // Clear the record id and data from the session. $this->releaseEditId($context, $recordId); $app->setUserState($context.'.data', null); // Redirect back to the edit screen. $this->setRedirect(JRoute::_('index.php?option=com_menus&view=menu&layout=edit', false)); break; default: // Clear the record id and data from the session. $this->releaseEditId($context, $recordId); $app->setUserState($context.'.data', null); // Redirect to the list screen. $this->setRedirect(JRoute::_('index.php?option=com_menus&view=menus', false)); break; } } } PKA>\: controllers/items.phpnuW+AregisterTask('unsetDefault', 'setDefault'); } /** * Proxy for getModel * @since 1.6 */ function getModel($name = 'Item', $prefix = 'MenusModel', $config = array()) { return parent::getModel($name, $prefix, array('ignore_request' => true)); } /** * Rebuild the nested set tree. * * @return bool False on failure or error, true on success. * @since 1.6 */ public function rebuild() { JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); $this->setRedirect('index.php?option=com_menus&view=items'); // Initialise variables. $model = $this->getModel(); if ($model->rebuild()) { // Reorder succeeded. $this->setMessage(JText::_('COM_MENUS_ITEMS_REBUILD_SUCCESS')); return true; } else { // Rebuild failed. $this->setMessage(JText::sprintf('COM_MENUS_ITEMS_REBUILD_FAILED')); return false; } } public function saveorder() { JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); // Get the arrays from the Request $order = JRequest::getVar('order', null, 'post', 'array'); $originalOrder = explode(',', JRequest::getString('original_order_values')); // Make sure something has changed if (!($order === $originalOrder)) { parent::saveorder(); } else { // Nothing to reorder $this->setRedirect(JRoute::_('index.php?option='.$this->option.'&view='.$this->view_list, false)); return true; } } /** * Method to set the home property for a list of items * * @since 1.6 */ function setDefault() { // Check for request forgeries JSession::checkToken('request') or die(JText::_('JINVALID_TOKEN')); // Get items to publish from the request. $cid = JRequest::getVar('cid', array(), '', 'array'); $data = array('setDefault' => 1, 'unsetDefault' => 0); $task = $this->getTask(); $value = JArrayHelper::getValue($data, $task, 0, 'int'); if (empty($cid)) { JError::raiseWarning(500, JText::_($this->text_prefix.'_NO_ITEM_SELECTED')); } else { // Get the model. $model = $this->getModel(); // Make sure the item ids are integers JArrayHelper::toInteger($cid); // Publish the items. if (!$model->setHome($cid, $value)) { JError::raiseWarning(500, $model->getError()); } else { if ($value == 1) { $ntext = 'COM_MENUS_ITEMS_SET_HOME'; } else { $ntext = 'COM_MENUS_ITEMS_UNSET_HOME'; } $this->setMessage(JText::plural($ntext, count($cid))); } } $this->setRedirect(JRoute::_('index.php?option='.$this->option.'&view='.$this->view_list, false)); } } PKA>\DDcontrollers/menus.phpnuW+A true)) { $model = parent::getModel($name, $prefix, $config); return $model; } /** * Removes an item */ public function delete() { // Check for request forgeries JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); // Get items to remove from the request. $cid = JRequest::getVar('cid', array(), '', 'array'); if (!is_array($cid) || count($cid) < 1) { JError::raiseWarning(500, JText::_('COM_MENUS_NO_MENUS_SELECTED')); } else { // Get the model. $model = $this->getModel(); // Make sure the item ids are integers jimport('joomla.utilities.arrayhelper'); JArrayHelper::toInteger($cid); // Remove the items. if (!$model->delete($cid)) { $this->setMessage($model->getError()); } else { $this->setMessage(JText::plural('COM_MENUS_N_MENUS_DELETED', count($cid))); } } $this->setRedirect('index.php?option=com_menus&view=menus'); } /** * Rebuild the menu tree. * * @return bool False on failure or error, true on success. */ public function rebuild() { JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); $this->setRedirect('index.php?option=com_menus&view=menus'); // Initialise variables. $model = $this->getModel('Item'); if ($model->rebuild()) { // Reorder succeeded. $this->setMessage(JText::_('JTOOLBAR_REBUILD_SUCCESS')); return true; } else { // Rebuild failed. $this->setMessage(JText::sprintf('JTOOLBAR_REBUILD_FAILED', $model->getMessage())); return false; } } /** * Temporary method. This should go into the 1.5 to 1.6 upgrade routines. */ public function resync() { // Initialise variables. $db = JFactory::getDbo(); $parts = null; // Load a lookup table of all the component id's. $components = $db->setQuery( 'SELECT element, extension_id' . ' FROM #__extensions' . ' WHERE type = '.$db->quote('component') )->loadAssocList('element', 'extension_id'); if ($error = $db->getErrorMsg()) { return JError::raiseWarning(500, $error); } // Load all the component menu links $items = $db->setQuery( 'SELECT id, link, component_id' . ' FROM #__menu' . ' WHERE type = '.$db->quote('component') )->loadObjectList(); if ($error = $db->getErrorMsg()) { return JError::raiseWarning(500, $error); } foreach ($items as $item) { // Parse the link. parse_str(parse_url($item->link, PHP_URL_QUERY), $parts); // Tease out the option. if (isset($parts['option'])) { $option = $parts['option']; // Lookup the component ID if (isset($components[$option])) { $componentId = $components[$option]; } else { // Mismatch. Needs human intervention. $componentId = -1; } // Check for mis-matched component id's in the menu link. if ($item->component_id != $componentId) { // Update the menu table. $log = "Link $item->id refers to $item->component_id, converting to $componentId ($item->link)"; echo "
$log"; $db->setQuery( 'UPDATE #__menu' . ' SET component_id = '.$componentId. ' WHERE id = '.$item->id )->query(); //echo "
".$db->getQuery(); if ($error = $db->getErrorMsg()) { return JError::raiseWarning(500, $error); } } } } } } PKA>\#1-1-controllers/item.phpnuW+AsetUserState($context . '.type', null); $app->setUserState($context . '.link', null); $menuType = $app->getUserStateFromRequest($this->context . '.filter.menutype', 'menutype', 'mainmenu', 'cmd'); $this->setRedirect(JRoute::_('index.php?option=com_menus&view=item&menutype=' . $menuType . $this->getRedirectToItemAppend(), false)); } return $result; } /** * Method to run batch operations. * * @param object $model The model. * * @return boolean True if successful, false otherwise and internal error is set. * * @since 1.6 */ public function batch($model = null) { JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); // Initialise variables. $model = $this->getModel('Item', '', array()); // Preset the redirect $this->setRedirect(JRoute::_('index.php?option=com_menus&view=items' . $this->getRedirectToListAppend(), false)); return parent::batch($model); } /** * Method to cancel an edit. * * @param string $key The name of the primary key of the URL variable. * * @return boolean True if access level checks pass, false otherwise. * * @since 1.6 */ public function cancel($key = null) { JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); // Initialise variables. $app = JFactory::getApplication(); $context = 'com_menus.edit.item'; $result = parent::cancel(); if ($result) { // Clear the ancillary data from the session. $app->setUserState($context . '.type', null); $app->setUserState($context . '.link', null); } } /** * Method to edit an existing record. * * @param string $key The name of the primary key of the URL variable. * @param string $urlVar The name of the URL variable if different from the primary key * (sometimes required to avoid router collisions). * * @return boolean True if access level check and checkout passes, false otherwise. * * @since 1.6 */ public function edit($key = null, $urlVar = null) { // Initialise variables. $app = JFactory::getApplication(); $result = parent::edit(); if ($result) { // Push the new ancillary data into the session. $app->setUserState('com_menus.edit.item.type', null); $app->setUserState('com_menus.edit.item.link', null); } return true; } /** * Method to save a record. * * @param string $key The name of the primary key of the URL variable. * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). * * @return boolean True if successful, false otherwise. * * @since 1.6 */ public function save($key = null, $urlVar = null) { // Check for request forgeries. JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); // Initialise variables. $app = JFactory::getApplication(); $model = $this->getModel('Item', '', array()); $data = JRequest::getVar('jform', array(), 'post', 'array'); $task = $this->getTask(); $context = 'com_menus.edit.item'; $recordId = JRequest::getInt('id'); if (!$this->checkEditId($context, $recordId)) { // Somehow the person just went to the form and saved it - we don't allow that. $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $recordId)); $this->setMessage($this->getError(), 'error'); $this->setRedirect(JRoute::_('index.php?option=com_menus&view=items' . $this->getRedirectToListAppend(), false)); return false; } // Populate the row id from the session. $data['id'] = $recordId; // The save2copy task needs to be handled slightly differently. if ($task == 'save2copy') { // Check-in the original row. if ($model->checkin($data['id']) === false) { // Check-in failed, go back to the item and display a notice. $this->setMessage(JText::sprintf('JLIB_APPLICATION_ERROR_CHECKIN_FAILED', $model->getError()), 'warning'); return false; } // Reset the ID and then treat the request as for Apply. $data['id'] = 0; $data['associations'] = array(); $task = 'apply'; } // Validate the posted data. // This post is made up of two forms, one for the item and one for params. $form = $model->getForm($data); if (!$form) { JError::raiseError(500, $model->getError()); return false; } if ($data['type'] == 'url') { $data['link'] = str_replace(array('"', '>', '<'), '', $data['link']); if (strstr($data['link'], ':')) { $segments = explode(':', $data['link']); $protocol = strtolower($segments[0]); $scheme = array('http', 'https', 'ftp', 'ftps', 'gopher', 'mailto', 'news', 'prospero', 'telnet', 'rlogin', 'tn3270', 'wais', 'url', 'mid', 'cid', 'nntp', 'tel', 'urn', 'ldap', 'file', 'fax', 'modem', 'git'); if (!in_array($protocol, $scheme)) { $app->enqueueMessage(JText::_('JLIB_APPLICATION_ERROR_SAVE_NOT_PERMITTED'), 'warning'); $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend($recordId), false)); return false; } } } $data = $model->validate($form, $data); // Check for the special 'request' entry. if ($data['type'] == 'component' && isset($data['request']) && is_array($data['request']) && !empty($data['request'])) { // Parse the submitted link arguments. $args = array(); parse_str(parse_url($data['link'], PHP_URL_QUERY), $args); // Merge in the user supplied request arguments. $args = array_merge($args, $data['request']); $data['link'] = 'index.php?' . urldecode(http_build_query($args, '', '&')); unset($data['request']); } // Check for validation errors. if ($data === false) { // Get the validation messages. $errors = $model->getErrors(); // Push up to three validation messages out to the user. for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++) { if ($errors[$i] instanceof Exception) { $app->enqueueMessage($errors[$i]->getMessage(), 'warning'); } else { $app->enqueueMessage($errors[$i], 'warning'); } } // Save the data in the session. $app->setUserState('com_menus.edit.item.data', $data); // Redirect back to the edit screen. $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend($recordId), false)); return false; } // Attempt to save the data. if (!$model->save($data)) { // Save the data in the session. $app->setUserState('com_menus.edit.item.data', $data); // Redirect back to the edit screen. $this->setMessage(JText::sprintf('JLIB_APPLICATION_ERROR_SAVE_FAILED', $model->getError()), 'warning'); $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend($recordId), false)); return false; } // Save succeeded, check-in the row. if ($model->checkin($data['id']) === false) { // Check-in failed, go back to the row and display a notice. $this->setMessage(JText::sprintf('JLIB_APPLICATION_ERROR_CHECKIN_FAILED', $model->getError()), 'warning'); $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend($recordId), false)); return false; } $this->setMessage(JText::_('COM_MENUS_SAVE_SUCCESS')); // Redirect the user and adjust session state based on the chosen task. switch ($task) { case 'apply': // Set the row data in the session. $recordId = $model->getState($this->context . '.id'); $this->holdEditId($context, $recordId); $app->setUserState('com_menus.edit.item.data', null); $app->setUserState('com_menus.edit.item.type', null); $app->setUserState('com_menus.edit.item.link', null); // Redirect back to the edit screen. $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend($recordId), false)); break; case 'save2new': // Clear the row id and data in the session. $this->releaseEditId($context, $recordId); $app->setUserState('com_menus.edit.item.data', null); $app->setUserState('com_menus.edit.item.type', null); $app->setUserState('com_menus.edit.item.link', null); $app->setUserState('com_menus.edit.item.menutype', $model->getState('item.menutype')); // Redirect back to the edit screen. $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend(), false)); break; default: // Clear the row id and data in the session. $this->releaseEditId($context, $recordId); $app->setUserState('com_menus.edit.item.data', null); $app->setUserState('com_menus.edit.item.type', null); $app->setUserState('com_menus.edit.item.link', null); // Redirect to the list screen. $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list . $this->getRedirectToListAppend(), false)); break; } } /** * Sets the type of the menu item currently being edited. * * @return void * * @since 1.6 */ function setType() { // Initialise variables. $app = JFactory::getApplication(); // Get the posted values from the request. $data = JRequest::getVar('jform', array(), 'post', 'array'); $recordId = JRequest::getInt('id'); // Get the type. $type = $data['type']; $type = json_decode(base64_decode($type)); $title = isset($type->title) ? $type->title : null; $recordId = isset($type->id) ? $type->id : 0; if ($title != 'alias' && $title != 'separator' && $title != 'url') { $title = 'component'; } $app->setUserState('com_menus.edit.item.type', $title); if ($title == 'component') { if (isset($type->request)) { $component = JComponentHelper::getComponent($type->request->option); $data['component_id'] = $component->id; $app->setUserState('com_menus.edit.item.link', 'index.php?' . JURI::buildQuery((array) $type->request)); } } // If the type is alias you just need the item id from the menu item referenced. elseif ($title == 'alias') { $app->setUserState('com_menus.edit.item.link', 'index.php?Itemid='); } unset($data['request']); $data['type'] = $title; if (JRequest::getCmd('fieldtype') == 'type') { $data['link'] = $app->getUserState('com_menus.edit.item.link'); } //Save the data in the session. $app->setUserState('com_menus.edit.item.data', $data); $this->type = $type; $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend($recordId), false)); } } PKA>\Vtables/index.htmlnuW+A PKA>\)tables/.htaccessnuW+A Order allow,deny Deny from all PKA>\#ztables/menu.phpnuW+A\! access.xmlnuW+A
PKA>\x config.xmlnuW+A
PKA>\  \"\"models/items.phpnuW+Aget('menu_associations', 0)) { $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 = JRequest::getVar('menutype', null); if ($menuType) { if ($menuType != $app->getUserState($this->context.'.filter.menutype')) { $app->setUserState($this->context.'.filter.menutype', $menuType); JRequest::setVar('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', 'a.id, a.menutype, a.title, a.alias, a.note, a.path, a.link, a.type, a.parent_id, a.level, a.published as apublished, a.component_id, a.ordering, 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')); $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 ' . ' 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'); $query->join('LEFT', $db->quoteName('#__languages').' AS l ON l.lang_code = a.language'); // Join over the users. $query->select('u.name AS editor'); $query->join('LEFT', $db->quoteName('#__users').' AS u ON u.id = a.checked_out'); //Join over components $query->select('c.element AS componentname'); $query->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'); $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); // Join over the associations. $assoc = isset($app->menu_associations) ? $app->menu_associations : 0; if ($assoc) { $query->select('COUNT(asso2.id)>1 as association'); $query->join('LEFT', '#__associations AS asso ON asso.id = a.id AND asso.context='.$db->quote('com_menus.item')); $query->join('LEFT', '#__associations AS asso2 ON asso2.key = asso.key'); $query->group('a.id'); } // Join over the extensions $query->select('e.name AS name'); $query->join('LEFT', '#__extensions AS e ON e.extension_id = a.component_id'); // Exclude the root category. $query->where('a.id > 1'); $query->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)).'
'; return $query; } } PKA>\)models/forms/.htaccessnuW+A Order allow,deny Deny from all PKA>\Vmodels/forms/index.htmlnuW+A PKA>\`models/forms/item_separator.xmlnuW+A
PKA>\}Cmodels/forms/item.xmlnuW+A
PKA>\Q݅ models/forms/item_component.xmlnuW+A
PKA>\x|models/forms/item_url.xmlnuW+A
PKA>\models/forms/item_alias.xmlnuW+A
PKA>\+{%%models/forms/menu.xmlnuW+A
PKA>\2-Q))models/menutypes.phpnuW+Arlu)) { $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'); // 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, true) || $lang->load($option->request['option'] . '.sys', JPATH_ADMINISTRATOR. '/components/'.$option->request['option'], null, false, true); } } } } } return $list; } protected function getTypeOptionsByComponent($component) { // Initialise variables. $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) { // Initialise variables. $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) { // Initialise variables. $options = array(); // Get the views for this component. $path = JPATH_SITE.'/components/'.$component.'/views'; if (JFolder::exists($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) { // Initialise variables. $options = array(); $layouts = array(); $layoutNames = array(); $templateLayouts = array(); $lang = JFactory::getLanguage(); // Get the layouts from the view folder. $path = JPATH_SITE.'/components/'.$component.'/views/'.$view.'/tmpl'; if (JFolder::exists($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(JFile::getName($layout), '_') === false) { $file = $layout; // Get the layout name. $layoutNames[] = JFile::stripext(JFile::getName($layout)); } } // 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 (JFolder::exists($folder . '/html/' . $component . '/' . $view)) { $template = JFile::getName($folder); $lang->load('tpl_' . $template . '.sys', JPATH_SITE, null, false, true) || $lang->load('tpl_' . $template . '.sys', JPATH_SITE . '/templates/' . $template, null, false, true); $templateLayouts = JFolder::files($folder . '/html/' . $component . '/' . $view, '.xml$', false, true); foreach ($templateLayouts as $layout) { $file = $layout; // Get the layout name. $templateLayoutName = JFile::stripext(JFile::getName($layout)); // 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] = JFile::getName($folder); } } } } // Process the found layouts. foreach ($layouts as $layout) { // Ignore private layouts. if (strpos(JFile::getName($layout), '_') === false) { $file = $layout; // Get the layout name. $layout = JFile::stripext(JFile::getName($layout)); // 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; } } PKA>\nnmodels/menu.phpnuW+Aauthorise('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 = (int) JRequest::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) { // Initialise variables. $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(); } 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'); $isNew = true; // Get a row instance. $table = $this->getTable(); // Load the row if saving an existing item. if ($id > 0) { $table->load($id); $isNew = false; } // 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); $query->from('#__modules as a'); $query->select('a.id, a.title, a.params, a.position'); $query->where('module = '.$db->quote('mod_menu')); $query->select('ag.title AS access_title'); $query->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'); } } PKA>\)models/.htaccessnuW+A Order allow,deny Deny from all PKA>\Vmodels/index.htmlnuW+A PKA>\,_`models/item.phpnuW+Aid)) { if ($record->published != -2) { return ; } $user = JFactory::getUser(); return $user->authorise('core.delete', 'com_menus.item.'.(int) $record->id); } } /** * Method to test whether a record can have its state edited. * * @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(); if (!empty($record->id)) { return $user->authorise('core.edit.state', 'com_menus.item.'.(int) $record->id); } // Default to component settings if menu item not known. else { return parent::canEditState($record); } } /** * Method to perform batch operations on an item or a set of items. * * @param array $commands An array of commands to perform. * @param array $pks An array of item ids. * @param array $contexts An array of item contexts. * * @return boolean Returns true on success, false on failure. * * @since 1.6 */ public function batch($commands, $pks, $contexts) { // Sanitize user ids. $pks = array_unique($pks); JArrayHelper::toInteger($pks); // Remove any values of zero. if (array_search(0, $pks, true)) { unset($pks[array_search(0, $pks, true)]); } if (empty($pks)) { $this->setError(JText::_('COM_MENUS_NO_ITEM_SELECTED')); return false; } $done = false; if (!empty($commands['menu_id'])) { $cmd = JArrayHelper::getValue($commands, 'move_copy', 'c'); if ($cmd == 'c') { $result = $this->batchCopy($commands['menu_id'], $pks, $contexts); if (is_array($result)) { $pks = $result; } else { return false; } } elseif ($cmd == 'm' && !$this->batchMove($commands['menu_id'], $pks, $contexts)) { return false; } $done = true; } if (!empty($commands['assetgroup_id'])) { if (!$this->batchAccess($commands['assetgroup_id'], $pks, $contexts)) { return false; } $done = true; } if (!empty($commands['language_id'])) { if (!$this->batchLanguage($commands['language_id'], $pks, $contexts)) { return false; } $done = true; } if (!$done) { $this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); return false; } return true; } /** * Batch copy menu items to a new menu or parent. * * @param integer $value The new menu or sub-item. * @param array $pks An array of row IDs. * @param array $contexts An array of item contexts. * * @return mixed An array of new IDs on success, boolean false on failure. * * @since 1.6 */ protected function batchCopy($value, $pks, $contexts) { // $value comes as {menutype}.{parent_id} $parts = explode('.', $value); $menuType = $parts[0]; $parentId = (int) JArrayHelper::getValue($parts, 1, 0); $table = $this->getTable(); $db = $this->getDbo(); $query = $db->getQuery(true); $i = 0; // Check that the parent exists if ($parentId) { if (!$table->load($parentId)) { if ($error = $table->getError()) { // Fatal error $this->setError($error); return false; } else { // Non-fatal error $this->setError(JText::_('JGLOBAL_BATCH_MOVE_PARENT_NOT_FOUND')); $parentId = 0; } } } // If the parent is 0, set it to the ID of the root item in the tree if (empty($parentId)) { if (!$parentId = $table->getRootId()) { $this->setError($db->getErrorMsg()); return false; } } // Check that user has create permission for menus $user = JFactory::getUser(); if (!$user->authorise('core.create', 'com_menus')) { $this->setError(JText::_('COM_MENUS_BATCH_MENU_ITEM_CANNOT_CREATE')); return false; } // We need to log the parent ID $parents = array(); // Calculate the emergency stop count as a precaution against a runaway loop bug $query->select('COUNT(id)'); $query->from($db->quoteName('#__menu')); $db->setQuery($query); $count = $db->loadResult(); if ($error = $db->getErrorMsg()) { $this->setError($error); return false; } // Parent exists so we let's proceed while (!empty($pks) && $count > 0) { // Pop the first id off the stack $pk = array_shift($pks); $table->reset(); // Check that the row actually exists if (!$table->load($pk)) { if ($error = $table->getError()) { // Fatal error $this->setError($error); return false; } else { // Not fatal error $this->setError(JText::sprintf('JGLOBAL_BATCH_MOVE_ROW_NOT_FOUND', $pk)); continue; } } // Copy is a bit tricky, because we also need to copy the children $query->clear(); $query->select('id'); $query->from($db->quoteName('#__menu')); $query->where('lft > ' . (int) $table->lft); $query->where('rgt < ' . (int) $table->rgt); $db->setQuery($query); $childIds = $db->loadColumn(); // Add child ID's to the array only if they aren't already there. foreach ($childIds as $childId) { if (!in_array($childId, $pks)) { array_push($pks, $childId); } } // Make a copy of the old ID and Parent ID $oldId = $table->id; $oldParentId = $table->parent_id; // Reset the id because we are making a copy. $table->id = 0; // If we a copying children, the Old ID will turn up in the parents list // otherwise it's a new top level item $table->parent_id = isset($parents[$oldParentId]) ? $parents[$oldParentId] : $parentId; $table->menutype = $menuType; // Set the new location in the tree for the node. $table->setLocation($table->parent_id, 'last-child'); // TODO: Deal with ordering? //$table->ordering = 1; $table->level = null; $table->lft = null; $table->rgt = null; $table->home = 0; // Alter the title & alias list($title, $alias) = $this->generateNewTitle($table->parent_id, $table->alias, $table->title); $table->title = $title; $table->alias = $alias; // Check the row. if (!$table->check()) { $this->setError($table->getError()); return false; } // Store the row. if (!$table->store()) { $this->setError($table->getError()); return false; } // Get the new item ID $newId = $table->get('id'); // Add the new ID to the array $newIds[$i] = $newId; $i++; // Now we log the old 'parent' to the new 'parent' $parents[$oldId] = $table->id; $count--; } // Rebuild the hierarchy. if (!$table->rebuild()) { $this->setError($table->getError()); return false; } // Rebuild the tree path. if (!$table->rebuildPath($table->id)) { $this->setError($table->getError()); return false; } // Clean the cache $this->cleanCache(); return $newIds; } /** * Batch move menu items to a new menu or parent. * * @param integer $value The new menu or sub-item. * @param array $pks An array of row IDs. * @param array $contexts An array of item contexts. * * @return boolean True on success. * * @since 1.6 */ protected function batchMove($value, $pks, $contexts) { // $value comes as {menutype}.{parent_id} $parts = explode('.', $value); $menuType = $parts[0]; $parentId = (int) JArrayHelper::getValue($parts, 1, 0); $table = $this->getTable(); $db = $this->getDbo(); $query = $db->getQuery(true); // Check that the parent exists. if ($parentId) { if (!$table->load($parentId)) { if ($error = $table->getError()) { // Fatal error $this->setError($error); return false; } else { // Non-fatal error $this->setError(JText::_('JGLOBAL_BATCH_MOVE_PARENT_NOT_FOUND')); $parentId = 0; } } } // Check that user has create and edit permission for menus $user = JFactory::getUser(); if (!$user->authorise('core.create', 'com_menus')) { $this->setError(JText::_('COM_MENUS_BATCH_MENU_ITEM_CANNOT_CREATE')); return false; } if (!$user->authorise('core.edit', 'com_menus')) { $this->setError(JText::_('COM_MENUS_BATCH_MENU_ITEM_CANNOT_EDIT')); return false; } // We are going to store all the children and just moved the menutype $children = array(); // Parent exists so we let's proceed foreach ($pks as $pk) { // Check that the row actually exists if (!$table->load($pk)) { if ($error = $table->getError()) { // Fatal error $this->setError($error); return false; } else { // Not fatal error $this->setError(JText::sprintf('JGLOBAL_BATCH_MOVE_ROW_NOT_FOUND', $pk)); continue; } } // Set the new location in the tree for the node. $table->setLocation($parentId, 'last-child'); // Set the new Parent Id $table->parent_id = $parentId; // Check if we are moving to a different menu if ($menuType != $table->menutype) { // Add the child node ids to the children array. $query->clear(); $query->select($db->quoteName('id')); $query->from($db->quoteName('#__menu')); $query->where($db->quoteName('lft') .' BETWEEN ' . (int) $table->lft . ' AND ' . (int) $table->rgt); $db->setQuery($query); $children = array_merge($children, (array) $db->loadColumn()); } // Check the row. if (!$table->check()) { $this->setError($table->getError()); return false; } // Store the row. if (!$table->store()) { $this->setError($table->getError()); return false; } // Rebuild the tree path. if (!$table->rebuildPath()) { $this->setError($table->getError()); return false; } } // Process the child rows if (!empty($children)) { // Remove any duplicates and sanitize ids. $children = array_unique($children); JArrayHelper::toInteger($children); // Update the menutype field in all nodes where necessary. $query->clear(); $query->update($db->quoteName('#__menu')); $query->set($db->quoteName('menutype') . ' = ' . $db->quote($menuType)); $query->where($db->quoteName('id') . ' IN (' . implode(',', $children) . ')'); $db->setQuery($query); $db->query(); // Check for a database error. if ($db->getErrorNum()) { $this->setError($db->getErrorMsg()); return false; } } // Clean the cache $this->cleanCache(); return true; } /** * Method to check if you can save a record. * * @param array $data An array of input data. * @param string $key The name of the key for the primary key. * * @return boolean * @since 1.6 */ protected function canSave($data = array(), $key = 'id') { return JFactory::getUser()->authorise('core.edit', $this->option); } /** * Method to get the row 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 mixed A JForm object on success, false on failure * @since 1.6 */ public function getForm($data = array(), $loadData = true) { // The folder and element vars are passed when saving the form. if (empty($data)) { $item = $this->getItem(); $this->setState('item.link', $item->link); // The type should already be set. } else { $this->setState('item.link', JArrayHelper::getValue($data, 'link')); $this->setState('item.type', JArrayHelper::getValue($data, 'type')); } // Get the form. $form = $this->loadForm('com_menus.item', 'item', array('control' => 'jform', 'load_data' => $loadData), true); if (empty($form)) { return false; } // Modify the form based on access controls. if (!$this->canEditState((object) $data)) { // Disable fields for display. $form->setFieldAttribute('menuordering', 'disabled', 'true'); $form->setFieldAttribute('published', 'disabled', 'true'); // Disable fields while saving. // The controller has already verified this is an article you can edit. $form->setFieldAttribute('menuordering', 'filter', 'unset'); $form->setFieldAttribute('published', 'filter', 'unset'); } 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. return array_merge((array)$this->getItem(), (array)JFactory::getApplication()->getUserState('com_menus.edit.item.data', array())); } /** * Get the necessary data to load an item help screen. * * @return object An object with key, url, and local properties for loading the item help screen. * @since 1.6 */ public function getHelp() { return (object) array('key' => $this->helpKey, 'url' => $this->helpURL, 'local' => $this->helpLocal); } /** * Method to get a menu item. * * @param integer $pk An optional id of the object to get, otherwise the id from the model state is used. * * @return mixed Menu item data object on success, false on failure. * @since 1.6 */ public function getItem($pk = null) { // Initialise variables. $pk = (!empty($pk)) ? $pk : (int)$this->getState('item.id'); // Get a level row instance. $table = $this->getTable(); // Attempt to load the row. $table->load($pk); // Check for a table object error. if ($error = $table->getError()) { $this->setError($error); $false = false; return $false; } // Prime required properties. if ($type = $this->getState('item.type')) { $table->type = $type; } if (empty($table->id)) { $table->parent_id = $this->getState('item.parent_id'); $table->menutype = $this->getState('item.menutype'); $table->params = '{}'; } // If the link has been set in the state, possibly changing link type. if ($link = $this->getState('item.link')) { // Check if we are changing away from the actual link type. if (MenusHelper::getLinkKey($table->link) != MenusHelper::getLinkKey($link)) { $table->link = $link; } } switch ($table->type) { case 'alias': $table->component_id = 0; $args = array(); parse_str(parse_url($table->link, PHP_URL_QUERY), $args); break; case 'separator': $table->link = ''; $table->component_id = 0; break; case 'url': $table->component_id = 0; parse_str(parse_url($table->link, PHP_URL_QUERY)); break; case 'component': default: // Enforce a valid type. $table->type = 'component'; // Ensure the integrity of the component_id field is maintained, particularly when changing the menu item type. $args = array(); parse_str(parse_url($table->link, PHP_URL_QUERY), $args); if (isset($args['option'])) { // Load the language file for the component. $lang = JFactory::getLanguage(); $lang->load($args['option'], JPATH_ADMINISTRATOR, null, false, true) || $lang->load($args['option'], JPATH_ADMINISTRATOR . '/components/' . $args['option'], null, false, true); // Determine the component id. $component = JComponentHelper::getComponent($args['option']); if (isset($component->id)) { $table->component_id = $component->id; } } break; } // We have a valid type, inject it into the state for forms to use. $this->setState('item.type', $table->type); // Convert to the JObject before adding the params. $properties = $table->getProperties(1); $result = JArrayHelper::toObject($properties, 'JObject'); // Convert the params field to an array. $registry = new JRegistry; $registry->loadString($table->params); $result->params = $registry->toArray(); // Merge the request arguments in to the params for a component. if ($table->type == 'component') { // Note that all request arguments become reserved parameter names. $result->request = $args; $result->params = array_merge($result->params, $args); } if ($table->type == 'alias') { // Note that all request arguments become reserved parameter names. $args = array(); parse_str(parse_url($table->link, PHP_URL_QUERY), $args); $result->params = array_merge($result->params, $args); } if ($table->type == 'url') { // Note that all request arguments become reserved parameter names. $args = array(); parse_str(parse_url($table->link, PHP_URL_QUERY), $args); $result->params = array_merge($result->params, $args); } // Load associated menu items if (JFactory::getApplication()->get('menu_associations', 0)) { if ($pk != null) { $result->associations = MenusHelper::getAssociations($pk); } else { $result->associations = array(); } } $result->menuordering = $pk; return $result; } /** * Get the list of modules not in trash. * * @return mixed An array of module records (id, title, position), or false on error. * @since 1.6 */ public function getModules() { $db = $this->getDbo(); $query = $db->getQuery(true); // Join on the module-to-menu mapping table. // We are only interested if the module is displayed on ALL or THIS menu item (or the inverse ID number). //sqlsrv changes for modulelink to menu manager $query->select('a.id, a.title, a.position, a.published, map.menuid'); $query->from('#__modules AS a'); $query->join('LEFT', sprintf('#__modules_menu AS map ON map.moduleid = a.id AND map.menuid IN (0, %1$d, -%1$d)', $this->getState('item.id'))); $query->select('(SELECT COUNT(*) FROM #__modules_menu WHERE moduleid = a.id AND menuid < 0) AS ' . $db->qn('except')); // Join on the asset groups table. $query->select('ag.title AS access_title'); $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); $query->where('a.published >= 0'); $query->where('a.client_id = 0'); $query->order('a.position, a.ordering'); $db->setQuery($query); $result = $db->loadObjectList(); if ($db->getErrorNum()) { $this->setError($db->getErrorMsg()); return false; } return $result; } /** * A protected method to get the where clause for the reorder * This ensures that the row will be moved relative to a row with the same menutype * * @param JTableMenu $table instance * * @return array An array of conditions to add to add to ordering queries. * @since 1.6 */ protected function getReorderConditions($table) { return 'menutype = ' . $this->_db->Quote($table->menutype); } /** * Returns a Table object, always creating it * * @param type $type The table type to instantiate * @param string $prefix A prefix for the table class name. Optional. * @param array $config Configuration array for model. Optional. * * @return JTable A database object * @since 1.6 */ public function getTable($type = 'Menu', $prefix = 'MenusTable', $config = array()) { return JTable::getInstance($type, $prefix, $config); } /** * Auto-populate the model state. * * Note. Calling getState in this method will result in recursion. * * @return void * @since 1.6 */ protected function populateState() { $app = JFactory::getApplication('administrator'); // Load the User state. $pk = (int) JRequest::getInt('id'); $this->setState('item.id', $pk); if (!($parentId = $app->getUserState('com_menus.edit.item.parent_id'))) { $parentId = JRequest::getInt('parent_id'); } $this->setState('item.parent_id', $parentId); $menuType = $app->getUserState('com_menus.edit.item.menutype'); if (JRequest::getCmd('menutype', false)) { $menuType = JRequest::getCmd('menutype', 'mainmenu'); } $this->setState('item.menutype', $menuType); if (!($type = $app->getUserState('com_menus.edit.item.type'))){ $type = JRequest::getCmd('type'); // Note a new menu item will have no field type. // The field is required so the user has to change it. } $this->setState('item.type', $type); if ($link = $app->getUserState('com_menus.edit.item.link')) { $this->setState('item.link', $link); } // Load the parameters. $params = JComponentHelper::getParams('com_menus'); $this->setState('params', $params); } /** * @param object $form A form object. * @param mixed $data The data expected for the form. * * @return void * @since 1.6 * @throws Exception if there is an error in the form event. */ protected function preprocessForm(JForm $form, $data, $group = 'content') { // Initialise variables. $link = $this->getState('item.link'); $type = $this->getState('item.type'); $formFile = false; // Initialise form with component view params if available. if ($type == 'component') { $link = htmlspecialchars_decode($link); // Parse the link arguments. $args = array(); parse_str(parse_url(htmlspecialchars_decode($link), PHP_URL_QUERY), $args); // Confirm that the option is defined. $option = ''; $base = ''; if (isset($args['option'])) { // The option determines the base path to work with. $option = $args['option']; $base = JPATH_SITE.'/components/'.$option; } // Confirm a view is defined. $formFile = false; if (isset($args['view'])) { $view = $args['view']; // Determine the layout to search for. if (isset($args['layout'])) { $layout = $args['layout']; } else { $layout = 'default'; } $formFile = false; // Check for the layout XML file. Use standard xml file if it exists. $path = JPath::clean($base.'/views/'.$view.'/tmpl/'.$layout.'.xml'); if (JFile::exists($path)) { $formFile = $path; } // if custom layout, get the xml file from the template folder // template folder is first part of file name -- template:folder if (!$formFile && (strpos($layout, ':') > 0 )) { $temp = explode(':', $layout); $templatePath = JPATH::clean(JPATH_SITE.'/templates/'.$temp[0].'/html/'.$option.'/'.$view.'/'.$temp[1].'.xml'); if (JFile::exists($templatePath)) { $formFile = $templatePath; } } } //Now check for a view manifest file if (!$formFile) { if (isset($view) && JFile::exists($path = JPath::clean($base.'/views/'.$view.'/metadata.xml'))) { $formFile = $path; } else { //Now check for a component manifest file $path = JPath::clean($base.'/metadata.xml'); if (JFile::exists($path)) { $formFile = $path; } } } } if ($formFile) { // If an XML file was found in the component, load it first. // We need to qualify the full path to avoid collisions with component file names. if ($form->loadFile($formFile, true, '/metadata') == false) { throw new Exception(JText::_('JERROR_LOADFILE_FAILED')); } // Attempt to load the xml file. if (!$xml = simplexml_load_file($formFile)) { throw new Exception(JText::_('JERROR_LOADFILE_FAILED')); } // Get the help data from the XML file if present. $help = $xml->xpath('/metadata/layout/help'); } else { // We don't have a component. Load the form XML to get the help path $xmlFile = JPath::find(JPATH_ROOT . '/administrator/components/com_menus/models/forms', 'item_' . $type . '.xml'); // Attempt to load the xml file. if ($xmlFile && !$xml = simplexml_load_file($xmlFile)) { throw new Exception(JText::_('JERROR_LOADFILE_FAILED')); } // Get the help data from the XML file if present. $help = $xml->xpath('/form/help'); } if (!empty($help)) { $helpKey = trim((string) $help[0]['key']); $helpURL = trim((string) $help[0]['url']); $helpLoc = trim((string) $help[0]['local']); $this->helpKey = $helpKey ? $helpKey : $this->helpKey; $this->helpURL = $helpURL ? $helpURL : $this->helpURL; $this->helpLocal = (($helpLoc == 'true') || ($helpLoc == '1') || ($helpLoc == 'local')) ? true : false; } // Now load the component params. // TODO: Work out why 'fixing' this breaks JForm if ($isNew = false) { $path = JPath::clean(JPATH_ADMINISTRATOR.'/components/'.$option.'/config.xml'); } else { $path='null'; } if (JFile::exists($path)) { // Add the component params last of all to the existing form. if (!$form->load($path, true, '/config')) { throw new Exception(JText::_('JERROR_LOADFILE_FAILED')); } } // Load the specific type file if (!$form->loadFile('item_'.$type, false, false)) { throw new Exception(JText::_('JERROR_LOADFILE_FAILED')); } // Association menu items if (JFactory::getApplication()->get('menu_associations', 0)) { $languages = JLanguageHelper::getLanguages('lang_code'); $addform = new JXMLElement('
'); $fields = $addform->addChild('fields'); $fields->addAttribute('name', 'associations'); $fieldset = $fields->addChild('fieldset'); $fieldset->addAttribute('name', 'item_associations'); $fieldset->addAttribute('description', 'COM_MENUS_ITEM_ASSOCIATIONS_FIELDSET_DESC'); $add = false; foreach ($languages as $tag => $language) { if ($tag != $data['language']) { $add = true; $field = $fieldset->addChild('field'); $field->addAttribute('name', $tag); $field->addAttribute('type', 'menuitem'); $field->addAttribute('language', $tag); $field->addAttribute('label', $language->title); $field->addAttribute('translate_label', 'false'); $option = $field->addChild('option', 'COM_MENUS_ITEM_FIELD_ASSOCIATION_NO_VALUE'); $option->addAttribute('value', ''); } } if ($add) { $form->load($addform, false); } } // Trigger the default form events. parent::preprocessForm($form, $data, $group); } /** * Method rebuild the entire nested set tree. * * @return boolean False on failure or error, true otherwise. * @since 1.6 */ public function rebuild() { // Initialiase variables. $db = $this->getDbo(); $table = $this->getTable(); if (!$table->rebuild()) { $this->setError($table->getError()); return false; } // Convert the parameters not in JSON format. $db->setQuery( 'SELECT id, params' . ' FROM #__menu' . ' WHERE params NOT LIKE '.$db->quote('{%') . ' AND params <> '.$db->quote('') ); $items = $db->loadObjectList(); if ($error = $db->getErrorMsg()) { $this->setError($error); return false; } foreach ($items as &$item) { $registry = new JRegistry; $registry->loadString($item->params); $params = (string)$registry; $db->setQuery( 'UPDATE #__menu' . ' SET params = '.$db->quote($params). ' WHERE id = '.(int) $item->id ); if (!$db->query()) { $this->setError($error); return false; } unset($registry); } // Clean the cache $this->cleanCache(); return true; } /** * Method to save the form data. * * @param array $data The form data. * * @return boolean True on success. * @since 1.6 */ public function save($data) { // Initialise variables. $pk = (!empty($data['id'])) ? $data['id'] : (int)$this->getState('item.id'); $isNew = true; $db = $this->getDbo(); $table = $this->getTable(); // Load the row if saving an existing item. if ($pk > 0) { $table->load($pk); $isNew = false; } if (!$isNew && $table->menutype == $data['menutype']) { if ($table->parent_id == $data['parent_id'] ) { // If first is chosen make the item the first child of the selected parent. if ($data['menuordering'] == -1) { $table->setLocation($data['parent_id'], 'first-child'); } // If last is chosen make it the last child of the selected parent. elseif ($data['menuordering'] == -2) { $table->setLocation($data['parent_id'], 'last-child'); } // Don't try to put an item after itself. All other ones put after the selected item. // $data['id'] is empty means it's a save as copy elseif ($data['menuordering'] && $table->id != $data['menuordering'] || empty($data['id'])) { $table->setLocation($data['menuordering'], 'after'); } // Just leave it where it is if no change is made. elseif ( $data['menuordering'] && $table->id == $data['menuordering']) { unset( $data['menuordering']); } } // Set the new parent id if parent id not matched and put in last position else { $table->setLocation($data['parent_id'], 'last-child'); } } // We have a new item, so it is not a change. elseif ($isNew) { $table->setLocation($data['parent_id'], 'last-child'); } // The menu type has changed so we need to just put this at the bottom // of the root level. else { $table->setLocation(1, 'last-child'); } // Bind the data. if (!$table->bind($data)) { $this->setError($table->getError()); return false; } // Alter the title & alias for save as copy. Also, unset the home record. if(!$isNew && $data['id'] == 0){ list($title, $alias) = $this->generateNewTitle($table->parent_id, $table->alias, $table->title); $table->title = $title; $table->alias = $alias; $table->home = 0; } // Check the data. if (!$table->check()) { $this->setError($table->getError()); return false; } // Store the data. if (!$table->store()) { $this->setError($table->getError()); return false; } // Rebuild the tree path. if (!$table->rebuildPath($table->id)) { $this->setError($table->getError()); return false; } $this->setState('item.id', $table->id); $this->setState('item.menutype', $table->menutype); // Load associated menu items if (JFactory::getApplication()->get('menu_associations', 0)) { // Adding self to the association $associations = $data['associations']; foreach ($associations as $tag=>$id) { if (empty($id)) { unset($associations[$tag]); } } // Detecting all item menus $all_language = $table->language == '*'; if ($all_language && !empty($associations)) { JError::raiseNotice(403, JText::_('COM_MENUS_ERROR_ALL_LANGUAGE_ASSOCIATED')); } $associations[$table->language]=$table->id; // Deleting old association for these items $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->delete('#__associations'); $query->where('context='.$db->quote('com_menus.item')); $query->where('id IN ('.implode(',', $associations).')'); $db->setQuery($query); $db->query(); if ($error = $db->getErrorMsg()) { $this->setError($error); return false; } if (!$all_language && count($associations)>1) { // Adding new association for these items $key = md5(json_encode($associations)); $query->clear(); $query->insert('#__associations'); foreach ($associations as $tag=>$id) { $query->values($id.','.$db->quote('com_menus.item').','.$db->quote($key)); } $db->setQuery($query); $db->query(); if ($error = $db->getErrorMsg()) { $this->setError($error); return false; } } } // Clean the cache $this->cleanCache(); if (isset($data['link'])) { $base = JURI::base(); $juri = JURI::getInstance($base.$data['link']); $option = $juri->getVar('option'); // Clean the cache parent::cleanCache($option); } return true; } /** * Method to save the reordered nested set tree. * First we save the new order values in the lft values of the changed ids. * Then we invoke the table rebuild to implement the new ordering. * * @param array $idArray id's of rows to be reordered * @param array $lft_array lft values of rows to be reordered * * @return boolean false on failuer or error, true otherwise * @since 1.6 */ public function saveorder($idArray = null, $lft_array = null) { // Get an instance of the table object. $table = $this->getTable(); if (!$table->saveorder($idArray, $lft_array)) { $this->setError($table->getError()); return false; } // Clean the cache $this->cleanCache(); return true; } /** * Method to change the home state of one or more items. * * @param array $pks A list of the primary keys to change. * @param int $value The value of the home state. * * @return boolean True on success. * @since 1.6 */ function setHome(&$pks, $value = 1) { // Initialise variables. $table = $this->getTable(); $pks = (array) $pks; $user = JFactory::getUser(); $languages = array(); $onehome = false; // Remember that we can set a home page for different languages, // so we need to loop through the primary key array. foreach ($pks as $i => $pk) { if ($table->load($pk)) { if (!array_key_exists($table->language, $languages)) { $languages[$table->language] = true; if ($table->home == $value) { unset($pks[$i]); JError::raiseNotice(403, JText::_('COM_MENUS_ERROR_ALREADY_HOME')); } else { $table->home = $value; if ($table->language == '*') { $table->published = 1; } if (!$this->canSave($table)) { // Prune items that you can't change. unset($pks[$i]); JError::raiseWarning(403, JText::_('JLIB_APPLICATION_ERROR_SAVE_NOT_PERMITTED')); } elseif (!$table->check()) { // Prune the items that failed pre-save checks. unset($pks[$i]); JError::raiseWarning(403, $table->getError()); } elseif (!$table->store()) { // Prune the items that could not be stored. unset($pks[$i]); JError::raiseWarning(403, $table->getError()); } } } else { unset($pks[$i]); if (!$onehome) { $onehome = true; JError::raiseNotice(403, JText::sprintf('COM_MENUS_ERROR_ONE_HOME')); } } } } // Clean the cache $this->cleanCache(); return true; } /** * Method to change the published state of one or more records. * * @param array $pks A list of the primary keys to change. * @param int $value The value of the published state. * * @return boolean True on success. * @since 1.6 */ function publish(&$pks, $value = 1) { // Initialise variables. $table = $this->getTable(); $pks = (array) $pks; // Default menu item existence checks. if ($value != 1) { foreach ($pks as $i => $pk) { if ($table->load($pk) && $table->home && $table->language == '*') { // Prune items that you can't change. JError::raiseWarning(403, JText::_('JLIB_DATABASE_ERROR_MENU_UNPUBLISH_DEFAULT_HOME')); unset($pks[$i]); break; } } } // Clean the cache $this->cleanCache(); return parent::publish($pks, $value); } /** * Method to change the title & alias. * * @param integer $parent_id The id of the parent. * @param string $alias The alias. * @param string $title The title. * * @return array Contains the modified title and alias. * * @since 1.6 */ protected function generateNewTitle($parent_id, $alias, $title) { // Alter the title & alias $table = $this->getTable(); while ($table->load(array('alias' => $alias, 'parent_id' => $parent_id))) { if ($title == $table->title) { $title = JString::increment($title); } $alias = JString::increment($alias, 'dash'); } return array($title, $alias); } /** * Custom clean cache method * * @since 1.6 */ protected function cleanCache($group = null, $client_id = 0) { parent::cleanCache('com_modules'); parent::cleanCache('mod_menu'); } } PKA>\xl  models/menus.phpnuW+AgetStoreId('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); $countPublished = $db->loadAssocList('menutype', 'count_published'); if ($db->getErrorNum()) { $this->setError($db->getErrorMsg()); return false; } // Get the unpublished menu counts. $query->clear('where') ->where('m.published = 0') ->where('m.menutype IN ('.$menuTypes.')'); $db->setQuery($query); $countUnpublished = $db->loadAssocList('menutype', 'count_published'); if ($db->getErrorNum()) { $this->setError($db->getErrorMsg()); return false; } // Get the trashed menu counts. $query->clear('where') ->where('m.published = -2') ->where('m.menutype IN ('.$menuTypes.')'); $db->setQuery($query); $countTrashed = $db->loadAssocList('menutype', 'count_published'); if ($db->getErrorNum()) { $this->setError($db->getErrorMsg()); 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.*')); $query->from($db->quoteName('#__menu_types').' AS a'); $query->group('a.id, a.menutype, a.title, a.description'); // 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) { // Initialise variables. $app = JFactory::getApplication('administrator'); // 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); $query->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; } } PKA>\Vmodels/fields/index.htmlnuW+A PKA>\)models/fields/.htaccessnuW+A Order allow,deny Deny from all PKA>\ Xׯmodels/fields/menutype.phpnuW+Aform->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; 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[] = ''; $html[] = ''; $html[] = ''; return implode("\n", $html); } } PKA>\7췈  models/fields/menuordering.phpnuW+Aform->getValue('parent_id', 0); if ( empty($parent_id)) { return false; } $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('a.id AS value, a.title AS text'); $query->from('#__menu AS a'); $query->where('a.published >= 0'); $query->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); $options = $db->loadObjectList(); // Check for a database error. if ($db->getErrorNum()) { JError::raiseWarning(500, $db->getErrorMsg()); } $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 '' . JText::_('COM_MENUS_ITEM_FIELD_ORDERING_TEXT') . ''; } else { return parent::getInput(); } } } PKA>\1sEEmodels/fields/menuparent.phpnuW+AgetQuery(true); $query->select('a.id AS value, a.title AS text, a.level'); $query->from('#__menu AS a'); $query->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); $query->where('NOT(a.lft >= p.lft AND a.rgt <= p.rgt)'); } $query->where('a.published != -2'); $query->group('a.id, a.title, a.level, a.lft, a.rgt, a.menutype, a.parent_id, a.published'); $query->order('a.lft ASC'); // Get the options. $db->setQuery($query); $options = $db->loadObjectList(); // Check for a database error. if ($db->getErrorNum()) { JError::raiseWarning(500, $db->getErrorMsg()); } // 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; } } PKA>\)helpers/.htaccessnuW+A Order allow,deny Deny from all PKA>\)helpers/html/.htaccessnuW+A Order allow,deny Deny from all PKA>\+/lRhelpers/html/menus.phpnuW+AgetQuery(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('
', $text), JText::_('COM_MENUS_TIP_ASSOCIATION'), 'menu/icon-16-links.png'); } /** * Returns a published state on a grid * * @param integer $value The state value. * @param integer $i The row index * @param boolean $enabled An optional setting for access control on the action. * @param string $checkbox An optional prefix for checkboxes. * * @return string The Html code * * @see JHtmlJGrid::state * * @since 1.7.1 */ public static function state($value, $i, $enabled = true, $checkbox = 'cb') { $states = array( 7 => array( 'unpublish', '', 'COM_MENUS_HTML_UNPUBLISH_SEPARATOR', '', false, 'publish', 'publish' ), 6 => array( 'publish', '', 'COM_MENUS_HTML_PUBLISH_SEPARATOR', '', false, 'unpublish', 'unpublish' ), 5 => array( 'unpublish', '', 'COM_MENUS_HTML_UNPUBLISH_ALIAS', '', false, 'publish', 'publish' ), 4 => array( 'publish', '', 'COM_MENUS_HTML_PUBLISH_ALIAS', '', false, 'unpublish', 'unpublish' ), 3 => array( 'unpublish', '', 'COM_MENUS_HTML_UNPUBLISH_URL', '', false, 'publish', 'publish' ), 2 => array( 'publish', '', 'COM_MENUS_HTML_PUBLISH_URL', '', false, 'unpublish', 'unpublish' ), 1 => array( 'unpublish', 'COM_MENUS_EXTENSION_PUBLISHED_ENABLED', 'COM_MENUS_HTML_UNPUBLISH_ENABLED', 'COM_MENUS_EXTENSION_PUBLISHED_ENABLED', true, 'publish', 'publish' ), 0 => array( 'publish', 'COM_MENUS_EXTENSION_UNPUBLISHED_ENABLED', 'COM_MENUS_HTML_PUBLISH_ENABLED', 'COM_MENUS_EXTENSION_UNPUBLISHED_ENABLED', true, 'unpublish', 'unpublish' ), -1 => array( 'unpublish', 'COM_MENUS_EXTENSION_PUBLISHED_DISABLED', 'COM_MENUS_HTML_UNPUBLISH_DISABLED', 'COM_MENUS_EXTENSION_PUBLISHED_DISABLED', true, 'warning', 'warning' ), -2 => array( 'publish', 'COM_MENUS_EXTENSION_UNPUBLISHED_DISABLED', 'COM_MENUS_HTML_PUBLISH_DISABLED', 'COM_MENUS_EXTENSION_UNPUBLISHED_DISABLED', true, 'unpublish', 'unpublish' ), ); return JHtml::_('jgrid.state', $states, $value, $i, 'items.', $enabled, true, $checkbox); } } PKA>\Vhelpers/html/index.htmlnuW+A PKA>\3helpers/menus.phpnuW+Aset($action->name, $user->authorise($action->name, $assetName)); } return $result; } /** * Gets a standard form of a link for lookups. * * @param mixed A link string or array of request variables. * * @return mixed A link in standard option-view-layout form, or false if the supplied response is invalid. */ public static function getLinkKey($request) { if (empty($request)) { return false; } // Check if the link is in the form of index.php?... if (is_string($request)) { $args = array(); if (strpos($request, 'index.php') === 0) { parse_str(parse_url(htmlspecialchars_decode($request), PHP_URL_QUERY), $args); } else { parse_str($request, $args); } $request = $args; } // Only take the option, view and layout parts. foreach ($request as $name => $value) { if ((!in_array($name, self::$_filter)) && (!($name == 'task' && !array_key_exists('view', $request)))) { // Remove the variables we want to ignore. unset($request[$name]); } } ksort($request); return 'index.php?'.http_build_query($request, '', '&'); } /** * Get the menu list for create a menu module * * @return array The menu array list * @since 1.6 */ public static function getMenuTypes() { $db = JFactory::getDbo(); $db->setQuery('SELECT a.menutype FROM #__menu_types AS a'); return $db->loadColumn(); } /** * Get a list of menu links for one or all menus. * * @param string An option menu to filter the list on, otherwise all menu links are returned as a grouped array. * @param int An optional parent ID to pivot results around. * @param int An optional mode. If parent ID is set and mode=2, the parent and children are excluded from the list. * @param array An optional array of states */ public static function getMenuLinks($menuType = null, $parentId = 0, $mode = 0, $published=array(), $languages=array()) { $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('a.id AS value, a.title AS text, a.level, a.menutype, a.type, a.template_style_id, a.checked_out'); $query->from('#__menu AS a'); $query->join('LEFT', $db->quoteName('#__menu').' AS b ON a.lft > b.lft AND a.rgt < b.rgt'); // Filter by the type if ($menuType) { $query->where('(a.menutype = '.$db->quote($menuType).' OR a.parent_id = 0)'); } if ($parentId) { if ($mode == 2) { // Prevent the parent and children from showing. $query->join('LEFT', '#__menu AS p ON p.id = '.(int) $parentId); $query->where('(a.lft <= p.lft OR a.rgt >= p.rgt)'); } } if (!empty($languages)) { if (is_array($languages)) { $languages = '(' . implode(',', array_map(array($db, 'quote'), $languages)) . ')'; } $query->where('a.language IN ' . $languages); } if (!empty($published)) { if (is_array($published)) $published = '(' . implode(',', $published) .')'; $query->where('a.published IN ' . $published); } $query->where('a.published != -2'); $query->group('a.id, a.title, a.level, a.menutype, a.type, a.template_style_id, a.checked_out, a.lft'); $query->order('a.lft ASC'); // Get the options. $db->setQuery($query); $links = $db->loadObjectList(); // Check for a database error. if ($error = $db->getErrorMsg()) { JError::raiseWarning(500, $error); return false; } // Pad the option text with spaces using depth level as a multiplier. foreach ($links as &$link) { $link->text = str_repeat('- ', $link->level).$link->text; } if (empty($menuType)) { // If the menutype is empty, group the items by menutype. $query->clear(); $query->select('*'); $query->from('#__menu_types'); $query->where('menutype <> '.$db->quote('')); $query->order('title, menutype'); $db->setQuery($query); $menuTypes = $db->loadObjectList(); // Check for a database error. if ($error = $db->getErrorMsg()) { JError::raiseWarning(500, $error); return false; } // Create a reverse lookup and aggregate the links. $rlu = array(); foreach ($menuTypes as &$type) { $rlu[$type->menutype] = &$type; $type->links = array(); } // Loop through the list of menu links. foreach ($links as &$link) { if (isset($rlu[$link->menutype])) { $rlu[$link->menutype]->links[] = &$link; // Cleanup garbage. unset($link->menutype); } } return $menuTypes; } else { return $links; } } static public function getAssociations($pk) { $associations = array(); $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->from('#__menu as m'); $query->innerJoin('#__associations as a ON a.id=m.id AND a.context='.$db->quote('com_menus.item')); $query->innerJoin('#__associations as a2 ON a.key=a2.key'); $query->innerJoin('#__menu as m2 ON a2.id=m2.id'); $query->where('m.id='.(int)$pk); $query->select('m2.language, m2.id'); $db->setQuery($query); $menuitems = $db->loadObjectList('language'); // Check for a database error. if ($error = $db->getErrorMsg()) { JError::raiseWarning(500, $error); return false; } foreach ($menuitems as $tag=>$item) { $associations[$tag] = $item->id; } return $associations; } } PKA>\Vhelpers/index.htmlnuW+A PKA>\{99 menus.phpnuW+Aauthorise('core.manage', 'com_menus')) { return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR')); } // Execute the task. $controller = JControllerLegacy::getInstance('Menus'); $controller->execute(JRequest::getCmd('task')); $controller->redirect(); PKA>\T menus.xmlnuW+A com_menus Joomla! Project April 2006 (C) 2005 - 2014 Open Source Matters. All rights reserved. GNU General Public License version 2 or later; see LICENSE.txt admin@joomla.org www.joomla.org 2.5.0 COM_MENUS_XML_DESCRIPTION config.xml controller.php index.html menus.php controllers helpers models views language/en-GB.com_menus.ini PKT>\jhOmenus/default.phpnuW+APKT>\Vmenus/index.htmlnuW+APKT>\)Rmenus/.htaccessnuW+APKT>\) .htaccessnuW+APKT>\)menu/.htaccessnuW+APKT>\cu $$ menu/edit.phpnuW+APKT>\Vmenu/index.htmlnuW+APKT>\VDitem/index.htmlnuW+APKT>\)item/.htaccessnuW+APKT>\ӂe e _item/edit_options.phpnuW+APKT>\,X((  +item/edit.phpnuW+APKT>\Vn?items/index.htmlnuW+APKT>\)?items/.htaccessnuW+APKT>\R `,`,@items/default.phpnuW+APKT>\V ,mindex.htmlnuW+APKA>\3hhmcontroller.phpnuW+APKA>\- +uviews/item/view.html.phpnuW+APKA>\dk;views/item/tmpl/edit.phpnuW+APKA>\ Yt `views/item/tmpl/edit_modules.phpnuW+APKA>\)views/item/tmpl/.htaccessnuW+APKA>\Vviews/item/tmpl/index.htmlnuW+APKA>\ /g g views/item/tmpl/edit_options.phpnuW+APKA>\Vviews/item/index.htmlnuW+APKA>\)views/item/.htaccessnuW+APKA>\)ɩviews/.htaccessnuW+APKA>\Vviews/menus/tmpl/index.htmlnuW+APKA>\views/menus/tmpl/default.phpnuW+APKA>\)Sviews/menus/tmpl/.htaccessnuW+APKA>\Vviews/menus/index.htmlnuW+APKA>\)views/menus/.htaccessnuW+APKA>\20Eviews/menus/view.html.phpnuW+APKA>\Vviews/items/index.htmlnuW+APKA>\"views/items/tmpl/default_batch.phpnuW+APKA>\Vviews/items/tmpl/index.htmlnuW+APKA>\i;))Cviews/items/tmpl/default.phpnuW+APKA>\);views/items/tmpl/.htaccessnuW+APKA>\)views/items/.htaccessnuW+APKA>\ҴǦviews/items/view.html.phpnuW+APKA>\wtWviews/menutypes/index.htmlnuW+APKA>\)views/menutypes/.htaccessnuW+APKA>\#H views/menutypes/tmpl/default.phpnuW+APKA>\)!views/menutypes/tmpl/.htaccessnuW+APKA>\wtW"views/menutypes/tmpl/index.htmlnuW+APKA>\m??0#views/menutypes/view.html.phpnuW+APKA>\V%views/index.htmlnuW+APKA>\)&views/menu/.htaccessnuW+APKA>\)&views/menu/tmpl/.htaccessnuW+APKA>\nA'views/menu/tmpl/edit.phpnuW+APKA>\V-views/menu/tmpl/index.htmlnuW+APKA>\V=.views/menu/index.htmlnuW+APKA>\.views/menu/view.html.phpnuW+APKA>\)6controllers/.htaccessnuW+APKA>\V7controllers/index.htmlnuW+APKA>\8controllers/menu.phpnuW+APKA>\: #Kcontrollers/items.phpnuW+APKA>\DDaWcontrollers/menus.phpnuW+APKA>\#1-1-hcontrollers/item.phpnuW+APKA>\V_tables/index.htmlnuW+APKA>\)tables/.htaccessnuW+APKA>\#z~tables/menu.phpnuW+APKA>\! access.xmlnuW+APKA>\x config.xmlnuW+APKA>\  \"\"models/items.phpnuW+APKA>\)7models/forms/.htaccessnuW+APKA>\Vmodels/forms/index.htmlnuW+APKA>\`bmodels/forms/item_separator.xmlnuW+APKA>\}C;models/forms/item.xmlnuW+APKA>\Q݅ models/forms/item_component.xmlnuW+APKA>\x|models/forms/item_url.xmlnuW+APKA>\&models/forms/item_alias.xmlnuW+APKA>\+{%%Qmodels/forms/menu.xmlnuW+APKA>\2-Q))models/menutypes.phpnuW+APKA>\nnmodels/menu.phpnuW+APKA>\)6models/.htaccessnuW+APKA>\V7models/index.htmlnuW+APKA>\,_`7models/item.phpnuW+APKA>\xl  models/menus.phpnuW+APKA>\V2models/fields/index.htmlnuW+APKA>\)models/fields/.htaccessnuW+APKA>\ Xׯ_models/fields/menutype.phpnuW+APKA>\7췈  Xmodels/fields/menuordering.phpnuW+APKA>\1sEEmodels/fields/menuparent.phpnuW+APKA>\)Thelpers/.htaccessnuW+APKA>\)helpers/html/.htaccessnuW+APKA>\+/lRhelpers/html/menus.phpnuW+APKA>\V helpers/html/index.htmlnuW+APKA>\3} helpers/menus.phpnuW+APKA>\Vd%helpers/index.htmlnuW+APKA>\{99 %menus.phpnuW+APKA>\T 7(menus.xmlnuW+APKZZG,