Source for file menuordering.php

Documentation is available at menuordering.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Administrator
  4.  * @subpackage  com_menus
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE.txt
  8.  */
  9.  
  10. defined('JPATH_BASE'or die;
  11.  
  12.  
  13. /**
  14.  * Form Field class for the Joomla Framework.
  15.  *
  16.  * @package     Joomla.Administrator
  17.  * @subpackage  com_menus
  18.  * @since       1.6
  19.  */
  20. {
  21.     /**
  22.      * The form field type.
  23.      *
  24.      * @var        string 
  25.      * @since   1.7
  26.      */
  27.     protected $type = 'MenuOrdering';
  28.  
  29.     /**
  30.      * Method to get the list of siblings in a menu.
  31.      * The method requires that parent be set.
  32.      *
  33.      * @return  array  The field option objects or false if the parent field has not been set
  34.      * @since   1.7
  35.      */
  36.     protected function getOptions()
  37.     {
  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.             ->select('a.id AS value, a.title AS text')
  49.             ->from('#__menu AS a')
  50.  
  51.             ->where('a.published >= 0')
  52.             ->where('a.parent_id =' . (int) $parent_id);
  53.         if ($menuType $this->form->getValue('menutype'))
  54.         {
  55.             $query->where('a.menutype = ' $db->quote($menuType));
  56.         }
  57.         else
  58.         {
  59.             $query->where('a.menutype != ' $db->quote(''));
  60.         }
  61.  
  62.         $query->order('a.lft ASC');
  63.  
  64.         // Get the options.
  65.         $db->setQuery($query);
  66.  
  67.         try
  68.         {
  69.             $options $db->loadObjectList();
  70.         }
  71.         catch (RuntimeException $e)
  72.         {
  73.             JError::raiseWarning(500$e->getMessage());
  74.         }
  75.  
  76.         $options array_merge(
  77.             array(array('value' => '-1''text' => JText::_('COM_MENUS_ITEM_FIELD_ORDERING_VALUE_FIRST'))),
  78.             $options,
  79.             array(array('value' => '-2''text' => JText::_('COM_MENUS_ITEM_FIELD_ORDERING_VALUE_LAST')))
  80.         );
  81.  
  82.         // Merge any additional options in the XML definition.
  83.         $options array_merge(parent::getOptions()$options);
  84.  
  85.         return $options;
  86.     }
  87.  
  88.     /**
  89.      * Method to get the field input markup
  90.      *
  91.      * @return  string  The field input markup.
  92.      * @since   1.7
  93.      */
  94.     protected function getInput()
  95.     {
  96.         if ($this->form->getValue('id'0== 0)
  97.         {
  98.             return '<span class="readonly">' JText::_('COM_MENUS_ITEM_FIELD_ORDERING_TEXT''</span>';
  99.         }
  100.         else
  101.         {
  102.             return parent::getInput();
  103.         }
  104.     }
  105. }

Documentation generated on Tue, 19 Nov 2013 15:07:57 +0100 by phpDocumentor 1.4.3