From f7f29c4328fd9fbbd209056c24bd9502f17c88be Mon Sep 17 00:00:00 2001 From: Jean-Marie Simonet Date: Fri, 13 Nov 2015 09:49:47 +0100 Subject: [PATCH 1/7] Creating an All Menu dropdown --- .../com_menus/models/forms/filter_items.xml | 6 +++- .../components/com_menus/models/items.php | 30 +------------------ .../com_menus/views/items/tmpl/default.php | 6 ++++ .../language/en-GB/en-GB.com_menus.ini | 4 +++ .../language/en-GB/en-GB.mod_menu.ini | 1 + .../modules/mod_menu/tmpl/default_enabled.php | 4 +++ 6 files changed, 21 insertions(+), 30 deletions(-) diff --git a/administrator/components/com_menus/models/forms/filter_items.xml b/administrator/components/com_menus/models/forms/filter_items.xml index 8f4ec675b1fdd..0acc10b889546 100644 --- a/administrator/components/com_menus/models/forms/filter_items.xml +++ b/administrator/components/com_menus/models/forms/filter_items.xml @@ -6,7 +6,9 @@ label="COM_MENUS_FILTER_CATEGORY" description="JOPTION_FILTER_CATEGORY_DESC" onchange="this.form.submit();" - /> + > + + JSTATUS_DESC + + diff --git a/administrator/components/com_menus/models/items.php b/administrator/components/com_menus/models/items.php index 2fb817aa0b9f8..665a9e147869f 100644 --- a/administrator/components/com_menus/models/items.php +++ b/administrator/components/com_menus/models/items.php @@ -105,12 +105,7 @@ protected function populateState($ordering = null, $direction = null) } else { - $menuType = $app->getUserState($this->context . '.menutype'); - - if (!$menuType) - { - $menuType = $this->getDefaultMenuType(); - } + $app->setUserState($this->context . '.menutype', ''); } $this->setState('filter.menutype', $menuType); @@ -152,29 +147,6 @@ protected function getStoreId($id = '') 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. * diff --git a/administrator/components/com_menus/views/items/tmpl/default.php b/administrator/components/com_menus/views/items/tmpl/default.php index 48f0d9076dbee..ae1d70dc4cba9 100644 --- a/administrator/components/com_menus/views/items/tmpl/default.php +++ b/administrator/components/com_menus/views/items/tmpl/default.php @@ -68,6 +68,9 @@ + + + @@ -187,6 +190,9 @@ escape($item->item_type); ?> + + escape($item->menutype); ?> + type == 'component') : ?> language == '*' || $item->home == '0') : ?> diff --git a/administrator/language/en-GB/en-GB.com_menus.ini b/administrator/language/en-GB/en-GB.com_menus.ini index 99e63b6aee29e..ae72405d98de6 100644 --- a/administrator/language/en-GB/en-GB.com_menus.ini +++ b/administrator/language/en-GB/en-GB.com_menus.ini @@ -37,6 +37,9 @@ COM_MENUS_HEADING_HOME_ASC="Home ascending" COM_MENUS_HEADING_HOME_DESC="Home descending" COM_MENUS_HEADING_LEVELS="View level" COM_MENUS_HEADING_LINKED_MODULES="Linked Modules" +COM_MENUS_HEADING_MENU="Menu" +COM_MENUS_HEADING_MENU_ASC="Menu ascending" +COM_MENUS_HEADING_MENU_DESC="Menu descending" COM_MENUS_HEADING_NUMBER_MENU_ITEMS="Number of Menu Items" COM_MENUS_HEADING_POSITION="Position" COM_MENUS_HEADING_PUBLISHED_ITEMS="Published" @@ -158,6 +161,7 @@ COM_MENUS_NO_MENUS_SELECTED="No menu selected." COM_MENUS_OPTION_SELECT_LEVEL="- Select Max Levels -" COM_MENUS_REQUEST_FIELDSET_LABEL="Required Settings" COM_MENUS_SAVE_SUCCESS="Menu item successfully saved." +COM_MENUS_SELECT_MENU="- Select Menu -" COM_MENUS_SUBMENU_ITEMS="Menu Items" COM_MENUS_SUBMENU_MENUS="Menus" COM_MENUS_SUCCESS_REORDERED="Menu item successfully reordered." diff --git a/administrator/language/en-GB/en-GB.mod_menu.ini b/administrator/language/en-GB/en-GB.mod_menu.ini index a11697888da71..64d77dc5c40a6 100644 --- a/administrator/language/en-GB/en-GB.mod_menu.ini +++ b/administrator/language/en-GB/en-GB.mod_menu.ini @@ -71,6 +71,7 @@ MOD_MENU_LOGOUT="Logout" MOD_MENU_MASS_MAIL_USERS="Mass Mail Users" MOD_MENU_MEDIA_MANAGER="Media" MOD_MENU_MENUS="Menus" +MOD_MENU_MENUS_ALL_ITEMS="All Menu Items" MOD_MENU_MENU_MANAGER="Manage" MOD_MENU_MENU_MANAGER_NEW_MENU="Add New Menu" MOD_MENU_MENU_MANAGER_NEW_MENU_ITEM="Add New Menu Item" diff --git a/administrator/modules/mod_menu/tmpl/default_enabled.php b/administrator/modules/mod_menu/tmpl/default_enabled.php index 976052c51ceab..4c1b037eef5c4 100644 --- a/administrator/modules/mod_menu/tmpl/default_enabled.php +++ b/administrator/modules/mod_menu/tmpl/default_enabled.php @@ -137,6 +137,10 @@ $menu->addSeparator(); + $menu->addChild(new JMenuNode(JText::_('MOD_MENU_MENUS_ALL_ITEMS'), 'index.php?option=com_menus&view=items', 'class:menumgr'), $createMenu); + $menu->getParent(); + $menu->addSeparator(); + // Menu Types $menuTypes = ModMenuHelper::getMenus(); $menuTypes = JArrayHelper::sortObjects($menuTypes, 'title', 1, false); From 6180a90467dbab1c90f54a29a3a87121a09119d7 Mon Sep 17 00:00:00 2001 From: Jean-Marie Simonet Date: Fri, 13 Nov 2015 12:10:07 +0100 Subject: [PATCH 2/7] Do not display drag and drop for ordering when menu items from all menus are displayed --- .../com_menus/views/items/tmpl/default.php | 49 ++++++++++--------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/administrator/components/com_menus/views/items/tmpl/default.php b/administrator/components/com_menus/views/items/tmpl/default.php index ae1d70dc4cba9..ff955ec31ed35 100644 --- a/administrator/components/com_menus/views/items/tmpl/default.php +++ b/administrator/components/com_menus/views/items/tmpl/default.php @@ -32,6 +32,7 @@ } $assoc = JLanguageAssociations::isEnabled(); +$menuType = (array) $app->getUserState('com_menus.items.menutype'); ?> @@ -56,9 +57,11 @@ - + + + @@ -136,26 +139,28 @@ } ?> - + if (!$canChange) + { + $iconClass = ' inactive'; + } + elseif (!$saveOrder) + { + $iconClass = ' inactive tip-top hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + + + + + From cc9aa5b3c4408605631732e369cbae5d7ccadacb Mon Sep 17 00:00:00 2001 From: Jean-Marie Simonet Date: Fri, 13 Nov 2015 12:36:09 +0100 Subject: [PATCH 3/7] Do not display New and Batch when displaying all menu items for all menus --- .../com_menus/views/items/view.html.php | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/administrator/components/com_menus/views/items/view.html.php b/administrator/components/com_menus/views/items/view.html.php index 59b594104bbb2..a243f114d0596 100644 --- a/administrator/components/com_menus/views/items/view.html.php +++ b/administrator/components/com_menus/views/items/view.html.php @@ -238,15 +238,19 @@ protected function addToolbar() { $canDo = JHelperContent::getActions('com_menus'); $user = JFactory::getUser(); + $menuType = (array) JFactory::getApplication()->getUserState('com_menus.items.menutype'); // Get the toolbar object instance $bar = JToolbar::getInstance('toolbar'); JToolbarHelper::title(JText::_('COM_MENUS_VIEW_ITEMS_TITLE'), 'list menumgr'); - if ($canDo->get('core.create')) + if (!empty($menuType)) { - JToolbarHelper::addNew('item.add'); + if ($canDo->get('core.create')) + { + JToolbarHelper::addNew('item.add'); + } } if ($canDo->get('core.edit')) @@ -276,17 +280,20 @@ protected function addToolbar() } // Add a batch button - if ($user->authorise('core.create', 'com_menus') - && $user->authorise('core.edit', 'com_menus') - && $user->authorise('core.edit.state', 'com_menus')) + if (!empty($menuType)) { - $title = JText::_('JTOOLBAR_BATCH'); + if ($user->authorise('core.create', 'com_menus') + && $user->authorise('core.edit', 'com_menus') + && $user->authorise('core.edit.state', 'com_menus')) + { + $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); + // Instantiate a new JLayoutFile instance and render the batch button + $layout = new JLayoutFile('joomla.toolbar.batch'); - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); + $dhtml = $layout->render(array('title' => $title)); + $bar->appendButton('Custom', $dhtml, 'batch'); + } } if ($this->state->get('filter.published') == -2 && $canDo->get('core.delete')) From 4cc6fc65ea97c207cfa835402188608747a3b803 Mon Sep 17 00:00:00 2001 From: Jean-Marie Simonet Date: Sat, 14 Nov 2015 17:45:18 +0100 Subject: [PATCH 4/7] Reinstating New and Batch buttons --- .../components/com_menus/controllers/item.php | 7 ++- .../com_menus/models/forms/item.xml | 5 +- .../views/items/tmpl/default_batch_body.php | 62 ++++++++++--------- .../views/items/tmpl/default_batch_footer.php | 9 ++- .../com_menus/views/items/view.html.php | 27 +++----- .../language/en-GB/en-GB.com_menus.ini | 1 + 6 files changed, 61 insertions(+), 50 deletions(-) diff --git a/administrator/components/com_menus/controllers/item.php b/administrator/components/com_menus/controllers/item.php index 02781fb537c55..fd1c49490fe0c 100644 --- a/administrator/components/com_menus/controllers/item.php +++ b/administrator/components/com_menus/controllers/item.php @@ -86,6 +86,10 @@ public function cancel($key = null) // Clear the ancillary data from the session. $app->setUserState($context . '.type', null); $app->setUserState($context . '.link', null); + + // Redirect to the list screen. + $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list . $this->getRedirectToListAppend() + . '&menutype=' . $app->getUserState('com_menus.items.menutype'), false)); } return $result; @@ -326,7 +330,8 @@ public function save($key = null, $urlVar = 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)); + $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list . $this->getRedirectToListAppend() + . '&menutype=' . $app->getUserState('com_menus.items.menutype'), false)); break; } diff --git a/administrator/components/com_menus/models/forms/item.xml b/administrator/components/com_menus/models/forms/item.xml index 8ba474d827bdb..290acb27a6c8d 100644 --- a/administrator/components/com_menus/models/forms/item.xml +++ b/administrator/components/com_menus/models/forms/item.xml @@ -56,7 +56,10 @@ label="COM_MENUS_ITEM_FIELD_ASSIGNED_LABEL" description="COM_MENUS_ITEM_FIELD_ASSIGNED_DESC" required="true" - size="1" /> + size="1" + > + + state->get('filter.published'); +$menuType = (array) JFactory::getApplication()->getUserState('com_menus.items.menutype'); ?> - -
-
-
- -
-
-
-
- -
-
-
-
- = 0) : ?> -
- + +
+
- +
-
- - +
+
+ +
- -
\ No newline at end of file +
+
+ = 0) : ?> +
+ +
+ +
+
+
+ + +
+ +
+ +
+

