ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
class.ilProgressBar.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
3
12{
13 protected $min; // [int]
14 protected $max; // [int]
15 protected $current; // [int]
16 protected $show_caption; // [bool]
17 protected $type; // [int]
18 protected $caption; // [text]
19 protected $striped; // [bool]
20 protected $animated; // [bool]
21
22 const TYPE_INFO = 1;
23 const TYPE_SUCCESS = 2;
24 const TYPE_WARNING = 3;
25 const TYPE_DANGER = 4;
26
32 protected function __construct()
33 {
34 $this->setMin(0);
35 $this->setMax(100);
36 $this->setShowCaption(true);
37 $this->setType(self::TYPE_INFO);
38 $this->setStriped(true);
39 }
40
46 public static function getInstance()
47 {
48 return new self();
49 }
50
51
52 //
53 // properties
54 //
55
61 protected function setType($a_value)
62 {
63 $valid = array(
64 self::TYPE_INFO
65 ,self::TYPE_SUCCESS
66 ,self::TYPE_WARNING
67 ,self::TYPE_DANGER
68 );
69 if(in_array($a_value, $valid))
70 {
71 $this->type = $a_value;
72 }
73 }
74
80 public function setMin($a_value)
81 {
82 $this->min = abs((int)$a_value);
83 }
84
90 public function setMax($a_value)
91 {
92 $this->max = abs((int)$a_value);
93 }
94
100 public function setCaption($a_value)
101 {
102 $this->caption = trim($a_value);
103 }
104
110 public function setShowCaption($a_value)
111 {
112 $this->show_caption = (bool)$a_value;
113 }
114
120 public function setStriped($a_value)
121 {
122 $this->striped = (bool)$a_value;
123 }
124
130 public function setAnimated($a_value)
131 {
132 $this->animated = (bool)$a_value;
133 }
134
140 public function setCurrent($a_value)
141 {
142 $this->current = abs($a_value);
143 }
144
145
146 //
147 // presentation
148 //
149
155 public function render()
156 {
157 $tpl = new ilTemplate("tpl.il_progress.html", true, true, "Services/UIComponent/ProgressBar");
158
159 $tpl->setVariable("MIN", $this->min);
160 $tpl->setVariable("MAX", $this->max);
161 $tpl->setVariable("CURRENT_INT", round($this->current));
162 $tpl->setVariable("CURRENT", round($this->current));
163 $tpl->setVariable("CAPTION", $this->caption);
164
165 $map = array(
166 self::TYPE_INFO => "info"
167 ,self::TYPE_SUCCESS => "success"
168 ,self::TYPE_WARNING => "warning"
169 ,self::TYPE_DANGER => "danger"
170 );
171 $css = array("progress-bar-".$map[$this->type]);
172
173 if($this->striped)
174 {
175 $css[] = "progress-bar-striped";
176 }
177
178 if($this->animated)
179 {
180 $css[] = "active";
181 }
182
183 $tpl->setVariable("CSS", implode(" ", $css));
184
185 if(!$this->show_caption)
186 {
187 $tpl->touchBlock("hide_caption_in_bl");
188 $tpl->touchBlock("hide_caption_out_bl");
189 }
190
191 return $tpl->get();
192 }
193}
global $tpl
Definition: ilias.php:8
setCaption($a_value)
Set Caption.
static getInstance()
Factory.
setMin($a_value)
Set minimum value.
setType($a_value)
Set type (currently unwanted)
__construct()
Constructor.
setShowCaption($a_value)
Toggle show caption status.
setCurrent($a_value)
Set current value.
setStriped($a_value)
Toggle striped layout.
setMax($a_value)
Set maximum value.
setAnimated($a_value)
Toggle animated layout.
special template class to simplify handling of ITX/PEAR
$valid