Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00031 class ilSelectInputGUI extends ilSubEnabledFormPropertyGUI
00032 {
00033 protected $options;
00034 protected $value;
00035
00042 function __construct($a_title = "", $a_postvar = "")
00043 {
00044 parent::__construct($a_title, $a_postvar);
00045 $this->setType("select");
00046 }
00047
00053 function setOptions($a_options)
00054 {
00055 $this->options = $a_options;
00056 }
00057
00063 function getOptions()
00064 {
00065 return $this->options;
00066 }
00067
00073 function setValue($a_value)
00074 {
00075 $this->value = $a_value;
00076 }
00077
00083 function getValue()
00084 {
00085 return $this->value;
00086 }
00087
00093 function setValueByArray($a_values)
00094 {
00095 $this->setValue($a_values[$this->getPostVar()]);
00096 }
00097
00103 function checkInput()
00104 {
00105 global $lng;
00106
00107 $_POST[$this->getPostVar()] =
00108 ilUtil::stripSlashes($_POST[$this->getPostVar()]);
00109 if ($this->getRequired() && trim($_POST[$this->getPostVar()]) == "")
00110 {
00111 $this->setAlert($lng->txt("msg_input_is_required"));
00112
00113 return false;
00114 }
00115 return $this->checkSubItemsInput();
00116 }
00117
00123 function insert(&$a_tpl)
00124 {
00125 foreach($this->getOptions() as $option_value => $option_text)
00126 {
00127 $a_tpl->setCurrentBlock("prop_select_option");
00128 $a_tpl->setVariable("VAL_SELECT_OPTION", $option_value);
00129 if ($option_value == $this->getValue())
00130 {
00131 $a_tpl->setVariable("CHK_SEL_OPTION",
00132 'selected="selected"');
00133 }
00134 $a_tpl->setVariable("TXT_SELECT_OPTION", $option_text);
00135 $a_tpl->parseCurrentBlock();
00136 }
00137 $a_tpl->setCurrentBlock("prop_select");
00138 $a_tpl->setVariable("POST_VAR", $this->getPostVar());
00139 if ($this->getDisabled())
00140 {
00141 $a_tpl->setVariable("DISABLED",
00142 " disabled=\"disabled\"");
00143 }
00144 $a_tpl->parseCurrentBlock();
00145 }
00146
00147 }