ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilSearchResultTableGUI.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 require_once('./Services/Repository/classes/class.ilObjectPlugin.php');
6 
16 {
17 
21  public function __construct($a_parent_obj, $a_parent_cmd, $a_presenter)
22  {
23  global $DIC;
24 
25  $ilCtrl = $DIC['ilCtrl'];
26  $lng = $DIC['lng'];
27  $ilAccess = $DIC['ilAccess'];
28  $lng = $DIC['lng'];
29 
30  $this->setId("ilSearchResultsTable");
31 
32  $this->presenter = $a_presenter;
33  $this->setId('search_' . $GLOBALS['DIC']['ilUser']->getId());
34  parent::__construct($a_parent_obj, $a_parent_cmd);
35  $this->setTitle($lng->txt("search_results"));
36  $this->setLimit(999);
37  // $this->setId("srcres");
38 
39  //$this->addColumn("", "", "1", true);
40  #$this->addColumn($this->lng->txt("type"), "type", "1");
41  #$this->addColumn($this->lng->txt("search_title_description"), "title_sort");
42  $this->addColumn($this->lng->txt("type"), "type", "1");
43  $this->addColumn($this->lng->txt("search_title_description"), "title");
44 
45  $all_cols = $this->getSelectableColumns();
46  foreach ($this->getSelectedColumns() as $col) {
47  $this->addColumn($all_cols[$col]['txt'], $col, '50px');
48  }
49 
50  if ($this->enabledRelevance()) {
51  #$this->addColumn($this->lng->txt('lucene_relevance_short'),'s_relevance','50px');
52  $this->addColumn($this->lng->txt('lucene_relevance_short'), 'relevance', '50px');
53  $this->setDefaultOrderField("s_relevance");
54  $this->setDefaultOrderDirection("desc");
55  }
56 
57 
58  $this->addColumn($this->lng->txt("actions"), "", "10px");
59 
60  $this->setEnableHeader(true);
61  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
62  $this->setRowTemplate("tpl.search_result_row.html", "Services/Search");
63  //$this->disable("footer");
64  $this->setEnableTitle(true);
65  $this->setEnableNumInfo(false);
66  $this->setShowRowsSelector(false);
67 
68  include_once "Services/Object/classes/class.ilObjectActivation.php";
69  }
70 
71  public function numericOrdering($a_field)
72  {
73  switch ($a_field) {
74  case 'relevance':
75  return true;
76  }
77 
78 
79  return parent::numericOrdering($a_field);
80  }
81 
86  public function getSelectableColumns()
87  {
88  global $DIC;
89 
90  $ilSetting = $DIC['ilSetting'];
91 
92 
93  return array('create_date' =>
94  array(
95  'txt' => $this->lng->txt('create_date'),
96  'default' => false
97  )
98  );
99  }
100 
101 
105  protected function fillRow($a_set)
106  {
107  global $DIC;
108 
109  $lng = $DIC['lng'];
110  $objDefinition = $DIC['objDefinition'];
111 
112  $obj_id = $a_set["obj_id"];
113  $ref_id = $a_set["ref_id"];
114  $type = $a_set['type'];
115  $title = $a_set['title'];
116  $description = $a_set['description'];
117  $relevance = $a_set['relevance'];
118 
119  if (!$type) {
120  return false;
121  }
122 
123  include_once './Services/Search/classes/Lucene/class.ilLuceneSearchObjectListGUIFactory.php';
125  $item_list_gui->initItem($ref_id, $obj_id, $title, $description);
126  $item_list_gui->setContainerObject($this->parent_obj);
127  $item_list_gui->setSearchFragment($this->presenter->lookupContent($obj_id, 0));
128  $item_list_gui->setSeparateCommands(true);
129 
130  ilObjectActivation::addListGUIActivationProperty($item_list_gui, $a_set);
131 
132  $this->presenter->appendAdditionalInformation($item_list_gui, $ref_id, $obj_id, $type);
133 
134  $this->tpl->setVariable("ACTION_HTML", $item_list_gui->getCommandsHTML());
135 
136  if ($html = $item_list_gui->getListItemHTML($ref_id, $obj_id, $title, $description)) {
137  $item_html[$ref_id]['html'] = $html;
138  $item_html[$ref_id]['type'] = $type;
139  }
140 
141  global $DIC;
142 
143  $lng = $DIC['lng'];
144 
145  if ($this->enabledRelevance()) {
146  include_once "Services/UIComponent/ProgressBar/classes/class.ilProgressBar.php";
147  $pbar = ilProgressBar::getInstance();
148  $pbar->setCurrent($relevance);
149 
150  $this->tpl->setCurrentBlock('relev');
151  $this->tpl->setVariable('REL_PBAR', $pbar->render());
152  $this->tpl->parseCurrentBlock();
153  }
154 
155 
156  $this->tpl->setVariable("ITEM_HTML", $html);
157 
158  foreach ($this->getSelectedColumns() as $field) {
159  switch ($field) {
160  case 'create_date':
161  $this->tpl->setCurrentBlock('creation');
162  $this->tpl->setVariable('CREATION_DATE', ilDatePresentation::formatDate(new ilDateTime(ilObject::_lookupCreationDate($obj_id), IL_CAL_DATETIME)));
163  $this->tpl->parseCurrentBlock();
164  }
165  }
166 
167 
168 
169  if (!$objDefinition->isPlugin($type)) {
170  $type_txt = $lng->txt('icon') . ' ' . $lng->txt('obj_' . $type);
171  $icon = ilObject::_getIcon($obj_id, 'small', $type);
172  } else {
173  include_once("./Services/Component/classes/class.ilPlugin.php");
174  $type_txt = ilObjectPlugin::lookupTxtById($type, "obj_" . $type);
175  $icon = ilObject::_getIcon($obj_id, 'small', $type);
176  }
177 
178  $this->tpl->setVariable(
179  "TYPE_IMG",
180  ilUtil::img(
181  $icon,
182  $type_txt,
183  '',
184  '',
185  0,
186  '',
187  'ilIcon'
188  )
189  );
190  }
191 
196  protected function enabledRelevance()
197  {
198  return ilSearchSettings::getInstance()->enabledLucene() and ilSearchSettings::getInstance()->isRelevanceVisible();
199  }
200 }
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
const IL_CAL_DATETIME
static lookupTxtById($plugin_id, $lang_var)
$type
global $DIC
Definition: saml.php:7
setEnableNumInfo($a_val)
Set enable num info.
getSelectableColumns()
Get selectable columns.
TableGUI class for search results.
enabledRelevance()
Check if relevance is visible.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
setId($a_val)
Set id.
global $ilCtrl
Definition: ilias.php:18
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
Class ilTable2GUI.
static getInstance()
Factory.
static _lookupCreationDate($a_id)
Lookup creation date.
Date and time handling
getSelectedColumns()
Get selected columns.
static addListGUIActivationProperty(ilObjectListGUI $a_list_gui, array &$a_item)
Get timing details for list gui.
static img($a_src, $a_alt=null, $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
global $ilSetting
Definition: privfeed.php:17
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.
setShowRowsSelector($a_value)
Toggle rows-per-page selector.
__construct($a_parent_obj, $a_parent_cmd, $a_presenter)
Constructor.
setEnableHeader($a_enableheader)
Set Enable Header.
getId()
Get element id.
setEnableTitle($a_enabletitle)
Set Enable Title.
$html
Definition: example_001.php:87
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
setLimit($a_limit=0, $a_default_limit=0)
static factory($a_type)
Get list gui by type This method caches all the returned list guis.