2 /************************************************************************/
4 /************************************************************************/
5 /* Copyright (c) 2002-2008 by Greg Gay, Joel Kronenberg & Heidi Hazelton*/
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 /************************************************************************/
15 define('AT_INCLUDE_PATH', '../include/');
17 global $db, $associated_forum;
19 $get_related_glossary = true;
20 require(AT_INCLUDE_PATH.'vitals.inc.php');
21 require(AT_INCLUDE_PATH.'lib/tinymce.inc.php');
22 require(AT_INCLUDE_PATH.'lib/filemanager.inc.php');
24 $cid = intval($_REQUEST['cid']);
32 require(AT_INCLUDE_PATH.'lib/editor_tab_functions.inc.php');
34 if ($_POST['close'] || $_GET['close']) {
36 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
38 $msg->addFeedback('CLOSED');
40 header('Location: '.AT_BASE_HREF.'tools/content/index.php');
45 if ($_REQUEST['cid'] == 0) {
46 header('Location: '.AT_BASE_HREF.'tools/content/index.php');
49 header('Location: '.$_base_path.url_rewrite('content.php?cid='.intval($_REQUEST['cid'])));
54 $num_tabs = count($tabs);
55 for ($i=0; $i < $num_tabs; $i++) {
56 if (isset($_POST['button_'.$i]) && ($_POST['button_'.$i] != -1)) {
58 $_POST['current_tab'] = $i;
63 if (isset($_GET['tab'])) {
64 $current_tab = intval($_GET['tab']);
66 if (isset($_POST['current_tab'])) {
67 $current_tab = intval($_POST['current_tab']);
70 if (isset($_POST['submit_file'])) {
71 paste_from_file(body_text);
72 } else if (isset($_POST['submit']) && ($_POST['submit'] != 'submit1')) {
73 /* we're saving. redirects if successful. */
74 save_changes(true, $current_tab);
77 if (isset($_POST['submit_file_alt'])) {
78 paste_from_file(body_text_alt);
79 } else if (isset($_POST['submit']) && ($_POST['submit'] != 'submit1')) {
80 /* we're saving. redirects if successful. */
81 save_changes(true, $current_tab);
84 if (isset($_POST['submit'])) {
85 /* we're saving. redirects if successful. */
86 save_changes(true, $current_tab);
89 if (!isset($current_tab) && isset($_POST['button_1']) && ($_POST['button_1'] == -1) && !isset($_POST['submit'])) {
91 } else if (!isset($current_tab) && (($_POST['desc_submit'] != '') || ($_POST['reverse'] != ''))) {
92 $current_tab = 4; /* after clicking 'make decisions' on accessibility tab */
93 } else if (!isset($current_tab)) {
98 $_section[0][0] = _AT('edit_content');
100 $_section[0][0] = _AT('add_content');
104 $result = $contentManager->getContentPage($cid);
106 if (!($content_row = @mysql_fetch_assoc($result))) {
107 require(AT_INCLUDE_PATH.'header.inc.php');
108 $msg->printErrors('PAGE_NOT_FOUND');
109 require (AT_INCLUDE_PATH.'footer.inc.php');
113 $path = $contentManager->getContentPath($cid);
114 $content_test = $contentManager->getContentTestsAssoc($cid);
116 if (defined('AT_FORCE_GET_FILE') && AT_FORCE_GET_FILE) {
117 $course_base_href = 'get.php/';
119 $course_base_href = 'content/' . $_SESSION['course_id'] . '/';
122 if ($content_row['content_path']) {
123 $content_base_href .= $content_row['content_path'].'/';
126 if (defined('AT_FORCE_GET_FILE') && AT_FORCE_GET_FILE) {
127 $content_base_href = 'get.php/';
129 $content_base_href = 'content/' . $_SESSION['course_id'] . '/';
133 if ($current_tab == 4) {
134 /* kludge for issue #1626: */
135 /* fixes the base href for the AChecker tab. */
136 $course_base_href = '';
137 $content_base_href = '';
142 // tools/filemanager/top.php
145 $_SESSION['done'] = 0;
147 if (!authenticate(AT_PRIV_FILES,AT_PRIV_RETURN)) {
148 authenticate(AT_PRIV_CONTENT);
151 $current_path = AT_CONTENT_DIR.$_SESSION['course_id'].'/';
155 /* get this courses MaxQuota and MaxFileSize: */
156 $sql = "SELECT max_quota, max_file_size FROM ".TABLE_PREFIX."courses WHERE course_id=$_SESSION[course_id]";
157 $result = mysql_query($sql, $db);
158 $row = mysql_fetch_array($result);
159 $my_MaxCourseSize = $row['max_quota'];
160 $my_MaxFileSize = $row['max_file_size'];
162 if ($my_MaxCourseSize == AT_COURSESIZE_DEFAULT) {
163 $my_MaxCourseSize = $MaxCourseSize;
165 if ($my_MaxFileSize == AT_FILESIZE_DEFAULT) {
166 $my_MaxFileSize = $MaxFileSize;
167 } else if ($my_MaxFileSize == AT_FILESIZE_SYSTEM_MAX) {
168 $my_MaxFileSize = megabytes_to_bytes(substr(ini_get('upload_max_filesize'), 0, -1));
174 if ($_GET['pathext'] != '') {
175 $pathext = urldecode($_GET['pathext']);
176 } else if ($_POST['pathext'] != '') {
177 $pathext = $_POST['pathext'];
180 if (strpos($pathext, '..') !== false) {
181 require(AT_INCLUDE_PATH.'header.inc.php');
182 $msg->printErrors('UNKNOWN');
183 require(AT_INCLUDE_PATH.'footer.inc.php');
186 if($_GET['back'] == 1) {
187 $pathext = substr($pathext, 0, -1);
188 $slashpos = strrpos($pathext, '/');
192 $pathext = substr($pathext, 0, ($slashpos+1));
198 /* remove the forward or backwards slash from the path */
199 $newpath = $current_path;
200 $depth = substr_count($pathext, '/');
202 if ($pathext != '') {
203 $bits = explode('/', $pathext);
204 foreach ($bits as $bit) {
208 $_section[$start_at][0] = $bit;
209 $_section[$start_at][1] = '../tools/filemanager/index.php?pathext=' . urlencode($bit_path) . SEP . 'popup=' . $popup . SEP . 'framed=' . $framed;
218 /* if upload successful, close the window */
220 $onload = 'closeWindow(\'progWin\');';
223 /* make new directory */
224 if (isset($_POST['mkdir'])) {
225 if ($_POST['mkdir_value'] && ($depth < $MaxDirDepth) ) {
226 $_POST['dirname'] = trim($_POST['dirname']);
228 /* anything else should be okay, since we're on *nix..hopefully */
229 $_POST['dirname'] = preg_replace('/[^a-zA-Z0-9._]/', '', $_POST['dirname']);
231 if ($_POST['dirname'] == '') {
232 $msg->addError(array('FOLDER_NOT_CREATED', $_POST['dirname'] ));
234 else if (strpos($_POST['dirname'], '..') !== false) {
235 $msg->addError('BAD_FOLDER_NAME');
238 $result = @mkdir($current_path.$pathext.$_POST['dirname'], 0700);
240 $msg->addError(array('FOLDER_NOT_CREATED', $_POST['dirname'] ));
243 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
248 $newpath = substr($current_path.$pathext, 0, -1);
251 /* open the directory */
252 if (!($dir = @opendir($newpath))) {
253 if (isset($_GET['create']) && ($newpath.'/' == $current_path)) {
255 if (!($dir = @opendir($newpath))) {
256 require(AT_INCLUDE_PATH.'header.inc.php');
257 $msg->printErrors('CANNOT_CREATE_DIR');
258 require(AT_INCLUDE_PATH.'footer.inc.php');
261 $msg->addFeedback('CONTENT_DIR_CREATED');
264 require(AT_INCLUDE_PATH.'header.inc.php');
266 $msg->printErrors('CANNOT_OPEN_DIR');
267 require(AT_INCLUDE_PATH.'footer.inc.php');
272 if (isset($_POST['cancel'])) {
273 $msg->addFeedback('CANCELLED');
278 $_SESSION['done'] = 1;
279 $popup = $_REQUEST['popup'];
280 $framed = $_REQUEST['framed'];
282 /* get this courses MaxQuota and MaxFileSize: */
283 $sql = "SELECT max_quota, max_file_size FROM ".TABLE_PREFIX."courses WHERE course_id=$_SESSION[course_id]";
284 $result = mysql_query($sql, $db);
285 $row = mysql_fetch_array($result);
286 $my_MaxCourseSize = $row['max_quota'];
287 $my_MaxFileSize = $row['max_file_size'];
289 if ($my_MaxCourseSize == AT_COURSESIZE_DEFAULT) {
290 $my_MaxCourseSize = $MaxCourseSize;
292 if ($my_MaxFileSize == AT_FILESIZE_DEFAULT) {
293 $my_MaxFileSize = $MaxFileSize;
294 } else if ($my_MaxFileSize == AT_FILESIZE_SYSTEM_MAX) {
295 $my_MaxFileSize = megabytes_to_bytes(substr(ini_get('upload_max_filesize'), 0, -1));
298 $path = AT_CONTENT_DIR . $_SESSION['course_id'].'/'.$_POST['pathext'];
300 if (isset($_POST['upload'])) {
302 if($_FILES['uploadedfile']['name']) {
303 // echo 'il file esiste';
304 $_FILES['uploadedfile']['name'] = trim($_FILES['uploadedfile']['name']);
305 $_FILES['uploadedfile']['name'] = str_replace(' ', '_', $_FILES['uploadedfile']['name']);
307 $path_parts = pathinfo($_FILES['uploadedfile']['name']);
308 $ext = $path_parts['extension'];
310 /* check if this file extension is allowed: */
311 /* $IllegalExtentions is defined in ./include/config.inc.php */
312 if (in_array($ext, $IllegalExtentions)) {
313 $errors = array('FILE_ILLEGAL', $ext);
314 $msg->addError($errors);
315 header('Location: index.php?pathext='.$_POST['pathext']);
319 /* also have to handle the 'application/x-zip-compressed' case */
320 if ( ($_FILES['uploadedfile']['type'] == 'application/x-zip-compressed')
321 || ($_FILES['uploadedfile']['type'] == 'application/zip')
322 || ($_FILES['uploadedfile']['type'] == 'application/x-zip')){
327 /* anything else should be okay, since we're on *nix.. hopefully */
328 $_FILES['uploadedfile']['name'] = str_replace(array(' ', '/', '\\', ':', '*', '?', '"', '<', '>', '|', '\''), '', $_FILES['uploadedfile']['name']);
331 /* if the file size is within allowed limits */
332 if( ($_FILES['uploadedfile']['size'] > 0) && ($_FILES['uploadedfile']['size'] <= $my_MaxFileSize) ) {
334 /* if adding the file will not exceed the maximum allowed total */
335 $course_total = dirsize($path);
337 if ((($course_total + $_FILES['uploadedfile']['size']) <= ($my_MaxCourseSize + $MaxCourseFloat)) || ($my_MaxCourseSize == AT_COURSESIZE_UNLIMITED)) {
339 /* check if this file exists first */
340 if (file_exists($path.$_FILES['uploadedfile']['name'])) {
341 /* this file already exists, so we want to prompt for override */
343 /* save it somewhere else, temporarily first */
344 /* file_name.time ? */
345 $_FILES['uploadedfile']['name'] = substr(time(), -4).'.'.$_FILES['uploadedfile']['name'];
347 $f = array('FILE_EXISTS',
348 substr($_FILES['uploadedfile']['name'], 5),
349 $_FILES['uploadedfile']['name'],
353 $msg->addFeedback($f);
356 /* copy the file in the directory */
357 $result = move_uploaded_file( $_FILES['uploadedfile']['tmp_name'], $path.$_FILES['uploadedfile']['name'] );
360 require(AT_INCLUDE_PATH.'header.inc.php');
361 $msg->printErrors('FILE_NOT_SAVED');
362 echo '<a href="tools/filemanager/index.php?pathext=' . $_POST['pathext'] . SEP . 'popup=' . $_GET['popup'] . '">' . _AT('back') . '</a>';
363 require(AT_INCLUDE_PATH.'footer.inc.php');
367 $f = array('FILE_UPLOADED_ZIP',
368 urlencode($_POST['pathext']),
369 urlencode($_FILES['uploadedfile']['name']),
372 //$msg->addFeedback($f);
376 $msg->addFeedback('FILE_UPLOADED');
379 $msg->addError(array('MAX_STORAGE_EXCEEDED', get_human_size($my_MaxCourseSize)));
382 $msg->addError(array('FILE_TOO_BIG', get_human_size($my_MaxFileSize)));
385 $msg->addError('FILE_NOT_SELECTED');
392 if ($current_tab == 5){
393 if ($_POST['alternatives']==1){
394 if (isset($_POST['add'])){
395 if (isset($_POST['resources'])){
396 if (isset($_POST['radio_alt'])){
398 $sql = "SELECT * FROM ".TABLE_PREFIX."primary_resources WHERE content_id='$cid' and primary_resource_id='$_POST[resources]'";
399 $result = mysql_query($sql, $db);
401 if (mysql_num_rows($result) > 0) {
402 while ($row = mysql_fetch_assoc($result)) {
403 $sql_contr = "SELECT * FROM ".TABLE_PREFIX."secondary_resources WHERE primary_resource_id='$row[primary_resource_id]' and secondary_resource='$_POST[radio_alt]'";
404 $contr = mysql_query($sql_contr, $db);
405 if (mysql_num_rows($contr) > 0) {
406 $msg->addError('ALTERNATIVE_ALREADY_DECLARED');
409 $sql_ins = "INSERT INTO ".TABLE_PREFIX."secondary_resources VALUES (NULL, '$row[primary_resource_id]', '$_POST[radio_alt]', 'en')";
410 $ins = mysql_query($sql_ins, $db);
411 $msg->addFeedback('ALTERNATIVE_ADDED');
417 $msg->addError('ALTERNATIVE_NOT_DEFINED');
420 $msg->addError('RESOURCE_NOT_DEFINED');
425 if ($_REQUEST[act]=='delete') {
426 $sql = "DELETE FROM ".TABLE_PREFIX."secondary_resources WHERE secondary_resource_id='$_REQUEST[id_alt]'";
427 $result = mysql_query($sql,$db);
428 $sql = "DELETE FROM ".TABLE_PREFIX."secondary_resources_types WHERE secondary_resource_id='$_REQUEST[id_alt]'";
429 $result = mysql_query($sql,$db);
431 $msg->addFeedback('ALTERNATIVE_DELETED');
437 if ($current_tab == 5) {
438 if (isset($_POST['save_types_and_language'])){
439 if(($_POST['alternatives']==1) || ($_GET['alternatives']==1)){
440 $sql = "SELECT primary_resource_id FROM ".TABLE_PREFIX."primary_resources WHERE content_id='$cid'";
441 $result = mysql_query($sql, $db);
443 if (mysql_num_rows($result) > 0) {
444 while ($row = mysql_fetch_assoc($result)) {
445 $sql_type = "SELECT * FROM ".TABLE_PREFIX."resource_types";
446 $result_type = mysql_query($sql_type, $db);
448 if (mysql_num_rows($result_type) > 0) {
449 while ($type = mysql_fetch_assoc($result_type)) {
450 $sql_contr = "SELECT * FROM ".TABLE_PREFIX."primary_resources_types WHERE primary_resource_id='$row[primary_resource_id]' and type_id='$type[type_id]'";
451 $contr = mysql_query($sql_contr, $db);
452 if (mysql_num_rows($contr) > 0) {
453 while ($control = mysql_fetch_assoc($contr)) {
454 if (isset($_POST['checkbox_'.$type[type].'_'.$row[primary_resource_id].'_primary']))
457 $sql_del = "DELETE FROM ".TABLE_PREFIX."primary_resources_types WHERE primary_resource_id='$control[primary_resource_id]' and type_id='$control[type_id]'";
458 $result_del = mysql_query($sql_del, $db);
463 if (isset($_POST['checkbox_'.$type[type].'_'.$row[primary_resource_id].'_primary'])){
464 $sql_ins = "INSERT INTO ".TABLE_PREFIX."primary_resources_types VALUES ($row[primary_resource_id], $type[type_id])";
465 $ins = mysql_query($sql_ins, $db);
468 $sql_alt = "SELECT * FROM ".TABLE_PREFIX."secondary_resources WHERE primary_resource_id='$row[primary_resource_id]'";
469 $result_alt = mysql_query($sql_alt, $db);
471 if (mysql_num_rows($result_alt) > 0) {
472 while ($alt = mysql_fetch_assoc($result_alt)) {
473 $sql_contr = "SELECT * FROM ".TABLE_PREFIX."secondary_resources_types WHERE secondary_resource_id='$alt[secondary_resource_id]' and type_id='$type[type_id]'";
474 $contr = mysql_query($sql_contr, $db);
475 if (mysql_num_rows($contr) > 0) {
476 while ($control = mysql_fetch_assoc($contr)) {
477 if (isset($_POST['checkbox_'.$type[type].'_'.$alt[secondary_resource_id].'_secondary']))
480 $sql_del = "DELETE FROM ".TABLE_PREFIX."secondary_resources_types WHERE secondary_resource_id='$control[secondary_resource_id]' and type_id='$control[type_id]'";
481 $result_del = mysql_query($sql_del, $db);
486 if (isset($_POST['checkbox_'.$type[type].'_'.$alt[secondary_resource_id].'_secondary'])){
487 $sql_ins = "INSERT INTO ".TABLE_PREFIX."secondary_resources_types VALUES ($alt[secondary_resource_id], $type[type_id])";
488 $ins = mysql_query($sql_ins, $db);
490 $lang=$_POST['lang_'.$alt[secondary_resource_id].'_secondary'];
491 $sql_up = "UPDATE ".TABLE_PREFIX."secondary_resources SET language_code='$lang' WHERE secondary_resource_id=$alt[secondary_resource_id]";
492 $up = mysql_query($sql_up, $db);
499 $lang=$_POST['lang_'.$row[primary_resource_id].'_primary'];
500 $sql_up = "UPDATE ".TABLE_PREFIX."primary_resources SET language_code='$lang' WHERE primary_resource_id=$row[primary_resource_id]";
501 $up = mysql_query($sql_up, $db);
502 /* Added feedback message after types and language are updated Greg Oct 19/08
505 $msg->addFeedback('RESOURCE_PROPERTIES_UPDATED');
513 if (isset($_POST['body_text_alt'])){
514 $cid_wholepage = $cid.'_wholepage';
515 $sql = "SELECT * FROM ".TABLE_PREFIX."primary_resources WHERE content_id='$cid' and resource='$cid_wholepage'";
516 $result = mysql_query($sql, $db);
517 if (mysql_num_rows($result) > 0){
518 while ($row = mysql_fetch_assoc($result)) {
519 $sql_type = "SELECT * FROM ".TABLE_PREFIX."resource_types";
520 $result_type = mysql_query($sql_type, $db);
522 if (mysql_num_rows($result_type) > 0) {
523 while ($type = mysql_fetch_assoc($result_type)) {
524 $sql_contr = "SELECT * FROM ".TABLE_PREFIX."primary_resources_types WHERE primary_resource_id='$row[primary_resource_id]' and type_id='$type[type_id]'";
525 $contr = mysql_query($sql_contr, $db);
526 if (mysql_num_rows($contr) > 0) {
527 while ($control = mysql_fetch_assoc($contr)) {
528 if (isset($_POST['checkbox_'.$type[type].'_'.$row[primary_resource_id].'_primary']))
531 $sql_del = "DELETE FROM ".TABLE_PREFIX."primary_resources_types WHERE primary_resource_id='$control[primary_resource_id]' and type_id='$control[type_id]'";
532 $result_del = mysql_query($sql_del, $db);
536 if (isset($_POST['checkbox_'.$type[type].'_'.$row[primary_resource_id].'_primary'])){
537 $sql_ins = "INSERT INTO ".TABLE_PREFIX."primary_resources_types VALUES ($row[primary_resource_id], $type[type_id])";
538 $ins = mysql_query($sql_ins, $db);
541 if ($_POST['body_text_alt'] != $_POST['body_text']){
542 $sql_check_secondary = "SELECT * FROM ".TABLE_PREFIX."secondary_resources WHERE primary_resource_id='$row[primary_resource_id]'";
543 $check_secondary = mysql_query($sql_check_secondary, $db);
544 if (mysql_num_rows($check_secondary) > 0) {
545 while ($secondary = mysql_fetch_assoc($check_secondary)) {
546 $sql_up = "UPDATE ".TABLE_PREFIX."secondary_resources SET secondary_resource='$_POST[body_text_alt]' WHERE secondary_resource_id=$secondary[secondary_resource_id]";
547 $up = mysql_query($sql_up, $db);
548 $msg->addFeedback('ALTERNATIVE_UPDATED');
551 $sql_ins = "INSERT INTO ".TABLE_PREFIX."secondary_resources VALUES (NULL, '$row[primary_resource_id]', '$_POST[body_text_alt]', 'en')";
552 $ins = mysql_query($sql_ins, $db);
553 $msg->addFeedback('ALTERNATIVE_ADDED');
555 $sql_alt = "SELECT * FROM ".TABLE_PREFIX."secondary_resources WHERE primary_resource_id='$row[primary_resource_id]'";
556 $result_alt = mysql_query($sql_alt, $db);
558 if (mysql_num_rows($result_alt) > 0) {
559 while ($alt = mysql_fetch_assoc($result_alt)) {
560 $sql_contr = "SELECT * FROM ".TABLE_PREFIX."secondary_resources_types WHERE secondary_resource_id='$alt[secondary_resource_id]' and type_id='$type[type_id]'";
561 $contr = mysql_query($sql_contr, $db);
562 if (mysql_num_rows($contr) > 0) {
563 while ($control = mysql_fetch_assoc($contr)) {
564 if (isset($_POST['checkbox_'.$type[type].'_'.$alt[secondary_resource_id].'_secondary']))
567 $sql_del = "DELETE FROM ".TABLE_PREFIX."secondary_resources_types WHERE secondary_resource_id='$control[secondary_resource_id]' and type_id='$control[type_id]'";
568 $result_del = mysql_query($sql_del, $db);
572 if (isset($_POST['checkbox_'.$type[type].'_'.$alt[secondary_resource_id].'_secondary'])){
573 $sql_ins = "INSERT INTO ".TABLE_PREFIX."secondary_resources_types VALUES ($alt[secondary_resource_id], $type[type_id])";
574 $ins = mysql_query($sql_ins, $db);
576 $lang = $_POST['lang_'.$alt[secondary_resource_id].'_secondary'];
577 $sql_up = "UPDATE ".TABLE_PREFIX."secondary_resources SET language_code='$lang' WHERE secondary_resource_id='$alt[secondary_resource_id]'";
578 $up = mysql_query($sql_up, $db);
581 $lang=$_POST['lang_'.$row[primary_resource_id].'_primary'];
582 $sql_up = "UPDATE ".TABLE_PREFIX."primary_resources SET language_code='$lang' WHERE primary_resource_id='$row[primary_resource_id]'";
583 $up = mysql_query($sql_up, $db);
597 //End Added by Silvia
599 //Extended Test within content functionality - Harris @Sep 9, 2008
600 //if ($current_tab == 6){
603 if (($current_tab == 0) || ($_current_tab == 5)) {
604 if (!isset($_REQUEST['setvisual']) && !isset($_REQUEST['settext'])) {
605 if ($_SESSION['prefs']['PREF_CONTENT_EDITOR'] == 1) {
606 $_POST['formatting'] = 1;
607 $_REQUEST['settext'] = 0;
608 $_REQUEST['setvisual'] = 0;
610 } else if ($_SESSION['prefs']['PREF_CONTENT_EDITOR'] == 2) {
611 $_POST['formatting'] = 1;
612 $_POST['settext'] = 0;
613 $_POST['setvisual'] = 1;
615 } else { // else if == 0
616 $_POST['formatting'] = 0;
617 $_REQUEST['settext'] = 0;
618 $_REQUEST['setvisual'] = 0;
621 if ((!$_POST['setvisual'] && $_POST['settext']) || !$_GET['setvisual']){
622 $onload = "document.form.ctitle.focus(); ";
626 // initialize buttons, texts, radio buttons for editor
627 if ($current_tab == 0)
629 $onload.="on_load();";
632 if ($current_tab == 5)
634 $onload.="on_load();";
637 require(AT_INCLUDE_PATH.'header.inc.php');
639 if ($current_tab == 0)
641 load_editor(false, "none");
644 if ($current_tab == 5)
646 load_editor(false, "none");
650 //TODO*************BOLOGNA****************REMOVE ME**************/
651 //loading toolbar for insert discussion topic or web link into the content
652 if ($current_tab == 0){
653 if(authenticate(AT_PRIV_CONTENT,AT_PRIV_RETURN)){
654 $home_links = get_home_navigation(); //vengono lette le caratteristiche di ogni modulo attivato nella home page.
655 $main_links = get_main_navigation($current_page); //vengono lette le caratteristiche di ogni modulo attivo nel main navigation
657 $num = count($main_links); //necessario elminare il primo e l'utlimo elemento poichè sono rispettivamente "Home" e "Manage"
658 unset($main_links[0]); //"Home" label
659 unset($main_links[$num-1]); //"Manage" label
661 $all_tools = $home_links; //$all_tools represent a merge between $home_links and main_links without repetitions.
663 foreach($main_links as $main) {
664 foreach($home_links as $home) {
665 if($home['title'] == $main['title']) {
679 $cid = intval($_REQUEST['cid']);
680 $pid = intval($_REQUEST['pid']);
683 <form action="<?php echo $_SERVER['PHP_SELF']; ?>?cid=<?php echo $cid; ?>" method="post" name="form" enctype="multipart/form-data">
687 //$content_row = sql_quote($content_row);
688 if (isset($_POST['current_tab'])) {
689 //$changes_made = check_for_changes($content_row);
691 $changes_made = array();
693 $_POST['formatting'] = $content_row['formatting'];
694 $_POST['head'] = $content_row['head'];
695 $_POST['use_customized_head'] = $content_row['use_customized_head'];
696 $_POST['title'] = $content_row['title'];
697 $_POST['body_text'] = $content_row['text'];
698 $_POST['keywords'] = $content_row['keywords'];
699 $_POST['test_message'] = $content_row['test_message'];
700 $_POST['allow_test_export'] = $content_row['allow_test_export'];
702 $_POST['day'] = substr($content_row['release_date'], 8, 2);
703 $_POST['month'] = substr($content_row['release_date'], 5, 2);
704 $_POST['year'] = substr($content_row['release_date'], 0, 4);
705 $_POST['hour'] = substr($content_row['release_date'], 11, 2);
706 $_POST['min']= substr($content_row['release_date'], 14, 2);
708 $_POST['ordering'] = $content_row['ordering'];
709 $_POST['related'] = $contentManager->getRelatedContent($cid);
711 $_POST['pid'] = $pid = $content_row['content_parent_id'];
713 $_POST['related_term'] = $glossary_ids_related;
718 if (!isset($_POST['current_tab'])) {
719 $_POST['day'] = date('d');
720 $_POST['month'] = date('m');
721 $_POST['year'] = date('Y');
722 $_POST['hour'] = date('H');
725 if (isset($_GET['pid'])) {
726 $pid = $_POST['pid'] = intval($_GET['pid']);
727 $_POST['ordering'] = count($contentManager->getContent($pid))+1;
730 $_POST['ordering'] = count($contentManager->getContent(0))+1;
735 echo '<input type="hidden" name="cid" value="'.$cid.'" />';
736 echo '<input type="hidden" name="title" value="'.htmlspecialchars($stripslashes($_POST['title'])).'" />';
737 if ($_REQUEST['sub'] == 1)
739 echo '<input type="hidden" name="sub" value="1" />';
740 echo '<input type="hidden" name="folder_title" value="'.htmlspecialchars($stripslashes($_POST['folder_title'])).'" />';
742 echo '<input type="submit" name="submit" style="display:none;"/>';
743 if (($current_tab != 0) && (($_current_tab != 5))) {
744 echo '<input type="hidden" name="body_text" value="'.htmlspecialchars($stripslashes($_POST['body_text'])).'" />';
745 echo '<input type="hidden" name="head" value="'.htmlspecialchars($stripslashes($_POST['head'])).'" />';
746 echo '<input type="hidden" name="use_customized_head" value="'.(($_POST['use_customized_head']=="") ? 0 : $_POST['use_customized_head']).'" />';
747 echo '<input type="hidden" name="displayhead" value="'.$_POST['displayhead'].'" />';
748 echo '<input type="hidden" name="setvisual" value="'.$_POST['setvisual'].'" />';
749 echo '<input type="hidden" name="settext" value="'.$_POST['settext'].'" />';
750 echo '<input type="hidden" name="formatting" value="'.$_POST['formatting'].'" />';
753 echo '<input type="hidden" name="ordering" value="'.$_POST['ordering'].'" />';
754 echo '<input type="hidden" name="pid" value="'.$pid.'" />';
756 echo '<input type="hidden" name="day" value="'.$_POST['day'].'" />';
757 echo '<input type="hidden" name="month" value="'.$_POST['month'].'" />';
758 echo '<input type="hidden" name="year" value="'.$_POST['year'].'" />';
759 echo '<input type="hidden" name="hour" value="'.$_POST['hour'].'" />';
760 echo '<input type="hidden" name="minute" value="'.$_POST['minute'].'" />';
761 echo '<input type="hidden" name="min" value="'.$_POST['min'].'" />';
763 echo '<input type="hidden" name="alternatives" value="'.$_POST['alternatives'].'" />';
765 echo '<input type="hidden" name="current_tab" value="'.$current_tab.'" />';
767 if (is_array($_POST['related']) && ($current_tab != 1)) {
768 foreach($_POST['related'] as $r_id) {
769 echo '<input type="hidden" name="related[]" value="'.$r_id.'" />';
772 echo '<input type="hidden" name="keywords" value="'.htmlspecialchars(stripslashes($_POST['keywords'])).'" />';
774 //content test association
775 echo '<input type="hidden" name="test_message" value="'.$_POST['test_message'].'" />';
777 /* get glossary terms */
778 $matches = find_terms(stripslashes($_POST['body_text']));
779 $num_terms = count($matches[0]);
780 $matches = $matches[0];
781 $word = str_replace(array('[?]', '[/?]'), '', $matches);
783 if (is_array($word)) {
784 /* update $_POST['glossary_defs'] with any new/changed terms */
785 for($i=0; $i<$num_terms; $i++) {
786 $word[$i] = urlencode($word[$i]);
787 if (!isset($_POST['glossary_defs'][$word[$i]])) {
788 $_POST['glossary_defs'][$word[$i]] = $glossary[$word[$i]];
793 if (is_array($_POST['glossary_defs']) && ($current_tab != 2)) {
794 foreach($_POST['glossary_defs'] as $w => $d) {
795 /* this term still exists in the content */
796 if (!in_array($w, $word)) {
797 unset($_POST['glossary_defs'][$w]);
800 echo '<input type="hidden" name="glossary_defs['.$w.']" value="'.htmlspecialchars(stripslashes($d)).'" />';
802 if (isset($_POST['related_term'])) {
803 foreach($_POST['related_term'] as $w => $d) {
804 echo '<input type="hidden" name="related_term['.$w.']" value="'.$d.'" />';
810 if (is_array($_POST['tid']) && $current_tab != 6){
811 /* Test & Survey --> Other tabs triggers this condition */
812 foreach ($_POST['tid'] as $i=>$tid){
813 echo '<input type="hidden" name="tid['.$i.']" value="'.$tid.'" />';
815 } elseif ($current_tab != 6){
816 /* Edit Content (On Edit content tab), without clicking Test & Survey */
819 while ($content_test_row = mysql_fetch_assoc($content_test)){
820 echo '<input type="hidden" name="tid['.$i++.']" value="'.$content_test_row['test_id'].'" />';
824 if (!isset($_POST['allow_test_export']) && $current_tab != 6) {
825 //export flag handling.
826 $sql = "SELECT `allow_test_export` FROM ".TABLE_PREFIX."content WHERE content_id=$_REQUEST[cid]";
827 $result2 = mysql_query($sql, $db);
829 $c_row = mysql_fetch_assoc($result2);
831 if (intval($c_row['allow_test_export'])==1){
832 echo '<input type="hidden" name="allow_test_export" value="1" />';
834 echo '<input type="hidden" name="allow_test_export" value="0" />';
837 echo '<input type="hidden" name="allow_test_export" value="'.intval($_POST['allow_test_export']).'" />';
841 $changes_made = check_for_changes($content_row);
846 <?php output_tabs($current_tab, $changes_made); ?>
848 <div class="input-form" style="width: 95%">
850 <?php if ($changes_made): ?>
851 <div class="unsaved">
852 <span style="color:red;"><?php echo _AT('save_changes_unsaved'); ?></span>
853 <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;" />
854 <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"'; } ?> />
855 <label for="close"><?php echo _AT('close_after_saving'); ?></label>
860 <?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" /> <input type="submit" name="close" value="<?php echo _AT('close'); ?>" /> <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>
864 // if ($current_tab != 5){
865 include(AT_INCLUDE_PATH.'html/editor_tabs/'.$tabs[$current_tab][1]);
866 echo '</div></form>';
870 // echo '</div></form>';
871 // include(AT_INCLUDE_PATH.'html/editor_tabs/'.$tabs[$current_tab][1]);
877 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>