Source for file ordering.php

Documentation is available at ordering.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Libraries
  4.  * @subpackage  Form
  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.  * Form Field class for the Joomla Platform.
  14.  *
  15.  * @package     Joomla.Libraries
  16.  * @subpackage  Form
  17.  * @since       3.2
  18.  */
  19. {
  20.     /**
  21.      * The form field type.
  22.      *
  23.      * @var        string 
  24.      * @since   3.2
  25.      */
  26.     protected $type = 'Ordering';
  27.  
  28.     /**
  29.      * Method to get the field input markup.
  30.      *
  31.      * @return  string    The field input markup.
  32.      *
  33.      * @since   3.2
  34.      */
  35.     protected function getInput()
  36.     {
  37.         $html array();
  38.         $attr '';
  39.  
  40.         // Initialize some field attributes.
  41.         $attr .= $this->element['class'' class="' . (string) $this->element['class''"' '';
  42.         $attr .= ((string) $this->element['disabled'== 'true'' disabled="disabled"' '';
  43.         $attr .= $this->element['size'' size="' . (int) $this->element['size''"' '';
  44.  
  45.         // Initialize JavaScript field attributes.
  46.         $attr .= $this->element['onchange'' onchange="' . (string) $this->element['onchange''"' '';
  47.  
  48.         $itemId = (int) $this->getItemId();
  49.  
  50.         $query $this->getQuery();
  51.  
  52.         // Create a read-only list (no name) with a hidden input to store the value.
  53.         if ((string) $this->element['readonly'== 'true')
  54.         {
  55.             $html[JHtml::_('list.ordering'''$querytrim($attr)$this->value$itemId 1);
  56.             $html['<input type="hidden" name="' $this->name . '" value="' $this->value . '"/>';
  57.         }
  58.         else
  59.         {
  60.             // Create a regular list.
  61.             $html[JHtml::_('list.ordering'$this->name$querytrim($attr)$this->value$itemId 1);
  62.         }
  63.  
  64.         return implode($html);
  65.     }
  66.  
  67.     /**
  68.      * Builds the query for the ordering list.
  69.      *
  70.      * @return  JDatabaseQuery  The query for the ordering form field
  71.      *
  72.      * @since   3.2
  73.      */
  74.     protected function getQuery()
  75.     {
  76.         $categoryId    = (int) $this->form->getValue('catid');
  77.         $contentType = (string) $this->element['content_type'];
  78.  
  79.         $ucmType new JUcmType;
  80.         $ucmRow $ucmType->getType($ucmType->getTypeId($contentType));
  81.         $ucmMapCommon json_decode($ucmRow->field_mappings)->common;
  82.  
  83.         if (is_object($ucmMapCommon))
  84.         {
  85.             $ordering $ucmMapCommon->core_ordering;
  86.             $title $ucmMapCommon->core_title;
  87.         }
  88.         elseif (is_array($ucmMapCommon))
  89.         {
  90.             $ordering $ucmMapCommon[0]->core_ordering;
  91.             $title $ucmMapCommon[0]->core_title;
  92.         }
  93.  
  94.         $db JFactory::getDbo();
  95.         $query $db->getQuery(true);
  96.         $query->select(array($db->quoteName($ordering'value')$db->quoteName($title'text')))
  97.             ->from($db->quoteName(json_decode($ucmRow->table)->special->dbtable))
  98.             ->where($db->quoteName('catid'' = ' . (int) $categoryId)
  99.             ->order('ordering');
  100.  
  101.         return $query;
  102.     }
  103.  
  104.     /**
  105.      * Retrieves the current Item's Id.
  106.      *
  107.      * @return  integer  The current item ID
  108.      *
  109.      * @since   3.2
  110.      */
  111.     protected function getItemId()
  112.     {
  113.         return (int) $this->form->getValue('id');
  114.     }
  115. }

Documentation generated on Tue, 19 Nov 2013 15:09:54 +0100 by phpDocumentor 1.4.3