ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
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  parent::__construct($a_parent_obj, $a_parent_cmd);
28  $this->setTitle($lng->txt("search_results"));
29  $this->setLimit(999);
30 // $this->setId("srcres");
31 
32  //$this->addColumn("", "", "1", true);
33  #$this->addColumn($this->lng->txt("type"), "type", "1");
34  #$this->addColumn($this->lng->txt("search_title_description"), "title_sort");
35  $this->addColumn($this->lng->txt("type"), "type", "1");
36  $this->addColumn($this->lng->txt("search_title_description"), "title");
37  if($this->enabledRelevance())
38  {
39  #$this->addColumn($this->lng->txt('lucene_relevance_short'),'s_relevance','50px');
40  $this->addColumn($this->lng->txt('lucene_relevance_short'),'relevance','50px');
41  $this->setDefaultOrderField("s_relevance");
42  $this->setDefaultOrderDirection("desc");
43  }
44  $this->addColumn($this->lng->txt("actions"), "", "10px");
45 
46  $this->setEnableHeader(true);
47  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
48  $this->setRowTemplate("tpl.search_result_row.html", "Services/Search");
49  //$this->disable("footer");
50  $this->setEnableTitle(true);
51  $this->setEnableNumInfo(false);
52 
53  include_once "Services/Object/classes/class.ilObjectActivation.php";
54  }
55 
56  public function numericOrdering($a_field)
57  {
58  switch($a_field)
59  {
60  case 'relevance':
61  return true;
62  }
63 
64 
65  return parent::numericOrdering($a_field);
66  }
67 
71  protected function fillRow($a_set)
72  {
73  global $lng, $objDefinition;
74 
75  $obj_id = $a_set["obj_id"];
76  $ref_id = $a_set["ref_id"];
77  $type = $a_set['type'];
78  $title = $a_set['title'];
79  $description = $a_set['description'];
80  $relevance = $a_set['relevance'];
81 
82  if(!$type)
83  {
84  return false;
85  }
86 
87  include_once './Services/Search/classes/Lucene/class.ilLuceneSearchObjectListGUIFactory.php';
88  $item_list_gui = ilLuceneSearchObjectListGUIFactory::factory($type);
89  $item_list_gui->initItem($ref_id,$obj_id,$title,$description);
90  $item_list_gui->setContainerObject($this->parent_obj);
91  $item_list_gui->setSearchFragment($this->presenter->lookupContent($obj_id,0));
92  $item_list_gui->setSeparateCommands(true);
93 
94  ilObjectActivation::addListGUIActivationProperty($item_list_gui, $a_set);
95 
96  $this->presenter->appendAdditionalInformation($item_list_gui,$ref_id,$obj_id,$type);
97 
98  $this->tpl->setVariable("ACTION_HTML", $item_list_gui->getCommandsHTML());
99 
100  if($html = $item_list_gui->getListItemHTML($ref_id,$obj_id,$title,$description))
101  {
102  $item_html[$ref_id]['html'] = $html;
103  $item_html[$ref_id]['type'] = $type;
104  }
105 
106  $this->tpl->setVariable("HREF_IMG", $item_list_gui->default_command["link"]);
107 
108  global $lng;
109 
110  if($this->enabledRelevance())
111  {
112  include_once "Services/UIComponent/ProgressBar/classes/class.ilProgressBar.php";
113  $pbar = ilProgressBar::getInstance();
114  $pbar->setCurrent($relevance);
115 
116  $this->tpl->setCurrentBlock('relev');
117  $this->tpl->setVariable('REL_PBAR', $pbar->render());
118  $this->tpl->parseCurrentBlock();
119  }
120 
121  $this->tpl->setVariable("ITEM_HTML", $html);
122 
123  if(!$objDefinition->isPlugin($type))
124  {
125  $type_txt = $lng->txt('icon').' '.$lng->txt('obj_'.$type);
126  $icon = ilObject::_getIcon($obj_id,'small',$type);
127  }
128  else
129  {
130  include_once("./Services/Component/classes/class.ilPlugin.php");
131  $type_txt = ilPlugin::lookupTxt("rep_robj", $type, "obj_".$type);
132  $icon = ilObject::_getIcon($obj_id,'small',$type);
133  }
134 
135  $this->tpl->setVariable(
136  "TYPE_IMG",
137  ilUtil::img(
138  $icon,
139  $type_txt,
140  '',
141  '',
142  0,
143  '',
144  'ilIcon'
145  )
146  );
147  }
148 
153  protected function enabledRelevance()
154  {
155  return ilSearchSettings::getInstance()->enabledLucene() and ilSearchSettings::getInstance()->isRelevanceVisible();
156  }
157 
158 }
159 ?>