Source for file menu.php
Documentation is available at menu.php
* @package Joomla.Administrator
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* Menu Item Model for Menus.
* @package Joomla.Administrator
* @var string The prefix to use with controller messages.
* Method to test whether a record can be deleted.
* @param object A record object.
* @return boolean True if allowed to delete the record. Defaults to the permission set in the component.
return $user->authorise('core.delete', 'com_menus.menu.' . (int)
$record->id);
* Method to test whether a record can be deleted.
* @param object A record object.
* @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component.
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())
* Method to auto-populate the model state.
* Note. Calling getState in this method will result in recursion.
$id =
$app->input->getInt('id');
* Method to get a menu item.
* @param integer The id of the menu item to get.
* @return mixed Menu item data object on success, false on failure.
public function &getItem($itemId =
null)
$itemId =
(!empty($itemId)) ?
$itemId : (int)
$this->getState('menu.id');
// Get a menu item row instance.
// Attempt to load the row.
$return =
$table->load($itemId);
// Check for a table object error.
if ($return ===
false &&
$table->getError())
$properties =
$table->getProperties(1);
* 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
public function getForm($data =
array(), $loadData =
true)
$form =
$this->loadForm('com_menus.menu', 'menu', array('control' =>
'jform', 'load_data' =>
$loadData));
* Method to get the data that should be injected in the form.
* @return mixed The data for the form.
// Check the session for previously entered form 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');
// Load the row if saving an existing item.
if (!$table->bind($data))
* Method to delete groups.
* @param array An array of item ids.
* @return boolean Returns true on success, false on failure.
public function delete($itemIds)
$itemIds = (array)
$itemIds;
// Get a group row instance.
// Iterate the items to delete each one.
foreach ($itemIds as $itemId)
// TODO: Delete the menu associations - Menu items and Modules
if (!$table->delete($itemId))
* Gets a list of all mod_mainmenu modules and collates them by menutype
$query =
$db->getQuery(true)
->from('#__modules as a')
->select('a.id, a.title, a.params, a.position')
->where('module = ' .
$db->quote('mod_menu'))
->select('ag.title AS access_title')
->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access');
$modules =
$db->loadObjectList();
foreach ($modules as &$module)
$params->loadString($module->params);
$menuType =
$params->get('menutype');
if (!isset
($result[$menuType]))
$result[$menuType] =
array();
$result[$menuType][] =
& $module;
* Custom clean cache method
protected function cleanCache($group =
null, $client_id =
0)
parent::cleanCache('com_modules');
parent::cleanCache('mod_menu');
Documentation generated on Tue, 19 Nov 2013 15:07:53 +0100 by phpDocumentor 1.4.3