Source for file accesslevel.php

Documentation is available at accesslevel.php

  1. <?php
  2. /**
  3.  * @package    FrameworkOnFramework
  4.  * @subpackage form
  5.  * @subpackage form
  6.  * @copyright  Copyright (C) 2010 - 2012 Akeeba Ltd. All rights reserved.
  7.  * @license    GNU General Public License version 2 or later; see LICENSE.txt
  8.  */
  9. // Protect from unauthorized access
  10. defined('_JEXEC'or die;
  11.  
  12. if (!class_exists('JFormFieldAccessLevel'))
  13. {
  14.     require_once JPATH_LIBRARIES '/joomla/form/fields/accesslevel.php';
  15. }
  16.  
  17. /**
  18.  * Form Field class for FOF
  19.  * Joomla! access levels
  20.  *
  21.  * @package  FrameworkOnFramework
  22.  * @since    2.0
  23.  */
  24. {
  25.     protected $static;
  26.  
  27.     protected $repeatable;
  28.     
  29.     /** @var int A monotonically increasing number, denoting the row number in a repeatable view */
  30.     public $rowid;
  31.     
  32.     /** @var   FOFTable  The item being rendered in a repeatable form field */
  33.     public $item;
  34.  
  35.     /**
  36.      * Method to get certain otherwise inaccessible properties from the form field object.
  37.      *
  38.      * @param   string  $name  The property name for which to the the value.
  39.      *
  40.      * @return  mixed  The property value or null.
  41.      *
  42.      * @since   2.0
  43.      */
  44.     public function __get($name)
  45.     {
  46.         switch ($name)
  47.         {
  48.             case 'static':
  49.                 if (empty($this->static))
  50.                 {
  51.                     $this->static = $this->getStatic();
  52.                 }
  53.  
  54.                 return $this->static;
  55.                 break;
  56.  
  57.             case 'repeatable':
  58.                 if (empty($this->repeatable))
  59.                 {
  60.                     $this->repeatable = $this->getRepeatable();
  61.                 }
  62.  
  63.                 return $this->static;
  64.                 break;
  65.  
  66.             default:
  67.                 return parent::__get($name);
  68.         }
  69.     }
  70.  
  71.     /**
  72.      * Get the rendering of this field type for static display, e.g. in a single
  73.      * item view (typically a "read" task).
  74.      *
  75.      * @since 2.0
  76.      *
  77.      * @return  string  The field HTML
  78.      */
  79.     public function getStatic()
  80.     {
  81.         $class $this->element['class'' class="' . (string) $this->element['class''"' '';
  82.  
  83.         $params $this->getOptions();
  84.  
  85.         $db JFactory::getDbo();
  86.         $query $db->getQuery(true);
  87.  
  88.         $query->select('a.id AS value, a.title AS text');
  89.         $query->from('#__viewlevels AS a');
  90.         $query->group('a.id, a.title, a.ordering');
  91.         $query->order('a.ordering ASC');
  92.         $query->order($query->qn('title'' ASC');
  93.  
  94.         // Get the options.
  95.         $db->setQuery($query);
  96.         $options $db->loadObjectList();
  97.  
  98.         // If params is an array, push these options to the array
  99.         if (is_array($params))
  100.         {
  101.             $options array_merge($params$options);
  102.         }
  103.  
  104.         // If all levels is allowed, push it into the array.
  105.         elseif ($params)
  106.         {
  107.             array_unshift($optionsJHtml::_('select.option'''JText::_('JOPTION_ACCESS_SHOW_ALL_LEVELS')));
  108.         }
  109.  
  110.         return '<span id="' $this->id . '" ' $class '>' .
  111.             htmlspecialchars(FOFFormFieldList::getOptionName($options$this->value)ENT_COMPAT'UTF-8'.
  112.             '</span>';
  113.     }
  114.  
  115.     /**
  116.      * Get the rendering of this field type for a repeatable (grid) display,
  117.      * e.g. in a view listing many item (typically a "browse" task)
  118.      *
  119.      * @since 2.0
  120.      *
  121.      * @return  string  The field HTML
  122.      */
  123.     public function getRepeatable()
  124.     {
  125.         $class $this->element['class'? (string) $this->element['class''';
  126.  
  127.         $params $this->getOptions();
  128.  
  129.         $db JFactory::getDbo();
  130.         $query $db->getQuery(true);
  131.  
  132.         $query->select('a.id AS value, a.title AS text');
  133.         $query->from('#__viewlevels AS a');
  134.         $query->group('a.id, a.title, a.ordering');
  135.         $query->order('a.ordering ASC');
  136.         $query->order($query->qn('title'' ASC');
  137.  
  138.         // Get the options.
  139.         $db->setQuery($query);
  140.         $options $db->loadObjectList();
  141.  
  142.         // If params is an array, push these options to the array
  143.         if (is_array($params))
  144.         {
  145.             $options array_merge($params$options);
  146.         }
  147.  
  148.         // If all levels is allowed, push it into the array.
  149.         elseif ($params)
  150.         {
  151.             array_unshift($optionsJHtml::_('select.option'''JText::_('JOPTION_ACCESS_SHOW_ALL_LEVELS')));
  152.         }
  153.  
  154.         return '<span class="' $this->id . ' ' $class '">' .
  155.             htmlspecialchars(FOFFormFieldList::getOptionName($options$this->value)ENT_COMPAT'UTF-8'.
  156.             '</span>';
  157.     }
  158. }

Documentation generated on Tue, 19 Nov 2013 14:53:17 +0100 by phpDocumentor 1.4.3