Source for file imagelist.php

Documentation is available at imagelist.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. if (!class_exists('JFormFieldImagelist'))
  12. {
  13.     require_once JPATH_LIBRARIES '/joomla/form/fields/imagelist.php';
  14. }
  15.  
  16. /**
  17.  * Form Field class for the FOF framework
  18.  * Media selection field.
  19.  *
  20.  * @package  FrameworkOnFramework
  21.  * @since    2.0
  22.  */
  23. {
  24.     protected $static;
  25.  
  26.     protected $repeatable;
  27.     
  28.     /** @var   FOFTable  The item being rendered in a repeatable form field */
  29.     public $item;
  30.     
  31.     /** @var int A monotonically increasing number, denoting the row number in a repeatable view */
  32.     public $rowid;
  33.  
  34.     /**
  35.      * Method to get certain otherwise inaccessible properties from the form field object.
  36.      *
  37.      * @param   string  $name  The property name for which to the the value.
  38.      *
  39.      * @return  mixed  The property value or null.
  40.      *
  41.      * @since   2.0
  42.      */
  43.     public function __get($name)
  44.     {
  45.         switch ($name)
  46.         {
  47.             case 'static':
  48.                 if (empty($this->static))
  49.                 {
  50.                     $this->static = $this->getStatic();
  51.                 }
  52.  
  53.                 return $this->static;
  54.                 break;
  55.  
  56.             case 'repeatable':
  57.                 if (empty($this->repeatable))
  58.                 {
  59.                     $this->repeatable = $this->getRepeatable();
  60.                 }
  61.  
  62.                 return $this->static;
  63.                 break;
  64.  
  65.             default:
  66.                 return parent::__get($name);
  67.         }
  68.     }
  69.  
  70.     /**
  71.      * Get the rendering of this field type for static display, e.g. in a single
  72.      * item view (typically a "read" task).
  73.      *
  74.      * @since 2.0
  75.      *
  76.      * @return  string  The field HTML
  77.      */
  78.     public function getStatic()
  79.     {
  80.         $imgattr array(
  81.             'id' => $this->id
  82.         );
  83.  
  84.         if ($this->element['class'])
  85.         {
  86.             $imgattr['class'= (string) $this->element['class'];
  87.         }
  88.  
  89.         if ($this->element['style'])
  90.         {
  91.             $imgattr['style'= (string) $this->element['style'];
  92.         }
  93.  
  94.         if ($this->element['width'])
  95.         {
  96.             $imgattr['width'= (string) $this->element['width'];
  97.         }
  98.  
  99.         if ($this->element['height'])
  100.         {
  101.             $imgattr['height'= (string) $this->element['height'];
  102.         }
  103.  
  104.         if ($this->element['align'])
  105.         {
  106.             $imgattr['align'= (string) $this->element['align'];
  107.         }
  108.  
  109.         if ($this->element['rel'])
  110.         {
  111.             $imgattr['rel'= (string) $this->element['rel'];
  112.         }
  113.  
  114.         if ($this->element['alt'])
  115.         {
  116.             $alt JText::_((string) $this->element['alt']);
  117.         }
  118.         else
  119.         {
  120.             $alt null;
  121.         }
  122.  
  123.         if ($this->element['title'])
  124.         {
  125.             $imgattr['title'JText::_((string) $this->element['title']);
  126.         }
  127.  
  128.         $path = (string) $this->element['directory'];
  129.         $path trim($path'/' DIRECTORY_SEPARATOR);
  130.  
  131.         if ($this->value && file_exists(JPATH_ROOT '/' $path '/' $this->value))
  132.         {
  133.             $src JURI::root('/' $path '/' $this->value;
  134.         }
  135.         else
  136.         {
  137.             $src '';
  138.         }
  139.  
  140.         return JHtml::image($src$alt$imgattr);
  141.     }
  142.  
  143.     /**
  144.      * Get the rendering of this field type for a repeatable (grid) display,
  145.      * e.g. in a view listing many item (typically a "browse" task)
  146.      *
  147.      * @since 2.0
  148.      *
  149.      * @return  string  The field HTML
  150.      */
  151.     public function getRepeatable()
  152.     {
  153.         return $this->getStatic();
  154.     }
  155. }

Documentation generated on Tue, 19 Nov 2013 15:05:18 +0100 by phpDocumentor 1.4.3