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/editor/editor_tab_functions.inc.php');
16 require_once(TR_INCLUDE_PATH.'../home/classes/ContentUtility.class.php');
18 global $_content_id, $_content_id, $contentManager, $_course_id;
21 Utility::authenticate(TR_PRIV_ISAUTHOR);
23 if (isset($_GET['pid'])) $pid = intval($_GET['pid']);
25 if (defined('TR_FORCE_GET_FILE') && TR_FORCE_GET_FILE) {
26 $course_base_href = 'get.php/';
28 $course_base_href = 'content/' . $_course_id . '/';
31 if ($cid > 0 && isset($contentManager)) {
32 $content_row = $contentManager->getContentPage($cid);
38 if ($_POST['title'] == '') {
39 $msg->addError(array('EMPTY_FIELDS', _AT('title')));
42 if (!$msg->containsErrors())
44 $_POST['title'] = $content_row['title'] = $_POST['title'];
47 { // edit existing content
48 $err = $contentManager->editContent($cid,
52 $content_row['formatting'],
54 $content_row['use_customized_head'],
59 // find out ordering and content_parent_id
61 { // insert sub content folder
62 $ordering = count($contentManager->getContent($pid))+1;
65 { // insert a top content folder
66 $ordering = count($contentManager->getContent(0)) + 1;
70 $cid = $contentManager->addContent($_SESSION['course_id'],
85 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
86 header('Location: '.$_base_path.'home/editor/edit_content_folder.php?_cid='.$cid);
92 { // edit existing content folder
93 if (!$content_row || !isset($contentManager)) {
94 $_pages['home/editor/edit_content_folder.php']['title_var'] = 'missing_content';
95 $_pages['home/editor/edit_content_folder.php']['parent'] = 'index.php';
96 $_pages['home/editor/edit_content_folder.php']['ignore'] = true;
98 require(TR_INCLUDE_PATH.'header.inc.php');
100 $msg->addError('MISSING_CONTENT');
103 require (TR_INCLUDE_PATH.'footer.inc.php');
107 /* the "heading navigation": */
108 $path = $contentManager->getContentPath($cid);
110 if ($content_row['content_path']) {
111 $content_base_href = $content_row['content_path'].'/';
114 $parent_headings = '';
115 $num_in_path = count($path);
117 /* the page title: */
119 $page_title .= $content_row['title'];
121 for ($i=0; $i<$num_in_path; $i++) {
122 $content_info = $path[$i];
123 if ($_SESSION['prefs']['PREF_NUMBERING']) {
124 if ($contentManager->_menu_info[$content_info['content_id']]['content_parent_id'] == 0) {
125 $top_num = $contentManager->_menu_info[$content_info['content_id']]['ordering'];
126 $parent_headings .= $top_num;
128 $top_num = $top_num.'.'.$contentManager->_menu_info[$content_info['content_id']]['ordering'];
129 $parent_headings .= $top_num;
131 if ($_SESSION['prefs']['PREF_NUMBERING']) {
132 $path[$i]['content_number'] = $top_num . ' ';
134 $parent_headings .= ' ';
138 if ($_SESSION['prefs']['PREF_NUMBERING']) {
139 if ($top_num != '') {
140 $top_num = $top_num.'.'.$content_row['ordering'];
141 $page_title .= $top_num.' ';
143 $top_num = $content_row['ordering'];
144 $page_title .= $top_num.' ';
149 // foreach ($path as $i=>$page) {
151 // $_pages['editor/edit_content_folder.php?cid='.$page['content_id']]['title'] = $page['content_number'] . $page['title'];
152 // $_pages['editor/edit_content_folder.php?cid='.$page['content_id']]['parent'] = 'index.php';
154 // $_pages['editor/edit_content_folder.php?cid='.$page['content_id']]['title'] = $page['content_number'] . $page['title'];
155 // $_pages['editor/edit_content_folder.php?cid='.$page['content_id']]['parent'] = 'editor/edit_content_folder.php?cid='.$parent;
158 // $_pages['editor/edit_content_folder.php?cid='.$page['content_id']]['ignore'] = true;
159 // $parent = $page['content_id'];
161 // $last_page = array_pop($_pages);
162 // $_pages['editor/edit_content_folder.php'] = $last_page;
165 $first_page = current($path);
167 ContentUtility::saveLastCid($cid);
169 if (isset($top_num) && $top_num != (int) $top_num) {
170 $top_num = substr($top_num, 0, strpos($top_num, '.'));
172 $_tool_shortcuts = ContentUtility::getToolShortcuts($content_row); // used by header.tmpl.php
175 // $sql = 'SELECT * FROM '.TABLE_PREFIX."content_prerequisites WHERE content_id=$_REQUEST[cid] AND type='".CONTENT_PRE_TEST."'";
176 // $result = mysql_query($sql, $db);
177 // while ($row = mysql_fetch_assoc($result)) {
178 // $_POST['pre_tid'][] = $row['item_id'];
181 $savant->assign('ftitle', $content_row['title']);
182 // $savant->assign('shortcuts', $shortcuts);
183 $savant->assign('cid', $cid);
186 if ($pid > 0 || !isset($pid)) {
187 $savant->assign('pid', $pid);
188 $savant->assign('course_id', $_course_id);
191 $onload = "document.form.title.focus();";
192 require(TR_INCLUDE_PATH.'header.inc.php');
193 $savant->display('home/editor/edit_content_folder.tmpl.php');
194 require(TR_INCLUDE_PATH.'footer.inc.php');
196 //save last visit page.
197 $_SESSION['last_visited_page'] = $server_protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];