2 /************************************************************************/
4 /************************************************************************/
5 /* Copyright (c) 2010 */
6 /* Inclusive Design Institute */
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 /************************************************************************/
13 define('TR_INCLUDE_PATH', '../../include/');
14 require_once(TR_INCLUDE_PATH.'vitals.inc.php');
15 require_once(TR_INCLUDE_PATH.'../home/classes/ContentUtility.class.php');
16 require_once(TR_INCLUDE_PATH.'classes/DAO/ContentForumsAssocDAO.class.php');
18 global $_current_user, $_course_id, $_content_id, $contentManager;
23 header('Location: '.$_base_href.'index.php');
26 if (defined('TR_FORCE_GET_FILE') && TR_FORCE_GET_FILE) {
27 $_SESSION['course_id'] = $_course_id; // used by get.php
30 /* show the content page */
31 if (isset($contentManager)) $content_row = $contentManager->getContentPage($cid);
33 if (!$content_row || !isset($contentManager)) {
34 $_pages['home/course/content.php']['title_var'] = 'missing_content';
35 $_pages['home/course/content.php']['parent'] = 'home/index.php';
36 $_pages['home/course/content.php']['ignore'] = true;
39 require(TR_INCLUDE_PATH.'header.inc.php');
41 $msg->addError('MISSING_CONTENT');
44 require (TR_INCLUDE_PATH.'footer.inc.php');
48 if (defined('TR_FORCE_GET_FILE') && TR_FORCE_GET_FILE) {
49 $course_base_href = 'get.php/';
51 $course_base_href = 'content/' . $_course_id . '/';
54 /* the "heading navigation": */
55 $path = $contentManager->getContentPath($cid);
57 if ($content_row['content_path']) {
58 $content_base_href = $content_row['content_path'].'/';
61 $parent_headings = '';
62 $num_in_path = count($path);
66 $page_title .= $content_row['title'];
68 for ($i=0; $i<$num_in_path; $i++) {
69 $content_info = $path[$i];
70 if ($_SESSION['prefs']['PREF_NUMBERING']) {
71 if ($contentManager->_menu_info[$content_info['content_id']]['content_parent_id'] == 0) {
72 $top_num = $contentManager->_menu_info[$content_info['content_id']]['ordering'];
73 $parent_headings .= $top_num;
75 $top_num = $top_num.'.'.$contentManager->_menu_info[$content_info['content_id']]['ordering'];
76 $parent_headings .= $top_num;
78 if ($_SESSION['prefs']['PREF_NUMBERING']) {
79 $path[$i]['content_number'] = $top_num . ' ';
81 $parent_headings .= ' ';
85 if ($_SESSION['prefs']['PREF_NUMBERING']) {
87 $top_num = $top_num.'.'.$content_row['ordering'];
88 $page_title .= $top_num.' ';
90 $top_num = $content_row['ordering'];
91 $page_title .= $top_num.' ';
97 foreach ($path as $i=>$page) {
98 // When login is a student, remove content folder from breadcrumb path as content folders are
99 // just toggles for students. Keep content folder in breadcrumb path for instructors as they
100 // can edit content folder title.
101 if ((!isset($_current_user) || !$_current_user->isAuthor($_course_id)) &&
102 $contentManager->_menu_info[$page['content_id']]['content_type'] == CONTENT_TYPE_FOLDER) {
107 if ($contentManager->_menu_info[$page['content_id']]['content_type'] == CONTENT_TYPE_FOLDER)
108 $content_url = 'home/editor/edit_content_folder.php?_cid='.$page['content_id'];
110 $content_url = 'home/course/content.php?_cid='.$page['content_id'];
113 $_pages[$content_url]['title'] = $page['content_number'] . $page['title'];
114 $_pages[$content_url]['parent'] = 'home/index.php';
116 $_pages[$content_url]['title'] = $page['content_number'] . $page['title'];
117 if (isset($_pages['home/editor/edit_content_folder.php?_cid='.$parent])) {
118 $_pages[$content_url]['parent'] = 'home/editor/edit_content_folder.php?_cid='.$parent;
120 $_pages[$content_url]['parent'] = 'home/course/content.php?_cid='.$parent;
124 $_pages[$content_url]['ignore'] = true;
125 $parent = $page['content_id'];
128 $last_page = array_pop($_pages);
129 $_pages['home/course/content.php'] = $last_page;
132 $first_page = current($path);
134 /* the tests associated with the content */
135 $content_test_ids = array(); //the html
136 $content_test_rows = $contentManager->getContentTestsAssoc($cid);
137 if (is_array($content_test_rows))
139 foreach ($content_test_rows as $content_test_row){
140 $content_test_ids[] = $content_test_row;
144 /* the forums associated with the content */
145 $contentForumsAssocDAO = new ContentForumsAssocDAO();
146 $content_forum_ids = $contentForumsAssocDAO->getByContent($cid);
147 //$content_test_rows = $contentManager->getContentTestsAssoc($cid);
148 //if (is_array($content_test_rows))
150 // foreach ($content_test_rows as $content_test_row){
151 // $content_test_ids[] = $content_test_row;
155 /*TODO***************BOLOGNA***************REMOVE ME**********/
156 /* the content forums extension page*/
157 //$content_forum_ids = array(); //the html
158 //$content_forum_rows = $contentManager->getContentForumsAssoc($cid);
159 //if (is_array($content_forum_rows))
161 // foreach ($content_forum_rows as $content_forum_row){
162 // $content_forum_ids[] = $content_forum_row;
166 // use any styles that were part of the imported document
167 // $_custom_css = $_base_href.'headstuff.php?cid='.$cid.SEP.'path='.urlEncode($_base_href.$course_base_href.$content_base_href);
169 if ($content_row['use_customized_head'] && strlen($content_row['head']) > 0)
171 $_custom_head .= $content_row['head'];
174 global $_custom_head;
176 <script language="javascript" type="text/javascript">
179 jQuery(\'a.tooltip\').tooltip( { showBody: ": ", showURL: false } );
185 if (isset($_SESSION['user_id'])) ContentUtility::saveLastCid($cid);
187 if (isset($top_num) && $top_num != (int) $top_num) {
188 $top_num = substr($top_num, 0, strpos($top_num, '.'));
191 $_tool_shortcuts = ContentUtility::getToolShortcuts($content_row);
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)){
195 $msg->addInfo('NO_PAGE_CONTENT');
196 $savant->assign('body', '');
198 // find whether the body has alternatives defined
199 list($has_text_alternative, $has_audio_alternative, $has_visual_alternative, $has_sign_lang_alternative)
200 = ContentUtility::applyAlternatives($cid, $content_row['text'], true);
202 // apply alternatives
203 if (intval($_GET['alternative']) > 0) {
204 $content = ContentUtility::applyAlternatives($cid, $content_row['text'], false, intval($_GET['alternative']));
206 $content = ContentUtility::applyAlternatives($cid, $content_row['text']);
209 $content = ContentUtility::formatContent($content, $content_row['formatting']);
211 $content_array = ContentUtility::getContentTable($content, $content_row['formatting']);
213 $savant->assign('content_table', $content_array[0]);
214 $savant->assign('body', $content_array[1]);
215 $savant->assign('has_text_alternative', $has_text_alternative);
216 $savant->assign('has_audio_alternative', $has_audio_alternative);
217 $savant->assign('has_visual_alternative', $has_visual_alternative);
218 $savant->assign('has_sign_lang_alternative', $has_sign_lang_alternative);
219 $savant->assign('cid', $cid);
221 //assign test pages if there are tests associated with this content page
222 if (!empty($content_test_ids)){
223 $savant->assign('test_message', $content_row['test_message']);
224 $savant->assign('test_ids', $content_test_ids);
226 $savant->assign('test_message', '');
227 $savant->assign('test_ids', array());
230 if (is_array($content_forum_ids)){
231 $savant->assign('forum_ids', $content_forum_ids);
235 $savant->assign('content_info', _AT('page_info', AT_date(_AT('page_info_date_format'), $content_row['last_modified'], TR_DATE_MYSQL_DATETIME), $content_row['revision'], AT_date(_AT('inbox_date_format'), $content_row['release_date'], TR_DATE_MYSQL_DATETIME)));
236 $savant->assign('course_id', $_course_id);
238 require(TR_INCLUDE_PATH.'header.inc.php');
240 $savant->display('home/course/content.tmpl.php');
242 //save last visit page.
243 $_SESSION['last_visited_page'] = $server_protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
245 require (TR_INCLUDE_PATH.'footer.inc.php');