ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilBaseViewGUI.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 
32 abstract class ilBaseViewGUI
33 {
34 
35  /*
36  * Spacer CSS Classes
37  */
38  const TOP_SPACER = "ilFixedTopSpacer";
39  const TOP_SPACER_BAR_ONLY = "ilFixedTopSpacerBarOnly";
40 
41 
42  const ROOT_CONTAINER = "container";
43  const ROOT_CRS = "crs";
44  const ROOT_GRP = "grp";
45 
50  protected $allow_desktop = true; // deprecated but we should discuss concepts
51 
52  protected $view_nav = true;
53 
54  protected $use_top_bar_url = false;
55 
57 
62  protected $dic = null;
63 
64  protected $ctrl = null;
65 
66  protected $ilias = null;
67 
68  protected $link_dir = "";
69 
74  protected $home_id = '';
75 
79  protected $home_obj_id = '';
80 
85  protected $home_type = '';
86 
90  protected $home_title = '';
91 
95  protected $home_url = '';
96 
102  protected $home_items = [];
103 
107  protected $show_home_link = false;
108 
113  protected $root_folder_id = ROOT_FOLDER_ID;
114 
118  protected $root_folder_items = []; // deprecated
119 
124  public $tree_root_id = ROOT_FOLDER_ID;
125 
132  protected $tree_root_types = [];
133 
138  protected $fix_tree_id = '';
139 
143  protected $current_ref_id = "";
144 
148  protected $current_type = "";
149 
150 
151  public function __construct()
152  {
153  global $DIC, $ilCtrl, $ilias, $lng;
154  $this->dic = $DIC;
155  $this->ctrl = $ilCtrl;
156  $this->ilias = $ilias;
157  $this->link_dir = (defined("ILIAS_MODULE"))
158  ? "../"
159  : "";
160  }
161 
165  public function allowDesktop()
166  {
167  return $this->allow_desktop;
168  }
169 
173  public function showViewNav()
174  {
175  return $this->view_nav;
176  }
177 
181  public function spacerClass()
182  {
183  return ($this->topBarOnly) ? self::TOP_SPACER_BAR_ONLY : self::TOP_SPACER;
184  }
185 
190  public function addCss()
191  {
192  return [];
193  }
194 
199  public function appendInlineCss()
200  {
201  return [];
202  }
203 
207  protected function getHomeLink()
208  {
209  return $this->link_dir . "goto.php?target=" . $this->home_type . "_" . $this->home_id;
210  }
211 
215  protected function getCmdLink($cmd)
216  {
217  global $ilCtrl;
218  $targetScript = ($ilCtrl->getTargetScript() !== 'ilias.php') ? "ilias.php" : "";
219  return $this->link_dir . $targetScript . $ilCtrl->getLinkTargetByClass(array('illtiroutergui',strtolower(get_class($this))), $cmd) . "&baseClass=illtiroutergui";
220  }
221 
225  public function redirectToHome($_msg_type=self::MSG_INFO, $_msg='')
226  {
227  //$msg = ($_msg !== '') ? '&view_msg='.$_msg.'&view_msg_type='.$_msg_type : '';
228  //$link = $this->getHomeLink().$msg;
229  $_SESSION[$_msg_type] = $_msg;
230  $link = $this->getHomeLink();
231  $this->dic->logger()->lti()->write("redirectLink: " . $link);
232  ilUtil::redirect($link);
233  exit;
234  }
235 
236  public function getHomeTitle()
237  {
238  return ilObject::_lookupTitle($this->home_obj_id);
239  }
240 
244  public function findEffectiveRefId()
245  {
246  if ((int) $_GET['ref_id']) {
247  $this->current_type = ilObject::_lookupType($_GET['ref_id'], true);
248  return $this->current_ref_id = (int) $_GET['ref_id'];
249  }
250 
251  $target_arr = explode('_', (string) $_GET['target']);
252  if (isset($target_arr[1]) and (int) $target_arr[1]) {
253  $this->current_type = ilObject::_lookupType($target_arr[1], true);
254  $this->home_title = ilObject::_lookupTitle(ilObject::_lookupObjectId($target_arr[1]));
255  return $this->current_ref_id = (int) $target_arr[1];
256  }
257  }
258 
259  public function getHttpPath()
260  {
261  include_once './Services/Http/classes/class.ilHTTPS.php';
262  $https = new ilHTTPS();
263 
264  if ($https->isDetected()) {
265  $protocol = 'https://';
266  } else {
267  $protocol = 'http://';
268  }
269  $host = $_SERVER['HTTP_HOST'];
270  $rq_uri = $_SERVER['REQUEST_URI'];
271  return ilUtil::removeTrailingPathSeparators($protocol . $host . $rq_uri);
272  }
273 
277  public function isContainer($obj_type)
278  {
279  //return true;
280  return preg_match("/(crs|grp|cat|root|folder)/", $obj_type);
281  }
282 
283  protected function log($txt)
284  {
285  $this->dic->logger()->lti()->write($txt);
286  }
287 
294  public function getSessionValue($sess_key)
295  {
296  if (isset($_SESSION[$sess_key]) && $_SESSION[$sess_key] != '') {
297  return $_SESSION[$sess_key];
298  } else {
299  return '';
300  }
301  }
302 }
$target_arr
Definition: goto.php:47
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
$home_title
home title (title of ref_id)
$_SESSION["AccountId"]
$home_url
home Link (see topbar_back_url concept in MainMenuGUI)
global $DIC
Definition: saml.php:7
$_GET["client_id"]
addCss()
css files are added to the header
$current_ref_id
ref_id from current request
$root_folder_items
all allowed items
static _lookupTitle($a_id)
lookup object title
Base class for all ILIAS Views
$root_folder_id
root folder id Don&#39;t allow any access to higher level objects in this view
redirectToHome($_msg_type=self::MSG_INFO, $_msg='')
$tree_root_id
dynamic tree_root_folder_id show tree from tree_root_id
static _lookupObjectId($a_ref_id)
lookup object id
global $ilCtrl
Definition: ilias.php:18
$show_home_link
show home link in topbar (similar to topbar_back_url = &#39;&#39; in MainMenu)
HTTPS.
$allow_desktop
override these switches in the view constructor
$fix_tree_id
Fix tree_id Show always tree from id.
spacerClass()
spacer_class
findEffectiveRefId()
Find effective ref_id for request.
$home_obj_id
home obj_id
$tree_root_types
tree root types show tree from ref_id with obj_types if requested obj_type of ref_id is in array of $...
$https
Definition: imgupload.php:19
redirection script todo: (a better solution should control the processing via a xml file) ...
static removeTrailingPathSeparators($path)
$txt
Definition: error.php:11
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
appendInlineCss()
content of css files are appended to the main page html just before </body> end tag ...
getCmdLink($cmd)
helper function for cmd link creation
$home_items
cache ref_ids of home subtree items if request is in home context $show_home_link = false else $show_...
global $lng
Definition: privfeed.php:17
$current_type
obj_type of current ref_id
getSessionValue($sess_key)
get session value != &#39;&#39;
getHomeLink()
helper function for home link creation
$home_id
home id (ref_id) The view maybe support a view home link in the topbar (static or dynamically...
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
Definition: bootstrap.php:27
static redirect($a_script)
$home_type
home type (obj_type of ref_id) The view maybe support a view home link in the topbar (static or dynam...