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. */
75 save_changes(true, $current_tab);
78 if (isset($_POST['submit_file_alt'])) {
79 paste_from_file(body_text_alt);
80 } else if (isset($_POST['submit']) && ($_POST['submit'] != 'submit1')) {
81 /* we're saving. redirects if successful. */
82 save_changes(true, $current_tab);
85 if (isset($_POST['submit'])) {
86 /* we're saving. redirects if successful. */
87 save_changes(true, $current_tab);
90 if (!isset($current_tab) && isset($_POST['button_1']) && ($_POST['button_1'] == -1) && !isset($_POST['submit'])) {
92 } else if (!isset($current_tab)) {
97 $_section[0][0] = _AT('edit_content');
99 $_section[0][0] = _AT('add_content');
102 if($current_tab == 0) {
104 <link rel="stylesheet" type="text/css" href="'.TR_BASE_HREF.'include/jscripts/infusion/framework/fss/css/fss-layout.css" />
105 <link rel="stylesheet" type="text/css" href="'.TR_BASE_HREF.'include/jscripts/infusion/framework/fss/css/fss-text.css" />
106 <script type="text/javascript" src="'.$_base_path.'home/editor/js/edit.js"></script>
111 if (isset($contentManager)) $content_row = $contentManager->getContentPage($cid);
113 if (!$content_row || !isset($contentManager)) {
114 require(TR_INCLUDE_PATH.'header.inc.php');
115 $msg->printErrors('MISSING_CONTENT');
116 require (TR_INCLUDE_PATH.'footer.inc.php');
120 $path = $contentManager->getContentPath($cid);
121 $content_tests = $contentManager->getContentTestsAssoc($cid);
123 if (defined('TR_FORCE_GET_FILE') && TR_FORCE_GET_FILE) {
124 $course_base_href = 'get.php/';
126 $course_base_href = 'content/' . $_SESSION['course_id'] . '/';
129 if ($content_row['content_path']) {
130 $content_base_href .= $content_row['content_path'].'/';
133 if (defined('TR_FORCE_GET_FILE') && TR_FORCE_GET_FILE) {
134 $content_base_href = 'get.php/';
136 $content_base_href = 'content/' . $_SESSION['course_id'] . '/';
140 if (($current_tab == 0) || ($current_tab == 2)) {
141 if ($_POST['formatting'] == null){
142 // this is a fresh load from just logged in
143 if (isset($_SESSION['prefs']['PREF_CONTENT_EDITOR']) && $_SESSION['prefs']['PREF_CONTENT_EDITOR'] == 0) {
144 $_POST['formatting'] = 0;
146 $_POST['formatting'] = 1;
151 require(TR_INCLUDE_PATH.'header.inc.php');
153 if ($current_tab == 0 || $current_tab == 2)
156 if ($_POST['complexeditor'] == '1') {
159 load_editor($simple, false, "none");
162 //TODO*************BOLOGNA****************REMOVE ME**************/
163 //loading toolbar for insert discussion topic or web link into the content
164 //if ($current_tab == 0){
165 // if(authenticate(TR_PRIV_CONTENT,TR_PRIV_RETURN)){
166 // $home_links = get_home_navigation(); //vengono lette le caratteristiche di ogni modulo attivato nella home page.
167 // $main_links = get_main_navigation($current_page); //vengono lette le caratteristiche di ogni modulo attivo nel main navigation
169 // $num = count($main_links); //necessario elminare il primo e l'utlimo elemento poichè sono rispettivamente "Home" e "Manage"
170 // unset($main_links[0]); //"Home" label
171 // unset($main_links[$num-1]); //"Manage" label
173 // $all_tools = $home_links; //$all_tools represent a merge between $home_links and main_links without repetitions.
175 // foreach($main_links as $main) {
176 // foreach($home_links as $home) {
177 // if($home['title'] == $main['title']) {
183 // $all_tools[]=$main;
190 $pid = intval($_REQUEST['pid']);
193 <form action="<?php echo $_SERVER['PHP_SELF']; ?>?_cid=<?php echo $cid; ?>" method="post" name="form" enctype="multipart/form-data">
197 //$content_row = sql_quote($content_row);
198 if (isset($_POST['current_tab'])) {
199 //$changes_made = check_for_changes($content_row);
201 $changes_made = array();
203 $_POST['formatting'] = $content_row['formatting'];
204 $_POST['head'] = $content_row['head'];
205 $_POST['use_customized_head'] = $content_row['use_customized_head'];
206 $_POST['title'] = $content_row['title'];
207 $_POST['body_text'] = $content_row['text'];
208 $_POST['weblink_text'] = $content_row['text'];
209 $_POST['keywords'] = $content_row['keywords'];
210 $_POST['test_message'] = $content_row['test_message'];
212 // $_POST['day'] = substr($content_row['release_date'], 8, 2);
213 // $_POST['month'] = substr($content_row['release_date'], 5, 2);
214 // $_POST['year'] = substr($content_row['release_date'], 0, 4);
215 // $_POST['hour'] = substr($content_row['release_date'], 11, 2);
216 // $_POST['min']= substr($content_row['release_date'], 14, 2);
218 $_POST['ordering'] = $content_row['ordering'];
219 // $_POST['related'] = $contentManager->getRelatedContent($cid);
221 $_POST['pid'] = $pid = $content_row['content_parent_id'];
223 // $_POST['related_term'] = $glossary_ids_related;
228 if (!isset($_POST['current_tab'])) {
229 $_POST['day'] = date('d');
230 $_POST['month'] = date('m');
231 $_POST['year'] = date('Y');
232 $_POST['hour'] = date('H');
235 if (isset($_GET['pid'])) {
236 $pid = $_POST['pid'] = intval($_GET['pid']);
237 $_POST['ordering'] = count($contentManager->getContent($pid))+1;
240 $_POST['ordering'] = count($contentManager->getContent(0))+1;
245 echo '<input type="hidden" name="_course_id" value="'.$_course_id.'" />';
246 echo '<input type="hidden" name="_cid" value="'.$cid.'" />';
247 echo '<input type="hidden" name="title" value="'.htmlspecialchars($stripslashes($_POST['title'])).'" />';
248 if ($_REQUEST['sub'] == 1)
250 echo '<input type="hidden" name="sub" value="1" />';
251 echo '<input type="hidden" name="folder_title" value="'.htmlspecialchars($stripslashes($_POST['folder_title'])).'" />';
253 echo '<input type="submit" name="submit" style="display:none;"/>';
254 if (($current_tab != 0) && (($_current_tab != 2))) {
255 echo '<input type="hidden" name="body_text" value="'.htmlspecialchars($stripslashes($_POST['body_text'])).'" />';
256 echo '<input type="hidden" name="weblink_text" value="'.htmlspecialchars($stripslashes($_POST['weblink_text'])).'" />';
257 echo '<input type="hidden" name="head" value="'.htmlspecialchars($stripslashes($_POST['head'])).'" />';
258 echo '<input type="hidden" name="use_customized_head" value="'.(($_POST['use_customized_head']=="") ? 0 : $_POST['use_customized_head']).'" />';
259 echo '<input type="hidden" name="displayhead" id="displayhead" value="'.$_POST['displayhead'].'" />';
260 echo '<input type="hidden" name="complexeditor" id="complexeditor" value="'.$_POST['complexeditor'].'" />';
261 echo '<input type="hidden" name="formatting" value="'.$_POST['formatting'].'" />';
264 echo '<input type="hidden" name="ordering" value="'.$_POST['ordering'].'" />';
265 echo '<input type="hidden" name="pid" value="'.$pid.'" />';
267 // echo '<input type="hidden" name="day" value="'.$_POST['day'].'" />';
268 // echo '<input type="hidden" name="month" value="'.$_POST['month'].'" />';
269 // echo '<input type="hidden" name="year" value="'.$_POST['year'].'" />';
270 // echo '<input type="hidden" name="hour" value="'.$_POST['hour'].'" />';
271 // echo '<input type="hidden" name="minute" value="'.$_POST['minute'].'" />';
272 // echo '<input type="hidden" name="min" value="'.$_POST['min'].'" />';
274 echo '<input type="hidden" name="alternatives" value="'.$_POST['alternatives'].'" />';
276 echo '<input type="hidden" name="current_tab" value="'.$current_tab.'" />';
278 // if (is_array($_POST['related']) && ($current_tab != 1)) {
279 // foreach($_POST['related'] as $r_id) {
280 // echo '<input type="hidden" name="related[]" value="'.$r_id.'" />';
283 echo '<input type="hidden" name="keywords" value="'.htmlspecialchars(stripslashes($_POST['keywords'])).'" />';
285 //content test association
286 echo '<input type="hidden" name="test_message" value="'.$_POST['test_message'].'" />';
288 /* get glossary terms */
289 // $matches = find_terms(stripslashes($_POST['body_text']));
290 // $num_terms = count($matches[0]);
291 // $matches = $matches[0];
292 // $word = str_replace(array('[?]', '[/?]'), '', $matches);
294 // if (is_array($word)) {
295 // /* update $_POST['glossary_defs'] with any new/changed terms */
296 // for($i=0; $i<$num_terms; $i++) {
297 // $word[$i] = $word[$i];
298 // if (!isset($_POST['glossary_defs'][$word[$i]])) {
299 // $_POST['glossary_defs'][$word[$i]] = $glossary[$word[$i]];
304 // if (is_array($_POST['glossary_defs']) && ($current_tab != 2)) {
305 // foreach($_POST['glossary_defs'] as $w => $d) {
306 // /* this term still exists in the content */
307 // if (!in_array($w, $word)) {
308 // unset($_POST['glossary_defs'][$w]);
311 // echo '<input type="hidden" name="glossary_defs['.$w.']" value="'.htmlspecialchars(stripslashes($d)).'" />';
313 // if (isset($_POST['related_term'])) {
314 // foreach($_POST['related_term'] as $w => $d) {
315 // echo '<input type="hidden" name="related_term['.$w.']" value="'.$d.'" />';
321 $sql = "SELECT pr.primary_resource_id, prt.type_id
322 FROM ".TABLE_PREFIX."primary_resources pr, ".
323 TABLE_PREFIX."primary_resources_types prt
324 WHERE pr.content_id = ".$cid."
325 AND pr.language_code = '".$_SESSION['lang']."'
326 AND pr.primary_resource_id = prt.primary_resource_id";
327 // $all_types_result = mysql_query($sql, $db);
328 $types = $dao->execute($sql);
331 if (is_array($types)) {
332 foreach ($types as $type) {
333 $row_alternatives['alt_'.$type['primary_resource_id'].'_'.$type['type_id']] = 1;
337 if ($current_tab != 2 && isset($_POST['use_post_for_alt']))
339 echo '<input type="hidden" name="use_post_for_alt" value="1" />';
340 if (is_array($_POST)) {
341 foreach ($_POST as $alt_id => $alt_value) {
342 if (substr($alt_id, 0 ,4) == 'alt_'){
343 echo '<input type="hidden" name="'.$alt_id.'" value="'.$alt_value.'" />';
350 if ($current_tab != 3){
351 // set content associated tests
352 if (isset($_POST['visited_tests'])) {
353 echo '<input type="hidden" name="visited_tests" value="1" />'."\n";
354 if (is_array($_POST['tid'])) {
355 foreach ($_POST['tid'] as $i=>$tid){
356 echo '<input type="hidden" name="tid['.$i.']" value="'.$tid.'" />';
361 if (is_array($content_tests)) {
362 foreach ($content_tests as $content_test_row) {
363 echo '<input type="hidden" name="tid['.$i++.']" value="'.$content_test_row['test_id'].'" />';
369 // if (is_array($_POST['pre_tid'])) {
370 // foreach ($_POST['pre_tid'] as $i=>$pre_tid){
371 // echo '<input type="hidden" name="pre_tid['.$i.']" value="'.$pre_tid.'" />';
377 // $sql = 'SELECT * FROM '.TABLE_PREFIX."content_prerequisites WHERE content_id=$cid AND type='".CONTENT_PRE_TEST."'";
378 // $pretests_result = mysql_query($sql, $db);
379 // while ($pretest_row = mysql_fetch_assoc($pretests_result)) {
380 // echo '<input type="hidden" name="pre_tid['.$i++.']" value="'.$pretest_row['item_id'].'" />';
386 $changes_made = check_for_changes($content_row, $row_alternatives);
391 <?php output_tabs($current_tab, $changes_made); ?>
394 <div class="input-form" style="width: 95%;">
396 <?php if ($changes_made): ?>
397 <div class="unsaved">
398 <span style="color:red;"><?php echo _AT('save_changes_unsaved'); ?></span>
399 <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;" />
400 <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"'; } ?> />
401 <label for="close"><?php echo _AT('close_after_saving'); ?></label>
406 <?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>
409 <?php include('editor_tabs/'.$tabs[$current_tab][1]); ?>
413 <?php require(TR_INCLUDE_PATH.'footer.inc.php'); ?>