2 /************************************************************************/
4 /************************************************************************/
5 /* Copyright (c) 2002-2008 by Greg Gay, Joel Kronenberg & Heidi Hazelton*/
6 /* Adaptive Technology Resource Centre / University of Toronto */
9 /* This program is free software. You can redistribute it and/or */
10 /* modify it under the terms of the GNU General Public License */
11 /* as published by the Free Software Foundation. */
12 /************************************************************************/
15 if (!defined('AT_INCLUDE_PATH')) { exit; }
17 //header('Cache-Control: private, pre-check=0, post-check=0, max-age=0');
21 $mtime = explode(' ', $mtime);
22 $mtime = $mtime[1] + $mtime[0];
29 global $content_base_href, $course_base_href;
32 global $contentManager;
36 global $framed, $popup;
39 global $substr, $strlen, $course_id;
41 require(AT_INCLUDE_PATH . 'lib/menu_pages.php');
42 require(AT_INCLUDE_PATH . 'lib/pref_functions.inc.php');
43 //require(AT_INCLUDE_PATH."../jscripts/opensocial/all_opensocial.php");
45 $savant->assign('lang_code', $_SESSION['lang']);
46 $savant->assign('lang_charset', $myLang->getCharacterSet());
47 $savant->assign('base_path', $_base_path);
48 $savant->assign('base_tmpl_path', $_SERVER['HTTP_HOST']);
49 $savant->assign('theme', $_SESSION['prefs']['PREF_THEME']);
50 $savant->assign('current_date', AT_date(_AT('announcement_date_format')));
51 $savant->assign('just_social', $_config['just_social']);
53 $theme_img = $_base_path . 'themes/'. $_SESSION['prefs']['PREF_THEME'] . '/images/';
54 $savant->assign('img', $theme_img);
56 $_tmp_base_href = AT_BASE_HREF;
57 if (isset($course_base_href) || isset($content_base_href)) {
58 $_tmp_base_href .= $course_base_href;
59 if ($content_base_href) {
60 $_tmp_base_href .= $content_base_href;
64 $savant->assign('content_base_href', $_tmp_base_href);
65 $savant->assign('base_href', AT_BASE_HREF);
67 //Handle pretty url pages
68 if ((($_config['course_dir_name'] + $_config['pretty_url']) > 0) && ($temp = strpos($_SERVER['PHP_SELF'], AT_PRETTY_URL_HANDLER)) > 0){
69 $current_page = $pretty_current_page; //this is set in AT_PRETTY_URL_HANDLER
72 if ($myLang->isRTL()) {
73 $savant->assign('rtl_css', '<link rel="stylesheet" href="'.$_base_path.'themes/'.$_SESSION['prefs']['PREF_THEME'].'/rtl.css" type="text/css" />');
75 $savant->assign('rtl_css', '');
79 if (isset($_custom_css)) {
80 $custom_head = '<link rel="stylesheet" href="'.$_custom_css.'" type="text/css" />';
83 if (isset($_custom_head)) {
91 $savant->assign('custom_css', $custom_head);
93 if ($onload && ($_SESSION['prefs']['PREF_FORM_FOCUS'] || ($substr($onload, -8) != 'focus();'))) {
94 $savant->assign('onload', $onload);
97 if (isset($_SESSION['valid_user']) && $_SESSION['valid_user'] === true) {
98 if (!empty($_SESSION['member_id'])) {
99 $savant->assign('user_name', get_display_name($_SESSION['member_id']));
101 $savant->assign('user_name', $_SESSION['login']);
104 $savant->assign('user_name', _AT('guest'));
107 if (!isset($_pages[$current_page])) {
109 $msg->addError('PAGE_NOT_FOUND'); // probably the wrong error
110 header('location: '.AT_BASE_HREF.'index.php');
114 $_top_level_pages = get_main_navigation($current_page);
116 $_current_top_level_page = get_current_main_page($current_page);
118 if (empty($_top_level_pages)) {
119 if (!$_SESSION['member_id'] && !$_SESSION['course_id']) {
120 $_top_level_pages = get_main_navigation($_pages[AT_NAV_PUBLIC][0]);
121 } else if ($_SESSION['course_id'] < 0) {
122 $_top_level_pages = get_main_navigation($_pages[AT_NAV_ADMIN][0]);
123 } else if (!$_SESSION['course_id']) {
124 $_top_level_pages = get_main_navigation($_pages[AT_NAV_START][0]);
126 $_top_level_pages = get_main_navigation($_pages[AT_NAV_COURSE][0]);
129 $_sub_level_pages = get_sub_navigation($current_page);
131 $_current_sub_level_page = get_current_sub_navigation_page($current_page);
133 $_path = get_path($current_page);
136 if (isset($_path[2]['url'], $_sub_level_pages[0]['url']) && $_path[2]['url'] == $_sub_level_pages[0]['url']) {
137 $back_to_page = $_path[3];
138 } else if (isset($_path[1]['url'], $_sub_level_pages[0]['url']) && $_path[1]['url'] == $_sub_level_pages[0]['url']) {
139 $back_to_page = isset($_path[2]) ? $_path[2] : null;
140 } else if (isset($_path[1])) {
141 $back_to_page = $_path[1];
144 if (isset($_SESSION['course_id']) && $_SESSION['course_id'] > 0) {
145 $_path[] = array('url' => $_base_path . url_rewrite('index.php'), 'title' => $_SESSION['course_title']);
146 } else if (isset($_SESSION['course_id']) && $_SESSION['course_id'] < 0) {
147 $_path[] = array('url' => $_base_path . 'admin/index.php', 'title' => _AT('administration'));
150 if (isset($_SESSION['member_id']) && $_SESSION['member_id']) {
151 $_path[] = array('url' => $_base_path . 'bounce.php?course=0', 'title' => _AT('my_start_page'));
152 } else if (!isset($_SESSION['course_id']) || !$_SESSION['course_id']) {
153 $_path[] = array('url' => $_base_path . 'login.php', 'title' => SITE_NAME);
156 $_path = array_reverse($_path);
158 if (isset($_pages[$current_page]['title'])) {
159 $_page_title = $_pages[$current_page]['title'];
161 $_page_title = _AT($_pages[$current_page]['title_var']);
166 /* calculate the section_title: */
167 if (isset($_SESSION['course_id']) && $_SESSION['course_id'] > 0) {
168 //Truncate course title if it's > 45.
169 $session_course_title = htmlentities($_SESSION['course_title'], ENT_QUOTES, 'UTF-8');
170 $section_title = validate_length($session_course_title, 45, VALIDATE_LENGTH_FOR_DISPLAY);
171 // If there is an icon, display it on the header
172 $sql = 'SELECT icon FROM '.TABLE_PREFIX.'courses WHERE course_id='.$_SESSION['course_id'];
173 $result = mysql_query($sql, $db);
174 $row = mysql_fetch_assoc($result);
175 if (!empty($row['icon'])){
176 //Check if this is a custom icon, if so, use get_course_icon.php to get it
177 //Otherwise, simply link it from the images/
178 $custom_icon_path = AT_CONTENT_DIR.$_SESSION['course_id']."/custom_icons/";
179 if (file_exists($custom_icon_path.$row['icon'])) {
180 if (defined('AT_FORCE_GET_FILE') && AT_FORCE_GET_FILE) {
181 $course_icon = $_base_path.'get_course_icon.php/?id='.$_SESSION['course_id'];
183 $course_icon = $_base_path.'content/' . $_SESSION['course_id'] . '/';
186 $course_icon = $_base_path.'images/courses/'.$row['icon'];
188 $savant->assign('icon', $course_icon);
190 } else if (!isset($_SESSION['valid_user']) || !$_SESSION['valid_user']) {
191 $section_title = SITE_NAME;
192 if (defined('HOME_URL') && HOME_URL) {
193 $_top_level_pages[] = array('url' => HOME_URL, 'title' => _AT('home'));
195 } else if ($_SESSION['course_id'] < 0) {
196 $section_title = _AT('administration');
197 } else if (!$_SESSION['course_id']) {
198 $section_title = _AT('my_start_page');
200 $savant->assign('current_top_level_page', $_current_top_level_page);
201 $savant->assign('sub_level_pages', $_sub_level_pages);
202 $savant->assign('current_sub_level_page', $_current_sub_level_page);
204 $savant->assign('path', $_path);
205 $savant->assign('back_to_page', isset($back_to_page) ? $back_to_page : null);
206 $savant->assign('page_title', htmlspecialchars($_page_title, ENT_COMPAT, "UTF-8"));
207 $savant->assign('top_level_pages', $_top_level_pages);
208 $savant->assign('section_title', $section_title);
210 if (isset($_pages[$current_page]['guide'])) {
211 $savant->assign('guide', AT_GUIDES_PATH . $_pages[$current_page]['guide']);
214 $myLang->sendContentTypeHeader();
216 if (isset($_SESSION['course_id']) && $_SESSION['course_id'] > -1) {
218 /* the list of our courses: */
219 /* used for the courses drop down */
220 global $system_courses;
221 if ($_SESSION['valid_user']) {
222 $sql = "SELECT E.course_id FROM ".TABLE_PREFIX."course_enrollment E WHERE E.member_id=$_SESSION[member_id] AND E.approved<>'n'";
223 $result = @mysql_query($sql, $db);
225 $nav_courses = array(); /* the list of courses we're enrolled in or own */
226 while ($row = @mysql_fetch_assoc($result)) {
227 //Truncate course title if it's > 45.
228 $system_courses[$row['course_id']]['title'] = htmlentities($system_courses[$row['course_id']]['title'], ENT_QUOTES, 'UTF-8');
229 $nav_courses[$row['course_id']] = validate_length($system_courses[$row['course_id']]['title'], 45, VALIDATE_LENGTH_FOR_DISPLAY);
232 natcasesort($nav_courses);
234 $savant->assign('nav_courses', $nav_courses);
237 if (($_SESSION['course_id'] > 0) && isset($_SESSION['prefs']['PREF_JUMP_REDIRECT']) && $_SESSION['prefs']['PREF_JUMP_REDIRECT']) {
238 $savant->assign('rel_url', $_rel_url);
240 $savant->assign('rel_url', '');
243 /* course specific elements: */
244 /* != 'public' special case for the about.php page, which is available from a course but hides the content menu */
245 $sequence_links = array();
246 if ($_SESSION['course_id'] > 0) {
247 $sequence_links = $contentManager->generateSequenceCrumbs($cid);
248 $savant->assign('sequence_links', $sequence_links);
252 if ($_SESSION['course_id'] > 0) {
253 $side_menu = array();
254 $side_menu = explode('|', $system_courses[$_SESSION['course_id']]['side_menu']);
255 $side_menu = array_intersect($side_menu, $_stacks);
256 $savant->assign('side_menu', $side_menu);
260 /* Register our Errorhandler on everypage */
261 //require_once(AT_INCLUDE_PATH . 'classes/ErrorHandler/ErrorHandler.class.php');
262 //$err = new ErrorHandler();
265 //TODO*******************BOLOGNA*******************REMOVE ME*******************/
266 // if filemanager is a inside a popup or a frame
267 // i don't like this code. i don't know were these two variables are coming from
268 // anyone can add ?framed=1 to a URL to alter the behaviour.
270 // global $course_id is set when a guest accessing a public course.
271 // This is to solve the issue that the google indexing fails as the session vars are lost.
272 if (isset($_SESSION['course_id'])) $course_id = $_SESSION['course_id'];
274 $savant->assign('course_id', $course_id);
276 if ((isset($_REQUEST['framed']) && $_REQUEST['framed']) || (isset($_REQUEST['popup']) && $_REQUEST['popup'])) {
277 $savant->assign('framed', 1);
278 $savant->assign('popup', 1);
280 if(isset($tool_flag) && ($tool_flag))
281 $savant->display('include/tm_header.tmpl.php'); //header for toolmanager
283 $savant->display('include/fm_header.tmpl.php');
286 //$savant->assign('opensocial', open_social_libs($_base_href));
287 $savant->display('include/header.tmpl.php');