phpMv  -UI toolkit 2.4.12
jQuery, jQuery UI, Twitter Bootstrap and Semantic-UI library for php & php MVC Frameworks
HtmlProgressbar.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Ajax\bootstrap\html;
4 
6 use Ajax\JsUtils;
7 
10 
12  protected $value;
13  protected $max;
14  protected $min;
15  protected $striped="";
16  protected $active;
17  protected $caption;
18  protected $stacked=false;
19  protected $style="";
20  protected $styleLimits=null;
21 
22  public function __construct($identifier, $style="info", $value=0, $max=100, $min=0) {
23  parent::__construct($identifier);
24  $this->_template=include 'templates/tplProgressbar.php';
25  $this->value=$value;
26  $this->min=$min;
27  $this->max=$max;
28  $this->setStyle($style);
29  }
30 
31  public function setActive($value) {
32  if(\is_array($this->content)){
33  foreach ($this->content as $pb){
34  $pb->setActive($value);
35  }
36  }else{
37  if ($value===true)
38  $this->active="active";
39  else
40  $this->active="";
41  }
42  return $this;
43  }
44 
45  public function setStriped($value) {
46  if(\is_array($this->content)){
47  foreach ($this->content as $pb){
48  $pb->setStriped($value);
49  }
50  }else{
51  if ($value===true)
52  $this->striped="progress-bar-striped";
53  else
54  $this->striped="";
55  }
56  return $this;
57  }
58 
59  public function showCaption($value) {
60  if(\is_array($this->content)){
61  foreach ($this->content as $pb){
62  $pb->showCaption($value);
63  }
64  }else{
65  if ($value===true)
66  $this->caption="%value%%";
67  else
68  $this->caption='<span class="sr-only">%value%% Complete (%style%)</span>';
69  }
70  return $this;
71  }
72 
73  public function getValue() {
74  return $this->value;
75  }
76 
77  public function stack(HtmlProgressbar $progressBar) {
78  $this->_template='%content%';
79  $progressBar->setStacked(true);
80  $progressBar->showCaption($this->caption=="%value%%");
81  $progressBar->setStriped($this->striped!=="" || $progressBar->isStriped());
82  $progressBar->setActive($this->active==="active" || $progressBar->isActive());
83  if (!is_array($this->content)) {
84  $this->content=array ();
85  }
86  $this->content []=$progressBar;
87  }
88 
89  public function setValue($value) {
90  $this->value=$value;
91  return $this;
92  }
93 
94  public function getMax() {
95  return $this->max;
96  }
97 
98  public function setMax($max) {
99  $this->max=$max;
100  return $this;
101  }
102 
103  public function getMin() {
104  return $this->min;
105  }
106 
107  public function setMin($min) {
108  $this->min=$min;
109  return $this;
110  }
111 
112  public function getStacked() {
113  return $this->stacked;
114  }
115 
116  public function setStacked($stacked) {
117  $this->stacked=$stacked;
118  return $this;
119  }
120 
127  public function setStyle($cssStyle) {
128  return $this->setMemberCtrl($this->style,CssRef::getStyle($cssStyle, "progress-bar"), CssRef::Styles("progress-bar"));
129  }
130 
131  /*
132  * (non-PHPdoc)
133  * @see \Ajax\bootstrap\html\base\BaseHtml::compile()
134  */
135  public function compile(JsUtils $js=NULL, &$view=NULL) {
136  $actualStyle=$this->style;
137  if(isset($this->styleLimits)&& JArray::isAssociative($this->styleLimits)){
138  foreach ($this->styleLimits as $k=>$v){
139  $actualStyle=$k;
140  if($v>$this->value)
141  break;
142  }
143  }
144  $this->style=$actualStyle;
145  $this->_template=str_replace("%caption%", $this->caption, $this->_template);
146  if ($this->getStacked()===false) {
147  $this->wrap('<div class="progress">', '</div>');
148  }
149  return parent::compile($js, $view);
150  }
151 
152  public function isStriped() {
153  return $this->striped;
154  }
155 
156  public function isActive() {
157  return $this->active;
158  }
159 
160  /* (non-PHPdoc)
161  * @see \Ajax\bootstrap\html\base\BaseHtml::fromDatabaseObject()
162  */
163  public function fromDatabaseObject($object, $function) {
164  $this->stack($function($object));
165  }
166 
167  public function getStyleLimits() {
168  return $this->styleLimits;
169  }
170 
177  public function setStyleLimits($styleLimits) {
178  $this->styleLimits=$styleLimits;
179  return $this;
180  }
181 
182 }
setStyle($cssStyle)
define the progressbar style avaible values : "success","info","warning","danger" ...
wrap($before, $after="")
Definition: BaseHtml.php:171
stack(HtmlProgressbar $progressBar)
compile(JsUtils $js=NULL, &$view=NULL)
__construct($identifier, $style="info", $value=0, $max=100, $min=0)
static isAssociative($array)
Definition: JArray.php:6
setMemberCtrl(&$name, $value, $typeCtrl)
Definition: BaseHtml.php:76
static Styles($prefix="btn")
Definition: CssRef.php:27
JQuery PHP library.
Definition: JsUtils.php:23
setStyleLimits($styleLimits)
Permet de modifier le style de la progressbar à partir de sa valeur actuelle $styleLimits est de la f...
static getStyle($cssStyle, $prefix)
return a valid style avaible values : "default","primary","success","info","warning","danger"
Definition: CssRef.php:346