ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilTermListTableGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once("./Services/Table/classes/class.ilTable2GUI.php");
5
15{
19 protected $glossary;
20
24 protected $term_perm;
25
29 function __construct($a_parent_obj, $a_parent_cmd, $a_tax_node)
30 {
31 global $ilCtrl, $lng;
32
33 $this->glossary = $a_parent_obj->object;
34 $this->setId("glotl".$this->glossary->getId());
35 $this->tax_node = $a_tax_node;
36
37 $this->selectable_cols = array();
38
39 include_once("./Modules/Glossary/classes/class.ilGlossaryTermPermission.php");
40 $this->term_perm = ilGlossaryTermPermission::getInstance();
41
42 include_once("./Modules/Glossary/classes/class.ilGlossaryAdvMetaDataAdapter.php");
43 $adv_ad = new ilGlossaryAdvMetaDataAdapter($this->glossary->getId());
44 $this->adv_fields = $adv_ad->getAllFields();
45 foreach ($this->adv_fields as $f)
46 {
47 $this->selectable_cols["md_".$f["id"]] = array(
48 "txt" => $f["title"],
49 "default" => false
50 );
51 }
52
53 // selectable columns
54 $this->selectable_cols["language"] = array(
55 "txt" => $lng->txt("language"),
56 "default" => true);
57 $this->selectable_cols["usage"] = array(
58 "txt" => $lng->txt("cont_usage"),
59 "default" => true);
60
61 // selectable columns of advanced metadata
62
63 parent::__construct($a_parent_obj, $a_parent_cmd);
64 $this->setTitle($lng->txt("cont_terms"));
65
66 $this->addColumn("", "", "1", true);
67 //$this->addColumn($this->lng->txt("cont_term"));
68
69 include_once("./Modules/Glossary/classes/class.ilGlossaryAdvMetaDataAdapter.php");
70 $adv_ap = new ilGlossaryAdvMetaDataAdapter($this->glossary->getId());
71 $this->adv_cols_order = $adv_ap->getColumnOrder();
72 $this->selected_cols = $this->getSelectedColumns();
73 foreach ($this->adv_cols_order as $c)
74 {
75 if ($c["id"] == 0)
76 {
77 $this->addColumn($lng->txt("cont_term"), "term");
78 }
79 else
80 {
81 if (in_array("md_".$c["id"], $this->selected_cols))
82 {
83 $this->addColumn($c["text"], "md_".$c["id"]);
84 }
85 }
86 }
87
88 foreach (array ("language", "usage") as $c)
89 {
90 if (in_array($c, $this->selected_cols))
91 {
92 $this->addColumn($this->selectable_cols[$c]["txt"]);
93 }
94 }
95
96 $this->setDefaultOrderDirection("asc");
97 $this->setDefaultOrderField("term");
98 $this->addColumn($this->lng->txt("cont_definitions"));
99
100 if ($this->showGlossaryColumn())
101 {
102 $this->addColumn($this->lng->txt("obj_glo"));
103 }
104
105 $this->addColumn("", "", "1");
106
107 $this->setEnableHeader(true);
108 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
109 $this->setRowTemplate("tpl.term_tbl_row.html", "Modules/Glossary");
110 $this->setEnableTitle(true);
111
112 $this->addMultiCommand("copyTerms", $lng->txt("copy"));
113 $this->addMultiCommand("referenceTerms", $lng->txt("glo_reference"));
114 $this->addMultiCommand("confirmTermDeletion", $lng->txt("delete"));
115 //$this->addMultiCommand("addDefinition", $lng->txt("cont_add_definition"));
116
117 $this->setShowRowsSelector(true);
118
119 $this->initFilter();
120 $this->setData($this->glossary->getTermList($this->filter["term"], "",
121 $this->filter["definition"], $this->tax_node, true, true, null, false, true));
122 }
123
131 {
132 include_once("./Modules/Glossary/classes/class.ilGlossaryTermReferences.php");
133 return (in_array($this->glossary->getVirtualMode(),
134 array("level", "subtree")) || ilGlossaryTermReferences::hasReferences($this->glossary->getId()));
135 }
136
137
145 {
146 return $this->selectable_cols;
147 }
148
154 function numericOrdering($a_field)
155 {
156 if (substr($a_field, 0, 3) == "md_")
157 {
158 $md_id = (int) substr($a_field, 3);
159 if ($this->adv_fields[$md_id]["type"] == ilAdvancedMDFieldDefinition::TYPE_DATE)
160 {
161 return true;
162 }
163 }
164 return false;
165 }
166
170 function initFilter()
171 {
172 global $lng, $ilDB;
173
174 // term
175 include_once("./Services/Form/classes/class.ilTextInputGUI.php");
176 $ti = new ilTextInputGUI($lng->txt("cont_term"), "term");
177 $ti->setMaxLength(64);
178 $ti->setSize(20);
179 $ti->setSubmitFormOnEnter(true);
180 $this->addFilterItem($ti);
181 $ti->readFromSession();
182 $this->filter["term"] = $ti->getValue();
183
184 // definition
185 if ($ilDB->getDBType() != "oracle")
186 {
187 include_once("./Services/Form/classes/class.ilTextInputGUI.php");
188 $ti = new ilTextInputGUI($lng->txt("cont_definition"), "defintion");
189 $ti->setMaxLength(64);
190 $ti->setSize(20);
191 $ti->setSubmitFormOnEnter(true);
192 $this->addFilterItem($ti);
193 $ti->readFromSession();
194 $this->filter["definition"] = $ti->getValue();
195 }
196 }
197
201 protected function fillRow($term)
202 {
203 global $lng, $ilCtrl;
204
205 include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
206
207 $defs = ilGlossaryDefinition::getDefinitionList($term["id"]);
208 $ilCtrl->setParameterByClass("ilobjglossarygui", "term_id", $term["id"]);
209 $ilCtrl->setParameterByClass("ilglossarytermgui", "term_id", $term["id"]);
210 $ilCtrl->setParameterByClass("ilglossarydefpagegui", "term_id", $term["id"]);
211
212 // actions drop down
213 //if ($this->glossary->getId() == $term["glo_id"])
214
215 if ($this->term_perm->checkPermission("write", $term["id"]) ||
216 $this->term_perm->checkPermission("edit_content", $term["id"]))
217 {
218 include_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
219 include_once("./Modules/Glossary/classes/class.ilGlossaryTermReferences.php");
220 if (ilGlossaryTerm::_lookGlossaryID($term["id"]) == $this->glossary->getId() ||
221 ilGlossaryTermReferences::isReferenced($this->glossary->getId(), $term["id"]))
222 {
223 $list = new ilAdvancedSelectionListGUI();
224 $list->addItem($lng->txt("cont_edit_term"), "", $ilCtrl->getLinkTargetByClass("ilglossarytermgui", "editTerm"));
225 if (count($defs) > 1)
226 {
227 $list->addItem($lng->txt("cont_edit_definitions"), "", $ilCtrl->getLinkTargetByClass("ilglossarytermgui", "listDefinitions"));
228 } else if (count($defs) == 1)
229 {
230 $ilCtrl->setParameterByClass("ilglossarydefpagegui", "def", $defs[0]["id"]);
231 $list->addItem($lng->txt("cont_edit_definition"), "", $ilCtrl->getLinkTargetByClass(array("ilglossarytermgui",
232 "iltermdefinitioneditorgui",
233 "ilglossarydefpagegui"), "edit"));
234 }
235 $list->addItem($lng->txt("cont_add_definition"), "", $ilCtrl->getLinkTargetByClass("ilobjglossarygui", "addDefinition"));
236 $ilCtrl->setParameterByClass("ilglossarydefpagegui", "def", "");
237
238 $list->setId("act_term_" . $term["id"]);
239 $list->setListTitle($lng->txt("actions"));
240 $this->tpl->setVariable("ACTIONS", $list->getHTML());
241 }
242 }
243
244
245 for($j=0; $j<count($defs); $j++)
246 {
247 $def = $defs[$j];
248
249 // text
250 $this->tpl->setCurrentBlock("definition");
251 $short_str = $def["short_text"];
252
253 // replace tex
254 // if a tex end tag is missing a tex end tag
255 $ltexs = strrpos($short_str, "[tex]");
256 $ltexe = strrpos($short_str, "[/tex]");
257 if ($ltexs > $ltexe)
258 {
259 $page = new ilGlossaryDefPage($def["id"]);
260 $page->buildDom();
261 $short_str = $page->getFirstParagraphText();
262 $short_str = strip_tags($short_str, "<br>");
263 $ltexe = strpos($short_str, "[/tex]", $ltexs);
264 $short_str = ilUtil::shortenText($short_str, $ltexe+6, true);
265 }
266
267 include_once './Services/MathJax/classes/class.ilMathJax.php';
268 $short_str = ilMathJax::getInstance()->insertLatexImages($short_str);
269
270 $short_str = ilPCParagraph::xml2output($short_str);
271 $this->tpl->setVariable("DEF_SHORT", $short_str);
272 $this->tpl->parseCurrentBlock();
273
274 $this->tpl->setCurrentBlock("definition_row");
275 $this->tpl->parseCurrentBlock();
276 }
277
278 $this->tpl->setCurrentBlock("check_col");
279 $this->tpl->setVariable("CHECKBOX_ID", $term["id"]);
280 $this->tpl->parseCurrentBlock();
281
282 $ilCtrl->setParameter($this->parent_obj, "term_id", $term["id"]);
283
284
285 // usage
286 if (in_array("usage", $this->getSelectedColumns()))
287 {
288 $nr_usage = ilGlossaryTerm::getNumberOfUsages($term["id"]);
289 if ($nr_usage > 0 && $this->glossary->getId() == $term["glo_id"])
290 {
291 $this->tpl->setCurrentBlock("link_usage");
292 $ilCtrl->setParameterByClass("ilglossarytermgui", "term_id", $term["id"]);
293 $this->tpl->setVariable("LUSAGE", ilGlossaryTerm::getNumberOfUsages($term["id"]));
294 $this->tpl->setVariable("LINK_USAGE",
295 $ilCtrl->getLinkTargetByClass("ilglossarytermgui", "listUsages"));
296 $ilCtrl->setParameterByClass("ilglossarytermgui", "term_id", "");
297 $this->tpl->parseCurrentBlock();
298 }
299 else
300 {
301 $this->tpl->setCurrentBlock("usage");
302 $this->tpl->setVariable("USAGE", ilGlossaryTerm::getNumberOfUsages($term["id"]));
303 $this->tpl->parseCurrentBlock();
304 }
305 $this->tpl->setCurrentBlock("td_usage");
306 $this->tpl->parseCurrentBlock();
307 }
308
309 // glossary title
310 if ($this->showGlossaryColumn())
311 {
312 $this->tpl->setCurrentBlock("glossary");
313 $this->tpl->setVariable("GLO_TITLE", ilObject::_lookupTitle($term["glo_id"]));
314 $this->tpl->parseCurrentBlock();
315 }
316
317 // output language
318 if (in_array("language", $this->getSelectedColumns()))
319 {
320 $this->tpl->setCurrentBlock("td_lang");
321 $this->tpl->setVariable("TEXT_LANGUAGE", $lng->txt("meta_l_".$term["language"]));
322 $this->tpl->parseCurrentBlock();
323 }
324
325
326 foreach ($this->adv_cols_order as $c)
327 {
328 if ($c["id"] == 0)
329 {
330 $this->tpl->setCurrentBlock("td");
331 $this->tpl->setVariable("TD_VAL", $term["term"]);
332 $this->tpl->parseCurrentBlock();
333 }
334 else
335 {
336 if (in_array("md_".$c["id"], $this->selected_cols))
337 {
338 $id = (int) $c["id"];
339
340 $val = " ";
341 if(isset($term["md_".$id."_presentation"]))
342 {
343 $pb = $term["md_".$id."_presentation"]->getHTML();
344 if($pb)
345 {
346 $val = $pb;
347 }
348 }
349
350 $this->tpl->setCurrentBlock("td");
351 $this->tpl->setVariable("TD_VAL", $val);
352 $this->tpl->parseCurrentBlock();
353 }
354 }
355 }
356 }
357
358}
359?>
An exception for terminatinating execution or to throw for unit testing.
User interface class for advanced drop-down selection lists.
Glossary definition page object.
static getDefinitionList($a_term_id)
static
static hasReferences($a_glossary_id)
Check if a glossary uses references.
static isReferenced($a_glo_id, $a_term_id)
Is a term referenced by one or multiple glossaries.
static getNumberOfUsages($a_term_id)
Get number of usages.
static _lookGlossaryID($term_id)
get glossary id form term id
static getInstance()
Singleton: get instance.
static _lookupTitle($a_id)
lookup object title
static xml2output($a_text, $a_wysiwyg=false, $a_replace_lists=true)
Converts xml from DB to output in edit textarea.
Class ilTable2GUI.
getSelectedColumns()
Get selected columns.
setEnableHeader($a_enableheader)
Set Enable Header.
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.
setShowRowsSelector($a_value)
Toggle rows-per-page selector.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
setData($a_data)
set table data @access public
setEnableTitle($a_enabletitle)
Set Enable Title.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
addMultiCommand($a_cmd, $a_text)
Add Command button.
addFilterItem($a_input_item, $a_optional=false)
Add filter item.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
setId($a_val)
Set id.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
showGlossaryColumn()
Show glossary column.
fillRow($term)
Fill table row.
__construct($a_parent_obj, $a_parent_cmd, $a_tax_node)
Constructor.
getSelectableColumns()
Get selectable columns.
numericOrdering($a_field)
Should this field be sorted numeric?
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.
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:17
global $ilDB