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/');
15 global $associated_forum, $_course_id, $_content_id;
17 require(TR_INCLUDE_PATH.'vitals.inc.php');
18 require_once(TR_INCLUDE_PATH.'lib/tinymce.inc.php');
19 require_once(TR_INCLUDE_PATH.'classes/FileUtility.class.php');
20 require_once(TR_INCLUDE_PATH.'classes/DAO/DAO.class.php');
22 Utility::authenticate(TR_PRIV_ISAUTHOR);
33 require(TR_INCLUDE_PATH.'../home/editor/editor_tab_functions.inc.php');
35 if ($_POST['close'] || $_GET['close']) {
37 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
39 $msg->addFeedback('CLOSED');
41 header('Location: '.TR_BASE_HREF.'home/course/index.php?_course_id='.$_course_id);
46 if (!isset($_content_id) || $_content_id == 0) {
47 header('Location: '.TR_BASE_HREF.'home/course/index.php?_course_id='.$_course_id);
50 header('Location: '.TR_BASE_HREF.'home/course/content.php?_cid='.$_content_id);
55 $num_tabs = count($tabs);
56 for ($i=0; $i < $num_tabs; $i++) {
57 if (isset($_POST['button_'.$i]) && ($_POST['button_'.$i] != -1)) {
59 $_POST['current_tab'] = $i;
64 if (isset($_GET['tab'])) {
65 $current_tab = intval($_GET['tab']);
67 if (isset($_POST['current_tab'])) {
68 $current_tab = intval($_POST['current_tab']);
71 if (isset($_POST['submit_file'])) {
72 paste_from_file(body_text);
73 } else if (isset($_POST['submit']) && ($_POST['submit'] != 'submit1')) {
74 /* we're saving. redirects if successful. */
76 save_changes(true, $current_tab);
79 if (isset($_POST['submit_file_alt'])) {
80 paste_from_file(body_text_alt);
81 } else if (isset($_POST['submit']) && ($_POST['submit'] != 'submit1')) {
82 /* we're saving. redirects if successful. */
83 save_changes(true, $current_tab);
86 if (isset($_POST['submit'])) {
87 /* we're saving. redirects if successful. */
89 save_changes(true, $current_tab);
92 if (!isset($current_tab) && isset($_POST['button_1']) && ($_POST['button_1'] == -1) && !isset($_POST['submit'])) {
94 } else if (!isset($current_tab)) {
99 $_section[0][0] = _AT('edit_content');
101 $_section[0][0] = _AT('add_content');
104 if($current_tab == 0) {
106 <link rel="stylesheet" type="text/css" href="'.TR_BASE_HREF.'include/jscripts/infusion/framework/fss/css/fss-layout.css" />
107 <link rel="stylesheet" type="text/css" href="'.TR_BASE_HREF.'include/jscripts/infusion/framework/fss/css/fss-text.css" />
108 <script type="text/javascript" src="'.$_base_path.'home/editor/js/edit.js"></script>
113 if (isset($contentManager)) $content_row = $contentManager->getContentPage($cid);
115 if (!$content_row || !isset($contentManager)) {
116 require(TR_INCLUDE_PATH.'header.inc.php');
117 $msg->printErrors('MISSING_CONTENT');
118 require (TR_INCLUDE_PATH.'footer.inc.php');
122 $path = $contentManager->getContentPath($cid);
123 $content_tests = $contentManager->getContentTestsAssoc($cid);
125 if (defined('TR_FORCE_GET_FILE') && TR_FORCE_GET_FILE) {
126 $course_base_href = 'get.php/';
128 $course_base_href = 'content/' . $_SESSION['course_id'] . '/';
131 if ($content_row['content_path']) {
132 $content_base_href .= $content_row['content_path'].'/';
135 if (defined('TR_FORCE_GET_FILE') && TR_FORCE_GET_FILE) {
136 $content_base_href = 'get.php/';
138 $content_base_href = 'content/' . $_SESSION['course_id'] . '/';
141 debug($content_base_href);exit;
142 if (($current_tab == 0) || ($current_tab == 2)) {
143 if ($_POST['formatting'] == null){
144 // this is a fresh load from just logged in
145 if (isset($_SESSION['prefs']['PREF_CONTENT_EDITOR']) && $_SESSION['prefs']['PREF_CONTENT_EDITOR'] == 0) {
146 $_POST['formatting'] = 0;
148 $_POST['formatting'] = 1;
153 require(TR_INCLUDE_PATH.'header.inc.php');
155 if ($current_tab == 0 || $current_tab == 2)
158 if ($_POST['complexeditor'] == '1') {
161 load_editor($simple, false, "none");
164 //TODO*************BOLOGNA****************REMOVE ME**************/
165 //loading toolbar for insert discussion topic or web link into the content
166 //if ($current_tab == 0){
167 // if(authenticate(TR_PRIV_CONTENT,TR_PRIV_RETURN)){
168 // $home_links = get_home_navigation(); //vengono lette le caratteristiche di ogni modulo attivato nella home page.
169 // $main_links = get_main_navigation($current_page); //vengono lette le caratteristiche di ogni modulo attivo nel main navigation
171 // $num = count($main_links); //necessario elminare il primo e l'utlimo elemento poichè sono rispettivamente "Home" e "Manage"
172 // unset($main_links[0]); //"Home" label
173 // unset($main_links[$num-1]); //"Manage" label
175 // $all_tools = $home_links; //$all_tools represent a merge between $home_links and main_links without repetitions.
177 // foreach($main_links as $main) {
178 // foreach($home_links as $home) {
179 // if($home['title'] == $main['title']) {
185 // $all_tools[]=$main;
192 $pid = intval($_REQUEST['pid']);
195 <form action="<?php echo $_SERVER['PHP_SELF']; ?>?_cid=<?php echo $cid; ?>" method="post" name="form" enctype="multipart/form-data">
199 //$content_row = sql_quote($content_row);
200 if (isset($_POST['current_tab'])) {
201 //$changes_made = check_for_changes($content_row);
203 $changes_made = array();
205 $_POST['formatting'] = $content_row['formatting'];
206 $_POST['head'] = $content_row['head'];
207 $_POST['use_customized_head'] = $content_row['use_customized_head'];
208 $_POST['title'] = $content_row['title'];
209 $_POST['body_text'] = $content_row['text'];
210 $_POST['weblink_text'] = $content_row['text'];
211 $_POST['keywords'] = $content_row['keywords'];
212 $_POST['test_message'] = $content_row['test_message'];
214 // $_POST['day'] = substr($content_row['release_date'], 8, 2);
215 // $_POST['month'] = substr($content_row['release_date'], 5, 2);
216 // $_POST['year'] = substr($content_row['release_date'], 0, 4);
217 // $_POST['hour'] = substr($content_row['release_date'], 11, 2);
218 // $_POST['min']= substr($content_row['release_date'], 14, 2);
220 $_POST['ordering'] = $content_row['ordering'];
221 // $_POST['related'] = $contentManager->getRelatedContent($cid);
223 $_POST['pid'] = $pid = $content_row['content_parent_id'];
225 // $_POST['related_term'] = $glossary_ids_related;
230 if (!isset($_POST['current_tab'])) {
231 $_POST['day'] = date('d');
232 $_POST['month'] = date('m');
233 $_POST['year'] = date('Y');
234 $_POST['hour'] = date('H');
237 if (isset($_GET['pid'])) {
238 $pid = $_POST['pid'] = intval($_GET['pid']);
239 $_POST['ordering'] = count($contentManager->getContent($pid))+1;
242 $_POST['ordering'] = count($contentManager->getContent(0))+1;
247 echo '<input type="hidden" name="_course_id" value="'.$_course_id.'" />';
248 echo '<input type="hidden" name="_cid" value="'.$cid.'" />';
249 echo '<input type="hidden" name="title" value="'.htmlspecialchars($stripslashes($_POST['title'])).'" />';
250 if ($_REQUEST['sub'] == 1)
252 echo '<input type="hidden" name="sub" value="1" />';
253 echo '<input type="hidden" name="folder_title" value="'.htmlspecialchars($stripslashes($_POST['folder_title'])).'" />';
255 echo '<input type="submit" name="submit" style="display:none;"/>';
256 if (($current_tab != 0) && (($_current_tab != 2))) {
257 echo '<input type="hidden" name="body_text" value="'.htmlspecialchars($stripslashes($_POST['body_text'])).'" />';
258 echo '<input type="hidden" name="weblink_text" value="'.htmlspecialchars($stripslashes($_POST['weblink_text'])).'" />';
259 echo '<input type="hidden" name="head" value="'.htmlspecialchars($stripslashes($_POST['head'])).'" />';
260 echo '<input type="hidden" name="use_customized_head" value="'.(($_POST['use_customized_head']=="") ? 0 : $_POST['use_customized_head']).'" />';
261 echo '<input type="hidden" name="displayhead" id="displayhead" value="'.$_POST['displayhead'].'" />';
262 echo '<input type="hidden" name="complexeditor" id="complexeditor" value="'.$_POST['complexeditor'].'" />';
263 echo '<input type="hidden" name="formatting" value="'.$_POST['formatting'].'" />';
266 echo '<input type="hidden" name="ordering" value="'.$_POST['ordering'].'" />';
267 echo '<input type="hidden" name="pid" value="'.$pid.'" />';
269 // echo '<input type="hidden" name="day" value="'.$_POST['day'].'" />';
270 // echo '<input type="hidden" name="month" value="'.$_POST['month'].'" />';
271 // echo '<input type="hidden" name="year" value="'.$_POST['year'].'" />';
272 // echo '<input type="hidden" name="hour" value="'.$_POST['hour'].'" />';
273 // echo '<input type="hidden" name="minute" value="'.$_POST['minute'].'" />';
274 // echo '<input type="hidden" name="min" value="'.$_POST['min'].'" />';
276 echo '<input type="hidden" name="alternatives" value="'.$_POST['alternatives'].'" />';
278 echo '<input type="hidden" name="current_tab" value="'.$current_tab.'" />';
280 // if (is_array($_POST['related']) && ($current_tab != 1)) {
281 // foreach($_POST['related'] as $r_id) {
282 // echo '<input type="hidden" name="related[]" value="'.$r_id.'" />';
285 echo '<input type="hidden" name="keywords" value="'.htmlspecialchars(stripslashes($_POST['keywords'])).'" />';
287 //content test association
288 echo '<input type="hidden" name="test_message" value="'.$_POST['test_message'].'" />';
290 /* get glossary terms */
291 // $matches = find_terms(stripslashes($_POST['body_text']));
292 // $num_terms = count($matches[0]);
293 // $matches = $matches[0];
294 // $word = str_replace(array('[?]', '[/?]'), '', $matches);
296 // if (is_array($word)) {
297 // /* update $_POST['glossary_defs'] with any new/changed terms */
298 // for($i=0; $i<$num_terms; $i++) {
299 // $word[$i] = $word[$i];
300 // if (!isset($_POST['glossary_defs'][$word[$i]])) {
301 // $_POST['glossary_defs'][$word[$i]] = $glossary[$word[$i]];
306 // if (is_array($_POST['glossary_defs']) && ($current_tab != 2)) {
307 // foreach($_POST['glossary_defs'] as $w => $d) {
308 // /* this term still exists in the content */
309 // if (!in_array($w, $word)) {
310 // unset($_POST['glossary_defs'][$w]);
313 // echo '<input type="hidden" name="glossary_defs['.$w.']" value="'.htmlspecialchars(stripslashes($d)).'" />';
315 // if (isset($_POST['related_term'])) {
316 // foreach($_POST['related_term'] as $w => $d) {
317 // echo '<input type="hidden" name="related_term['.$w.']" value="'.$d.'" />';
323 $sql = "SELECT pr.primary_resource_id, prt.type_id
324 FROM ".TABLE_PREFIX."primary_resources pr, ".
325 TABLE_PREFIX."primary_resources_types prt
326 WHERE pr.content_id = ".$cid."
327 AND pr.language_code = '".$_SESSION['lang']."'
328 AND pr.primary_resource_id = prt.primary_resource_id";
329 // $all_types_result = mysql_query($sql, $db);
330 $types = $dao->execute($sql);
333 if (is_array($types)) {
334 foreach ($types as $type) {
335 $row_alternatives['alt_'.$type['primary_resource_id'].'_'.$type['type_id']] = 1;
339 if ($current_tab != 2 && isset($_POST['use_post_for_alt']))
341 echo '<input type="hidden" name="use_post_for_alt" value="1" />';
342 if (is_array($_POST)) {
343 foreach ($_POST as $alt_id => $alt_value) {
344 if (substr($alt_id, 0 ,4) == 'alt_'){
345 echo '<input type="hidden" name="'.$alt_id.'" value="'.$alt_value.'" />';
352 if ($current_tab != 3){
353 // set content associated tests
354 if (isset($_POST['visited_tests'])) {
355 echo '<input type="hidden" name="visited_tests" value="1" />'."\n";
356 if (is_array($_POST['tid'])) {
357 foreach ($_POST['tid'] as $i=>$tid){
358 echo '<input type="hidden" name="tid['.$i.']" value="'.$tid.'" />';
363 if (is_array($content_tests)) {
364 foreach ($content_tests as $content_test_row) {
365 echo '<input type="hidden" name="tid['.$i++.']" value="'.$content_test_row['test_id'].'" />';
371 // if (is_array($_POST['pre_tid'])) {
372 // foreach ($_POST['pre_tid'] as $i=>$pre_tid){
373 // echo '<input type="hidden" name="pre_tid['.$i.']" value="'.$pre_tid.'" />';
379 // $sql = 'SELECT * FROM '.TABLE_PREFIX."content_prerequisites WHERE content_id=$cid AND type='".CONTENT_PRE_TEST."'";
380 // $pretests_result = mysql_query($sql, $db);
381 // while ($pretest_row = mysql_fetch_assoc($pretests_result)) {
382 // echo '<input type="hidden" name="pre_tid['.$i++.']" value="'.$pretest_row['item_id'].'" />';
388 $changes_made = check_for_changes($content_row, $row_alternatives);
393 <?php output_tabs($current_tab, $changes_made); ?>
396 <div class="input-form" style="width: 95%;">
398 <?php if ($changes_made): ?>
399 <div class="unsaved">
400 <span style="color:red;"><?php echo _AT('save_changes_unsaved'); ?></span>
401 <input type="submit" name="submit" value="<?php echo _AT('save'); ?>" title="<?php echo _AT('save_changes'); ?> alt-s" accesskey="s" style="border: 1px solid red;" />
402 <input type="submit" name="close" class="button green" value="<?php echo _AT('close'); ?>" /> <input type="checkbox" id="close" name="save_n_close" value="1" <?php if ($_SESSION['save_n_close']) { echo 'checked="checked"'; } ?> />
403 <label for="close"><?php echo _AT('close_after_saving'); ?></label>
408 <?php //if ($cid) { echo _AT('save_changes_saved'); } ?> <input type="submit" name="submit" value="<?php echo _AT('save'); ?>" title="<?php echo _AT('save_changes'); ?> alt-s" accesskey="s" class="button"/> <input type="submit" name="close" value="<?php echo _AT('close'); ?>" class="button"/> <input type="checkbox" style="border:0px;" id="close" name="save_n_close" value="1" <?php if ($_SESSION['save_n_close']) { echo 'checked="checked"'; } ?>/><label for="close"><?php echo _AT('close_after_saving'); ?></label>
411 <?php include('editor_tabs/'.$tabs[$current_tab][1]); ?>
415 <?php require(TR_INCLUDE_PATH.'footer.inc.php'); ?>