ILIAS  Release_4_2_x_branch Revision 61807
 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"), "", "1");
34  $this->addColumn($this->lng->txt("search_title_description"), "");
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'),'','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 
55  protected function fillRow($a_set)
56  {
57  global $lng, $objDefinition;
58 
59  $obj_id = $a_set["obj_id"];
60  $ref_id = $a_set["ref_id"];
61  $type = $a_set['type'];
62  $title = $a_set['title'];
63  $description = $a_set['description'];
64  $relevance = $a_set['relevance'];
65 
66  if(!$type)
67  {
68  return false;
69  }
70 
71  include_once './Services/Search/classes/Lucene/class.ilLuceneSearchObjectListGUIFactory.php';
72  $item_list_gui = ilLuceneSearchObjectListGUIFactory::factory($type);
73  $item_list_gui->initItem($ref_id,$obj_id,$title,$description);
74  $item_list_gui->setContainerObject($this->parent_obj);
75  $item_list_gui->setSearchFragment($this->presenter->lookupContent($obj_id,0));
76  $item_list_gui->setSeparateCommands(true);
77 
78  $this->presenter->appendAdditionalInformation($item_list_gui,$ref_id,$obj_id,$type);
79 
80  $this->tpl->setVariable("ACTION_HTML", $item_list_gui->getCommandsHTML());
81 
82  if($html = $item_list_gui->getListItemHTML($ref_id,$obj_id,$title,$description))
83  {
84  $item_html[$ref_id]['html'] = $html;
85  $item_html[$ref_id]['type'] = $type;
86  }
87 
88  global $lng;
89 
90  if($this->enabledRelevance())
91  {
92  $width1 = (int) ((int) $relevance / 2);
93  $width2 = (int) ((50 - $width1));
94 
95  $this->tpl->setCurrentBlock('relev');
96  $this->tpl->setVariable('VAL_REL',sprintf("%d %%",$relevance));
97  $this->tpl->setVariable('WIDTH_A',$width1);
98  $this->tpl->setVariable('WIDTH_B',$width2);
99  $this->tpl->setVariable('IMG_A',ilUtil::getImagePath("relevance_blue.gif"));
100  $this->tpl->setVariable('IMG_B',ilUtil::getImagePath("relevance_dark.gif"));
101  $this->tpl->parseCurrentBlock();
102  }
103 
104  $this->tpl->setVariable("ITEM_HTML", $html);
105 
106  if(!$objDefinition->isPlugin($type))
107  {
108  $type_txt = $lng->txt('icon').' '.$lng->txt('obj_'.$type);
109  $icon = ilUtil::getImagePath('icon_'.$type.'.gif');
110  }
111  else
112  {
113  include_once("./Services/Component/classes/class.ilPlugin.php");
114  $type_txt = ilPlugin::lookupTxt("rep_robj", $type, "obj_".$type);
115  $icon = ilObject::_getIcon($obj_id,'small',$type);
116  }
117 
118  $this->tpl->setVariable(
119  "TYPE_IMG",
120  ilUtil::img(
121  $icon,
122  $type_txt
123  )
124  );
125  }
126 
131  protected function enabledRelevance()
132  {
133  return ilSearchSettings::getInstance()->enabledLucene() and ilSearchSettings::getInstance()->isRelevanceVisible();
134  }
135 
136 }
137 ?>