Source for file fieldsearchable.php

Documentation is available at fieldsearchable.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.  * Generic field header, with text input (search) filter
  13.  *
  14.  * @package  FrameworkOnFramework
  15.  * @since    2.0
  16.  */
  17. {
  18.     /**
  19.      * Get the filter field
  20.      *
  21.      * @return  string  The HTML
  22.      */
  23.     protected function getFilter()
  24.     {
  25.         // Initialize some field attributes.
  26.         $size        = $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';
  27.         $maxLength   = $this->element['maxlength'] ? ' maxlength="' . (int) $this->element['maxlength'] . '"' : '';
  28.         $filterclass = $this->element['filterclass'] ? ' class="' . (string) $this->element['filterclass'] . '"' : '';
  29.         $placeholder = $this->element['placeholder'] ? $this->element['placeholder'] : $this->getLabel();
  30.         $name        = $this->element['searchfieldname'] ? $this->element['searchfieldname'] : $this->name;
  31.         $placeholder = 'placeholder="' . JText::_($placeholder) . '"';
  32.  
  33.         if ($this->element['searchfieldname'])
  34.         {
  35.             $model       = $this->form->getModel();
  36.             $searchvalue = $model->getState((string) $this->element['searchfieldname']);
  37.         }
  38.         else
  39.         {
  40.             $searchvalue = $this->value;
  41.         }
  42.  
  43.         // Initialize JavaScript field attributes.
  44.         if ($this->element['onchange'])
  45.         {
  46.             $onchange = ' onchange="' . (string) $this->element['onchange'] . '"';
  47.         }
  48.         else
  49.         {
  50.             $onchange = ' onchange="document.adminForm.submit();"';
  51.         }
  52.  
  53.         return '<input type="text" name="' . $name . '" id="' . $this->id . '"' . ' value="'
  54.             . htmlspecialchars($searchvalue, ENT_COMPAT, 'UTF-8') . '"' . $filterclass . $size . $placeholder . $onchange . $maxLength . '/>';
  55.     }
  56.  
  57.     /**
  58.      * Get the buttons HTML code
  59.      *
  60.      * @return  string  The HTML
  61.      */
  62.     protected function getButtons()
  63.     {
  64.         $buttonclass = $this->element['buttonclass'] ? (string) $this->element['buttonclass'] : 'btn hasTip hasTooltip';
  65.         $buttonsState = strtolower($this->element['buttons']);
  66.         $show_buttons = !in_array($buttonsState, array('no', 'false', '0'));
  67.  
  68.         if (!$show_buttons)
  69.         {
  70.             return '';
  71.         }
  72.  
  73.         $html = '';
  74.  
  75.         $html .= '<button class="' . $buttonclass . '" onclick="this.form.submit();" title="' . JText::_('JSEARCH_FILTER') . '" >' . "\n";
  76.         $html .= '<i class="icon-search"></i>';
  77.         $html .= '</button>' . "\n";
  78.         $html .= '<button class="' . $buttonclass . '" onclick="document.adminForm.' . $this->id . '.value=\'\';this.form.submit();" title="' . JText::_('JSEARCH_RESET') . '">' . "\n";
  79.         $html .= '<i class="icon-remove"></i>';
  80.         $html .= '</button>' . "\n";
  81.  
  82.         return $html;
  83.     }
  84. }

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