ILIAS  release_8 Revision v8.24
class.ilAlphabetInputGUI.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
27{
28 private string $value = "";
29 protected array $letters = [];
30 protected object $parent_object;
31 protected string $parent_cmd = "";
32 protected bool $highlight = false;
33 protected string $highlight_letter = "";
34 protected bool $fix_db_umlauts = false;
35 protected ?bool $db_supports_distinct_umlauts = null;
36 protected ilDBInterface $db;
37
38 public function __construct(
39 string $a_title = "",
40 string $a_postvar = ""
41 ) {
42 global $DIC;
43
44 $this->lng = $DIC->language();
45 $this->ctrl = $DIC->ctrl();
46 $this->db = $DIC->database();
47 parent::__construct($a_title, $a_postvar);
48 }
49
54 private function dbSupportsDisctinctUmlauts(): ?bool
55 {
56 if (!isset($this->db_supports_distinct_umlauts)) {
57 $set = $this->db->query(
58 "SELECT (" . $this->db->quote("A", "text") . " = " . $this->db->quote("Ä", "text") . ") t FROM DUAL "
59 );
60 $rec = $this->db->fetchAssoc($set);
61 $this->db_supports_distinct_umlauts = !(bool) $rec["t"];
62 }
63
65 }
66
67 public function setValue(string $a_value): void
68 {
69 $this->value = $a_value;
70 }
71
72 public function getValue(): string
73 {
74 return $this->value;
75 }
76
77 public function setValueByArray(array $a_values): void
78 {
79 $this->setValue($a_values[$this->getPostVar()]);
80 }
81
82 public function setLetters(array $a_val): void
83 {
84 $this->letters = $a_val;
85 }
86
87 public function getLetters(): array
88 {
89 return $this->letters;
90 }
91
92 public function checkInput(): bool
93 {
95
96 if ($this->getRequired() && trim($this->str($this->getPostVar())) == "") {
97 $this->setAlert($lng->txt("msg_input_is_required"));
98 return false;
99 }
100
101 return true;
102 }
103
104 public function getInput(): string
105 {
106 return $this->str($this->getPostVar());
107 }
108
109 public function setFixDBUmlauts(bool $a_val): void
110 {
111 $this->fix_db_umlauts = $a_val;
112 }
113
114 public function getFixDBUmlauts(): bool
115 {
117 }
118
119 public function fixDBUmlauts(string $l): string
120 {
121 if ($this->fix_db_umlauts && !$this->dbSupportsDisctinctUmlauts()) {
122 $l = str_replace(array("Ä", "Ö", "Ü", "ä", "ö", "ü"), array("A", "O", "U", "a", "o", "u"), $l);
123 }
124 return $l;
125 }
126
127
128 protected function render(string $a_mode = ""): string
129 {
130 return "";
131 }
132
133 public function setParentCommand(
134 object $a_obj,
135 string $a_cmd
136 ): void {
137 $this->parent_object = $a_obj;
138 $this->parent_cmd = $a_cmd;
139 }
140
141 public function setHighlighted(
142 string $a_high_letter
143 ): void {
144 $this->highlight = ($a_high_letter != "");
145 $this->highlight_letter = $a_high_letter;
146 }
147
148 public function getToolbarHTML(): string
149 {
150 $ilCtrl = $this->ctrl;
152
153 $lng->loadLanguageModule("form");
154
155 $tpl = new ilTemplate("tpl.prop_alphabet.html", true, true, "Services/Form");
156 foreach ($this->getLetters() as $l) {
157 if (is_null($l)) {
158 continue;
159 }
160 $l = $this->fixDBUmlauts($l);
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 $tpl->setVariable("CLASS", ' class="ilHighlighted" ');
168 }
169 $tpl->parseCurrentBlock();
170 }
171 $ilCtrl->setParameter($this->parent_object, "letter", "");
172 $tpl->setVariable("TXT_ALL", $lng->txt("form_alphabet_all"));
173 $tpl->setVariable("HREF_ALL", $ilCtrl->getLinkTarget($this->parent_object, $this->parent_cmd));
174 if ($this->highlight && $this->highlight_letter === null) {
175 $tpl->setVariable("CLASSA", ' class="ilHighlighted" ');
176 }
177 return $tpl->get();
178 }
179}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setParentCommand(object $a_obj, string $a_cmd)
__construct(string $a_title="", string $a_postvar="")
setValueByArray(array $a_values)
getToolbarHTML()
Get input item HTML to be inserted into ilToolbarGUI.
checkInput()
Check input, strip slashes etc.
setHighlighted(string $a_high_letter)
dbSupportsDisctinctUmlauts()
Only temp fix for #8603, should go to db classes.
This class represents a property in a property form.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
special template class to simplify handling of ITX/PEAR
global $DIC
Definition: feed.php:28
Interface ilDBInterface.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$lng