ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilAlphabetInputGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once("./Services/Form/classes/class.ilFormPropertyGUI.php");
6 include_once 'Services/UIComponent/Toolbar/interfaces/interface.ilToolbarItem.php';
7 
16 {
17  protected $letters;
18  protected $parent_object;
19  protected $parent_cmd;
20  protected $highlight;
21  protected $highlight_letter;
22 
29  function __construct($a_title = "", $a_postvar = "")
30  {
31  parent::__construct($a_title, $a_postvar);
32  }
33 
39  function setValue($a_value)
40  {
41  $this->value = $a_value;
42  }
43 
49  function getValue()
50  {
51  return $this->value;
52  }
53 
54 
60  function setValueByArray($a_values)
61  {
62  $this->setValue($a_values[$this->getPostVar()]);
63  }
64 
70  function setLetters($a_val)
71  {
72  $this->letters = $a_val;
73  }
74 
80  function getLetters()
81  {
82  return $this->letters;
83  }
84 
90  function checkInput()
91  {
92  global $lng;
93 
95  if ($this->getRequired() && trim($_POST[$this->getPostVar()]) == "")
96  {
97  $this->setAlert($lng->txt("msg_input_is_required"));
98 
99  return false;
100  }
101 
102  return true;
103  }
104 
108  protected function render($a_mode = "")
109  {
110  die("only implemented for toolbar usage");
111  }
112 
118 // function insert(&$a_tpl)
119 // {
120 // $a_tpl->setCurrentBlock("prop_generic");
121 // $a_tpl->setVariable("PROP_GENERIC", "zz");
122 // $a_tpl->parseCurrentBlock();
123 // }
124 
131  function setParentCommand($a_obj, $a_cmd)
132  {
133  $this->parent_object = $a_obj;
134  $this->parent_cmd = $a_cmd;
135  }
136 
143  function setHighlighted($a_high_letter)
144  {
145  $this->highlight = true;
146  $this->highlight_letter = $a_high_letter;
147  }
148 
152  function getToolbarHTML()
153  {
154  global $ilCtrl, $lng;
155 
156  $lng->loadLanguageModule("form");
157 
158  $tpl = new ilTemplate("tpl.prop_alphabet.html", true, true, "Services/Form");
159  foreach ((array)$this->getLetters() as $l)
160  {
161  $tpl->setCurrentBlock("letter");
162  $tpl->setVariable("TXT_LET", $l);
163  $ilCtrl->setParameter($this->parent_object, "letter", rawurlencode($l));
164  $tpl->setVariable("TXT_LET", $l);
165  $tpl->setVariable("HREF_LET", $ilCtrl->getLinkTarget($this->parent_object, $this->parent_cmd));
166  if ($this->highlight && $this->highlight_letter !== null && $this->highlight_letter == $l)
167  {
168  $tpl->setVariable("CLASS", ' class="ilHighlighted" ');
169  }
170  $tpl->parseCurrentBlock();
171  }
172  $ilCtrl->setParameter($this->parent_object, "letter", "");
173  $tpl->setVariable("TXT_ALL", $lng->txt("form_alphabet_all"));
174  $tpl->setVariable("HREF_ALL", $ilCtrl->getLinkTarget($this->parent_object, $this->parent_cmd));
175  if ($this->highlight && $this->highlight_letter === null)
176  {
177  $tpl->setVariable("CLASSA", ' class="ilHighlighted" ');
178  }
179  return $tpl->get();
180  }
181 
182 }
183 ?>