ILIAS  release_4-3 Revision
 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  if (in_array($this->glossary->getVirtualMode(),
37  array("level", "subtree")))
38  {
39  $this->addColumn($this->lng->txt("obj_glo"));
40  }
41 
42  $this->setEnableHeader(true);
43  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
44  $this->setRowTemplate("tpl.term_tbl_row.html", "Modules/Glossary");
45  $this->setEnableTitle(true);
46 
47  $this->addMultiCommand("confirmTermDeletion", $lng->txt("delete"));
48  $this->addMultiCommand("addDefinition", $lng->txt("cont_add_definition"));
49 
50  $this->initFilter();
51  $this->setData($this->glossary->getTermList($this->filter["term"], "",
52  $this->filter["definition"], 0, true));
53  }
54 
58  function initFilter()
59  {
60  global $lng, $rbacreview, $ilUser, $ilDB;
61 
62  // term
63  include_once("./Services/Form/classes/class.ilTextInputGUI.php");
64  $ti = new ilTextInputGUI($lng->txt("cont_term"), "term");
65  $ti->setMaxLength(64);
66  $ti->setSize(20);
67  $ti->setSubmitFormOnEnter(true);
68  $this->addFilterItem($ti);
69  $ti->readFromSession();
70  $this->filter["term"] = $ti->getValue();
71 
72  // definition
73  if ($ilDB->getDBType() != "oracle")
74  {
75  include_once("./Services/Form/classes/class.ilTextInputGUI.php");
76  $ti = new ilTextInputGUI($lng->txt("cont_definition"), "defintion");
77  $ti->setMaxLength(64);
78  $ti->setSize(20);
79  $ti->setSubmitFormOnEnter(true);
80  $this->addFilterItem($ti);
81  $ti->readFromSession();
82  $this->filter["definition"] = $ti->getValue();
83  }
84  }
85 
89  protected function fillRow($term)
90  {
91  global $lng, $ilCtrl;
92 
93  $defs = ilGlossaryDefinition::getDefinitionList($term["id"]);
94  $ilCtrl->setParameterByClass("ilglossarytermgui", "term_id", $term["id"]);
95 
96  for($j=0; $j<count($defs); $j++)
97  {
98  $def = $defs[$j];
99 
100  if ($this->glossary->getId() == $term["glo_id"])
101  {
102  // up
103  if ($j > 0)
104  {
105  $this->tpl->setCurrentBlock("move_up");
106  $this->tpl->setVariable("TXT_UP", $lng->txt("up"));
107  $ilCtrl->setParameter($this->parent_obj, "term_id", $term["id"]);
108  $ilCtrl->setParameter($this->parent_obj, "def", $def["id"]);
109  $this->tpl->setVariable("LINK_UP",
110  $ilCtrl->getLinkTarget($this->parent_obj, "moveDefinitionUp"));
111  $this->tpl->parseCurrentBlock();
112  }
113 
114  // down
115  if ($j+1 < count($defs))
116  {
117  $this->tpl->setCurrentBlock("move_down");
118  $this->tpl->setVariable("TXT_DOWN", $lng->txt("down"));
119  $ilCtrl->setParameter($this->parent_obj, "term_id", $term["id"]);
120  $ilCtrl->setParameter($this->parent_obj, "def", $def["id"]);
121  $this->tpl->setVariable("LINK_DOWN",
122  $ilCtrl->getLinkTarget($this->parent_obj, "moveDefinitionDown"));
123  $this->tpl->parseCurrentBlock();
124  }
125 
126  // delete
127  $this->tpl->setCurrentBlock("delete");
128  $ilCtrl->setParameter($this->parent_obj, "term_id", $term["id"]);
129  $ilCtrl->setParameter($this->parent_obj, "def", $def["id"]);
130  $this->tpl->setVariable("LINK_DELETE",
131  $ilCtrl->getLinkTarget($this->parent_obj, "confirmDefinitionDeletion"));
132  $this->tpl->setVariable("TXT_DELETE", $lng->txt("delete"));
133  $this->tpl->parseCurrentBlock();
134 
135  // edit
136  $this->tpl->setCurrentBlock("edit");
137  $ilCtrl->setParameterByClass("ilpageobjectgui", "term_id", $term["id"]);
138  $ilCtrl->setParameterByClass("ilpageobjectgui", "def", $def["id"]);
139  $this->tpl->setVariable("LINK_EDIT",
140  $ilCtrl->getLinkTargetByClass(array("ilglossarytermgui",
141  "iltermdefinitioneditorgui",
142  "ilpageobjectgui"), "edit"));
143  $this->tpl->setVariable("TXT_EDIT", $lng->txt("edit"));
144  $this->tpl->parseCurrentBlock();
145  }
146 
147  // text
148  $this->tpl->setCurrentBlock("definition");
149  $short_str = $def["short_text"];
150 
151  // replace tex
152  // if a tex end tag is missing a tex end tag
153  $ltexs = strrpos($short_str, "[tex]");
154  $ltexe = strrpos($short_str, "[/tex]");
155  if ($ltexs > $ltexe)
156  {
157  $page =& new ilPageObject("gdf", $def["id"]);
158  $page->buildDom();
159  $short_str = $page->getFirstParagraphText();
160  $short_str = strip_tags($short_str, "<br>");
161  $ltexe = strpos($short_str, "[/tex]", $ltexs);
162  $short_str = ilUtil::shortenText($short_str, $ltexe+6, true);
163  }
164  $short_str = ilUtil::insertLatexImages($short_str);
165  $short_str = ilPCParagraph::xml2output($short_str);
166  $this->tpl->setVariable("DEF_SHORT", $short_str);
167  $this->tpl->parseCurrentBlock();
168 
169  $this->tpl->setCurrentBlock("definition_row");
170  $this->tpl->parseCurrentBlock();
171  }
172 
173  $this->tpl->setCurrentBlock("check_col");
174  $this->tpl->setVariable("CHECKBOX_ID", $term["id"]);
175  $this->tpl->parseCurrentBlock();
176 
177  // edit term link
178  $this->tpl->setCurrentBlock("edit_term");
179  $this->tpl->setVariable("TEXT_TERM", $term["term"]);
180  $ilCtrl->setParameter($this->parent_obj, "term_id", $term["id"]);
181  if ($this->glossary->getId() == $term["glo_id"])
182  {
183  $this->tpl->setVariable("LINK_EDIT_TERM",
184  $ilCtrl->getLinkTargetByClass("ilglossarytermgui", "editTerm"));
185  $this->tpl->setVariable("TXT_EDIT_TERM", $lng->txt("edit"));
186  }
187  $this->tpl->parseCurrentBlock();
188 
189  // usage
190  $nr_usage = ilGlossaryTerm::getNumberOfUsages($term["id"]);
191  if ($nr_usage > 0 && $this->glossary->getId() == $term["glo_id"])
192  {
193  $this->tpl->setCurrentBlock("link_usage");
194  $ilCtrl->setParameterByClass("ilglossarytermgui", "term_id", $term["id"]);
195  $this->tpl->setVariable("LUSAGE", ilGlossaryTerm::getNumberOfUsages($term["id"]));
196  $this->tpl->setVariable("LINK_USAGE",
197  $ilCtrl->getLinkTargetByClass("ilglossarytermgui", "listUsages"));
198  $ilCtrl->setParameterByClass("ilglossarytermgui", "term_id", "");
199  $this->tpl->parseCurrentBlock();
200  }
201  else
202  {
203  $this->tpl->setCurrentBlock("usage");
204  $this->tpl->setVariable("USAGE", ilGlossaryTerm::getNumberOfUsages($term["id"]));
205  $this->tpl->parseCurrentBlock();
206  }
207 
208  // glossary title
209  if (in_array($this->glossary->getVirtualMode(),
210  array("level", "subtree")))
211  {
212  $this->tpl->setCurrentBlock("glossary");
213  $this->tpl->setVariable("GLO_TITLE", ilObject::_lookupTitle($term["glo_id"]));
214  $this->tpl->parseCurrentBlock();
215  }
216 
217  // output term and language
218  $this->tpl->setVariable("TEXT_LANGUAGE", $lng->txt("meta_l_".$term["language"]));
219 
220  }
221 
222 }
223 ?>