ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
4 include_once("./Services/Table/classes/class.ilTable2GUI.php");
5 
15 {
16 
20  function __construct($a_parent_obj, $a_parent_cmd)
21  {
22  global $ilCtrl, $lng, $ilAccess, $lng;
23 
24  $this->glossary = $a_parent_obj->object;
25  $this->setId("glotl".$this->glossary->getId());
26 
27  parent::__construct($a_parent_obj, $a_parent_cmd);
28  $this->setTitle($lng->txt("cont_terms"));
29 
30  $this->addColumn("", "", "1", true);
31  $this->addColumn($this->lng->txt("cont_term"));
32  $this->addColumn($this->lng->txt("language"));
33  $this->addColumn($this->lng->txt("cont_usage"));
34  $this->addColumn($this->lng->txt("cont_definitions"));
35 
36  $this->setEnableHeader(true);
37  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
38  $this->setRowTemplate("tpl.term_tbl_row.html", "Modules/Glossary");
39  $this->setEnableTitle(true);
40 
41  $this->addMultiCommand("confirmTermDeletion", $lng->txt("delete"));
42  $this->addMultiCommand("addDefinition", $lng->txt("cont_add_definition"));
43 
44  $this->initFilter();
45  $this->setData($this->glossary->getTermList($this->filter["term"], "",
46  $this->filter["definition"]));
47 
48  }
49 
53  function initFilter()
54  {
55  global $lng, $rbacreview, $ilUser, $ilDB;
56 
57  // term
58  include_once("./Services/Form/classes/class.ilTextInputGUI.php");
59  $ti = new ilTextInputGUI($lng->txt("cont_term"), "term");
60  $ti->setMaxLength(64);
61  $ti->setSize(20);
62  $ti->setSubmitFormOnEnter(true);
63  $this->addFilterItem($ti);
64  $ti->readFromSession();
65  $this->filter["term"] = $ti->getValue();
66 
67  // definition
68  if ($ilDB->getDBType() != "oracle")
69  {
70  include_once("./Services/Form/classes/class.ilTextInputGUI.php");
71  $ti = new ilTextInputGUI($lng->txt("cont_definition"), "defintion");
72  $ti->setMaxLength(64);
73  $ti->setSize(20);
74  $ti->setSubmitFormOnEnter(true);
75  $this->addFilterItem($ti);
76  $ti->readFromSession();
77  $this->filter["definition"] = $ti->getValue();
78  }
79  }
80 
84  protected function fillRow($term)
85  {
86  global $lng, $ilCtrl;
87 
88  $defs = ilGlossaryDefinition::getDefinitionList($term["id"]);
89  $ilCtrl->setParameterByClass("ilglossarytermgui", "term_id", $term["id"]);
90 
91  for($j=0; $j<count($defs); $j++)
92  {
93  $def = $defs[$j];
94 
95  // up
96  if ($j > 0)
97  {
98  $this->tpl->setCurrentBlock("move_up");
99  $this->tpl->setVariable("TXT_UP", $lng->txt("up"));
100  $ilCtrl->setParameter($this->parent_obj, "term_id", $term["id"]);
101  $ilCtrl->setParameter($this->parent_obj, "def", $def["id"]);
102  $this->tpl->setVariable("LINK_UP",
103  $ilCtrl->getLinkTarget($this->parent_obj, "moveDefinitionUp"));
104  $this->tpl->parseCurrentBlock();
105  }
106 
107  // down
108  if ($j+1 < count($defs))
109  {
110  $this->tpl->setCurrentBlock("move_down");
111  $this->tpl->setVariable("TXT_DOWN", $lng->txt("down"));
112  $ilCtrl->setParameter($this->parent_obj, "term_id", $term["id"]);
113  $ilCtrl->setParameter($this->parent_obj, "def", $def["id"]);
114  $this->tpl->setVariable("LINK_DOWN",
115  $ilCtrl->getLinkTarget($this->parent_obj, "moveDefinitionDown"));
116  $this->tpl->parseCurrentBlock();
117  }
118 
119  // delete
120  $this->tpl->setCurrentBlock("delete");
121  $ilCtrl->setParameter($this->parent_obj, "term_id", $term["id"]);
122  $ilCtrl->setParameter($this->parent_obj, "def", $def["id"]);
123  $this->tpl->setVariable("LINK_DELETE",
124  $ilCtrl->getLinkTarget($this->parent_obj, "confirmDefinitionDeletion"));
125  $this->tpl->setVariable("TXT_DELETE", $lng->txt("delete"));
126  $this->tpl->parseCurrentBlock();
127 
128  // edit
129  $this->tpl->setCurrentBlock("edit");
130  $ilCtrl->setParameterByClass("ilpageobjectgui", "term_id", $term["id"]);
131  $ilCtrl->setParameterByClass("ilpageobjectgui", "def", $def["id"]);
132  $this->tpl->setVariable("LINK_EDIT",
133  $ilCtrl->getLinkTargetByClass(array("ilglossarytermgui",
134  "iltermdefinitioneditorgui",
135  "ilpageobjectgui"), "edit"));
136  $this->tpl->setVariable("TXT_EDIT", $lng->txt("edit"));
137  $this->tpl->parseCurrentBlock();
138 
139  // text
140  $this->tpl->setCurrentBlock("definition");
141  $short_str = $def["short_text"];
142 
143  // replace tex
144  // if a tex end tag is missing a tex end tag
145  $ltexs = strrpos($short_str, "[tex]");
146  $ltexe = strrpos($short_str, "[/tex]");
147  if ($ltexs > $ltexe)
148  {
149  $page =& new ilPageObject("gdf", $def["id"]);
150  $page->buildDom();
151  $short_str = $page->getFirstParagraphText();
152  $short_str = strip_tags($short_str, "<br>");
153  $ltexe = strpos($short_str, "[/tex]", $ltexs);
154  $short_str = ilUtil::shortenText($short_str, $ltexe+6, true);
155  }
156  $short_str = ilUtil::insertLatexImages($short_str);
157  $short_str = ilPCParagraph::xml2output($short_str);
158  $this->tpl->setVariable("DEF_SHORT", $short_str);
159  $this->tpl->parseCurrentBlock();
160 
161  $this->tpl->setCurrentBlock("definition_row");
162  $this->tpl->parseCurrentBlock();
163  }
164 
165  $this->tpl->setCurrentBlock("check_col");
166  $this->tpl->setVariable("CHECKBOX_ID", $term["id"]);
167  $this->tpl->parseCurrentBlock();
168 
169  // edit term link
170  $this->tpl->setCurrentBlock("edit_term");
171  $this->tpl->setVariable("TEXT_TERM", $term["term"]);
172  $ilCtrl->setParameter($this->parent_obj, "term_id", $term["id"]);
173  $this->tpl->setVariable("LINK_EDIT_TERM",
174  $ilCtrl->getLinkTargetByClass("ilglossarytermgui", "editTerm"));
175  $this->tpl->setVariable("TXT_EDIT_TERM", $lng->txt("edit"));
176  $this->tpl->parseCurrentBlock();
177 
178  // usage
179  $nr_usage = ilGlossaryTerm::getNumberOfUsages($term["id"]);
180  if ($nr_usage > 0)
181  {
182  $this->tpl->setCurrentBlock("link_usage");
183  $ilCtrl->setParameterByClass("ilglossarytermgui", "term_id", $term["id"]);
184  $this->tpl->setVariable("LUSAGE", ilGlossaryTerm::getNumberOfUsages($term["id"]));
185  $this->tpl->setVariable("LINK_USAGE",
186  $ilCtrl->getLinkTargetByClass("ilglossarytermgui", "listUsages"));
187  $ilCtrl->setParameterByClass("ilglossarytermgui", "term_id", "");
188  $this->tpl->parseCurrentBlock();
189  }
190  else
191  {
192  $this->tpl->setCurrentBlock("usage");
193  $this->tpl->setVariable("USAGE", ilGlossaryTerm::getNumberOfUsages($term["id"]));
194  $this->tpl->parseCurrentBlock();
195  }
196 
197  // output term and language
198  $this->tpl->setVariable("TEXT_LANGUAGE", $lng->txt("meta_l_".$term["language"]));
199 
200  }
201 
202 }
203 ?>