Overview

Namespaces

  • None
  • PHP
  • Pry
    • Auth
      • Interfaces
    • Config
    • Controller
    • Date
    • Db
    • Feed
      • Abstracts
      • Writers
    • File
      • Decorator
    • Form
      • Element
    • Image
    • Log
      • Writer
    • Net
      • Exception
    • Session
    • Util
    • Validate
      • Validator
    • View

Classes

  • AutoCompleter
  • Checkbox
  • Colorpicker
  • Date
  • DatePicker
  • Email
  • File
  • Hidden
  • Html
  • Ip
  • Mac
  • Multi
  • NumericStepper
  • Password
  • Radio
  • Select
  • Slider
  • Submit
  • Text
  • Textarea
  • Overview
  • Namespace
  • Class
  • Tree
  1: <?php
  2: 
  3: /**
  4:  * Pry Framework
  5:  *
  6:  * LICENSE
  7:  *
  8:  * This source file is subject to the new BSD license that is bundled
  9:  * with this package in the file LICENSE.txt.
 10:  * 
 11:  */
 12: 
 13: namespace Pry\Form\Element;
 14: 
 15: /**
 16:  *
 17:  * @category Pry
 18:  * @package Form
 19:  * @subpackage Form_Element
 20:  * @version 1.2.0
 21:  * @author Olivier ROGER <oroger.fr>
 22:  */
 23: class Slider extends Hidden
 24: {
 25: 
 26:     /**
 27:      * Limite haute du slider
 28:      *
 29:      * @var int
 30:      */
 31:     private $maxRange;
 32: 
 33:     /**
 34:      * Limite basse du slider
 35:      *
 36:      * @var int
 37:      */
 38:     private $minRange;
 39: 
 40:     /**
 41:      * Pas du slider
 42:      * @var int
 43:      */
 44:     private $step;
 45: 
 46:     /**
 47:      * Afficher la valeur du slider
 48:      * @var boolean
 49:      */
 50:     private $displayValue;
 51:     private $unit;
 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: }
153: 
154: ?>
Pry API documentation generated by ApiGen 2.8.0