ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilSearchBaseGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 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 
35 include_once 'Services/Search/classes/class.ilSearchSettings.php';
36 
38 {
39  var $settings = null;
40 
41  protected $ctrl = null;
42  var $ilias = null;
43  var $lng = null;
44  var $tpl = null;
45 
50  function ilSearchBaseGUI()
51  {
52  global $ilCtrl,$ilias,$lng,$tpl,$ilMainMenu;
53 
54  $this->ilias =& $ilias;
55  $this->ctrl =& $ilCtrl;
56  $this->tpl =& $tpl;
57  $this->lng =& $lng;
58  $this->lng->loadLanguageModule('search');
59 
60  $ilMainMenu->setActive('search');
61  $this->settings =& new ilSearchSettings();
62  }
63 
64  function prepareOutput()
65  {
66  $this->tpl->addBlockFile("CONTENT", "content", "tpl.search_base.html",'Services/Search');
67  $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
69 
70  }
71 
79  protected function addPager($result,$a_session_key)
80  {
81  global $tpl;
82 
83  $_SESSION["$a_session_key"] = max($_SESSION["$a_session_key"],$this->search_cache->getResultPageNumber());
84 
85  if($_SESSION["$a_session_key"] == 1 and
86  (count($result->getResults()) < $result->getMaxHits()))
87  {
88  return true;
89  }
90 
91  if($this->search_cache->getResultPageNumber() > 1)
92  {
93  $this->ctrl->setParameter($this,'page_number',$this->search_cache->getResultPageNumber() - 1);
94  $this->tpl->setCurrentBlock('prev');
95  $this->tpl->setVariable('PREV_LINK',$this->ctrl->getLinkTarget($this,'performSearch'));
96  $this->tpl->setVariable('TXT_PREV',$this->lng->txt('search_page_prev'));
97  $this->tpl->parseCurrentBlock();
98  }
99  for($i = 1;$i <= $_SESSION["$a_session_key"];$i++)
100  {
101  if($i == $this->search_cache->getResultPageNumber())
102  {
103  $this->tpl->setCurrentBlock('pages_link');
104  $this->tpl->setVariable('NUMBER',$i);
105  $this->tpl->parseCurrentBlock();
106  continue;
107  }
108 
109  $this->ctrl->setParameter($this,'page_number',$i);
110  $link = '<a href="'.$this->ctrl->getLinkTarget($this,'performSearch').'" /a>'.$i.'</a> ';
111  $this->tpl->setCurrentBlock('pages_link');
112  $this->tpl->setVariable('NUMBER',$link);
113  $this->tpl->parseCurrentBlock();
114  }
115 
116 
117  if(count($result->getResults()) >= $result->getMaxHits())
118  {
119  $this->tpl->setCurrentBlock('next');
120  $this->ctrl->setParameter($this,'page_number',$this->search_cache->getResultPageNumber() + 1);
121  $this->tpl->setVariable('NEXT_LINK',$this->ctrl->getLinkTarget($this,'performSearch'));
122  $this->tpl->setVariable('TXT_NEXT',$this->lng->txt('search_page_next'));
123  $this->tpl->parseCurrentBlock();
124  }
125 
126  $this->tpl->setCurrentBlock('prev_next');
127  $this->tpl->setVariable('SEARCH_PAGE',$this->lng->txt('search_page'));
128  $this->tpl->parseCurrentBlock();
129 
130  $this->ctrl->clearParameters($this);
131  }
132 
133 }
134 ?>