ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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");
5
15{
16
20 function __construct($a_parent_obj, $a_parent_cmd, $a_presenter)
21 {
22 global $ilCtrl, $lng, $ilAccess, $lng;
23
24 $this->setId("ilSearchResultsTable");
25
26 $this->presenter = $a_presenter;
27 $this->setId('search_'.$GLOBALS['ilUser']->getId());
28 parent::__construct($a_parent_obj, $a_parent_cmd);
29 $this->setTitle($lng->txt("search_results"));
30 $this->setLimit(999);
31// $this->setId("srcres");
32
33 //$this->addColumn("", "", "1", true);
34 #$this->addColumn($this->lng->txt("type"), "type", "1");
35 #$this->addColumn($this->lng->txt("search_title_description"), "title_sort");
36 $this->addColumn($this->lng->txt("type"), "type", "1");
37 $this->addColumn($this->lng->txt("search_title_description"), "title");
38
39 $all_cols = $this->getSelectableColumns();
40 foreach($this->getSelectedColumns() as $col)
41 {
42 $this->addColumn($all_cols[$col]['txt'], $col,'50px');
43 }
44
45 if($this->enabledRelevance())
46 {
47 #$this->addColumn($this->lng->txt('lucene_relevance_short'),'s_relevance','50px');
48 $this->addColumn($this->lng->txt('lucene_relevance_short'),'relevance','50px');
49 $this->setDefaultOrderField("s_relevance");
50 $this->setDefaultOrderDirection("desc");
51 }
52
53
54 $this->addColumn($this->lng->txt("actions"), "", "10px");
55
56 $this->setEnableHeader(true);
57 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
58 $this->setRowTemplate("tpl.search_result_row.html", "Services/Search");
59 //$this->disable("footer");
60 $this->setEnableTitle(true);
61 $this->setEnableNumInfo(false);
62 $this->setShowRowsSelector(false);
63
64 include_once "Services/Object/classes/class.ilObjectActivation.php";
65 }
66
67 public function numericOrdering($a_field)
68 {
69 switch($a_field)
70 {
71 case 'relevance':
72 return true;
73 }
74
75
76 return parent::numericOrdering($a_field);
77 }
78
83 public function getSelectableColumns()
84 {
85 global $ilSetting;
86
87
88 return array('create_date' =>
89 array(
90 'txt' => $this->lng->txt('create_date'),
91 'default' => false
92 )
93 );
94 }
95
96
100 protected function fillRow($a_set)
101 {
102 global $lng, $objDefinition;
103
104 $obj_id = $a_set["obj_id"];
105 $ref_id = $a_set["ref_id"];
106 $type = $a_set['type'];
107 $title = $a_set['title'];
108 $description = $a_set['description'];
109 $relevance = $a_set['relevance'];
110
111 if(!$type)
112 {
113 return false;
114 }
115
116 include_once './Services/Search/classes/Lucene/class.ilLuceneSearchObjectListGUIFactory.php';
117 $item_list_gui = ilLuceneSearchObjectListGUIFactory::factory($type);
118 $item_list_gui->initItem($ref_id,$obj_id,$title,$description);
119 $item_list_gui->setContainerObject($this->parent_obj);
120 $item_list_gui->setSearchFragment($this->presenter->lookupContent($obj_id,0));
121 $item_list_gui->setSeparateCommands(true);
122
124
125 $this->presenter->appendAdditionalInformation($item_list_gui,$ref_id,$obj_id,$type);
126
127 $this->tpl->setVariable("ACTION_HTML", $item_list_gui->getCommandsHTML());
128
129 if($html = $item_list_gui->getListItemHTML($ref_id,$obj_id,$title,$description))
130 {
131 $item_html[$ref_id]['html'] = $html;
132 $item_html[$ref_id]['type'] = $type;
133 }
134
135 $this->tpl->setVariable("HREF_IMG", $item_list_gui->default_command["link"]);
136
137 global $lng;
138
139 if($this->enabledRelevance())
140 {
141 include_once "Services/UIComponent/ProgressBar/classes/class.ilProgressBar.php";
143 $pbar->setCurrent($relevance);
144
145 $this->tpl->setCurrentBlock('relev');
146 $this->tpl->setVariable('REL_PBAR', $pbar->render());
147 $this->tpl->parseCurrentBlock();
148 }
149
150
151 $this->tpl->setVariable("ITEM_HTML", $html);
152
153 foreach($this->getSelectedColumns() as $field)
154 {
155 switch($field)
156 {
157 case 'create_date':
158 $this->tpl->setCurrentBlock('creation');
159 $this->tpl->setVariable('CREATION_DATE', ilDatePresentation::formatDate(new ilDateTime(ilObject::_lookupCreationDate($obj_id),IL_CAL_DATETIME)));
160 $this->tpl->parseCurrentBlock();
161 }
162 }
163
164
165
166 if(!$objDefinition->isPlugin($type))
167 {
168 $type_txt = $lng->txt('icon').' '.$lng->txt('obj_'.$type);
169 $icon = ilObject::_getIcon($obj_id,'small',$type);
170 }
171 else
172 {
173 include_once("./Services/Component/classes/class.ilPlugin.php");
174 $type_txt = ilPlugin::lookupTxt("rep_robj", $type, "obj_".$type);
175 $icon = ilObject::_getIcon($obj_id,'small',$type);
176 }
177
178 $this->tpl->setVariable(
179 "TYPE_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
201}
202?>
const IL_CAL_DATETIME
static formatDate(ilDateTime $date)
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.
_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 lookupTxt($a_mod_prefix, $a_pl_id, $a_lang_var)
Lookup language text.
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.
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.
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.
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['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:40
global $ilSetting
Definition: privfeed.php:40
$ref_id
Definition: sahs_server.php:39