+
+ \ No newline at end of file diff --git a/administrator/components/com_menus/views/items/tmpl/default_batch_footer.php b/administrator/components/com_menus/views/items/tmpl/default_batch_footer.php index f5f004c133320..5c5c146100520 100644 --- a/administrator/components/com_menus/views/items/tmpl/default_batch_footer.php +++ b/administrator/components/com_menus/views/items/tmpl/default_batch_footer.php @@ -8,10 +8,13 @@ */ defined('_JEXEC') or die; +$menuType = (array) JFactory::getApplication()->getUserState('com_menus.items.menutype'); ?> - \ No newline at end of file + + + diff --git a/administrator/components/com_menus/views/items/view.html.php b/administrator/components/com_menus/views/items/view.html.php index a243f114d0596..59b594104bbb2 100644 --- a/administrator/components/com_menus/views/items/view.html.php +++ b/administrator/components/com_menus/views/items/view.html.php @@ -238,19 +238,15 @@ protected function addToolbar() { $canDo = JHelperContent::getActions('com_menus'); $user = JFactory::getUser(); - $menuType = (array) JFactory::getApplication()->getUserState('com_menus.items.menutype'); // Get the toolbar object instance $bar = JToolbar::getInstance('toolbar'); JToolbarHelper::title(JText::_('COM_MENUS_VIEW_ITEMS_TITLE'), 'list menumgr'); - if (!empty($menuType)) + if ($canDo->get('core.create')) { - if ($canDo->get('core.create')) - { - JToolbarHelper::addNew('item.add'); - } + JToolbarHelper::addNew('item.add'); } if ($canDo->get('core.edit')) @@ -280,20 +276,17 @@ protected function addToolbar() } // Add a batch button - if (!empty($menuType)) + if ($user->authorise('core.create', 'com_menus') + && $user->authorise('core.edit', 'com_menus') + && $user->authorise('core.edit.state', 'com_menus')) { - if ($user->authorise('core.create', 'com_menus') - && $user->authorise('core.edit', 'com_menus') - && $user->authorise('core.edit.state', 'com_menus')) - { - $title = JText::_('JTOOLBAR_BATCH'); + $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); + // Instantiate a new JLayoutFile instance and render the batch button + $layout = new JLayoutFile('joomla.toolbar.batch'); - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } + $dhtml = $layout->render(array('title' => $title)); + $bar->appendButton('Custom', $dhtml, 'batch'); } if ($this->state->get('filter.published') == -2 && $canDo->get('core.delete')) diff --git a/administrator/language/en-GB/en-GB.com_menus.ini b/administrator/language/en-GB/en-GB.com_menus.ini index ae72405d98de6..8a13c72afbe0a 100644 --- a/administrator/language/en-GB/en-GB.com_menus.ini +++ b/administrator/language/en-GB/en-GB.com_menus.ini @@ -162,6 +162,7 @@ COM_MENUS_OPTION_SELECT_LEVEL="- Select Max Levels -" COM_MENUS_REQUEST_FIELDSET_LABEL="Required Settings" COM_MENUS_SAVE_SUCCESS="Menu item successfully saved." COM_MENUS_SELECT_MENU="- Select Menu -" +COM_MENUS_SELECT_MENU_FIRST="To use batch processing, please first select a Menu in the manager." COM_MENUS_SUBMENU_ITEMS="Menu Items" COM_MENUS_SUBMENU_MENUS="Menus" COM_MENUS_SUCCESS_REORDERED="Menu item successfully reordered." From 91522b9b9a12ac4b60099b26a30f278a495eb57a Mon Sep 17 00:00:00 2001 From: Jean-Marie Simonet Date: Sat, 14 Nov 2015 17:57:28 +0100 Subject: [PATCH 5/7] cs --- .../components/com_menus/controllers/item.php | 12 ++++++++---- .../views/items/tmpl/default_batch_body.php | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/administrator/components/com_menus/controllers/item.php b/administrator/components/com_menus/controllers/item.php index fd1c49490fe0c..5a547aa4e9323 100644 --- a/administrator/components/com_menus/controllers/item.php +++ b/administrator/components/com_menus/controllers/item.php @@ -88,8 +88,10 @@ public function cancel($key = null) $app->setUserState($context . '.link', null); // Redirect to the list screen. - $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list . $this->getRedirectToListAppend() - . '&menutype=' . $app->getUserState('com_menus.items.menutype'), false)); + $this->setRedirect( + JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list . $this->getRedirectToListAppend() + . '&menutype=' . $app->getUserState('com_menus.items.menutype'), false) + ); } return $result; @@ -330,8 +332,10 @@ public function save($key = null, $urlVar = 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() - . '&menutype=' . $app->getUserState('com_menus.items.menutype'), false)); + $this->setRedirect( + JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list . $this->getRedirectToListAppend() + . '&menutype=' . $app->getUserState('com_menus.items.menutype'), false) + ); break; } diff --git a/administrator/components/com_menus/views/items/tmpl/default_batch_body.php b/administrator/components/com_menus/views/items/tmpl/default_batch_body.php index 58153d3becfc1..3155711b300f7 100644 --- a/administrator/components/com_menus/views/items/tmpl/default_batch_body.php +++ b/administrator/components/com_menus/views/items/tmpl/default_batch_body.php @@ -51,4 +51,4 @@

- \ No newline at end of file + From 74b65c61f4e80d37c38b5453a491d025d452fba2 Mon Sep 17 00:00:00 2001 From: Jean-Marie Simonet Date: Sat, 14 Nov 2015 18:13:36 +0100 Subject: [PATCH 6/7] cs --- .../components/com_menus/controllers/item.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/administrator/components/com_menus/controllers/item.php b/administrator/components/com_menus/controllers/item.php index 5a547aa4e9323..48d6df694331d 100644 --- a/administrator/components/com_menus/controllers/item.php +++ b/administrator/components/com_menus/controllers/item.php @@ -89,8 +89,10 @@ public function cancel($key = null) // Redirect to the list screen. $this->setRedirect( - JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list . $this->getRedirectToListAppend() - . '&menutype=' . $app->getUserState('com_menus.items.menutype'), false) + JRoute::_( + 'index.php?option=' . $this->option . '&view=' . $this->view_list . $this->getRedirectToListAppend() + . '&menutype=' . $app->getUserState('com_menus.items.menutype'), false + ) ); } @@ -333,8 +335,10 @@ public function save($key = null, $urlVar = null) // Redirect to the list screen. $this->setRedirect( - JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list . $this->getRedirectToListAppend() - . '&menutype=' . $app->getUserState('com_menus.items.menutype'), false) + JRoute::_( + 'index.php?option=' . $this->option . '&view=' . $this->view_list . $this->getRedirectToListAppend() + . '&menutype=' . $app->getUserState('com_menus.items.menutype'), false + ) ); break; } From 25d76f484388b5cff4bc880dd77156d4dd9bd623 Mon Sep 17 00:00:00 2001 From: bertmert Date: Thu, 25 Feb 2016 21:28:25 +0100 Subject: [PATCH 7/7] Suppress drag and drop ordering --- .../components/com_menus/views/items/tmpl/default.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/administrator/components/com_menus/views/items/tmpl/default.php b/administrator/components/com_menus/views/items/tmpl/default.php index ff955ec31ed35..eed69494aca13 100644 --- a/administrator/components/com_menus/views/items/tmpl/default.php +++ b/administrator/components/com_menus/views/items/tmpl/default.php @@ -24,15 +24,15 @@ $ordering = ($listOrder == 'a.lft'); $canOrder = $user->authorise('core.edit.state', 'com_menus'); $saveOrder = ($listOrder == 'a.lft' && strtolower($listDirn) == 'asc'); +$menuType = (array) $app->getUserState('com_menus.items.menutype'); -if ($saveOrder) +if ($saveOrder && !empty($menuType)) { $saveOrderingUrl = 'index.php?option=com_menus&task=items.saveOrderAjax&tmpl=component'; JHtml::_('sortablelist.sortable', 'itemList', 'adminForm', strtolower($listDirn), $saveOrderingUrl, false, true); } $assoc = JLanguageAssociations::isEnabled(); -$menuType = (array) $app->getUserState('com_menus.items.menutype'); ?>
- - + +
- + + - - - - - - - id); ?>