ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilSubItemListGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 
25 include_once './Services/Search/classes/class.ilSearchSettings.php';
26 
36 abstract class ilSubItemListGUI
37 {
38  protected static $MAX_SUBITEMS = 5;
39 
40  protected $cmdClass = null;
41 
42  protected $tpl;
43  private $highlighter = null;
44 
45  private static $details = array();
46 
47  private $subitem_ids = array();
48  private $item_list_gui;
49  private $ref_id;
50  private $obj_id;
51  private $type;
52 
58  public function __construct($a_cmd_class)
59  {
60 
61  $this->cmdClass = $a_cmd_class;
62  self::$MAX_SUBITEMS = ilSearchSettings::getInstance()->getMaxSubitems();
63  }
64 
74  public static final function setShowDetails($a_obj_id)
75  {
76  $_SESSION['lucene_search']['details'][$a_obj_id] = true;
77  }
78 
86  public static final function resetDetails()
87  {
88  $_SESSION['lucene_search']['details'] = array();
89  }
90 
99  public static final function enabledDetails($a_obj_id)
100  {
101  return isset($_SESSION['lucene_search']['details'][$a_obj_id]) and $_SESSION['lucene_search']['details'][$a_obj_id];
102  }
103 
108  public function getCmdClass()
109  {
110  return $this->cmdClass;
111  }
112 
113 
119  public function setHighlighter($a_highlighter)
120  {
121  $this->highlighter = $a_highlighter;
122  }
123 
129  public function getHighlighter()
130  {
131  return $this->highlighter;
132  }
133 
138  public function getRefId()
139  {
140  return $this->ref_id;
141  }
142 
147  public function getObjId()
148  {
149  return $this->obj_id;
150  }
151 
156  public function getType()
157  {
158  return $this->type;
159  }
160 
166  public function getSubItemIds($a_limited = false)
167  {
168  if($a_limited and !self::enabledDetails($this->getObjId()))
169  {
170  return array_slice($this->subitem_ids,0,self::$MAX_SUBITEMS);
171  }
172 
173  return $this->subitem_ids;
174  }
175 
180  public function getItemListGUI()
181  {
182  return $this->item_list_gui;
183  }
184 
190  public function init($item_list_gui,$a_ref_id,$a_subitem_ids)
191  {
192  $this->tpl = new ilTemplate('tpl.subitem_list.html',true,true,'Services/Object');
193  $this->item_list_gui = $item_list_gui;
194  $this->ref_id = $a_ref_id;
195  $this->obj_id = ilObject::_lookupObjId($this->getRefId());
196  $this->type = ilObject::_lookupType($this->getObjId());
197 
198  $this->subitem_ids = $a_subitem_ids;
199  }
200 
205  protected function showDetailsLink()
206  {
207  global $ilCtrl,$lng;
208 
209  if(count($this->getSubItemIds()) <= self::$MAX_SUBITEMS)
210  {
211  return;
212  }
213  if(self::enabledDetails($this->getObjId()))
214  {
215  return;
216  }
217 
218  $additional = count($this->getSubItemIds()) - self::$MAX_SUBITEMS;
219 
220  $ilCtrl->setParameterByClass(get_class($this->getCmdClass()), 'details', (int) $this->getObjId());
221  $link = $ilCtrl->getLinkTargetByClass(get_class($this->getCmdClass()),'');
222  $ilCtrl->clearParametersByClass(get_class($this->getCmdClass()));
223 
224  $this->tpl->setCurrentBlock('choose_details');
225  $this->tpl->setVariable('LUC_DETAILS_LINK',$link);
226  $this->tpl->setVariable('LUC_NUM_HITS',sprintf($lng->txt('lucene_more_hits_link'),$additional));
227  $this->tpl->parseCurrentBlock();
228 
229 
230  }
231 
232  // begin-patch mime_filter
233  protected function parseRelevance($sub_item)
234  {
235  if(!ilSearchSettings::getInstance()->isSubRelevanceVisible() ||
236  !ilSearchSettings::getInstance()->enabledLucene())
237  {
238  return '';
239  }
240 
241  $relevance = $this->getHighlighter()->getRelevance($this->getObjId(),$sub_item);
242 
243  //$this->tpl->addBlockFile('SUB_REL','sub_rel','tpl.lucene_sub_relevance.html','Services/Search');
244 
245  include_once "Services/UIComponent/ProgressBar/classes/class.ilProgressBar.php";
246  $pbar = ilProgressBar::getInstance();
247  $pbar->setCurrent($relevance);
248 
249  $this->tpl->setVariable('REL_PBAR', $pbar->render());
250  }
251  // end-patch mime_filter
252 
253  abstract public function getHTML();
254 
255 
256 }
257 ?>
__construct($a_cmd_class)
Constructor.
$_SESSION["AccountId"]
getHighlighter()
get highlighter
Base class for all sub item list gui&#39;s.
static resetDetails()
reset details As long as static::resetDetails is not possible this method is final ...
global $ilCtrl
Definition: ilias.php:18
showDetailsLink()
show details link
static getInstance()
Factory.
static _lookupObjId($a_id)
getCmdClass()
get cmd class
special template class to simplify handling of ITX/PEAR
setHighlighter($a_highlighter)
set highlighter
static setShowDetails($a_obj_id)
set show details.
$additional
Definition: goto.php:52
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
static enabledDetails($a_obj_id)
enabled show details As long as static::enableDetails is not possible this method is final ...
init($item_list_gui, $a_ref_id, $a_subitem_ids)
init
global $lng
Definition: privfeed.php:17
getItemListGUI()
get item list gui
getSubItemIds($a_limited=false)
get sub item ids