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