ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilDurationInputGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2007 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
32 {
33  protected $months = 0;
34  protected $days = 0;
35  protected $hours = 0;
36  protected $minutes = 0;
37  protected $seconds = 0;
38  protected $showmonths = false;
39  protected $showdays = false;
40  protected $showhours = true;
41  protected $showminutes = true;
42  protected $showseconds = false;
43 
50  function __construct($a_title = "", $a_postvar = "")
51  {
52  parent::__construct($a_title, $a_postvar);
53  $this->setType("duration");
54  }
55 
61  function setDays($a_days)
62  {
63  $this->days = $a_days;
64  }
65 
71  function getDays()
72  {
73  return $this->days;
74  }
75 
81  function setHours($a_hours)
82  {
83  $this->hours = $a_hours;
84  }
85 
91  function getHours()
92  {
93  return $this->hours;
94  }
95 
101  function setMinutes($a_minutes)
102  {
103  $this->minutes = $a_minutes;
104  }
105 
111  function getMinutes()
112  {
113  return $this->minutes;
114  }
115 
121  function setSeconds($a_seconds)
122  {
123  $this->seconds = $a_seconds;
124  }
125 
133  public function setMonths($a_months)
134  {
135  $this->months = $a_months;
136  }
137 
144  public function getMonths()
145  {
146  return $this->months;
147  }
148 
154  function getSeconds()
155  {
156  return $this->seconds;
157  }
158 
165  public function setShowMonths($a_show_months)
166  {
167  $this->showmonths = $a_show_months;
168  }
169 
175  public function getShowMonths()
176  {
177  return $this->showmonths;
178  }
179 
185  function setShowDays($a_showdays)
186  {
187  $this->showdays = $a_showdays;
188  }
189 
195  function getShowDays()
196  {
197  return $this->showdays;
198  }
199 
205  function setShowHours($a_showhours)
206  {
207  $this->showhours = $a_showhours;
208  }
209 
215  function getShowHours()
216  {
217  return $this->showhours;
218  }
219 
225  function setShowMinutes($a_showminutes)
226  {
227  $this->showminutes = $a_showminutes;
228  }
229 
235  function getShowMinutes()
236  {
237  return $this->showminutes;
238  }
239 
245  function setShowSeconds($a_showseconds)
246  {
247  $this->showseconds = $a_showseconds;
248  }
249 
255  function getShowSeconds()
256  {
257  return $this->showseconds;
258  }
259 
265  function setValueByArray($a_values)
266  {
267  $this->setMonths($a_values[$this->getPostVar()]["MM"]);
268  $this->setDays($a_values[$this->getPostVar()]["dd"]);
269  $this->setHours($a_values[$this->getPostVar()]["hh"]);
270  $this->setMinutes($a_values[$this->getPostVar()]["mm"]);
271  $this->setSeconds($a_values[$this->getPostVar()]["ss"]);
272  }
273 
279  function checkInput()
280  {
281  global $lng;
282 
283  $_POST[$this->getPostVar()]["MM"] =
284  ilUtil::stripSlashes($_POST[$this->getPostVar()]["MM"]);
285  $_POST[$this->getPostVar()]["dd"] =
286  ilUtil::stripSlashes($_POST[$this->getPostVar()]["dd"]);
287  $_POST[$this->getPostVar()]["hh"] =
288  ilUtil::stripSlashes($_POST[$this->getPostVar()]["hh"]);
289  $_POST[$this->getPostVar()]["mm"] =
290  ilUtil::stripSlashes($_POST[$this->getPostVar()]["mm"]);
291  $_POST[$this->getPostVar()]["ss"] =
292  ilUtil::stripSlashes($_POST[$this->getPostVar()]["ss"]);
293 
294  return true;
295  }
296 
301  function insert(&$a_tpl)
302  {
303  global $lng;
304 
305  if($this->getShowMonths())
306  {
307  $a_tpl->setCurrentBlock("dur_months");
308  $a_tpl->setVariable("TXT_MONTHS", $lng->txt("form_months"));
309  $val = array();
310  for ($i=0; $i<=36; $i++)
311  {
312  $val[$i] = $i;
313  }
314  $a_tpl->setVariable("SELECT_MONTHS",
315  ilUtil::formSelect($this->getMonths(), $this->getPostVar()."[MM]",
316  $val, false, true));
317  $a_tpl->parseCurrentBlock();
318  }
319  if ($this->getShowDays())
320  {
321  $a_tpl->setCurrentBlock("dur_days");
322  $a_tpl->setVariable("TXT_DAYS", $lng->txt("form_days"));
323  $val = array();
324  for ($i=0; $i<=366; $i++)
325  {
326  $val[$i] = $i;
327  }
328  $a_tpl->setVariable("SELECT_DAYS",
329  ilUtil::formSelect($this->getDays(), $this->getPostVar()."[dd]",
330  $val, false, true));
331  $a_tpl->parseCurrentBlock();
332  }
333  if ($this->getShowHours())
334  {
335  $a_tpl->setCurrentBlock("dur_hours");
336  $a_tpl->setVariable("TXT_HOURS", $lng->txt("form_hours"));
337  $val = array();
338  for ($i=0; $i<=23; $i++)
339  {
340  $val[$i] = $i;
341  }
342  $a_tpl->setVariable("SELECT_HOURS",
343  ilUtil::formSelect($this->getHours(), $this->getPostVar()."[hh]",
344  $val, false, true));
345  $a_tpl->parseCurrentBlock();
346  }
347  if ($this->getShowMinutes())
348  {
349  $a_tpl->setCurrentBlock("dur_minutes");
350  $a_tpl->setVariable("TXT_MINUTES", $lng->txt("form_minutes"));
351  $val = array();
352  for ($i=0; $i<=59; $i++)
353  {
354  $val[$i] = $i;
355  }
356  $a_tpl->setVariable("SELECT_MINUTES",
357  ilUtil::formSelect($this->getMinutes(), $this->getPostVar()."[mm]",
358  $val, false, true));
359  $a_tpl->parseCurrentBlock();
360  }
361  if ($this->getShowSeconds())
362  {
363  $a_tpl->setCurrentBlock("dur_seconds");
364  $a_tpl->setVariable("TXT_SECONDS", $lng->txt("form_seconds"));
365  $val = array();
366  for ($i=0; $i<=59; $i++)
367  {
368  $val[$i] = $i;
369  }
370  $a_tpl->setVariable("SELECT_SECONDS",
371  ilUtil::formSelect($this->getSeconds(), $this->getPostVar()."[ss]",
372  $val, false, true));
373  $a_tpl->parseCurrentBlock();
374  }
375  $a_tpl->setCurrentBlock("prop_duration");
376  $a_tpl->parseCurrentBlock();
377  }
378 
379 }