ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 {
41  protected $ctrl;
42 
46  protected $lng;
47 
48  protected static $MAX_SUBITEMS = 5;
49 
50  protected $cmdClass = null;
51 
52  protected $tpl;
53  private $highlighter = null;
54 
55  private static $details = array();
56 
57  private $subitem_ids = array();
58  private $item_list_gui;
59  private $ref_id;
60  private $obj_id;
61  private $type;
62 
68  public function __construct($a_cmd_class)
69  {
70  global $DIC;
71 
72  $this->ctrl = $DIC->ctrl();
73  $this->lng = $DIC->language();
74 
75  $this->cmdClass = $a_cmd_class;
76  self::$MAX_SUBITEMS = ilSearchSettings::getInstance()->getMaxSubitems();
77  }
78 
88  final public static function setShowDetails($a_obj_id)
89  {
90  $_SESSION['lucene_search']['details'][$a_obj_id] = true;
91  }
92 
100  final public static function resetDetails()
101  {
102  $_SESSION['lucene_search']['details'] = array();
103  }
104 
113  final public static function enabledDetails($a_obj_id)
114  {
115  return isset($_SESSION['lucene_search']['details'][$a_obj_id]) and $_SESSION['lucene_search']['details'][$a_obj_id];
116  }
117 
122  public function getCmdClass()
123  {
124  return $this->cmdClass;
125  }
126 
127 
133  public function setHighlighter($a_highlighter)
134  {
135  $this->highlighter = $a_highlighter;
136  }
137 
143  public function getHighlighter()
144  {
145  return $this->highlighter;
146  }
147 
152  public function getRefId()
153  {
154  return $this->ref_id;
155  }
156 
161  public function getObjId()
162  {
163  return $this->obj_id;
164  }
165 
170  public function getType()
171  {
172  return $this->type;
173  }
174 
180  public function getSubItemIds($a_limited = false)
181  {
182  if ($a_limited and !self::enabledDetails($this->getObjId())) {
183  return array_slice($this->subitem_ids, 0, self::$MAX_SUBITEMS);
184  }
185 
186  return $this->subitem_ids;
187  }
188 
193  public function getItemListGUI()
194  {
195  return $this->item_list_gui;
196  }
197 
203  public function init($item_list_gui, $a_ref_id, $a_subitem_ids)
204  {
205  $this->tpl = new ilTemplate('tpl.subitem_list.html', true, true, 'Services/Object');
206  $this->item_list_gui = $item_list_gui;
207  $this->ref_id = $a_ref_id;
208  $this->obj_id = ilObject::_lookupObjId($this->getRefId());
209  $this->type = ilObject::_lookupType($this->getObjId());
210 
211  $this->subitem_ids = $a_subitem_ids;
212  }
213 
218  protected function showDetailsLink()
219  {
221  $lng = $this->lng;
222 
223  if (count($this->getSubItemIds()) <= self::$MAX_SUBITEMS) {
224  return;
225  }
226  if (self::enabledDetails($this->getObjId())) {
227  return;
228  }
229 
230  $additional = count($this->getSubItemIds()) - self::$MAX_SUBITEMS;
231 
232  $ilCtrl->setParameterByClass(get_class($this->getCmdClass()), 'details', (int) $this->getObjId());
233  $link = $ilCtrl->getLinkTargetByClass(get_class($this->getCmdClass()), '');
234  $ilCtrl->clearParametersByClass(get_class($this->getCmdClass()));
235 
236  $this->tpl->setCurrentBlock('choose_details');
237  $this->tpl->setVariable('LUC_DETAILS_LINK', $link);
238  $this->tpl->setVariable('LUC_NUM_HITS', sprintf($lng->txt('lucene_more_hits_link'), $additional));
239  $this->tpl->parseCurrentBlock();
240  }
241 
242  // begin-patch mime_filter
243  protected function parseRelevance($sub_item)
244  {
245  if (!ilSearchSettings::getInstance()->isSubRelevanceVisible() ||
246  !ilSearchSettings::getInstance()->enabledLucene()) {
247  return '';
248  }
249 
250  $relevance = $this->getHighlighter()->getRelevance($this->getObjId(), $sub_item);
251 
252  //$this->tpl->addBlockFile('SUB_REL','sub_rel','tpl.lucene_sub_relevance.html','Services/Search');
253 
254  include_once "Services/UIComponent/ProgressBar/classes/class.ilProgressBar.php";
255  $pbar = ilProgressBar::getInstance();
256  $pbar->setCurrent($relevance);
257 
258  $this->tpl->setVariable('REL_PBAR', $pbar->render());
259  }
260  // end-patch mime_filter
261 
262  abstract public function getHTML();
263 }
__construct($a_cmd_class)
Constructor.
$_SESSION["AccountId"]
global $DIC
Definition: saml.php:7
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:50
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
getItemListGUI()
get item list gui
getSubItemIds($a_limited=false)
get sub item ids