Source for file button.php

Documentation is available at button.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. /**
  13.  * Form Field class for the FOF framework
  14.  * Supports a button input.
  15.  *
  16.  * @package  FrameworkOnFramework
  17.  * @since    2.0
  18.  */
  19. class FOFFormFieldButton extends FOFFormFieldText implements FOFFormField
  20. {
  21.     protected $static;
  22.  
  23.     protected $repeatable;
  24.  
  25.     /**
  26.      * Method to get certain otherwise inaccessible properties from the form field object.
  27.      *
  28.      * @param   string  $name  The property name for which to the the value.
  29.      *
  30.      * @return  mixed  The property value or null.
  31.      *
  32.      * @since   2.0
  33.      */
  34.     public function __get($name)
  35.     {
  36.         switch ($name)
  37.         {
  38.             case 'static':
  39.                 if (empty($this->static))
  40.                 {
  41.                     $this->static = $this->getStatic();
  42.                 }
  43.  
  44.                 return $this->static;
  45.                 break;
  46.  
  47.             case 'repeatable':
  48.                 if (empty($this->repeatable))
  49.                 {
  50.                     $this->repeatable = $this->getRepeatable();
  51.                 }
  52.  
  53.                 return $this->static;
  54.                 break;
  55.  
  56.             default:
  57.                 return parent::__get($name);
  58.         }
  59.     }
  60.  
  61.     /**
  62.      * Get the rendering of this field type for static display, e.g. in a single
  63.      * item view (typically a "read" task).
  64.      *
  65.      * @since 2.0
  66.      *
  67.      * @return  string  The field HTML
  68.      */
  69.     public function getInput()
  70.     {
  71.         $this->label = '';
  72.  
  73.         $text $this->element['text'];
  74.         $class $this->element['class'? (string) $this->element['class''';
  75.         $icon $this->element['icon'? (string) $this->element['icon''';
  76.         $onclick $this->element['onclick''onclick="' . (string) $this->element['onclick''"' '';
  77.  
  78.         $this->value = JText::_($text);
  79.  
  80.         if ($icon)
  81.         {
  82.             $icon '<span class="icon ' $icon '"></span>';
  83.         }
  84.  
  85.         return '<button id="' $this->id . '" class="btn ' $class '" ' .
  86.             $onclick '>' .
  87.             $icon .
  88.             htmlspecialchars($this->valueENT_COMPAT'UTF-8'.
  89.             '</button>';
  90.     }
  91.  
  92.     /**
  93.      * Method to get the field title.
  94.      *
  95.      * @return  string  The field title.
  96.      */
  97.     protected function getTitle()
  98.     {
  99.         return null;
  100.     }
  101. }

Documentation generated on Tue, 19 Nov 2013 14:54:47 +0100 by phpDocumentor 1.4.3