ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 
16 {
17 
21  protected $glossary;
22 
26  protected $adv_cols_order = array();
27 
31  function __construct($a_parent_obj, $a_parent_cmd, $a_glossary, $a_offline,
32  $a_tax_node, $a_tax_id = 0)
33  {
34  global $ilCtrl, $lng, $ilAccess, $lng;
35 
36  $this->glossary = $a_glossary;
37  $this->offline = $a_offline;
38  $this->tax_node = $a_tax_node;
39  $this->tax_id = $a_tax_id;
40  $this->setId("glopr".$this->glossary->getId());
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 
46 
47  parent::__construct($a_parent_obj, $a_parent_cmd);
48  //$this->setTitle($lng->txt("cont_terms"));
49 
50  if ($this->glossary->getPresentationMode() == "full_def")
51  {
52  $this->addColumn($lng->txt("cont_terms"));
53  }
54  else
55  {
56  include_once("./Modules/Glossary/classes/class.ilGlossaryAdvMetaDataAdapter.php");
57  $adv_ap = new ilGlossaryAdvMetaDataAdapter($this->glossary->getId());
58  $this->adv_cols_order = $adv_ap->getColumnOrder();
59  foreach ($this->adv_cols_order as $c)
60  {
61  if ($c["id"] == 0)
62  {
63  $this->addColumn($lng->txt("cont_term"), "term");
64  }
65  else
66  {
67  $this->addColumn($c["text"], "md_".$c["id"]);
68  }
69  }
70 
71 
72  $this->addColumn($lng->txt("cont_definitions"));
73  if ($this->glossary->isVirtual())
74  {
75  $this->addColumn($lng->txt("obj_glo"));
76  }
77  }
78 
79  $this->setEnableHeader(true);
80  if (!$this->offline)
81  {
82  $this->setFormAction($ilCtrl->getFormAction($this->parent_obj));
83  }
84  else
85  {
86  $this->disable("footer");
87  }
88  $this->setRowTemplate("tpl.term_tbl_pres_row.html", "Modules/Glossary");
89  $this->setEnableTitle(true);
90 
91  if (!$this->offline)
92  {
93  $this->initFilter();
94  $this->setFilterCommand("applyFilter");
95 
96  $this->setShowRowsSelector(true);
97  }
98 
99  // advanced metadata
100  include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordGUI.php');
101  $this->record_gui = new ilAdvancedMDRecordGUI(ilAdvancedMDRecordGUI::MODE_FILTER,'glo',$this->glossary->getId(),'term');
102  $this->record_gui->setTableGUI($this);
103  $this->record_gui->parse();
104  //$this->setDefaultOrderField("login");
105  //$this->setDefaultOrderDirection("asc");
106  $this->setData($this->glossary->getTermList($this->filter["term"], $_GET["letter"],
107  $this->filter["definition"], $this->tax_node, false, true, $this->record_gui->getFilterElements(), false, true));
108 // $this->setData(array());
109  }
110 
116  protected function getAdvMDRecordGUI()
117  {
118  return $this->record_gui;
119  }
120 
124  function initFilter()
125  {
126  global $lng, $rbacreview, $ilUser, $ilDB;
127 
128  // term
129  include_once("./Services/Form/classes/class.ilTextInputGUI.php");
130  $ti = new ilTextInputGUI($lng->txt("cont_term"), "term");
131  $ti->setMaxLength(64);
132  $ti->setSize(20);
133  $ti->setSubmitFormOnEnter(true);
134  $this->addFilterItem($ti);
135  $ti->readFromSession();
136  $this->filter["term"] = $ti->getValue();
137 
138  // definition
139  if ($ilDB->getDBType() != "oracle")
140  {
141  include_once("./Services/Form/classes/class.ilTextInputGUI.php");
142  $ti = new ilTextInputGUI($lng->txt("cont_definition"), "defintion");
143  $ti->setMaxLength(64);
144  $ti->setSize(20);
145  $ti->setSubmitFormOnEnter(true);
146  $this->addFilterItem($ti);
147  $ti->readFromSession();
148  $this->filter["definition"] = $ti->getValue();
149  }
150  }
151 
157  function numericOrdering($a_field)
158  {
159  if (substr($a_field, 0, 3) == "md_")
160  {
161  $md_id = (int) substr($a_field, 3);
162  if ($this->adv_fields[$md_id]["type"] == ilAdvancedMDFieldDefinition::TYPE_DATE)
163  {
164  return true;
165  }
166  }
167  return false;
168  }
169 
173  protected function fillRow($term)
174  {
175  global $lng, $ilCtrl;
176 
177  $defs = ilGlossaryDefinition::getDefinitionList($term["id"]);
178  $ilCtrl->setParameter($this->parent_obj, "term_id", $term["id"]);
179 
180  if ($this->glossary->getPresentationMode() == "full_def")
181  {
182  $this->tpl->setCurrentBlock("fd_td");
183  $this->tpl->setVariable("FULL_DEF",
184  $this->parent_obj->listDefinitions($_GET["ref_id"], $term["id"], true));
185  $this->tpl->parseCurrentBlock();
186  }
187  else
188  {
189  if(sizeof($defs))
190  {
191  for ($j=0; $j < count($defs); $j++)
192  {
193  $def = $defs[$j];
194  if (count($defs) > 1)
195  {
196  if (!$this->offline)
197  {
198  if (!empty ($filter))
199  {
200  $ilCtrl->setParameter($this->parent_obj, "term", $filter);
201  $ilCtrl->setParameter($this->parent_obj, "oldoffset", $_GET["oldoffset"]);
202  }
203  $ilCtrl->setParameter($this->parent_obj, "term_id", $term["id"]);
204  $ilCtrl->setParameter($this->parent_obj, "offset", $_GET["offset"]);
205  $def_href = $ilCtrl->getLinkTarget($this->parent_obj, "listDefinitions");
206  $ilCtrl->clearParameters($this->parent_obj);
207  }
208  else
209  {
210  $def_href = "term_".$term["id"].".html";
211  }
212  $this->tpl->parseCurrentBlock();
213 
214  $this->tpl->setCurrentBlock("definition");
215  $this->tpl->setVariable("DEF_TEXT", $lng->txt("cont_definition")." ".($j + 1));
216  $this->tpl->setVariable("HREF_DEF", $def_href."#ilPageTocDef".($j + 1));
217  $this->tpl->parseCurrentBlock();
218  }
219 
220  // check dirty short texts
221  $this->tpl->setCurrentBlock("definition");
222  if ($def["short_text_dirty"])
223  {
224  // #18022
225  $def_obj = new ilGlossaryDefinition($def["id"]);
226  $def_obj->updateShortText();
227  $short_str = $def_obj->getShortText();
228  }
229  else
230  {
231  $short_str = $def["short_text"];
232  }
233  // replace tex
234  // if a tex end tag is missing a tex end tag
235  $ltexs = strrpos($short_str, "[tex]");
236  $ltexe = strrpos($short_str, "[/tex]");
237  if ($ltexs > $ltexe)
238  {
239  $page = new ilGlossaryDefPage($def["id"]);
240  $page->buildDom();
241  $short_str = $page->getFirstParagraphText();
242  $short_str = strip_tags($short_str, "<br>");
243  $ltexe = strpos($short_str, "[/tex]", $ltexs);
244  $short_str = ilUtil::shortenText($short_str, $ltexe+6, true);
245  }
246 
247  include_once './Services/MathJax/classes/class.ilMathJax.php';
248  if (!$this->offline)
249  {
250  $short_str = ilMathJax::getInstance()->insertLatexImages($short_str);
251  }
252  else
253  {
254  $short_str = ilMathJax::getInstance()->insertLatexImages($short_str, '[tex]', '[/tex]',
255  $this->parent_obj->getOfflineDirectory().'/teximg','./teximg');
256  }
257 
258  $short_str = ilPCParagraph::xml2output($short_str);
259 
260  $this->tpl->setVariable("DEF_SHORT", $short_str);
261  $this->tpl->parseCurrentBlock();
262 
263  $this->tpl->setCurrentBlock("definition_row");
264  $this->tpl->parseCurrentBlock();
265  }
266  }
267  else
268  {
269  $this->tpl->touchBlock("def_td");
270  }
271 
272  // display additional column 'glossary' for meta glossaries
273  if ($this->glossary->isVirtual())
274  {
275  $this->tpl->setCurrentBlock("glossary_row");
276  $glo_title = ilObject::_lookupTitle($term["glo_id"]);
277  $this->tpl->setVariable("GLO_TITLE", $glo_title);
278  $this->tpl->parseCurrentBlock();
279  }
280 
281  }
282 
283  $ilCtrl->clearParameters($this->parent_obj);
284 
285  // advanced metadata
286  foreach ($this->adv_cols_order as $c)
287  {
288  if ($c["id"] == 0)
289  {
290  $this->tpl->setCurrentBlock("link_start");
291  if (!$this->offline)
292  {
293  if (!empty ($filter))
294  {
295  $ilCtrl->setParameter($this->parent_obj, "term", $filter);
296  $ilCtrl->setParameter($this->parent_obj, "oldoffset", $_GET["oldoffset"]);
297  }
298  $ilCtrl->setParameter($this->parent_obj, "term_id", $term["id"]);
299  $ilCtrl->setParameter($this->parent_obj, "offset", $_GET["offset"]);
300  $this->tpl->setVariable("LINK_VIEW_TERM",
301  $ilCtrl->getLinkTarget($this->parent_obj, "listDefinitions"));
302  $ilCtrl->clearParameters($this->parent_obj);
303  }
304  else
305  {
306  $this->tpl->setVariable("LINK_VIEW_TERM", "term_".$term["id"].".html");
307  }
308  $this->tpl->parseCurrentBlock();
309 
310  $this->tpl->setCurrentBlock("link_end");
311  $this->tpl->setVariable("ANCHOR_TERM", "term_".$term["id"]);
312  $this->tpl->parseCurrentBlock();
313 
314  $this->tpl->setCurrentBlock("td");
315  $this->tpl->setVariable("TEXT", $term["term"]);
316  $this->tpl->parseCurrentBlock();
317  }
318  else
319  {
320  $id = $c["id"];
321 
322  $val = " ";
323  if(isset($term["md_".$id."_presentation"]))
324  {
325  $pb = $term["md_".$id."_presentation"]->getList();
326  if($pb)
327  {
328  $val = $pb;
329  }
330  }
331 
332  $this->tpl->setCurrentBlock("td");
333  $this->tpl->setVariable("TEXT", $val);
334  $this->tpl->parseCurrentBlock();
335  }
336  }
337  }
338 
339 }
340 ?>
__construct($a_parent_obj, $a_parent_cmd, $a_glossary, $a_offline, $a_tax_node, $a_tax_id=0)
Constructor.
static getDefinitionList($a_term_id)
static
$_GET["client_id"]
Term list table for presentation mode.
static shortenText($a_str, $a_len, $a_dots=false, $a_next_blank=false, $a_keep_extension=false)
shorten a string to given length.
addFilterItem($a_input_item, $a_optional=false)
Add filter item.
static _lookupTitle($a_id)
lookup object title
setId($a_val)
Set id.
global $ilCtrl
Definition: ilias.php:18
static xml2output($a_text, $a_wysiwyg=false, $a_replace_lists=true)
Converts xml from DB to output in edit textarea.
Class ilTable2GUI.
This class represents a text property in a property form.
$ilUser
Definition: imgupload.php:18
setMaxLength($a_maxlength)
Set Max Length.
Glossary definition page object.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
Create styles array
The data for the language used.
getAllFields()
Get all advanced metadata fields.
Class ilGlossaryDefinition.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
disable($a_module_name)
diesables particular modules of table
numericOrdering($a_field)
Should this field be sorted numeric?
static getInstance()
Singleton: get instance.
global $lng
Definition: privfeed.php:17
global $ilDB
setShowRowsSelector($a_value)
Toggle rows-per-page selector.
setEnableHeader($a_enableheader)
Set Enable Header.
getAdvMDRecordGUI()
needed for advmd filter handling
setEnableTitle($a_enabletitle)
Set Enable Title.
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.
setFilterCommand($a_val, $a_caption=null)
Set filter command.