Source for file ordering.php

Documentation is available at ordering.php

  1. <?php
  2. /**
  3.  * @package    FrameworkOnFramework
  4.  * @subpackage form
  5.  * @copyright  Copyright (C) 2010 - 2012 Akeeba Ltd. All rights reserved.
  6.  * @license    GNU General Public License version 2 or later; see LICENSE.txt
  7.  */
  8. // Protect from unauthorized access
  9. defined('_JEXEC'or die;
  10.  
  11. /**
  12.  * Form Field class for FOF
  13.  * Renders the row ordering interface checkbox in browse views
  14.  *
  15.  * @package  FrameworkOnFramework
  16.  * @since    2.0
  17.  */
  18. class FOFFormFieldOrdering extends JFormField implements FOFFormField
  19. {
  20.     protected $static;
  21.  
  22.     protected $repeatable;
  23.  
  24.     /** @var   FOFTable  The item being rendered in a repeatable form field */
  25.     public $item;
  26.     
  27.     /** @var int A monotonically increasing number, denoting the row number in a repeatable view */
  28.     public $rowid;
  29.  
  30.     /**
  31.      * Method to get certain otherwise inaccessible properties from the form field object.
  32.      *
  33.      * @param   string  $name  The property name for which to the the value.
  34.      *
  35.      * @return  mixed  The property value or null.
  36.      *
  37.      * @since   2.0
  38.      */
  39.     public function __get($name)
  40.     {
  41.         switch ($name)
  42.         {
  43.             case 'static':
  44.                 if (empty($this->static))
  45.                 {
  46.                     $this->static = $this->getStatic();
  47.                 }
  48.  
  49.                 return $this->static;
  50.                 break;
  51.  
  52.             case 'repeatable':
  53.                 if (empty($this->repeatable))
  54.                 {
  55.                     $this->repeatable = $this->getRepeatable();
  56.                 }
  57.  
  58.                 return $this->static;
  59.                 break;
  60.  
  61.             default:
  62.                 return parent::__get($name);
  63.         }
  64.     }
  65.  
  66.     /**
  67.      * Method to get the field input markup for this field type.
  68.      *
  69.      * @since 2.0
  70.      *
  71.      * @return  string  The field input markup.
  72.      */
  73.     protected function getInput()
  74.     {
  75.         throw new Exception(__CLASS__ . ' cannot be used in input forms');
  76.     }
  77.  
  78.     /**
  79.      * Get the rendering of this field type for static display, e.g. in a single
  80.      * item view (typically a "read" task).
  81.      *
  82.      * @since 2.0
  83.      *
  84.      * @return  string  The field HTML
  85.      */
  86.     public function getStatic()
  87.     {
  88.         throw new Exception(__CLASS__ . ' cannot be used in single item display forms');
  89.     }
  90.  
  91.     /**
  92.      * Get the rendering of this field type for a repeatable (grid) display,
  93.      * e.g. in a view listing many item (typically a "browse" task)
  94.      *
  95.      * @since 2.0
  96.      *
  97.      * @return  string  The field HTML
  98.      */
  99.     public function getRepeatable()
  100.     {
  101.         if (!($this->item instanceof FOFTable))
  102.         {
  103.             throw new Exception(__CLASS__ . ' needs a FOFTable to act upon');
  104.         }
  105.  
  106.         $html '';
  107.  
  108.         $viewObject $this->form->getView();
  109.  
  110.         $ordering $viewObject->getLists()->order == 'ordering';
  111.  
  112.         if (!$viewObject->hasAjaxOrderingSupport())
  113.         {
  114.             // Ye olde Joomla! 2.5 method
  115.             $disabled $ordering '' 'disabled="disabled"';
  116.             $html .= '<span>';
  117.             $html .= $viewObject->pagination->orderUpIcon($this->rowidtrue'orderup''Move Up'$ordering);
  118.             $html .= '</span><span>';
  119.             $html .= $viewObject->pagination->orderDownIcon($this->rowid$viewObject->pagination->totaltrue'orderdown''Move Down'$ordering);
  120.             $html .= '</span>';
  121.             $html .= '<input type="text" name="order[]" size="5" value="' $this->value . '" ' $disabled;
  122.             $html .= 'class="text_area" style="text-align: center" />';
  123.         }
  124.         else
  125.         {
  126.             // The modern drag'n'drop method
  127.             if ($viewObject->getPerms()->editstate)
  128.             {
  129.                 $disableClassName '';
  130.                 $disabledLabel '';
  131.  
  132.                 $hasAjaxOrderingSupport $viewObject->hasAjaxOrderingSupport();
  133.  
  134.                 if (!$hasAjaxOrderingSupport['saveOrder'])
  135.                 {
  136.                     $disabledLabel JText::_('JORDERINGDISABLED');
  137.                     $disableClassName 'inactive tip-top';
  138.                 }
  139.  
  140.                 $html .= '<span class="sortable-handler ' $disableClassName '" title="' $disabledLabel '" rel="tooltip">';
  141.                 $html .= '<i class="icon-menu"></i>';
  142.                 $html .= '</span>';
  143.                 $html .= '<input type="text" style="display:none"  name="order[]" size="5"';
  144.                 $html .= 'value="' $this->value . '"  class="input-mini text-area-order " />';
  145.             }
  146.             else
  147.             {
  148.                 $html .= '<span class="sortable-handler inactive" >';
  149.                 $html .= '<i class="icon-menu"></i>';
  150.                 $html .= '</span>';
  151.             }
  152.         }
  153.  
  154.         return $html;
  155.     }
  156. }

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