ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilPresentationListTableGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once("./Services/Table/classes/class.ilTable2GUI.php");
5 
15 {
19  function __construct($a_parent_obj, $a_parent_cmd, $a_glossary, $a_offline,
20  $a_tax_node)
21  {
22  global $ilCtrl, $lng, $ilAccess, $lng;
23 
24  $this->glossary = $a_glossary;
25  $this->offline = $a_offline;
26  $this->tax_node = $a_tax_node;
27  $this->setId("glopr".$this->glossary->getId());
28 
29  parent::__construct($a_parent_obj, $a_parent_cmd);
30  //$this->setTitle($lng->txt("cont_terms"));
31 
32  if ($this->glossary->getPresentationMode() == "full_def")
33  {
34  $this->addColumn($lng->txt("cont_terms"));
35  }
36  else
37  {
38  $this->addColumn($lng->txt("cont_term"));
39  $this->addColumn($lng->txt("cont_definitions"));
40  if ($this->glossary->isVirtual())
41  {
42  $this->addColumn($lng->txt("obj_glo"));
43  }
44  }
45 
46  $this->setEnableHeader(true);
47  if (!$this->offline)
48  {
49  $this->setFormAction($ilCtrl->getFormAction($this->parent_obj));
50  }
51  else
52  {
53  $this->disable("footer");
54  }
55  $this->setRowTemplate("tpl.term_tbl_pres_row.html", "Modules/Glossary");
56  $this->setEnableTitle(true);
57 
58  if (!$this->offline)
59  {
60  $this->initFilter();
61  $this->setFilterCommand("applyFilter");
62  }
63  //$this->setDefaultOrderField("login");
64  //$this->setDefaultOrderDirection("asc");
65 
66  $this->setData($this->glossary->getTermList($this->filter["term"], $_GET["letter"],
67  $this->filter["definition"], $this->tax_node));
68 
69  }
70 
74  function initFilter()
75  {
76  global $lng, $rbacreview, $ilUser, $ilDB;
77 
78  // term
79  include_once("./Services/Form/classes/class.ilTextInputGUI.php");
80  $ti = new ilTextInputGUI($lng->txt("cont_term"), "term");
81  $ti->setMaxLength(64);
82  $ti->setSize(20);
83  $ti->setSubmitFormOnEnter(true);
84  $this->addFilterItem($ti);
85  $ti->readFromSession();
86  $this->filter["term"] = $ti->getValue();
87 
88  // definition
89  if ($ilDB->getDBType() != "oracle")
90  {
91  include_once("./Services/Form/classes/class.ilTextInputGUI.php");
92  $ti = new ilTextInputGUI($lng->txt("cont_definition"), "defintion");
93  $ti->setMaxLength(64);
94  $ti->setSize(20);
95  $ti->setSubmitFormOnEnter(true);
96  $this->addFilterItem($ti);
97  $ti->readFromSession();
98  $this->filter["definition"] = $ti->getValue();
99  }
100  }
101 
105  protected function fillRow($term)
106  {
107  global $lng, $ilCtrl;
108 
109  $defs = ilGlossaryDefinition::getDefinitionList($term["id"]);
110  $ilCtrl->setParameter($this->parent_obj, "term_id", $term["id"]);
111 
112  if ($this->glossary->getPresentationMode() == "full_def")
113  {
114  $this->tpl->setVariable("FULL_DEF",
115  $this->parent_obj->listDefinitions($_GET["ref_id"], $term["id"], true));
116  }
117  else
118  {
119  for ($j=0; $j < count($defs); $j++)
120  {
121  $def = $defs[$j];
122  if (count($defs) > 1)
123  {
124  $this->tpl->setCurrentBlock("definition");
125  $this->tpl->setVariable("DEF_TEXT", $lng->txt("cont_definition")." ".($j + 1));
126  $this->tpl->parseCurrentBlock();
127  }
128 
129  // check dirty short texts
130  $this->tpl->setCurrentBlock("definition");
131  if ($def["short_text_dirty"])
132  {
133  $def = new ilGlossaryDefinition($def["id"]);
134  $def->updateShortText();
135  $short_str = $def->getShortText();
136  }
137  else
138  {
139  $short_str = $def["short_text"];
140  }
141  // replace tex
142  // if a tex end tag is missing a tex end tag
143  $ltexs = strrpos($short_str, "[tex]");
144  $ltexe = strrpos($short_str, "[/tex]");
145  if ($ltexs > $ltexe)
146  {
147  $page =& new ilPageObject("gdf", $def["id"]);
148  $page->buildDom();
149  $short_str = $page->getFirstParagraphText();
150  $short_str = strip_tags($short_str, "<br>");
151  $ltexe = strpos($short_str, "[/tex]", $ltexs);
152  $short_str = ilUtil::shortenText($short_str, $ltexe+6, true);
153  }
154  if (!$this->offline)
155  {
156  $short_str = ilUtil::insertLatexImages($short_str);
157  }
158  else
159  {
160  $short_str = ilUtil::buildLatexImages($short_str,
161  $this->parent_obj->getOfflineDirectory());
162  }
163  $short_str = ilPCParagraph::xml2output($short_str);
164 
165  $this->tpl->setVariable("DEF_SHORT", $short_str);
166  $this->tpl->parseCurrentBlock();
167 
168  $this->tpl->setCurrentBlock("definition_row");
169  $this->tpl->parseCurrentBlock();
170  }
171 // $this->tpl->touchBlock("def_td");
172 
173  // display additional column 'glossary' for meta glossaries
174  if ($this->glossary->isVirtual())
175  {
176  $this->tpl->setCurrentBlock("glossary_row");
177  $glo_title = ilObject::_lookupTitle($term["glo_id"]);
178  $this->tpl->setVariable("GLO_TITLE", $glo_title);
179  $this->tpl->parseCurrentBlock();
180  }
181 
182  $this->tpl->setCurrentBlock("view_term");
183  $this->tpl->setVariable("TEXT_TERM", $term["term"]);
184  if (!$this->offline)
185  {
186  if (!empty ($filter))
187  {
188  $ilCtrl->setParameter($this, "term", $filter);
189  $ilCtrl->setParameter($this, "oldoffset", $_GET["oldoffset"]);
190  }
191  $ilCtrl->setParameter($this, "term_id", $term["id"]);
192  $ilCtrl->setParameter($this, "offset", $_GET["offset"]);
193  $this->tpl->setVariable("LINK_VIEW_TERM",
194  $ilCtrl->getLinkTarget($this->parent_obj, "listDefinitions"));
195  $ilCtrl->clearParameters($this);
196  }
197  else
198  {
199  $this->tpl->setVariable("LINK_VIEW_TERM", "term_".$term["id"].".html");
200  }
201  $this->tpl->setVariable("ANCHOR_TERM", "term_".$term["id"]);
202  $this->tpl->parseCurrentBlock();
203  }
204 
205  $ilCtrl->clearParameters($this->parent_obj);
206 
207  }
208 
209 }
210 ?>