165bcbe59913bb7e744c4460e926197a25bc4bab
[acontent.git] / docs / include / header.inc.php
1 <?php
2 /************************************************************************/
3 /* AContent                                                             */
4 /************************************************************************/
5 /* Copyright (c) 2010                                                   */
6 /* Inclusive Design Institute                                           */
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.                        */
11 /************************************************************************/
12
13 if (!defined('TR_INCLUDE_PATH')) { exit; }
14
15 //Timer, to display "Time Spent" in footer, debug information
16 $mtime = microtime(); 
17 $mtime = explode(' ', $mtime); 
18 $mtime = $mtime[1] + $mtime[0]; 
19 $starttime = $mtime; 
20 //Timer Ends
21
22 global $myLang;
23 global $savant;
24 global $onload;
25 global $_custom_css;
26 global $_custom_head;
27 global $_base_path;
28 global $_pages;
29 global $framed, $popup;
30 global $_current_user, $_course_id, $_sequence_links, $_tool_shortcuts;
31 global $validate_content;
32 global $contentManager;
33 global $course_base_href, $content_base_href;
34
35 include_once(TR_INCLUDE_PATH.'classes/Menu.class.php');
36
37 $menu =new Menu();
38 $_top_level_pages = $menu->getTopPages();
39
40 $_all_pages =  $menu->getAllPages();
41
42 $_current_root_page = $menu->getRootPage();
43
44 $_breadcrumb_path = $menu->getPath();
45
46 $current_page = $menu->getCurrentPage();
47
48 $_sub_menus = $menu->getSubMenus();
49 $back_to_page = $menu->getBackToPage();
50 $_pages = $menu->getAllPages();   // add "param" element into $_pages items
51
52 //debug($_base_path.$current_page);
53 //debug($back_to_page);
54 //debug($_sub_menus);
55 //exit;
56
57 //debug($_top_level_pages);
58 //debug($_all_pages);
59 //debug($_current_root_page);
60 //debug($_current_page);
61
62 $savant->assign('path', $_breadcrumb_path);
63 $savant->assign('top_level_pages', $_top_level_pages);
64 $savant->assign('current_top_level_page', $_current_root_page);
65 $savant->assign('sub_menus', $_sub_menus);
66 if ($back_to_page <> '') $savant->assign('back_to_page', $back_to_page);
67 $savant->assign('current_page', $_base_path.$current_page);
68
69 if (isset($_pages[$current_page]['title'])) {
70         $_page_title = $_all_pages[$current_page]['title'];
71 } else {
72         $_page_title = _AT($_all_pages[$current_page]['title_var']);
73 }
74 $savant->assign('page_title', htmlspecialchars($_page_title, ENT_COMPAT, "UTF-8"));
75
76 if ($_course_id > 0) {
77         $sequence_links = $contentManager->generateSequenceCrumbs($_content_id);
78         $savant->assign('sequence_links', $sequence_links);
79 }
80
81 if (isset($_current_user))
82 {
83   $savant->assign('user_name', $_current_user->getUserName());
84   if ($_course_id > 0) $savant->assign('isAuthor', $_current_user->isAuthor($_course_id));
85 }
86
87 if ($myLang->isRTL()) {
88         $savant->assign('rtl_css', '<link rel="stylesheet" href="'.$_base_path.'themes/'.$_SESSION['prefs']['PREF_THEME'].'/rtl.css" type="text/css" />');
89 } else {
90         $savant->assign('rtl_css', '');
91 }
92
93 $_tmp_base_href = TR_BASE_HREF;
94 if (isset($course_base_href) || isset($content_base_href)) {
95         $_tmp_base_href .= $course_base_href;
96         if ($content_base_href) {
97                 $_tmp_base_href .= $content_base_href;
98         }
99 }
100
101 // Setup array of content tools for shortcuts tool bar.
102 $savant->assign('tool_shortcuts', $_tool_shortcuts);  // array of content tools for shortcuts tool bar.
103
104 $savant->assign('content_base_href', $_tmp_base_href);
105 $savant->assign('lang_code', $_SESSION['lang']);
106 $savant->assign('lang_charset', $myLang->getCharacterSet());
107 $savant->assign('base_path', $_base_path);
108 $savant->assign('theme', $_SESSION['prefs']['PREF_THEME']);
109
110 $theme_img  = $_base_path . 'themes/'. $_SESSION['prefs']['PREF_THEME'] . '/images/';
111 $savant->assign('img', $theme_img);
112
113 // course categories for search tool
114 require_once(TR_INCLUDE_PATH.'classes/DAO/CourseCategoriesDAO.class.php');
115 $courseCategoriesDAO = new CourseCategoriesDAO();
116 $savant->assign('categories', $courseCategoriesDAO->getAll());
117
118 // get custom css
119 $custom_css = '';
120 if (isset($_custom_css)) {
121         $custom_css = '<link rel="stylesheet" href="'.$_custom_css.'" type="text/css" />';
122 }
123
124 if (isset($_custom_head)) {
125         $custom_css .= '
126 ' . $_custom_head;
127 }
128
129 if (isset($_pages[$current_page]['guide'])) 
130 {
131         $script_name = substr($_SERVER['PHP_SELF'], strlen($_base_path));
132         $savant->assign('guide', TR_GUIDES_PATH .'index.php?p='. htmlentities_utf8($script_name));
133 }
134
135 $savant->assign('custom_css', $custom_css);
136
137 if ($onload) $savant->assign('onload', $onload);
138 $savant->assign('course_id', $_course_id);
139
140 if ($framed || $popup) {
141         $savant->assign('framed', 1);
142     $savant->assign('popup', 1);
143
144         $savant->display('include/fm_header.tmpl.php');
145
146 } else {
147     $savant->display('include/header.tmpl.php');
148 }
149
150 ?>