| [ Index ] |
PHP Cross Reference of Joomla 2.5.4 DE |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved. 4 * @license GNU General Public License version 2 or later; see LICENSE.txt 5 */ 6 7 defined('JPATH_BASE') or die; 8 9 JFormHelper::loadFieldClass('list'); 10 11 /** 12 * Form Field class for the Joomla Framework. 13 * 14 * @package Joomla.Administrator 15 * @subpackage com_menus 16 * @since 1.6 17 */ 18 class JFormFieldMenuParent extends JFormFieldList 19 { 20 /** 21 * The form field type. 22 * 23 * @var string 24 * @since 1.6 25 */ 26 protected $type = 'MenuParent'; 27 28 /** 29 * Method to get the field options. 30 * 31 * @return array The field option objects. 32 * @since 1.6 33 */ 34 protected function getOptions() 35 { 36 // Initialize variables. 37 $options = array(); 38 39 $db = JFactory::getDbo(); 40 $query = $db->getQuery(true); 41 42 $query->select('a.id AS value, a.title AS text, a.level'); 43 $query->from('#__menu AS a'); 44 $query->join('LEFT', $db->quoteName('#__menu').' AS b ON a.lft > b.lft AND a.rgt < b.rgt'); 45 46 if ($menuType = $this->form->getValue('menutype')) { 47 $query->where('a.menutype = '.$db->quote($menuType)); 48 } 49 else { 50 $query->where('a.menutype != '.$db->quote('')); 51 } 52 53 // Prevent parenting to children of this item. 54 if ($id = $this->form->getValue('id')) { 55 $query->join('LEFT', $db->quoteName('#__menu').' AS p ON p.id = '.(int) $id); 56 $query->where('NOT(a.lft >= p.lft AND a.rgt <= p.rgt)'); 57 } 58 59 $query->where('a.published != -2'); 60 $query->group('a.id, a.title, a.level, a.lft, a.rgt, a.menutype, a.parent_id, a.published'); 61 $query->order('a.lft ASC'); 62 63 // Get the options. 64 $db->setQuery($query); 65 66 $options = $db->loadObjectList(); 67 68 // Check for a database error. 69 if ($db->getErrorNum()) { 70 JError::raiseWarning(500, $db->getErrorMsg()); 71 } 72 73 // Pad the option text with spaces using depth level as a multiplier. 74 for ($i = 0, $n = count($options); $i < $n; $i++) { 75 $options[$i]->text = str_repeat('- ', $options[$i]->level).$options[$i]->text; 76 } 77 78 // Merge any additional options in the XML definition. 79 $options = array_merge(parent::getOptions(), $options); 80 81 return $options; 82 } 83 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Tue Apr 3 11:40:28 2012 | Cross-referenced by PHPXref 0.7.1 |