Source for file email.php

Documentation is available at email.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('JFormFieldEMail'))
  12. {
  13.     require_once JPATH_LIBRARIES '/joomla/form/fields/email.php';
  14. }
  15.  
  16. /**
  17.  * Form Field class for the FOF framework
  18.  * Supports a one line text field.
  19.  *
  20.  * @package  FrameworkOnFramework
  21.  * @since    2.0
  22.  */
  23. class FOFFormFieldEmail extends JFormFieldEMail implements FOFFormField
  24. {
  25.     protected $static;
  26.  
  27.     protected $repeatable;
  28.     
  29.     /** @var   FOFTable  The item being rendered in a repeatable form field */
  30.     public $item;
  31.     
  32.     /** @var int A monotonically increasing number, denoting the row number in a repeatable view */
  33.     public $rowid;
  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.         $dolink $this->element['show_link'== 'true';
  83.         $empty_replacement '';
  84.  
  85.         if ($this->element['empty_replacement'])
  86.         {
  87.             $empty_replacement = (string) $this->element['empty_replacement'];
  88.         }
  89.  
  90.         if (!empty($empty_replacement&& empty($this->value))
  91.         {
  92.             $this->value = JText::_($empty_replacement);
  93.         }
  94.  
  95.         $innerHtml htmlspecialchars($this->valueENT_COMPAT'UTF-8');
  96.  
  97.         if ($dolink)
  98.         {
  99.             $innerHtml '<a href="mailto:' $innerHtml '">' .
  100.                 $innerHtml '</a>';
  101.         }
  102.  
  103.         return '<span id="' $this->id . '" ' $class '>' .
  104.             $innerHtml .
  105.             '</span>';
  106.     }
  107.  
  108.     /**
  109.      * Get the rendering of this field type for a repeatable (grid) display,
  110.      * e.g. in a view listing many item (typically a "browse" task)
  111.      *
  112.      * @since 2.0
  113.      *
  114.      * @return  string  The field HTML
  115.      */
  116.     public function getRepeatable()
  117.     {
  118.         // Initialise
  119.         $class '';
  120.         $show_link false;
  121.         $link_url '';
  122.         $empty_replacement '';
  123.  
  124.         // Get field parameters
  125.         if ($this->element['class'])
  126.         {
  127.             $class = (string) $this->element['class'];
  128.         }
  129.  
  130.         if ($this->element['show_link'== 'true')
  131.         {
  132.             $show_link true;
  133.         }
  134.  
  135.         if ($this->element['url'])
  136.         {
  137.             $link_url $this->element['url'];
  138.         }
  139.         else
  140.         {
  141.             $link_url 'mailto:' htmlspecialchars($this->valueENT_COMPAT'UTF-8');
  142.         }
  143.  
  144.         if ($this->element['empty_replacement'])
  145.         {
  146.             $empty_replacement = (string) $this->element['empty_replacement'];
  147.         }
  148.  
  149.         // Get the (optionally formatted) value
  150.         if (!empty($empty_replacement&& empty($this->value))
  151.         {
  152.             $this->value = JText::_($empty_replacement);
  153.         }
  154.  
  155.         $value htmlspecialchars($this->valueENT_COMPAT'UTF-8');
  156.  
  157.         // Create the HTML
  158.         $html '<span class="' $this->id . ' ' $class '">';
  159.  
  160.         if ($show_link)
  161.         {
  162.             $html .= '<a href="' $link_url '">';
  163.         }
  164.  
  165.         $html .= $value;
  166.  
  167.         if ($show_link)
  168.         {
  169.             $html .= '</a>';
  170.         }
  171.  
  172.         $html .= '</span>';
  173.  
  174.         return $html;
  175.     }
  176. }

Documentation generated on Tue, 19 Nov 2013 15:02:27 +0100 by phpDocumentor 1.4.3