| [ 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 JFormFieldMenuOrdering extends JFormFieldList 19 { 20 /** 21 * The form field type. 22 * 23 * @var string 24 * @since 1.7 25 */ 26 protected $type = 'MenuOrdering'; 27 28 /** 29 * Method to get the list of siblings in a menu. 30 * The method requires that parent be set. 31 * 32 * @return array The field option objects or false if the parent field has not been set 33 * @since 1.7 34 */ 35 protected function getOptions() 36 { 37 // Initialize variables. 38 $options = array(); 39 40 // Get the parent 41 $parent_id = $this->form->getValue('parent_id', 0); 42 if ( empty($parent_id)) 43 { 44 return false; 45 } 46 $db = JFactory::getDbo(); 47 $query = $db->getQuery(true); 48 49 $query->select('a.id AS value, a.title AS text'); 50 $query->from('#__menu AS a'); 51 52 $query->where('a.published >= 0'); 53 $query->where('a.parent_id =' . (int) $parent_id); 54 if ($menuType = $this->form->getValue('menutype')) { 55 $query->where('a.menutype = '.$db->quote($menuType)); 56 } 57 else { 58 $query->where('a.menutype != '.$db->quote('')); 59 } 60 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 $options = array_merge( 74 array(array ('value' =>'-1', 'text'=>JText::_('COM_MENUS_ITEM_FIELD_ORDERING_VALUE_FIRST'))), 75 $options, 76 array(array( 'value' =>'-2', 'text'=>JText::_('COM_MENUS_ITEM_FIELD_ORDERING_VALUE_LAST'))) 77 ); 78 79 // Merge any additional options in the XML definition. 80 $options = array_merge(parent::getOptions(), $options); 81 82 return $options; 83 } 84 /** 85 * Method to get the field input markup 86 * 87 * @return string The field input markup. 88 * @since 1.7 89 */ 90 protected function getInput() 91 { 92 if ($this->form->getValue('id', 0) == 0) 93 { 94 return '<span class="readonly">' . JText::_('COM_MENUS_ITEM_FIELD_ORDERING_TEXT') . '</span>'; 95 } 96 else 97 { 98 return parent::getInput(); 99 } 100 } 101 }
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 |