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