ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 {
20  protected $lng;
21 
25  protected $ctrl;
26 
27  protected $letters;
28  protected $parent_object;
29  protected $parent_cmd;
30  protected $highlight;
31  protected $highlight_letter;
32 
36  protected $fix_db_umlauts = false;
37 
44  public function __construct($a_title = "", $a_postvar = "")
45  {
46  global $DIC;
47 
48  $this->lng = $DIC->language();
49  $this->ctrl = $DIC->ctrl();
50  parent::__construct($a_title, $a_postvar);
51  }
52 
58  public function setValue($a_value)
59  {
60  $this->value = $a_value;
61  }
62 
68  public function getValue()
69  {
70  return $this->value;
71  }
72 
73 
79  public function setValueByArray($a_values)
80  {
81  $this->setValue($a_values[$this->getPostVar()]);
82  }
83 
89  public function setLetters($a_val)
90  {
91  $this->letters = $a_val;
92  }
93 
99  public function getLetters()
100  {
101  return $this->letters;
102  }
103 
109  public function checkInput()
110  {
111  $lng = $this->lng;
112 
113  $_POST[$this->getPostVar()] = ilUtil::stripSlashes($_POST[$this->getPostVar()]);
114  if ($this->getRequired() && trim($_POST[$this->getPostVar()]) == "") {
115  $this->setAlert($lng->txt("msg_input_is_required"));
116 
117  return false;
118  }
119 
120  return true;
121  }
122 
128  public function setFixDBUmlauts($a_val)
129  {
130  $this->fix_db_umlauts = $a_val;
131  }
132 
138  public function getFixDBUmlauts()
139  {
140  return $this->fix_db_umlauts;
141  }
142 
149  public function fixDBUmlauts($l)
150  {
151  if ($this->fix_db_umlauts && !ilUtil::dbSupportsDisctinctUmlauts()) {
152  $l = str_replace(array("Ä", "Ö", "Ü", "ä", "ö", "ü"), array("A", "O", "U", "a", "o", "u"), $l);
153  }
154  return $l;
155  }
156 
157 
161  protected function render($a_mode = "")
162  {
163  die("only implemented for toolbar usage");
164  }
165 
171  // function insert($a_tpl)
172  // {
173  // $a_tpl->setCurrentBlock("prop_generic");
174  // $a_tpl->setVariable("PROP_GENERIC", "zz");
175  // $a_tpl->parseCurrentBlock();
176  // }
177 
184  public function setParentCommand($a_obj, $a_cmd)
185  {
186  $this->parent_object = $a_obj;
187  $this->parent_cmd = $a_cmd;
188  }
189 
196  public function setHighlighted($a_high_letter)
197  {
198  $this->highlight = true;
199  $this->highlight_letter = $a_high_letter;
200  }
201 
205  public function getToolbarHTML()
206  {
208  $lng = $this->lng;
209 
210  $lng->loadLanguageModule("form");
211 
212  $tpl = new ilTemplate("tpl.prop_alphabet.html", true, true, "Services/Form");
213  foreach ((array) $this->getLetters() as $l) {
214  $l = $this->fixDBUmlauts($l);
215  $tpl->setCurrentBlock("letter");
216  $tpl->setVariable("TXT_LET", $l);
217  $ilCtrl->setParameter($this->parent_object, "letter", rawurlencode($l));
218  $tpl->setVariable("TXT_LET", $l);
219  $tpl->setVariable("HREF_LET", $ilCtrl->getLinkTarget($this->parent_object, $this->parent_cmd));
220  if ($this->highlight && $this->highlight_letter !== null && $this->highlight_letter == $l) {
221  $tpl->setVariable("CLASS", ' class="ilHighlighted" ');
222  }
223  $tpl->parseCurrentBlock();
224  }
225  $ilCtrl->setParameter($this->parent_object, "letter", "");
226  $tpl->setVariable("TXT_ALL", $lng->txt("form_alphabet_all"));
227  $tpl->setVariable("HREF_ALL", $ilCtrl->getLinkTarget($this->parent_object, $this->parent_cmd));
228  if ($this->highlight && $this->highlight_letter === null) {
229  $tpl->setVariable("CLASSA", ' class="ilHighlighted" ');
230  }
231  return $tpl->get();
232  }
233 }
getFixDBUmlauts()
Get fix db umlauts.
global $DIC
Definition: saml.php:7
$tpl
Definition: ilias.php:10
getPostVar()
Get Post Variable.
fixDBUmlauts($l)
Fix db umlauts.
This class represents a text property in a property form.
Interface for property form input GUI classes that can be used in ilToolbarGUI.
checkInput()
Check input, strip slashes etc.
static dbSupportsDisctinctUmlauts()
Only temp fix for #8603, should go to db classes.
setHighlighted($a_high_letter)
Set highlighted.
setParentCommand($a_obj, $a_cmd)
Insert property html.
setAlert($a_alert)
Set Alert Text.
global $ilCtrl
Definition: ilias.php:18
setFixDBUmlauts($a_val)
Set fix db umlauts.
special template class to simplify handling of ITX/PEAR
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
Create styles array
The data for the language used.
__construct($a_title="", $a_postvar="")
Constructor.
global $l
Definition: afr.php:30
This class represents a property in a property form.
getLetters()
Get letters available.
getToolbarHTML()
Get HTML for toolbar.
setLetters($a_val)
Set letters available.
setValueByArray($a_values)
Set value by array.
render($a_mode="")
Render item.
setValue($a_value)
Set Value.
$_POST["username"]