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/');
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']);
33 require(AT_INCLUDE_PATH.'lib/editor_tab_functions.inc.php');
35 if ($_POST['close'] || $_GET['close']) {
37 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
39 $msg->addFeedback('CLOSED');
41 header('Location: '.AT_BASE_HREF.'tools/content/index.php');
46 if ($_REQUEST['cid'] == 0) {
47 header('Location: '.$_base_path.'content.php?cid='.intval($_REQUEST['new_pid']));
50 header('Location: '.$_base_path.url_rewrite('content.php?cid='.intval($_REQUEST['cid'])));
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'])) {
\r
79 paste_from_file(body_text_alt);
\r
80 } else if (isset($_POST['submit']) && ($_POST['submit'] != 'submit1')) {
\r
81 /* we're saving. redirects if successful. */
\r
82 save_changes(true, $current_tab);
\r
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) && (($_POST['desc_submit'] != '') || ($_POST['reverse'] != ''))) {
93 $current_tab = 4; /* after clicking 'make decisions' on accessibility tab */
94 } else if (!isset($current_tab)) {
99 $_section[0][0] = _AT('edit_content');
101 $_section[0][0] = _AT('add_content');
105 $result = $contentManager->getContentPage($cid);
107 if (!($content_row = @mysql_fetch_assoc($result))) {
108 require(AT_INCLUDE_PATH.'header.inc.php');
109 $msg->printErrors('PAGE_NOT_FOUND');
110 require (AT_INCLUDE_PATH.'footer.inc.php');
114 $path = $contentManager->getContentPath($cid);
115 $content_test = $contentManager->getContentTestsAssoc($cid);
117 if (defined('AT_FORCE_GET_FILE') && AT_FORCE_GET_FILE) {
118 $course_base_href = 'get.php/';
120 $course_base_href = 'content/' . $_SESSION['course_id'] . '/';
123 if ($content_row['content_path']) {
124 $content_base_href .= $content_row['content_path'].'/';
127 if (defined('AT_FORCE_GET_FILE') && AT_FORCE_GET_FILE) {
128 $content_base_href = 'get.php/';
130 $content_base_href = 'content/' . $_SESSION['course_id'] . '/';
134 if ($current_tab == 4) {
135 /* kludge for issue #1626: */
136 /* fixes the base href for the AChecker tab. */
137 $course_base_href = '';
138 $content_base_href = '';
143 // tools/filemanager/top.php
146 $_SESSION['done'] = 0;
148 if (!authenticate(AT_PRIV_FILES,AT_PRIV_RETURN)) {
149 authenticate(AT_PRIV_CONTENT);
152 $current_path = AT_CONTENT_DIR.$_SESSION['course_id'].'/';
156 /* get this courses MaxQuota and MaxFileSize: */
157 $sql = "SELECT max_quota, max_file_size FROM ".TABLE_PREFIX."courses WHERE course_id=$_SESSION[course_id]";
158 $result = mysql_query($sql, $db);
159 $row = mysql_fetch_array($result);
160 $my_MaxCourseSize = $row['max_quota'];
161 $my_MaxFileSize = $row['max_file_size'];
163 if ($my_MaxCourseSize == AT_COURSESIZE_DEFAULT) {
164 $my_MaxCourseSize = $MaxCourseSize;
166 if ($my_MaxFileSize == AT_FILESIZE_DEFAULT) {
167 $my_MaxFileSize = $MaxFileSize;
168 } else if ($my_MaxFileSize == AT_FILESIZE_SYSTEM_MAX) {
169 $my_MaxFileSize = megabytes_to_bytes(substr(ini_get('upload_max_filesize'), 0, -1));
175 if ($_GET['pathext'] != '') {
176 $pathext = urldecode($_GET['pathext']);
177 } else if ($_POST['pathext'] != '') {
178 $pathext = $_POST['pathext'];
181 if (strpos($pathext, '..') !== false) {
182 require(AT_INCLUDE_PATH.'header.inc.php');
183 $msg->printErrors('UNKNOWN');
184 require(AT_INCLUDE_PATH.'footer.inc.php');
187 if($_GET['back'] == 1) {
188 $pathext = substr($pathext, 0, -1);
189 $slashpos = strrpos($pathext, '/');
193 $pathext = substr($pathext, 0, ($slashpos+1));
199 /* remove the forward or backwards slash from the path */
200 $newpath = $current_path;
201 $depth = substr_count($pathext, '/');
203 if ($pathext != '') {
204 $bits = explode('/', $pathext);
205 foreach ($bits as $bit) {
209 $_section[$start_at][0] = $bit;
210 $_section[$start_at][1] = '../tools/filemanager/index.php?pathext=' . urlencode($bit_path) . SEP . 'popup=' . $popup . SEP . 'framed=' . $framed;
219 /* if upload successful, close the window */
221 $onload = 'closeWindow(\'progWin\');';
224 /* make new directory */
225 if (isset($_POST['mkdir'])) {
226 if ($_POST['mkdir_value'] && ($depth < $MaxDirDepth) ) {
227 $_POST['dirname'] = trim($_POST['dirname']);
229 /* anything else should be okay, since we're on *nix..hopefully */
230 $_POST['dirname'] = ereg_replace('[^a-zA-Z0-9._]', '', $_POST['dirname']);
232 if ($_POST['dirname'] == '') {
233 $msg->addError(array('FOLDER_NOT_CREATED', $_POST['dirname'] ));
235 else if (strpos($_POST['dirname'], '..') !== false) {
236 $msg->addError('BAD_FOLDER_NAME');
239 $result = @mkdir($current_path.$pathext.$_POST['dirname'], 0700);
241 $msg->addError(array('FOLDER_NOT_CREATED', $_POST['dirname'] ));
244 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
249 $newpath = substr($current_path.$pathext, 0, -1);
252 /* open the directory */
253 if (!($dir = @opendir($newpath))) {
254 if (isset($_GET['create']) && ($newpath.'/' == $current_path)) {
256 if (!($dir = @opendir($newpath))) {
257 require(AT_INCLUDE_PATH.'header.inc.php');
258 $msg->printErrors('CANNOT_CREATE_DIR');
259 require(AT_INCLUDE_PATH.'footer.inc.php');
262 $msg->addFeedback('CONTENT_DIR_CREATED');
265 require(AT_INCLUDE_PATH.'header.inc.php');
267 $msg->printErrors('CANNOT_OPEN_DIR');
268 require(AT_INCLUDE_PATH.'footer.inc.php');
273 if (isset($_POST['cancel'])) {
274 $msg->addFeedback('CANCELLED');
279 $_SESSION['done'] = 1;
280 $popup = $_REQUEST['popup'];
281 $framed = $_REQUEST['framed'];
283 /* get this courses MaxQuota and MaxFileSize: */
284 $sql = "SELECT max_quota, max_file_size FROM ".TABLE_PREFIX."courses WHERE course_id=$_SESSION[course_id]";
285 $result = mysql_query($sql, $db);
286 $row = mysql_fetch_array($result);
287 $my_MaxCourseSize = $row['max_quota'];
288 $my_MaxFileSize = $row['max_file_size'];
290 if ($my_MaxCourseSize == AT_COURSESIZE_DEFAULT) {
291 $my_MaxCourseSize = $MaxCourseSize;
293 if ($my_MaxFileSize == AT_FILESIZE_DEFAULT) {
294 $my_MaxFileSize = $MaxFileSize;
295 } else if ($my_MaxFileSize == AT_FILESIZE_SYSTEM_MAX) {
296 $my_MaxFileSize = megabytes_to_bytes(substr(ini_get('upload_max_filesize'), 0, -1));
299 $path = AT_CONTENT_DIR . $_SESSION['course_id'].'/'.$_POST['pathext'];
301 if (isset($_POST['upload'])) {
303 if($_FILES['uploadedfile']['name']) {
304 // echo 'il file esiste';
305 $_FILES['uploadedfile']['name'] = trim($_FILES['uploadedfile']['name']);
306 $_FILES['uploadedfile']['name'] = str_replace(' ', '_', $_FILES['uploadedfile']['name']);
308 $path_parts = pathinfo($_FILES['uploadedfile']['name']);
309 $ext = $path_parts['extension'];
311 /* check if this file extension is allowed: */
312 /* $IllegalExtentions is defined in ./include/config.inc.php */
313 if (in_array($ext, $IllegalExtentions)) {
314 $errors = array('FILE_ILLEGAL', $ext);
315 $msg->addError($errors);
316 header('Location: index.php?pathext='.$_POST['pathext']);
320 /* also have to handle the 'application/x-zip-compressed' case */
321 if ( ($_FILES['uploadedfile']['type'] == 'application/x-zip-compressed')
322 || ($_FILES['uploadedfile']['type'] == 'application/zip')
323 || ($_FILES['uploadedfile']['type'] == 'application/x-zip')){
328 /* anything else should be okay, since we're on *nix.. hopefully */
329 $_FILES['uploadedfile']['name'] = str_replace(array(' ', '/', '\\', ':', '*', '?', '"', '<', '>', '|', '\''), '', $_FILES['uploadedfile']['name']);
332 /* if the file size is within allowed limits */
333 if( ($_FILES['uploadedfile']['size'] > 0) && ($_FILES['uploadedfile']['size'] <= $my_MaxFileSize) ) {
335 /* if adding the file will not exceed the maximum allowed total */
336 $course_total = dirsize($path);
338 if ((($course_total + $_FILES['uploadedfile']['size']) <= ($my_MaxCourseSize + $MaxCourseFloat)) || ($my_MaxCourseSize == AT_COURSESIZE_UNLIMITED)) {
340 /* check if this file exists first */
341 if (file_exists($path.$_FILES['uploadedfile']['name'])) {
342 /* this file already exists, so we want to prompt for override */
344 /* save it somewhere else, temporarily first */
345 /* file_name.time ? */
346 $_FILES['uploadedfile']['name'] = substr(time(), -4).'.'.$_FILES['uploadedfile']['name'];
348 $f = array('FILE_EXISTS',
349 substr($_FILES['uploadedfile']['name'], 5),
350 $_FILES['uploadedfile']['name'],
354 $msg->addFeedback($f);
357 /* copy the file in the directory */
358 $result = move_uploaded_file( $_FILES['uploadedfile']['tmp_name'], $path.$_FILES['uploadedfile']['name'] );
361 require(AT_INCLUDE_PATH.'header.inc.php');
362 $msg->printErrors('FILE_NOT_SAVED');
363 echo '<a href="tools/filemanager/index.php?pathext=' . $_POST['pathext'] . SEP . 'popup=' . $_GET['popup'] . '">' . _AT('back') . '</a>';
364 require(AT_INCLUDE_PATH.'footer.inc.php');
368 $f = array('FILE_UPLOADED_ZIP',
369 urlencode($_POST['pathext']),
370 urlencode($_FILES['uploadedfile']['name']),
373 //$msg->addFeedback($f);
377 $msg->addFeedback('FILE_UPLOADED');
380 $msg->addError(array('MAX_STORAGE_EXCEEDED', get_human_size($my_MaxCourseSize)));
383 $msg->addError(array('FILE_TOO_BIG', get_human_size($my_MaxFileSize)));
386 $msg->addError('FILE_NOT_SELECTED');
393 if ($current_tab == 5){
394 if ($_POST['alternatives']==1){
395 if (isset($_POST['add'])){
396 if (isset($_POST['resources'])){
397 if (isset($_POST['radio_alt'])){
399 $sql = "SELECT * FROM ".TABLE_PREFIX."primary_resources WHERE content_id='$cid' and primary_resource_id='$_POST[resources]'";
400 $result = mysql_query($sql, $db);
402 if (mysql_num_rows($result) > 0) {
403 while ($row = mysql_fetch_assoc($result)) {
404 $sql_contr = "SELECT * FROM ".TABLE_PREFIX."secondary_resources WHERE primary_resource_id='$row[primary_resource_id]' and secondary_resource='$_POST[radio_alt]'";
405 $contr = mysql_query($sql_contr, $db);
406 if (mysql_num_rows($contr) > 0) {
407 $msg->addError('ALTERNATIVE_ALREADY_DECLARED');
410 $sql_ins = "INSERT INTO ".TABLE_PREFIX."secondary_resources VALUES (NULL, '$row[primary_resource_id]', '$_POST[radio_alt]', 'en')";
411 $ins = mysql_query($sql_ins, $db);
412 $msg->addFeedback('ALTERNATIVE_ADDED');
418 $msg->addError('ALTERNATIVE_NOT_DEFINED');
421 $msg->addError('RESOURCE_NOT_DEFINED');
426 if ($_REQUEST[act]=='delete') {
427 $sql = "DELETE FROM ".TABLE_PREFIX."secondary_resources WHERE secondary_resource_id='$_REQUEST[id_alt]'";
428 $result = mysql_query($sql,$db);
429 $sql = "DELETE FROM ".TABLE_PREFIX."secondary_resources_types WHERE secondary_resource_id='$_REQUEST[id_alt]'";
430 $result = mysql_query($sql,$db);
432 $msg->addFeedback('ALTERNATIVE_DELETED');
438 if ($current_tab == 5) {
439 if (isset($_POST['save_types_and_language'])){
440 if(($_POST['alternatives']==1) || ($_GET['alternatives']==1)){
441 $sql = "SELECT primary_resource_id FROM ".TABLE_PREFIX."primary_resources WHERE content_id='$cid'";
442 $result = mysql_query($sql, $db);
444 if (mysql_num_rows($result) > 0) {
445 while ($row = mysql_fetch_assoc($result)) {
446 $sql_type = "SELECT * FROM ".TABLE_PREFIX."resource_types";
447 $result_type = mysql_query($sql_type, $db);
449 if (mysql_num_rows($result_type) > 0) {
450 while ($type = mysql_fetch_assoc($result_type)) {
451 $sql_contr = "SELECT * FROM ".TABLE_PREFIX."primary_resources_types WHERE primary_resource_id='$row[primary_resource_id]' and type_id='$type[type_id]'";
452 $contr = mysql_query($sql_contr, $db);
453 if (mysql_num_rows($contr) > 0) {
454 while ($control = mysql_fetch_assoc($contr)) {
455 if (isset($_POST['checkbox_'.$type[type].'_'.$row[primary_resource_id].'_primary']))
458 $sql_del = "DELETE FROM ".TABLE_PREFIX."primary_resources_types WHERE primary_resource_id='$control[primary_resource_id]' and type_id='$control[type_id]'";
459 $result_del = mysql_query($sql_del, $db);
464 if (isset($_POST['checkbox_'.$type[type].'_'.$row[primary_resource_id].'_primary'])){
465 $sql_ins = "INSERT INTO ".TABLE_PREFIX."primary_resources_types VALUES ($row[primary_resource_id], $type[type_id])";
466 $ins = mysql_query($sql_ins, $db);
469 $sql_alt = "SELECT * FROM ".TABLE_PREFIX."secondary_resources WHERE primary_resource_id='$row[primary_resource_id]'";
470 $result_alt = mysql_query($sql_alt, $db);
472 if (mysql_num_rows($result_alt) > 0) {
473 while ($alt = mysql_fetch_assoc($result_alt)) {
474 $sql_contr = "SELECT * FROM ".TABLE_PREFIX."secondary_resources_types WHERE secondary_resource_id='$alt[secondary_resource_id]' and type_id='$type[type_id]'";
475 $contr = mysql_query($sql_contr, $db);
476 if (mysql_num_rows($contr) > 0) {
477 while ($control = mysql_fetch_assoc($contr)) {
478 if (isset($_POST['checkbox_'.$type[type].'_'.$alt[secondary_resource_id].'_secondary']))
481 $sql_del = "DELETE FROM ".TABLE_PREFIX."secondary_resources_types WHERE secondary_resource_id='$control[secondary_resource_id]' and type_id='$control[type_id]'";
482 $result_del = mysql_query($sql_del, $db);
487 if (isset($_POST['checkbox_'.$type[type].'_'.$alt[secondary_resource_id].'_secondary'])){
488 $sql_ins = "INSERT INTO ".TABLE_PREFIX."secondary_resources_types VALUES ($alt[secondary_resource_id], $type[type_id])";
489 $ins = mysql_query($sql_ins, $db);
491 $lang=$_POST['lang_'.$alt[secondary_resource_id].'_secondary'];
492 $sql_up = "UPDATE ".TABLE_PREFIX."secondary_resources SET language_code='$lang' WHERE secondary_resource_id=$alt[secondary_resource_id]";
493 $up = mysql_query($sql_up, $db);
500 $lang=$_POST['lang_'.$row[primary_resource_id].'_primary'];
501 $sql_up = "UPDATE ".TABLE_PREFIX."primary_resources SET language_code='$lang' WHERE primary_resource_id=$row[primary_resource_id]";
502 $up = mysql_query($sql_up, $db);
503 /* Added feedback message after types and language are updated Greg Oct 19/08
506 $msg->addFeedback('RESOURCE_PROPERTIES_UPDATED');
514 if (isset($_POST['body_text_alt'])){
515 $cid_wholepage = $cid.'_wholepage';
516 $sql = "SELECT * FROM ".TABLE_PREFIX."primary_resources WHERE content_id='$cid' and resource='$cid_wholepage'";
517 $result = mysql_query($sql, $db);
518 if (mysql_num_rows($result) > 0){
519 while ($row = mysql_fetch_assoc($result)) {
520 $sql_type = "SELECT * FROM ".TABLE_PREFIX."resource_types";
521 $result_type = mysql_query($sql_type, $db);
523 if (mysql_num_rows($result_type) > 0) {
524 while ($type = mysql_fetch_assoc($result_type)) {
525 $sql_contr = "SELECT * FROM ".TABLE_PREFIX."primary_resources_types WHERE primary_resource_id='$row[primary_resource_id]' and type_id='$type[type_id]'";
526 $contr = mysql_query($sql_contr, $db);
527 if (mysql_num_rows($contr) > 0) {
528 while ($control = mysql_fetch_assoc($contr)) {
529 if (isset($_POST['checkbox_'.$type[type].'_'.$row[primary_resource_id].'_primary']))
532 $sql_del = "DELETE FROM ".TABLE_PREFIX."primary_resources_types WHERE primary_resource_id='$control[primary_resource_id]' and type_id='$control[type_id]'";
533 $result_del = mysql_query($sql_del, $db);
537 if (isset($_POST['checkbox_'.$type[type].'_'.$row[primary_resource_id].'_primary'])){
538 $sql_ins = "INSERT INTO ".TABLE_PREFIX."primary_resources_types VALUES ($row[primary_resource_id], $type[type_id])";
539 $ins = mysql_query($sql_ins, $db);
542 if ($_POST['body_text_alt'] != $_POST['body_text']){
543 $sql_check_secondary = "SELECT * FROM ".TABLE_PREFIX."secondary_resources WHERE primary_resource_id='$row[primary_resource_id]'";
544 $check_secondary = mysql_query($sql_check_secondary, $db);
545 if (mysql_num_rows($check_secondary) > 0) {
546 while ($secondary = mysql_fetch_assoc($check_secondary)) {
547 $sql_up = "UPDATE ".TABLE_PREFIX."secondary_resources SET secondary_resource='$_POST[body_text_alt]' WHERE secondary_resource_id=$secondary[secondary_resource_id]";
548 $up = mysql_query($sql_up, $db);
549 $msg->addFeedback('ALTERNATIVE_UPDATED');
552 $sql_ins = "INSERT INTO ".TABLE_PREFIX."secondary_resources VALUES (NULL, '$row[primary_resource_id]', '$_POST[body_text_alt]', 'en')";
553 $ins = mysql_query($sql_ins, $db);
554 $msg->addFeedback('ALTERNATIVE_ADDED');
556 $sql_alt = "SELECT * FROM ".TABLE_PREFIX."secondary_resources WHERE primary_resource_id='$row[primary_resource_id]'";
557 $result_alt = mysql_query($sql_alt, $db);
559 if (mysql_num_rows($result_alt) > 0) {
560 while ($alt = mysql_fetch_assoc($result_alt)) {
561 $sql_contr = "SELECT * FROM ".TABLE_PREFIX."secondary_resources_types WHERE secondary_resource_id='$alt[secondary_resource_id]' and type_id='$type[type_id]'";
562 $contr = mysql_query($sql_contr, $db);
563 if (mysql_num_rows($contr) > 0) {
564 while ($control = mysql_fetch_assoc($contr)) {
565 if (isset($_POST['checkbox_'.$type[type].'_'.$alt[secondary_resource_id].'_secondary']))
568 $sql_del = "DELETE FROM ".TABLE_PREFIX."secondary_resources_types WHERE secondary_resource_id='$control[secondary_resource_id]' and type_id='$control[type_id]'";
569 $result_del = mysql_query($sql_del, $db);
573 if (isset($_POST['checkbox_'.$type[type].'_'.$alt[secondary_resource_id].'_secondary'])){
574 $sql_ins = "INSERT INTO ".TABLE_PREFIX."secondary_resources_types VALUES ($alt[secondary_resource_id], $type[type_id])";
575 $ins = mysql_query($sql_ins, $db);
577 $lang = $_POST['lang_'.$alt[secondary_resource_id].'_secondary'];
578 $sql_up = "UPDATE ".TABLE_PREFIX."secondary_resources SET language_code='$lang' WHERE secondary_resource_id='$alt[secondary_resource_id]'";
579 $up = mysql_query($sql_up, $db);
582 $lang=$_POST['lang_'.$row[primary_resource_id].'_primary'];
583 $sql_up = "UPDATE ".TABLE_PREFIX."primary_resources SET language_code='$lang' WHERE primary_resource_id='$row[primary_resource_id]'";
584 $up = mysql_query($sql_up, $db);
598 //End Added by Silvia
600 //Extended Test within content functionality - Harris @Sep 9, 2008
601 //if ($current_tab == 6){
604 if (($current_tab == 0) || ($_current_tab == 5)) {
605 if (!isset($_REQUEST['setvisual']) && !isset($_REQUEST['settext'])) {
606 if ($_SESSION['prefs']['PREF_CONTENT_EDITOR'] == 1) {
607 $_POST['formatting'] = 1;
608 $_REQUEST['settext'] = 0;
609 $_REQUEST['setvisual'] = 0;
611 } else if ($_SESSION['prefs']['PREF_CONTENT_EDITOR'] == 2) {
612 $_POST['formatting'] = 1;
613 $_POST['settext'] = 0;
614 $_POST['setvisual'] = 1;
616 } else { // else if == 0
617 $_POST['formatting'] = 0;
618 $_REQUEST['settext'] = 0;
619 $_REQUEST['setvisual'] = 0;
622 if ((!$_POST['setvisual'] && $_POST['settext']) || !$_GET['setvisual']){
623 $onload = ' document.form.ctitle.focus(); ';
627 // initialize buttons, texts, radio buttons for editor
628 if ($current_tab == 0)
630 $onload.="on_load();";
633 if ($current_tab == 5)
635 $onload.="on_load();";
638 require(AT_INCLUDE_PATH.'header.inc.php');
640 if ($current_tab == 0)
642 load_editor(false, "none");
645 if ($current_tab == 5)
647 load_editor(false, "none");
650 $cid = intval($_REQUEST['cid']);
651 $pid = intval($_REQUEST['pid']);
654 <form action="<?php echo $_SERVER['PHP_SELF']; ?>?cid=<?php echo $cid; ?>" method="post" name="form" enctype="multipart/form-data">
658 //$content_row = sql_quote($content_row);
659 if (isset($_POST['current_tab'])) {
660 //$changes_made = check_for_changes($content_row);
662 $changes_made = array();
664 $_POST['formatting'] = $content_row['formatting'];
665 $_POST['head'] = $content_row['head'];
666 $_POST['use_customized_head'] = $content_row['use_customized_head'];
667 $_POST['title'] = $content_row['title'];
668 $_POST['body_text'] = $content_row['text'];
669 $_POST['keywords'] = $content_row['keywords'];
670 $_POST['test_message'] = $content_row['test_message'];
671 $_POST['allow_test_export'] = $content_row['allow_test_export'];
673 $_POST['day'] = substr($content_row['release_date'], 8, 2);
674 $_POST['month'] = substr($content_row['release_date'], 5, 2);
675 $_POST['year'] = substr($content_row['release_date'], 0, 4);
676 $_POST['hour'] = substr($content_row['release_date'], 11, 2);
677 $_POST['minute']= substr($content_row['release_date'], 14, 2);
679 $_POST['ordering'] = $_POST['new_ordering'] = $content_row['ordering'];
680 $_POST['related'] = $contentManager->getRelatedContent($cid);
682 $_POST['pid'] = $pid = $_POST['new_pid'] = $content_row['content_parent_id'];
684 $_POST['related_term'] = $glossary_ids_related;
689 if (!isset($_POST['current_tab'])) {
690 $_POST['day'] = date('d');
691 $_POST['month'] = date('m');
692 $_POST['year'] = date('Y');
693 $_POST['hour'] = date('H');
694 $_POST['minute'] = 0;
696 if (isset($_GET['pid'])) {
697 $pid = intval($_GET['pid']);
699 $_POST['new_pid'] = $pid;
700 $_POST['ordering'] = count($contentManager->getContent(0))+1;
701 $_POST['new_ordering'] = count($contentManager->getContent($pid))+1;
703 $_POST['pid'] = $_POST['new_pid'] = 0;
704 $_POST['ordering'] = $_POST['new_ordering'] = count($contentManager->getContent($pid))+1;
708 //$changes_made = check_for_changes($content_row);
710 // echo $alternatives;
711 // echo '<input type="hidden" name="alternatives" value="$alternatives" />';
712 echo '<input type="hidden" name="cid" value="'.$cid.'" />';
713 echo '<input type="hidden" name="title" value="'.htmlspecialchars($stripslashes($_POST['title'])).'" />';
714 echo '<input type="submit" name="submit" style="display:none;"/>';
715 if (($current_tab != 0) && (($_current_tab != 5))) {
716 echo '<input type="hidden" name="body_text" value="'.htmlspecialchars($stripslashes($_POST['body_text'])).'" />';
717 echo '<input type="hidden" name="head" value="'.htmlspecialchars($stripslashes($_POST['head'])).'" />';
718 echo '<input type="hidden" name="use_customized_head" value="'.(($_POST['use_customized_head']=="") ? 0 : $_POST['use_customized_head']).'" />';
719 echo '<input type="hidden" name="displayhead" value="'.$_POST['displayhead'].'" />';
720 echo '<input type="hidden" name="setvisual" value="'.$_POST['setvisual'].'" />';
721 echo '<input type="hidden" name="settext" value="'.$_POST['settext'].'" />';
722 echo '<input type="hidden" name="formatting" value="'.$_POST['formatting'].'" />';
724 if ($current_tab != 1) {
725 echo '<input type="hidden" name="new_ordering" value="'.$_POST['new_ordering'].'" />';
726 echo '<input type="hidden" name="new_pid" value="'.$_POST['new_pid'].'" />';
729 echo '<input type="hidden" name="ordering" value="'.$_POST['ordering'].'" />';
730 echo '<input type="hidden" name="pid" value="'.$pid.'" />';
732 echo '<input type="hidden" name="day" value="'.$_POST['day'].'" />';
733 echo '<input type="hidden" name="month" value="'.$_POST['month'].'" />';
734 echo '<input type="hidden" name="year" value="'.$_POST['year'].'" />';
735 echo '<input type="hidden" name="hour" value="'.$_POST['hour'].'" />';
736 echo '<input type="hidden" name="minute" value="'.$_POST['minute'].'" />';
738 echo '<input type="hidden" name="alternatives" value="'.$_POST['alternatives'].'" />';
740 echo '<input type="hidden" name="current_tab" value="'.$current_tab.'" />';
742 if (is_array($_POST['related']) && ($current_tab != 1)) {
743 foreach($_POST['related'] as $r_id) {
744 echo '<input type="hidden" name="related[]" value="'.$r_id.'" />';
748 echo '<input type="hidden" name="keywords" value="'.htmlspecialchars(stripslashes($_POST['keywords'])).'" />';
750 //content test association
751 echo '<input type="hidden" name="test_message" value="'.$_POST['test_message'].'" />';
753 /* get glossary terms */
754 $matches = find_terms(stripslashes($_POST['body_text']));
755 $num_terms = count($matches[0]);
756 $matches = $matches[0];
757 $word = str_replace(array('[?]', '[/?]'), '', $matches);
759 if (is_array($word)) {
760 /* update $_POST['glossary_defs'] with any new/changed terms */
761 for($i=0; $i<$num_terms; $i++) {
762 $word[$i] = urlencode($word[$i]);
763 if (!isset($_POST['glossary_defs'][$word[$i]])) {
764 $_POST['glossary_defs'][$word[$i]] = $glossary[$word[$i]];
769 if (is_array($_POST['glossary_defs']) && ($current_tab != 2)) {
770 foreach($_POST['glossary_defs'] as $w => $d) {
771 /* this term still exists in the content */
772 if (!in_array($w, $word)) {
773 unset($_POST['glossary_defs'][$w]);
776 echo '<input type="hidden" name="glossary_defs['.$w.']" value="'.htmlspecialchars(stripslashes($d)).'" />';
778 if (isset($_POST['related_term'])) {
779 foreach($_POST['related_term'] as $w => $d) {
780 echo '<input type="hidden" name="related_term['.$w.']" value="'.$d.'" />';
786 if (is_array($_POST['tid']) && $current_tab != 6){
787 /* Test & Survey --> Other tabs triggers this condition */
788 foreach ($_POST['tid'] as $i=>$tid){
789 echo '<input type="hidden" name="tid['.$i.']" value="'.$tid.'" />';
791 } elseif ($current_tab != 6){
792 /* Edit Content (On Edit content tab), without clicking Test & Survey */
795 while ($content_test_row = mysql_fetch_assoc($content_test)){
796 echo '<input type="hidden" name="tid['.$i++.']" value="'.$content_test_row['test_id'].'" />';
800 if (!isset($_POST['allow_test_export']) && $current_tab != 6) {
801 //export flag handling.
802 $sql = "SELECT `allow_test_export` FROM ".TABLE_PREFIX."content WHERE content_id=$_REQUEST[cid]";
803 $result2 = mysql_query($sql, $db);
805 $c_row = mysql_fetch_assoc($result2);
807 if (intval($c_row['allow_test_export'])==1){
808 echo '<input type="hidden" name="allow_test_export" value="1" />';
810 echo '<input type="hidden" name="allow_test_export" value="0" />';
813 echo '<input type="hidden" name="allow_test_export" value="'.intval($_POST['allow_test_export']).'" />';
817 $changes_made = check_for_changes($content_row);
822 <?php output_tabs($current_tab, $changes_made); ?>
824 <div class="input-form" style="width: 95%">
826 <?php if ($changes_made): ?>
827 <div class="unsaved">
828 <span style="color:red;"><?php echo _AT('save_changes_unsaved'); ?></span>
829 <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;" />
830 <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"'; } ?> />
831 <label for="close"><?php echo _AT('close_after_saving'); ?></label>
836 <?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>
840 // if ($current_tab != 5){
841 include(AT_INCLUDE_PATH.'html/editor_tabs/'.$tabs[$current_tab][1]);
842 echo '</div></form>';
846 // echo '</div></form>';
847 // include(AT_INCLUDE_PATH.'html/editor_tabs/'.$tabs[$current_tab][1]);
853 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>