ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilPresentationListTableGUI.php
Go to the documentation of this file.
1 <?php
2 
26 {
28  protected array $adv_fields;
29  protected \ILIAS\Glossary\Presentation\PresentationGUIRequest $request;
30  protected int $tax_id;
31  protected int $tax_node;
33  protected array $adv_cols_order = array();
34  protected bool $offline;
36  protected array $filter = [];
37 
38  public function __construct(
39  object $a_parent_obj,
40  string $a_parent_cmd,
41  ilObjGlossary $a_glossary,
42  bool $a_offline,
43  int $a_tax_node,
44  int $a_tax_id = 0
45  ) {
46  global $DIC;
47 
48  $this->lng = $DIC->language();
49  $this->ctrl = $DIC->ctrl();
50 
51  $this->glossary = $a_glossary;
52  $this->offline = $a_offline;
53  $this->tax_node = $a_tax_node;
54  $this->tax_id = $a_tax_id;
55  $this->setId("glopr" . $this->glossary->getId());
56  $this->request = $DIC->glossary()
57  ->internal()
58  ->gui()
59  ->presentation()
60  ->request();
61 
62  $gdf = new ilGlossaryDefPage();
63  $this->page_config = $gdf->getPageConfig();
64 
65  $adv_ad = new ilGlossaryAdvMetaDataAdapter($this->glossary->getRefId());
66  $this->adv_fields = $adv_ad->getAllFields();
67 
68 
69  parent::__construct($a_parent_obj, $a_parent_cmd);
70  //$this->setTitle($this->lng->txt("cont_terms"));
71 
72  $adv_ap = new ilGlossaryAdvMetaDataAdapter($this->glossary->getRefId());
73  $this->adv_cols_order = $adv_ap->getColumnOrder();
74  foreach ($this->adv_cols_order as $c) {
75  if ($c["id"] == 0) {
76  $this->addColumn($this->lng->txt("cont_term"), "term");
77  } else {
78  $this->addColumn($c["text"], "md_" . $c["id"]);
79  }
80  }
81 
82 
83  $this->addColumn($this->lng->txt("cont_definitions"));
84  if ($this->glossary->isVirtual()) {
85  $this->addColumn($this->lng->txt("obj_glo"));
86  }
87 
88  $this->setEnableHeader(true);
89  if (!$this->offline) {
90  $this->setFormAction($this->ctrl->getFormAction($this->parent_obj));
91  } else {
92  $this->disable("footer");
93  }
94  $this->setRowTemplate("tpl.term_tbl_pres_row.html", "Modules/Glossary");
95  $this->setEnableTitle(true);
96 
97  if (!$this->offline) {
98  $this->initFilter();
99  $this->setFilterCommand("applyFilter");
100 
101  $this->setShowRowsSelector(true);
102  }
103 
104  // advanced metadata
105  $this->record_gui = new ilAdvancedMDRecordGUI(
107  'glo',
108  $this->glossary->getId(),
109  'term'
110  );
111  $this->record_gui->setTableGUI($this);
112  $this->record_gui->parse();
113  //$this->setDefaultOrderField("login");
114  //$this->setDefaultOrderDirection("asc");
115  $this->setData($this->glossary->getTermList(
116  $this->filter["term"] ?? "",
117  $this->request->getLetter(),
118  $this->filter["definition"] ?? "",
120  false,
121  true,
122  $this->record_gui->getFilterElements(),
123  false,
124  true
125  ));
126  if ($this->offline) {
127  $this->setLimit(count($this->getData()));
128  $this->resetOffset();
129  }
130  // $this->setData(array());
131  }
132 
134  {
135  return $this->record_gui;
136  }
137 
138  public function initFilter(): void
139  {
140  // term
141  $ti = new ilTextInputGUI($this->lng->txt("cont_term"), "term");
142  $ti->setMaxLength(64);
143  $ti->setSize(20);
144  $ti->setSubmitFormOnEnter(true);
145  $this->addFilterItem($ti);
146  $ti->readFromSession();
147  $this->filter["term"] = $ti->getValue();
148 
149  // definition
150  if ($this->glossary->supportsLongTextQuery()) {
151  $ti = new ilTextInputGUI($this->lng->txt("cont_definition"), "defintion");
152  $ti->setMaxLength(64);
153  $ti->setSize(20);
154  $ti->setSubmitFormOnEnter(true);
155  $this->addFilterItem($ti);
156  $ti->readFromSession();
157  $this->filter["definition"] = $ti->getValue();
158  }
159  }
160 
161  public function numericOrdering(string $a_field): bool
162  {
163  if (strpos($a_field, "md_") === 0) {
164  $md_id = (int) substr($a_field, 3);
165  if ($this->adv_fields[$md_id]["type"] == ilAdvancedMDFieldDefinition::TYPE_DATE) {
166  return true;
167  }
168  }
169  return false;
170  }
171 
172  protected function fillRow(array $a_set): void
173  {
174  $term_id = $a_set["id"];
175  $this->ctrl->setParameter($this->parent_obj, "term_id", $term_id);
176 
177  // check dirty short texts
178  $this->tpl->setCurrentBlock("definition");
179  if (ilGlossaryTerm::_lookShortTextDirty($term_id)) {
180  // #18022
181  $term_obj = new ilGlossaryTerm($term_id);
182  $term_obj->updateShortText();
183  $short_str = $term_obj->getShortText();
184  } else {
185  $short_str = ilGlossaryTerm::_lookShortText($term_id);
186  }
187 
188  if (!$this->page_config->getPreventHTMLUnmasking()) {
189  $short_str = str_replace(["&lt;", "&gt;"], ["<", ">"], $short_str);
190  }
191 
192  // replace tex
193  // if a tex end tag is missing a tex end tag
194  $ltexs = strrpos($short_str, "[tex]");
195  $ltexe = strrpos($short_str, "[/tex]");
196  if ($ltexs > $ltexe) {
197  $page = new ilGlossaryDefPage($term_id);
198  $page->buildDom();
199  $short_str = $page->getFirstParagraphText();
200  $short_str = strip_tags($short_str, "<br>");
201  $ltexe = strpos($short_str, "[/tex]", $ltexs);
202  $short_str = ilStr::shortenTextExtended($short_str, $ltexe + 6, true);
203  }
204 
205  if (!$this->offline) {
206  $short_str = ilMathJax::getInstance()->insertLatexImages($short_str);
207  } else {
208  $short_str = ilMathJax::getInstance()->insertLatexImages(
209  $short_str,
210  '[tex]',
211  '[/tex]'
212  );
213  }
214 
215  $short_str = ilPCParagraph::xml2output($short_str, false, true, false);
216 
217  $this->tpl->setVariable("DEF_SHORT", $short_str);
218  $this->tpl->parseCurrentBlock();
219 
220  $this->tpl->setCurrentBlock("definition_row");
221  $this->tpl->parseCurrentBlock();
222 
223  // display additional column 'glossary' for meta glossaries
224  if ($this->glossary->isVirtual()) {
225  $this->tpl->setCurrentBlock("glossary_row");
226  $glo_title = ilObject::_lookupTitle($a_set["glo_id"]);
227  $this->tpl->setVariable("GLO_TITLE", $glo_title);
228  $this->tpl->parseCurrentBlock();
229  }
230 
231  $this->ctrl->clearParameters($this->parent_obj);
232 
233  // advanced metadata
234  foreach ($this->adv_cols_order as $c) {
235  if ($c["id"] == 0) {
236  $this->tpl->setCurrentBlock("link_start");
237  if (!$this->offline) {
238  $this->ctrl->setParameter($this->parent_obj, "term_id", $term_id);
239  $this->tpl->setVariable(
240  "LINK_VIEW_TERM",
241  $this->ctrl->getLinkTarget($this->parent_obj, "listDefinitions")
242  );
243 
244  $this->ctrl->clearParameters($this->parent_obj);
245  } else {
246  $this->tpl->setVariable("LINK_VIEW_TERM", "term_" . $term_id . ".html");
247  }
248  $this->tpl->parseCurrentBlock();
249 
250  $this->tpl->setCurrentBlock("link_end");
251  $this->tpl->setVariable("ANCHOR_TERM", "term_" . $term_id);
252  $this->tpl->parseCurrentBlock();
253 
254  $this->tpl->setCurrentBlock("td");
255  $this->tpl->setVariable("TEXT", $a_set["term"]);
256  } else {
257  $id = $c["id"];
258 
259  $val = " ";
260  if (isset($a_set["md_" . $id . "_presentation"])) {
261  $pb = $a_set["md_" . $id . "_presentation"]->getList();
262  if ($pb) {
263  $val = $pb;
264  }
265  }
266 
267  $this->tpl->setCurrentBlock("td");
268  $this->tpl->setVariable("TEXT", $val);
269  }
270  $this->tpl->parseCurrentBlock();
271  }
272  }
273 }
setData(array $a_data)
__construct(object $a_parent_obj, string $a_parent_cmd, ilObjGlossary $a_glossary, bool $a_offline, int $a_tax_node, int $a_tax_id=0)
setFormAction(string $a_form_action, bool $a_multipart=false)
addFilterItem(ilTableFilterItem $a_input_item, bool $a_optional=false)
setEnableTitle(bool $a_enabletitle)
ILIAS Glossary Presentation PresentationGUIRequest $request
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static xml2output(string $a_text, bool $a_wysiwyg=false, bool $a_replace_lists=true, bool $unmask=true)
Converts xml from DB to output in edit textarea.
setId(string $a_val)
static _lookShortTextDirty(int $term_id)
get definition short text dirty
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
resetOffset(bool $a_in_determination=false)
setShowRowsSelector(bool $a_value)
Toggle rows-per-page selector.
__construct(VocabulariesInterface $vocabularies)
static _lookupTitle(int $obj_id)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setFilterCommand(string $a_val, string $a_caption="")
static _lookShortText(int $term_id)
get definition short text
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getAllFields()
Get all advanced metadata fields.
static getInstance()
Singleton: get instance for use in ILIAS requests with a config loaded from the settings.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static shortenTextExtended(string $a_str, int $a_len, bool $a_dots=false, bool $a_next_blank=false, bool $a_keep_extension=false)
setLimit(int $a_limit=0, int $a_default_limit=0)
setTableGUI(ilTable2GUI $a_val)
Set table for self::MODE_TABLE_FILTER.
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
disable(string $a_module_name)
filter(string $filter_id, $class_path, string $cmd, bool $activated=true, bool $expanded=true)
setEnableHeader(bool $a_enableheader)