ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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
4include_once("./Services/Table/classes/class.ilTable2GUI.php");
5require_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 $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 $this->addColumn($all_cols[$col]['txt'], $col, '50px');
43 }
44
45 if ($this->enabledRelevance()) {
46 #$this->addColumn($this->lng->txt('lucene_relevance_short'),'s_relevance','50px');
47 $this->addColumn($this->lng->txt('lucene_relevance_short'), 'relevance', '50px');
48 $this->setDefaultOrderField("s_relevance");
49 $this->setDefaultOrderDirection("desc");
50 }
51
52
53 $this->addColumn($this->lng->txt("actions"), "", "10px");
54
55 $this->setEnableHeader(true);
56 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
57 $this->setRowTemplate("tpl.search_result_row.html", "Services/Search");
58 //$this->disable("footer");
59 $this->setEnableTitle(true);
60 $this->setEnableNumInfo(false);
61 $this->setShowRowsSelector(false);
62
63 include_once "Services/Object/classes/class.ilObjectActivation.php";
64 }
65
66 public function numericOrdering($a_field)
67 {
68 switch ($a_field) {
69 case 'relevance':
70 return true;
71 }
72
73
74 return parent::numericOrdering($a_field);
75 }
76
81 public function getSelectableColumns()
82 {
83 global $ilSetting;
84
85
86 return array('create_date' =>
87 array(
88 'txt' => $this->lng->txt('create_date'),
89 'default' => false
90 )
91 );
92 }
93
94
98 protected function fillRow($a_set)
99 {
100 global $lng, $objDefinition;
101
102 $obj_id = $a_set["obj_id"];
103 $ref_id = $a_set["ref_id"];
104 $type = $a_set['type'];
105 $title = $a_set['title'];
106 $description = $a_set['description'];
107 $relevance = $a_set['relevance'];
108
109 if (!$type) {
110 return false;
111 }
112
113 include_once './Services/Search/classes/Lucene/class.ilLuceneSearchObjectListGUIFactory.php';
115 $item_list_gui->initItem($ref_id, $obj_id, $title, $description);
116 $item_list_gui->setContainerObject($this->parent_obj);
117 $item_list_gui->setSearchFragment($this->presenter->lookupContent($obj_id, 0));
118 $item_list_gui->setSeparateCommands(true);
119
121
122 $this->presenter->appendAdditionalInformation($item_list_gui, $ref_id, $obj_id, $type);
123
124 $this->tpl->setVariable("ACTION_HTML", $item_list_gui->getCommandsHTML());
125
126 if ($html = $item_list_gui->getListItemHTML($ref_id, $obj_id, $title, $description)) {
127 $item_html[$ref_id]['html'] = $html;
128 $item_html[$ref_id]['type'] = $type;
129 }
130
131 $this->tpl->setVariable("HREF_IMG", $item_list_gui->default_command["link"]);
132
133 global $lng;
134
135 if ($this->enabledRelevance()) {
136 include_once "Services/UIComponent/ProgressBar/classes/class.ilProgressBar.php";
138 $pbar->setCurrent($relevance);
139
140 $this->tpl->setCurrentBlock('relev');
141 $this->tpl->setVariable('REL_PBAR', $pbar->render());
142 $this->tpl->parseCurrentBlock();
143 }
144
145
146 $this->tpl->setVariable("ITEM_HTML", $html);
147
148 foreach ($this->getSelectedColumns() as $field) {
149 switch ($field) {
150 case 'create_date':
151 $this->tpl->setCurrentBlock('creation');
152 $this->tpl->setVariable('CREATION_DATE', ilDatePresentation::formatDate(new ilDateTime(ilObject::_lookupCreationDate($obj_id), IL_CAL_DATETIME)));
153 $this->tpl->parseCurrentBlock();
154 }
155 }
156
157
158
159 if (!$objDefinition->isPlugin($type)) {
160 $type_txt = $lng->txt('icon') . ' ' . $lng->txt('obj_' . $type);
161 $icon = ilObject::_getIcon($obj_id, 'small', $type);
162 } else {
163 include_once("./Services/Component/classes/class.ilPlugin.php");
164 $type_txt = ilObjectPlugin::lookupTxtById($type, "obj_" . $type);
165 $icon = ilObject::_getIcon($obj_id, 'small', $type);
166 }
167
168 $this->tpl->setVariable(
169 "TYPE_IMG",
171 $icon,
172 $type_txt,
173 '',
174 '',
175 0,
176 '',
177 'ilIcon'
178 )
179 );
180 }
181
186 protected function enabledRelevance()
187 {
188 return ilSearchSettings::getInstance()->enabledLucene() and ilSearchSettings::getInstance()->isRelevanceVisible();
189 }
190}
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_DATETIME
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false)
Format a date @access public.
@classDescription Date and time handling
static factory($a_type)
Get list gui by type This method caches all the returned list guis.
static addListGUIActivationProperty(ilObjectListGUI $a_list_gui, array &$a_item)
Get timing details for list gui.
static lookupTxtById($plugin_id, $lang_var)
static _lookupCreationDate($a_id)
Lookup creation date.
static _getIcon( $a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
static getInstance()
Factory.
TableGUI class for search results.
enabledRelevance()
Check if relevance is visible.
getSelectableColumns()
Get selectable columns.
numericOrdering($a_field)
Should this field be sorted numeric?
__construct($a_parent_obj, $a_parent_cmd, $a_presenter)
Constructor.
Class ilTable2GUI.
getSelectedColumns()
Get selected columns.
setEnableHeader($a_enableheader)
Set Enable Header.
setShowRowsSelector($a_value)
Toggle rows-per-page selector.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
getId()
Get element id.
setEnableTitle($a_enabletitle)
Set Enable Title.
setEnableNumInfo($a_val)
Set enable num info.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setLimit($a_limit=0, $a_default_limit=0)
set max.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
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.
setId($a_val)
Set id.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
static img($a_src, $a_alt="", $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
$html
Definition: example_001.php:87
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
global $ilCtrl
Definition: ilias.php:18
global $ilSetting
Definition: privfeed.php:17
$type