ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilPresentationListTableGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4
12{
13
17 protected $glossary;
18
22 protected $adv_cols_order = array();
23
27 protected $lng;
28
32 protected $ctrl;
33
37 protected $offline;
38
42 protected $page_config;
43
44
48 public function __construct(
49 $a_parent_obj,
50 $a_parent_cmd,
51 $a_glossary,
52 $a_offline,
53 $a_tax_node,
54 $a_tax_id = 0
55 ) {
56 global $DIC;
57
58 $this->lng = $DIC->language();
59 $this->ctrl = $DIC->ctrl();
60
61 $this->glossary = $a_glossary;
62 $this->offline = $a_offline;
63 $this->tax_node = $a_tax_node;
64 $this->tax_id = $a_tax_id;
65 $this->setId("glopr" . $this->glossary->getId());
66
67 $gdf = new ilGlossaryDefPage();
68 $this->page_config = $gdf->getPageConfig();
69
70 $adv_ad = new ilGlossaryAdvMetaDataAdapter($this->glossary->getRefId());
71 $this->adv_fields = $adv_ad->getAllFields();
72
73
74 parent::__construct($a_parent_obj, $a_parent_cmd);
75 //$this->setTitle($this->lng->txt("cont_terms"));
76
77 if ($this->glossary->getPresentationMode() == "full_def") {
78 $this->addColumn($this->lng->txt("cont_terms"));
79 } else {
80 $adv_ap = new ilGlossaryAdvMetaDataAdapter($this->glossary->getRefId());
81 $this->adv_cols_order = $adv_ap->getColumnOrder();
82 foreach ($this->adv_cols_order as $c) {
83 if ($c["id"] == 0) {
84 $this->addColumn($this->lng->txt("cont_term"), "term");
85 } else {
86 $this->addColumn($c["text"], "md_" . $c["id"]);
87 }
88 }
89
90
91 $this->addColumn($this->lng->txt("cont_definitions"));
92 if ($this->glossary->isVirtual()) {
93 $this->addColumn($this->lng->txt("obj_glo"));
94 }
95 }
96
97 $this->setEnableHeader(true);
98 if (!$this->offline) {
99 $this->setFormAction($this->ctrl->getFormAction($this->parent_obj));
100 } else {
101 $this->disable("footer");
102 }
103 $this->setRowTemplate("tpl.term_tbl_pres_row.html", "Modules/Glossary");
104 $this->setEnableTitle(true);
105
106 if (!$this->offline) {
107 $this->initFilter();
108 $this->setFilterCommand("applyFilter");
109
110 $this->setShowRowsSelector(true);
111 }
112
113 // advanced metadata
114 $this->record_gui = new ilAdvancedMDRecordGUI(ilAdvancedMDRecordGUI::MODE_FILTER, 'glo', $this->glossary->getId(), 'term');
115 $this->record_gui->setTableGUI($this);
116 $this->record_gui->parse();
117 //$this->setDefaultOrderField("login");
118 //$this->setDefaultOrderDirection("asc");
119 $this->setData($this->glossary->getTermList(
120 $this->filter["term"],
121 $_GET["letter"],
122 $this->filter["definition"],
123 $this->tax_node,
124 false,
125 true,
126 $this->record_gui->getFilterElements(),
127 false,
128 true
129 ));
130 if ($this->offline) {
131 $this->setLimit(count($this->getData()));
132 $this->resetOffset();
133 }
134 // $this->setData(array());
135 }
136
142 protected function getAdvMDRecordGUI()
143 {
144 return $this->record_gui;
145 }
146
150 public function initFilter()
151 {
152 // term
153 $ti = new ilTextInputGUI($this->lng->txt("cont_term"), "term");
154 $ti->setMaxLength(64);
155 $ti->setSize(20);
156 $ti->setSubmitFormOnEnter(true);
157 $this->addFilterItem($ti);
158 $ti->readFromSession();
159 $this->filter["term"] = $ti->getValue();
160
161 // definition
162 if ($this->glossary->supportsLongTextQuery()) {
163 $ti = new ilTextInputGUI($this->lng->txt("cont_definition"), "defintion");
164 $ti->setMaxLength(64);
165 $ti->setSize(20);
166 $ti->setSubmitFormOnEnter(true);
167 $this->addFilterItem($ti);
168 $ti->readFromSession();
169 $this->filter["definition"] = $ti->getValue();
170 }
171 }
172
178 public function numericOrdering($a_field)
179 {
180 if (substr($a_field, 0, 3) == "md_") {
181 $md_id = (int) substr($a_field, 3);
182 if ($this->adv_fields[$md_id]["type"] == ilAdvancedMDFieldDefinition::TYPE_DATE) {
183 return true;
184 }
185 }
186 return false;
187 }
188
192 protected function fillRow($term)
193 {
194 $defs = ilGlossaryDefinition::getDefinitionList($term["id"]);
195 $this->ctrl->setParameter($this->parent_obj, "term_id", $term["id"]);
196
197 if ($this->glossary->getPresentationMode() == "full_def") {
198 $this->tpl->setCurrentBlock("fd_td");
199 $this->tpl->setVariable(
200 "FULL_DEF",
201 $this->parent_obj->listDefinitions($_GET["ref_id"], $term["id"], true)
202 );
203 $this->tpl->parseCurrentBlock();
204 } else {
205 if (sizeof($defs)) {
206 for ($j = 0; $j < count($defs); $j++) {
207 $def = $defs[$j];
208 if (count($defs) > 1) {
209 if (!$this->offline) {
210 if (!empty($filter)) {
211 $this->ctrl->setParameter($this->parent_obj, "term", $filter);
212 $this->ctrl->setParameter($this->parent_obj, "oldoffset", $_GET["oldoffset"]);
213 }
214 $this->ctrl->setParameter($this->parent_obj, "term_id", $term["id"]);
215 $this->ctrl->setParameter($this->parent_obj, "offset", $_GET["offset"]);
216 $def_href = $this->ctrl->getLinkTarget($this->parent_obj, "listDefinitions");
217 $this->ctrl->clearParameters($this->parent_obj);
218 } else {
219 $def_href = "term_" . $term["id"] . ".html";
220 }
221 $this->tpl->parseCurrentBlock();
222
223 $this->tpl->setCurrentBlock("definition");
224 $this->tpl->setVariable("DEF_TEXT", $this->lng->txt("cont_definition") . " " . ($j + 1));
225 $this->tpl->setVariable("HREF_DEF", $def_href . "#ilPageTocDef" . ($j + 1));
226 $this->tpl->parseCurrentBlock();
227 }
228
229 // check dirty short texts
230 $this->tpl->setCurrentBlock("definition");
231 if ($def["short_text_dirty"]) {
232 // #18022
233 $def_obj = new ilGlossaryDefinition($def["id"]);
234 $def_obj->updateShortText();
235 $short_str = $def_obj->getShortText();
236 } else {
237 $short_str = $def["short_text"];
238 }
239
240 if (!$this->page_config->getPreventHTMLUnmasking()) {
241 $short_str = str_replace("&lt;", "<", $short_str);
242 $short_str = str_replace("&gt;", ">", $short_str);
243 }
244
245 // replace tex
246 // if a tex end tag is missing a tex end tag
247 $ltexs = strrpos($short_str, "[tex]");
248 $ltexe = strrpos($short_str, "[/tex]");
249 if ($ltexs > $ltexe) {
250 $page = new ilGlossaryDefPage($def["id"]);
251 $page->buildDom();
252 $short_str = $page->getFirstParagraphText();
253 $short_str = strip_tags($short_str, "<br>");
254 $ltexe = strpos($short_str, "[/tex]", $ltexs);
255 $short_str = ilUtil::shortenText($short_str, $ltexe + 6, true);
256 }
257
258 if (!$this->offline) {
259 $short_str = ilMathJax::getInstance()->insertLatexImages($short_str);
260 } else {
261 $short_str = ilMathJax::getInstance()->insertLatexImages(
262 $short_str,
263 '[tex]',
264 '[/tex]',
265 $this->parent_obj->getOfflineDirectory() . '/teximg',
266 './teximg'
267 );
268 }
269
270 $short_str = ilPCParagraph::xml2output($short_str, false, true, false);
271
272 $this->tpl->setVariable("DEF_SHORT", $short_str);
273 $this->tpl->parseCurrentBlock();
274
275 $this->tpl->setCurrentBlock("definition_row");
276 $this->tpl->parseCurrentBlock();
277 }
278 } else {
279 $this->tpl->touchBlock("def_td");
280 }
281
282 // display additional column 'glossary' for meta glossaries
283 if ($this->glossary->isVirtual()) {
284 $this->tpl->setCurrentBlock("glossary_row");
285 $glo_title = ilObject::_lookupTitle($term["glo_id"]);
286 $this->tpl->setVariable("GLO_TITLE", $glo_title);
287 $this->tpl->parseCurrentBlock();
288 }
289 }
290
291 $this->ctrl->clearParameters($this->parent_obj);
292
293 // advanced metadata
294 foreach ($this->adv_cols_order as $c) {
295 if ($c["id"] == 0) {
296 $this->tpl->setCurrentBlock("link_start");
297 if (!$this->offline) {
298 if (!empty($filter)) {
299 $this->ctrl->setParameter($this->parent_obj, "term", $filter);
300 $this->ctrl->setParameter($this->parent_obj, "oldoffset", $_GET["oldoffset"]);
301 }
302 $this->ctrl->setParameter($this->parent_obj, "term_id", $term["id"]);
303 $this->ctrl->setParameter($this->parent_obj, "offset", $_GET["offset"]);
304 $this->tpl->setVariable(
305 "LINK_VIEW_TERM",
306 $this->ctrl->getLinkTarget($this->parent_obj, "listDefinitions")
307 );
308 $this->ctrl->clearParameters($this->parent_obj);
309 } else {
310 $this->tpl->setVariable("LINK_VIEW_TERM", "term_" . $term["id"] . ".html");
311 }
312 $this->tpl->parseCurrentBlock();
313
314 $this->tpl->setCurrentBlock("link_end");
315 $this->tpl->setVariable("ANCHOR_TERM", "term_" . $term["id"]);
316 $this->tpl->parseCurrentBlock();
317
318 $this->tpl->setCurrentBlock("td");
319 $this->tpl->setVariable("TEXT", $term["term"]);
320 $this->tpl->parseCurrentBlock();
321 } else {
322 $id = $c["id"];
323
324 $val = " ";
325 if (isset($term["md_" . $id . "_presentation"])) {
326 $pb = $term["md_" . $id . "_presentation"]->getList();
327 if ($pb) {
328 $val = $pb;
329 }
330 }
331
332 $this->tpl->setCurrentBlock("td");
333 $this->tpl->setVariable("TEXT", $val);
334 $this->tpl->parseCurrentBlock();
335 }
336 }
337 }
338}
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
Glossary definition page object.
Class ilGlossaryDefinition.
static getDefinitionList($a_term_id)
static
static getInstance()
Singleton: get instance.
static _lookupTitle($a_id)
lookup object title
static xml2output($a_text, $a_wysiwyg=false, $a_replace_lists=true, $unmask=true)
Converts xml from DB to output in edit textarea.
Term list table for presentation mode.
getAdvMDRecordGUI()
needed for advmd filter handling
numericOrdering($a_field)
Should this field be sorted numeric?
__construct( $a_parent_obj, $a_parent_cmd, $a_glossary, $a_offline, $a_tax_node, $a_tax_id=0)
Constructor.
Class ilTable2GUI.
setEnableHeader($a_enableheader)
Set Enable Header.
setShowRowsSelector($a_value)
Toggle rows-per-page selector.
setData($a_data)
set table data @access public
setEnableTitle($a_enabletitle)
Set Enable Title.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
resetOffset($a_in_determination=false)
Reset offset.
setLimit($a_limit=0, $a_default_limit=0)
set max.
addFilterItem($a_input_item, $a_optional=false)
Add filter item.
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
setId($a_val)
Set id.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
setFilterCommand($a_val, $a_caption=null)
Set filter command.
disable($a_module_name)
diesables particular modules of table
This class represents a text property in a property form.
static shortenText( $a_str, $a_len, $a_dots=false, $a_next_blank=false, $a_keep_extension=false)
shorten a string to given length.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$DIC
Definition: xapitoken.php:46