ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilGloAdvColSortInputGUI.php
Go to the documentation of this file.
1 <?php
2 
27 {
28  private \ILIAS\Repository\InternalGUIService $gui;
29  protected array $value;
30 
31  public function __construct(
32  string $a_title = "",
33  string $a_id = ""
34  ) {
35  global $DIC;
36 
37  $this->lng = $DIC->language();
38  parent::__construct($a_title, $a_id);
39  $this->setType("glo_adv_col_sort");
40  // temp workaround
41  $this->gui = $DIC->repository()->internal()->gui();
42  }
43 
44  public function setValue(array $a_value): void
45  {
46  $this->value = $a_value;
47  }
48 
49  public function getValue(): array
50  {
51  return $this->value;
52  }
53 
54 
58  public function checkInput(): bool
59  {
60  return true;
61  }
62 
63  public function getInput(): array
64  {
65  $val = $this->arrayArray($this->getPostVar());
67  return $val;
68  }
69 
70  public function render(): string
71  {
72  $lng = $this->lng;
73  $up = $this->gui->symbol()->glyph("up")->render();
74  $down = $this->gui->symbol()->glyph("down")->render();
75 
76  $tpl = new ilTemplate("tpl.adv_col_sort_input.html", true, true, "components/ILIAS/Glossary");
77  if (is_array($this->getValue())) {
78  foreach ($this->getValue() as $k => $v) {
79  $tpl->setCurrentBlock("item");
80  $tpl->setVariable("TEXT", $v["text"]);
81  $tpl->setVariable("ID", $this->getFieldId() . "~" . $k);
82  $tpl->setVariable("DOWN", $down);
83  $tpl->setVariable("TXT_DOWN", $lng->txt("down"));
84  $tpl->setVariable("UP", $up);
85  $tpl->setVariable("TXT_UP", $lng->txt("up"));
86  $tpl->setVariable('NAME', $this->getPostVar() . "[" . $k . "][id]");
87  $tpl->setVariable('TNAME', $this->getPostVar() . "[" . $k . "][text]");
88  $tpl->setVariable('VAL', ilLegacyFormElementsUtil::prepareFormOutput($v["id"]));
89  $tpl->setVariable('TVAL', ilLegacyFormElementsUtil::prepareFormOutput($v["text"]));
90  $tpl->parseCurrentBlock();
91  }
92  }
93 
94  return $tpl->get();
95  }
96 
97  public function insert(ilTemplate $a_tpl): void
98  {
99  $a_tpl->setCurrentBlock("prop_generic");
100  $a_tpl->setVariable("PROP_GENERIC", $this->render());
101  $a_tpl->parseCurrentBlock();
102  }
103 
104  public function setValueByArray(array $a_values): void
105  {
106  if ($this->getPostVar() && isset($a_values[$this->getPostVar()])) {
107  $this->setValue($a_values[$this->getPostVar()]);
108  }
109  }
110 
111  public function getTableFilterHTML(): string
112  {
113  $html = $this->render();
114  return $html;
115  }
116 }
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
static stripSlashesRecursive($a_data, bool $a_strip_html=true, string $a_allow="")
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...
static prepareFormOutput($a_str, bool $a_strip=false)
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544
global $DIC
Definition: shib_login.php:22
checkInput()
Input should always be valid, since we sort only.
ILIAS Repository InternalGUIService $gui
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
__construct(Container $dic, ilPlugin $plugin)
__construct(string $a_title="", string $a_id="")
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...