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