Overview

Packages

  • Auth
  • Config
  • Controller
  • Date
  • Db
  • Feed
    • Abstract
    • Writers
  • File
    • Decorator
  • Form
    • Element
  • Image
  • Log
    • Writer
  • Net
    • Exception
  • None
  • PHP
  • PHPMailer
  • Session
  • Util
  • Validate
    • Validator
  • Zend
    • Registry

Classes

  • Form_Element_AutoCompleter
  • Form_Element_Checkbox
  • Form_Element_Colorpicker
  • Form_Element_Date
  • Form_Element_DatePicker
  • Form_Element_Email
  • Form_Element_File
  • Form_Element_Hidden
  • Form_Element_Html
  • Form_Element_Ip
  • Form_Element_Mac
  • Form_Element_Multi
  • Form_Element_NumericStepper
  • Form_Element_Password
  • Form_Element_Radio
  • Form_Element_Select
  • Form_Element_Slider
  • Form_Element_Submit
  • Form_Element_Text
  • Form_Element_Textarea
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Pry Framework
  4:  *
  5:  * LICENSE
  6:  *
  7:  * This source file is subject to the new BSD license that is bundled
  8:  * with this package in the file LICENSE.txt.
  9:  * 
 10:  * @version $Revision: 276 $
 11:  */
 12: 
 13: /**
 14:  *
 15:  * @category Pry
 16:  * @package Form
 17:  * @subpackage Form_Element
 18:  * @version 1.2.0
 19:  * @author Olivier ROGER <oroger.fr>
 20:  */
 21: class Form_Element_Slider extends Form_Element_Hidden
 22: {
 23:     
 24:     /**
 25:      * Limite haute du slider
 26:      *
 27:      * @var int
 28:      */
 29:     private $maxRange;
 30:     
 31:     /**
 32:      * Limite basse du slider
 33:      *
 34:      * @var int
 35:      */
 36:     private $minRange;
 37:     
 38:     /**
 39:      * Pas du slider
 40:      * @var int
 41:      */
 42:     private $step;
 43: 
 44:     /**
 45:      * Afficher la valeur du slider
 46:      * @var boolean
 47:      */
 48:     private $displayValue;
 49: 
 50:     private $unit;
 51: 
 52:     
 53:     /**
 54:      * Constructeur
 55:      *
 56:      * @param string $nom
 57:      * @param Form_Form $form
 58:      */
 59:     public function __construct($nom,$form)
 60:     {
 61:         parent::__construct($nom,$form);
 62:         $this->nom          = $nom;
 63:         $this->maxRange     = 100;
 64:         $this->minRange     = 0;
 65:         $this->start        = 0;
 66:         $this->step         = 1;
 67:         $this->displayValue = false;
 68:     }
 69:     
 70:     /**
 71:      * Défini le range du slider
 72:      *
 73:      * @param int $min
 74:      * @param int $max
 75:      * @return Form_Element_Slider
 76:      */
 77:     public function setRange($min,$max)
 78:     {
 79:         $this->maxRange = $max;
 80:         $this->minRange = $min;
 81:         return $this;
 82:     }
 83:     
 84:     /**
 85:      * Défini le pas du slider
 86:      * @param int $val
 87:      * @return Form_Element_Slider
 88:      */
 89:     public function step($val)
 90:     {
 91:         $this->step = $val;
 92:         return $this;
 93:     }
 94: 
 95:     /**
 96:      * Valeur de départ
 97:      * @param mixed $val
 98:      */
 99:     public function setStartValue($val)
100:     {
101:         $this->start = $val;
102:         return $this;
103:     }
104: 
105:     /**
106:      * Affiche ou non la valeur courante du slider
107:      * @param boolean $bool
108:      * @param string $unit Unité à afficher à coté de la valeur
109:      * @return Form_Element_Slider
110:      */
111:     public function displayValue($bool,$unit='%')
112:     {
113:         $this->displayValue = $bool;
114:         $this->unit = $unit;
115:         return $this;
116:     }
117:     
118:     public function __toString()
119:     {
120:         $css = $this->cssClass();
121:         $html = '';
122:         if(!empty($this->label))
123:         {
124:             $html .= "\t".'<label for="'.$this->attrs['id'].'" class="'.$this->cssLabel.'">'.$this->label.'</label>'."\n";
125:             if($this->labelNewLine)
126:                 $html.="\t".'<br />'."\n";
127:         }
128: 
129:         $value = $this->form->getPostedvalue($this->attrs['name']);
130:         if(empty($value))
131:             $value = $this->start;
132: 
133:         $html .= '<div id="prynslide_'.$this->nom.'"></div>';
134:         if($this->displayValue)
135:             $html .='<div id="prynslidedisp_'.$this->nom.'">'.$value.$this->unit.'</div>';
136: 
137:         $this->form->javascript.='$("#prynslide_'.$this->nom.'").slider({
138:             max : '.$this->maxRange.',
139:             min : '.$this->minRange.',
140:             step : '.$this->step.',
141:             value : '.$value.',
142:             change : function(event,ui){$("#'.$this->attrs['id'].'").val(ui.value)}';
143: 
144:         if($this->displayValue)
145:             $this->form->javascript.=',slide:function(event,ui){$("#prynslidedisp_'.$this->nom.'").html(ui.value+"%")}';
146: 
147:         $this->form->javascript.='});';
148:         $html.= parent::__toString();
149:         return $html;
150:     }
151: }
152:  ?>
Pry Framework API documentation generated by ApiGen 2.6.1