2 /****************************************************************/
4 /****************************************************************/
5 /* Copyright (c) 2002-2009 */
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 /****************************************************************/
14 define('AT_INCLUDE_PATH', 'include/');
15 require(AT_INCLUDE_PATH.'vitals.inc.php');
17 $cid = $_GET['cid'] = intval($_GET['cid']);
20 header('Location: '.$_base_href.'index.php');
24 /* show the content page */
25 $result = $contentManager->getContentPage($cid);
27 if (!($content_row = mysql_fetch_assoc($result))) {
28 $_pages['content.php']['title_var'] = 'missing_content';
29 $_pages['content.php']['parent'] = 'index.php';
30 $_pages['content.php']['ignore'] = true;
33 require(AT_INCLUDE_PATH.'header.inc.php');
35 $msg->addError('PAGE_NOT_FOUND');
38 require (AT_INCLUDE_PATH.'footer.inc.php');
42 if (defined('AT_FORCE_GET_FILE') && AT_FORCE_GET_FILE) {
43 $course_base_href = 'get.php/';
45 $course_base_href = 'content/' . $_SESSION['course_id'] . '/';
48 /* the "heading navigation": */
49 $path = $contentManager->getContentPath($cid);
51 if ($content_row['content_path']) {
52 $content_base_href = $content_row['content_path'].'/';
55 $parent_headings = '';
56 $num_in_path = count($path);
60 $page_title .= $content_row['title'];
62 for ($i=0; $i<$num_in_path; $i++) {
63 $content_info = $path[$i];
64 if ($_SESSION['prefs']['PREF_NUMBERING']) {
65 if ($contentManager->_menu_info[$content_info['content_id']]['content_parent_id'] == 0) {
66 $top_num = $contentManager->_menu_info[$content_info['content_id']]['ordering'];
67 $parent_headings .= $top_num;
69 $top_num = $top_num.'.'.$contentManager->_menu_info[$content_info['content_id']]['ordering'];
70 $parent_headings .= $top_num;
72 if ($_SESSION['prefs']['PREF_NUMBERING']) {
73 $path[$i]['content_number'] = $top_num . ' ';
75 $parent_headings .= ' ';
79 if ($_SESSION['prefs']['PREF_NUMBERING']) {
81 $top_num = $top_num.'.'.$content_row['ordering'];
82 $page_title .= $top_num.' ';
84 $top_num = $content_row['ordering'];
85 $page_title .= $top_num.' ';
91 foreach ($path as $i=>$page) {
92 // When login is a student, remove content folder from breadcrumb path as content folders are
93 // just toggles for students. Keep content folder in breadcrumb path for instructors as they
94 // can edit content folder title.
95 if (!authenticate(AT_PRIV_CONTENT, AT_PRIV_RETURN) &&
96 $contentManager->_menu_info[$page['content_id']]['content_type'] == CONTENT_TYPE_FOLDER) {
101 if ($contentManager->_menu_info[$page['content_id']]['content_type'] == CONTENT_TYPE_FOLDER)
102 $content_url = 'editor/edit_content_folder.php?cid='.$page['content_id'];
104 $content_url = 'content.php?cid='.$page['content_id'];
107 $_pages[$content_url]['title'] = $page['content_number'] . $page['title'];
108 $_pages[$content_url]['parent'] = 'index.php';
110 $_pages[$content_url]['title'] = $page['content_number'] . $page['title'];
111 $_pages[$content_url]['parent'] = 'editor/edit_content_folder.php?cid='.$parent;
114 $_pages[$content_url]['ignore'] = true;
115 $parent = $page['content_id'];
117 $last_page = array_pop($_pages);
118 $_pages['content.php'] = $last_page;
121 $first_page = current($path);
123 /* the content test extension page */
124 $content_test_ids = array(); //the html
125 $content_test_rs = $contentManager->getContentTestsAssoc($cid);
126 while ($content_test_row = mysql_fetch_assoc($content_test_rs)){
127 $content_test_ids[] = $content_test_row;
130 /*TODO***************BOLOGNA***************REMOVE ME**********/
131 /* the content forums extension page*/
132 $content_forum_ids = array(); //the html
133 $content_forum_rs = $contentManager->getContentForumsAssoc($cid);
134 while ($content_forum_row = mysql_fetch_assoc($content_forum_rs)){
135 $content_forum_ids[] = $content_forum_row;
138 // use any styles that were part of the imported document
139 // $_custom_css = $_base_href.'headstuff.php?cid='.$cid.SEP.'path='.urlEncode($_base_href.$course_base_href.$content_base_href);
141 if ($content_row['use_customized_head'] && strlen($content_row['head']) > 0)
143 $_custom_head .= $content_row['head'];
146 global $_custom_head;
148 <script language="javascript" type="text/javascript">
151 jQuery(\'a.tooltip\').tooltip( { showBody: ": ", showURL: false } );
159 if (isset($top_num) && $top_num != (int) $top_num) {
160 $top_num = substr($top_num, 0, strpos($top_num, '.'));
163 $shortcuts = array();
164 if (( ($content_row['r_date'] <= $content_row['n_date'])
165 && ((!$content_row['content_parent_id'] && ($_SESSION['packaging'] == 'top'))
166 || ($_SESSION['packaging'] == 'all'))
167 ) || authenticate(AT_PRIV_CONTENT, AT_PRIV_RETURN)) {
169 $shortcuts[] = array('title' => _AT('export_content'), 'url' => $_base_href . 'tools/ims/ims_export.php?cid='.$cid);
172 if (authenticate(AT_PRIV_CONTENT, AT_PRIV_RETURN)) {
173 $shortcuts[] = array('title' => _AT('edit_this_page'), 'url' => $_base_href . 'editor/edit_content.php?cid='.$cid);
174 $shortcuts[] = array('title' => _AT('add_top_folder'), 'url' => $_base_href . 'editor/edit_content_folder.php');
176 if ($contentManager->_menu_info[$cid]['content_parent_id']) {
177 $shortcuts[] = array('title' => _AT('add_sibling_folder'), 'url' => $_base_href .
178 'editor/edit_content_folder.php?pid='.$contentManager->_menu_info[$cid]['content_parent_id']);
180 $shortcuts[] = array('title' => _AT('add_top_page'), 'url' => $_base_href . 'editor/edit_content.php');
181 if ($contentManager->_menu_info[$cid]['content_parent_id']) {
182 $shortcuts[] = array('title' => _AT('add_sibling_page'), 'url' => $_base_href .
183 'editor/edit_content.php?pid='.$contentManager->_menu_info[$cid]['content_parent_id']);
185 $shortcuts[] = array('title' => _AT('delete_this_page'), 'url' => $_base_href . 'editor/delete_content.php?cid='.$cid);
187 $savant->assign('shortcuts', $shortcuts);
189 /* if i'm an admin then let me see content, otherwise only if released */
190 $released_status = $contentManager->isReleased($cid);
192 if ($released_status === TRUE || authenticate(AT_PRIV_CONTENT, AT_PRIV_RETURN)) {
193 //if it has test and forum associated with it, still display it even if the content is empty
194 if ($content_row['text'] == '' && (empty($content_test_ids) && empty($content_forum_ids))){
195 $msg->addInfo('NO_PAGE_CONTENT');
196 $savant->assign('body', '');
198 if ($released_status !== TRUE) {
199 /* show the instructor that this content hasn't been released yet */
200 $infos = array('NOT_RELEASED', AT_date(_AT('announcement_date_format'), $released_status, AT_DATE_UNIX_TIMESTAMP));
201 $msg->addInfo($infos);
205 $pre_test_id = $contentManager->getPretest($cid);
207 if (intval($pre_test_id) > 0)
209 if (authenticate(AT_PRIV_CONTENT, AT_PRIV_RETURN)) {
210 $msg->addInfo('PRETEST');
213 header('Location: '.url_rewrite('tools/test_intro.php?tid='.$pre_test_id.SEP.'cid='.$cid, AT_PRETTY_URL_IS_HEADER));
217 // if one of the prerequisite test(s) has expired, student cannot view the content
218 if (intval($pre_test_id) != -1 || authenticate(AT_PRIV_CONTENT, AT_PRIV_RETURN))
220 //Silvia: to provide appropriated content on the basis of users' preferences
221 $content = provide_alternatives($cid, $content_row['text']);
223 $content = format_content($content, $content_row['formatting'], $glossary);
225 $content_array = get_content_table($content);
227 $savant->assign('content_table', $content_array[0]);
228 $savant->assign('body', $content_array[1]);
230 //assign test pages if there are tests associated with this content page
231 if (!empty($content_test_ids)){
232 $savant->assign('test_message', $content_row['test_message']);
233 $savant->assign('test_ids', $content_test_ids);
235 $savant->assign('test_message', '');
236 $savant->assign('test_ids', array());
239 /*TODO***************BOLOGNA***************REMOVE ME**********/
240 //assign forum pages if there are forums associated with this content page
241 if (!empty($content_forum_ids)){
242 $savant->assign('forum_message','');
243 $savant->assign('forum_ids', $content_forum_ids);
245 $savant->assign('forum_message', '');
246 $savant->assign('forum_ids', array());
251 $infos = array('NOT_RELEASED', AT_date(_AT('announcement_date_format'), $released_status, AT_DATE_UNIX_TIMESTAMP));
252 $msg->addInfo($infos);
256 $savant->assign('content_info', _AT('page_info', AT_date(_AT('inbox_date_format'), $content_row['last_modified'], AT_DATE_MYSQL_DATETIME), $content_row['revision'], AT_date(_AT('inbox_date_format'), $content_row['release_date'], AT_DATE_MYSQL_DATETIME)));
258 require(AT_INCLUDE_PATH.'header.inc.php');
260 $savant->display('content.tmpl.php');
262 //save last visit page.
263 $_SESSION['last_visited_page'] = $server_protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
265 require (AT_INCLUDE_PATH.'footer.inc.php');