• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

Services/Form/classes/class.ilDurationInputGUI.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2007 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00031 class ilDurationInputGUI extends ilFormPropertyGUI
00032 {
00033         protected $days = 0;
00034         protected $hours = 0;
00035         protected $minutes = 0;
00036         protected $seconds = 0;
00037         protected $showdays = false;
00038         protected $showhours = true;
00039         protected $showminutes = true;
00040         protected $showseconds = false;
00041         
00048         function __construct($a_title = "", $a_postvar = "")
00049         {
00050                 parent::__construct($a_title, $a_postvar);
00051                 $this->setType("duration");
00052         }
00053 
00059         function setDays($a_days)
00060         {
00061                 $this->days = $a_days;
00062         }
00063 
00069         function getDays()
00070         {
00071                 return $this->days;
00072         }
00073 
00079         function setHours($a_hours)
00080         {
00081                 $this->hours = $a_hours;
00082         }
00083 
00089         function getHours()
00090         {
00091                 return $this->hours;
00092         }
00093 
00099         function setMinutes($a_minutes)
00100         {
00101                 $this->minutes = $a_minutes;
00102         }
00103 
00109         function getMinutes()
00110         {
00111                 return $this->minutes;
00112         }
00113 
00119         function setSeconds($a_seconds)
00120         {
00121                 $this->seconds = $a_seconds;
00122         }
00123 
00129         function getSeconds()
00130         {
00131                 return $this->seconds;
00132         }
00133 
00139         function setShowDays($a_showdays)
00140         {
00141                 $this->showdays = $a_showdays;
00142         }
00143 
00149         function getShowDays()
00150         {
00151                 return $this->showdays;
00152         }
00153 
00159         function setShowHours($a_showhours)
00160         {
00161                 $this->showhours = $a_showhours;
00162         }
00163 
00169         function getShowHours()
00170         {
00171                 return $this->showhours;
00172         }
00173 
00179         function setShowMinutes($a_showminutes)
00180         {
00181                 $this->showminutes = $a_showminutes;
00182         }
00183 
00189         function getShowMinutes()
00190         {
00191                 return $this->showminutes;
00192         }
00193 
00199         function setShowSeconds($a_showseconds)
00200         {
00201                 $this->showseconds = $a_showseconds;
00202         }
00203 
00209         function getShowSeconds()
00210         {
00211                 return $this->showseconds;
00212         }
00213 
00219         function setValueByArray($a_values)
00220         {
00221                 $this->setDays($a_values[$this->getPostVar()]["dd"]);
00222                 $this->setHours($a_values[$this->getPostVar()]["hh"]);
00223                 $this->setMinutes($a_values[$this->getPostVar()]["mm"]);
00224                 $this->setSeconds($a_values[$this->getPostVar()]["ss"]);
00225         }
00226 
00232         function checkInput()
00233         {
00234                 global $lng;
00235                 
00236                 $_POST[$this->getPostVar()]["dd"] = 
00237                         ilUtil::stripSlashes($_POST[$this->getPostVar()]["dd"]);
00238                 $_POST[$this->getPostVar()]["hh"] = 
00239                         ilUtil::stripSlashes($_POST[$this->getPostVar()]["hh"]);
00240                 $_POST[$this->getPostVar()]["mm"] = 
00241                         ilUtil::stripSlashes($_POST[$this->getPostVar()]["mm"]);
00242                 $_POST[$this->getPostVar()]["ss"] = 
00243                         ilUtil::stripSlashes($_POST[$this->getPostVar()]["ss"]);
00244 
00245                 return true;
00246         }
00247 
00252         function insert(&$a_tpl)
00253         {
00254                 global $lng;
00255                 
00256                 if ($this->getShowDays())
00257                 {
00258                         $a_tpl->setCurrentBlock("dur_days");
00259                         $a_tpl->setVariable("TXT_DAYS", $lng->txt("form_days"));
00260                         $val = array();
00261                         for ($i=0; $i<=366; $i++)
00262                         {
00263                                 $val[$i] = $i;
00264                         }
00265                         $a_tpl->setVariable("SELECT_DAYS",
00266                                 ilUtil::formSelect($this->getDays(), $this->getPostVar()."[dd]",
00267                                 $val, false, true));
00268                         $a_tpl->parseCurrentBlock();
00269                 }
00270                 if ($this->getShowHours())
00271                 {
00272                         $a_tpl->setCurrentBlock("dur_hours");
00273                         $a_tpl->setVariable("TXT_HOURS", $lng->txt("form_hours"));
00274                         $val = array();
00275                         for ($i=0; $i<=23; $i++)
00276                         {
00277                                 $val[$i] = $i;
00278                         }
00279                         $a_tpl->setVariable("SELECT_HOURS",
00280                                 ilUtil::formSelect($this->getHours(), $this->getPostVar()."[hh]",
00281                                 $val, false, true));
00282                         $a_tpl->parseCurrentBlock();
00283                 }
00284                 if ($this->getShowMinutes())
00285                 {
00286                         $a_tpl->setCurrentBlock("dur_minutes");
00287                         $a_tpl->setVariable("TXT_MINUTES", $lng->txt("form_minutes"));
00288                         $val = array();
00289                         for ($i=0; $i<=59; $i++)
00290                         {
00291                                 $val[$i] = $i;
00292                         }
00293                         $a_tpl->setVariable("SELECT_MINUTES",
00294                                 ilUtil::formSelect($this->getMinutes(), $this->getPostVar()."[mm]",
00295                                 $val, false, true));
00296                         $a_tpl->parseCurrentBlock();
00297                 }
00298                 if ($this->getShowSeconds())
00299                 {
00300                         $a_tpl->setCurrentBlock("dur_seconds");
00301                         $a_tpl->setVariable("TXT_SECONDS", $lng->txt("form_seconds"));
00302                         $val = array();
00303                         for ($i=0; $i<=59; $i++)
00304                         {
00305                                 $val[$i] = $i;
00306                         }
00307                         $a_tpl->setVariable("SELECT_SECONDS",
00308                                 ilUtil::formSelect($this->getSeconds(), $this->getPostVar()."[ss]",
00309                                 $val, false, true));
00310                         $a_tpl->parseCurrentBlock();
00311                 }
00312                 $a_tpl->setCurrentBlock("prop_duration");
00313                 $a_tpl->parseCurrentBlock();
00314         }
00315 
00316 }

Generated on Fri Dec 13 2013 17:56:57 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1