| [ PHPXref.com ] | [ Generated: Sun Jul 20 16:32:03 2008 ] | [ ATutor 1.5.2 ] |
| [ Index ] [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
1 <?php 2 /************************************************************************/ 3 /* ATutor */ 4 /************************************************************************/ 5 /* Copyright (c) 2002-2006 by Greg Gay, Joel Kronenberg & Heidi Hazelton*/ 6 /* Adaptive Technology Resource Centre / University of Toronto */ 7 /* http://atutor.ca */ 8 /* */ 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 /************************************************************************/ 13 // $Id: edit_content.php 5866 2005-12-15 16:16:03Z joel $ 14 15 define('AT_INCLUDE_PATH', '../include/'); 16 17 $get_related_glossary = true; 18 require(AT_INCLUDE_PATH.'vitals.inc.php'); 19 require(AT_INCLUDE_PATH.'lib/tinymce.inc.php'); 20 21 $cid = intval($_REQUEST['cid']); 22 23 if ($_POST) { 24 $do_check = TRUE; 25 } else { 26 $do_check = FALSE; 27 } 28 29 require(AT_INCLUDE_PATH.'lib/editor_tab_functions.inc.php'); 30 31 32 33 if ($_POST['close'] || $_GET['close']) { 34 if ($_GET['close']) { 35 $msg->addFeedback('CONTENT_UPDATED'); 36 } else { 37 $msg->addFeedback('CLOSED'); 38 if ($cid == 0) { 39 header('Location: '.$_base_href.'tools/content/index.php'); 40 exit; 41 } 42 } 43 44 if ($_REQUEST['cid'] == 0) { 45 header('Location: '.$_base_path.'content.php?cid='.intval($_REQUEST['new_pid'])); 46 exit; 47 } 48 header('Location: '.$_base_path.'content.php?cid='.intval($_REQUEST['cid'])); 49 exit; 50 } 51 52 $tabs = get_tabs(); 53 $num_tabs = count($tabs); 54 for ($i=0; $i < $num_tabs; $i++) { 55 if (isset($_POST['button_'.$i]) && ($_POST['button_'.$i] != -1)) { 56 $current_tab = $i; 57 $_POST['current_tab'] = $i; 58 break; 59 } 60 } 61 62 if (isset($_POST['submit_file'])) { 63 paste_from_file(); 64 } else if (isset($_POST['submit']) && ($_POST['submit'] != 'submit1')) { 65 /* we're saving. redirects if successful. */ 66 save_changes(true); 67 } 68 if (isset($_GET['tab'])) { 69 $current_tab = intval($_GET['tab']); 70 } 71 72 if (!isset($current_tab) && isset($_POST['button_1']) && ($_POST['button_1'] == -1) && !isset($_POST['submit'])) { 73 $current_tab = 1; 74 } else if (!isset($current_tab) && (($_POST['desc_submit'] != '') || ($_POST['reverse'] != ''))) { 75 $current_tab = 4; /* after clicking 'make decisions' on accessibility tab */ 76 } else if (!isset($current_tab)) { 77 $current_tab = 0; 78 } 79 80 if ($cid) { 81 $_section[0][0] = _AT('edit_content'); 82 } else { 83 $_section[0][0] = _AT('add_content'); 84 } 85 86 if ($cid) { 87 $result = $contentManager->getContentPage($cid); 88 89 if (!($content_row = @mysql_fetch_assoc($result))) { 90 require (AT_INCLUDE_PATH.'header.inc.php'); 91 $msg->printErrors('PAGE_NOT_FOUND'); 92 require (AT_INCLUDE_PATH.'footer.inc.php'); 93 exit; 94 } 95 96 $path = $contentManager->getContentPath($cid); 97 98 if (defined('AT_FORCE_GET_FILE') && AT_FORCE_GET_FILE) { 99 $course_base_href = 'get.php/'; 100 } else { 101 $course_base_href = 'content/' . $_SESSION['course_id'] . '/'; 102 } 103 104 if ($content_row['content_path']) { 105 $content_base_href .= $content_row['content_path'].'/'; 106 } 107 } else { 108 if (defined('AT_FORCE_GET_FILE') && AT_FORCE_GET_FILE) { 109 $content_base_href = 'get.php/'; 110 } else { 111 $content_base_href = 'content/' . $_SESSION['course_id'] . '/'; 112 } 113 } 114 115 if ($current_tab == 4) { 116 /* kludge for issue #1626: */ 117 /* fixes the base href for the AChecker tab. */ 118 $course_base_href = ''; 119 $content_base_href = ''; 120 } 121 122 if ($current_tab == 0) { 123 if ((!$_POST['setvisual'] && $_POST['settext']) || !$_GET['setvisual']){ 124 $onload = ' document.form.ctitle.focus();'; 125 } 126 } 127 128 require (AT_INCLUDE_PATH.'header.inc.php'); 129 130 if ($current_tab == 0) { 131 //used for visual editor 132 if (($_POST['setvisual'] && !$_POST['settext']) || $_GET['setvisual']){ 133 load_editor(); 134 } 135 } 136 137 $cid = intval($_REQUEST['cid']); 138 $pid = intval($_REQUEST['pid']); 139 140 ?> 141 <form action="<?php echo $_SERVER['PHP_SELF']; ?>?cid=<?php echo $cid; ?>" method="post" name="form" enctype="multipart/form-data"> 142 <?php 143 144 if ($cid) { 145 //$content_row = sql_quote($content_row); 146 if (isset($_POST['current_tab'])) { 147 //$changes_made = check_for_changes($content_row); 148 } else { 149 $changes_made = array(); 150 151 $_POST['formatting'] = $content_row['formatting']; 152 $_POST['title'] = $content_row['title']; 153 $_POST['body_text'] = $content_row['text']; 154 $_POST['keywords'] = $content_row['keywords']; 155 156 $_POST['day'] = substr($content_row['release_date'], 8, 2); 157 $_POST['month'] = substr($content_row['release_date'], 5, 2); 158 $_POST['year'] = substr($content_row['release_date'], 0, 4); 159 $_POST['hour'] = substr($content_row['release_date'], 11, 2); 160 $_POST['minute']= substr($content_row['release_date'], 14, 2); 161 162 $_POST['ordering'] = $_POST['new_ordering'] = $content_row['ordering']; 163 $_POST['related'] = $contentManager->getRelatedContent($cid); 164 165 $_POST['pid'] = $pid = $_POST['new_pid'] = $content_row['content_parent_id']; 166 167 $_POST['related_term'] = $glossary_ids_related; 168 } 169 } else { 170 $cid = 0; 171 if (!isset($_POST['current_tab'])) { 172 $_POST['day'] = date('d'); 173 $_POST['month'] = date('m'); 174 $_POST['year'] = date('Y'); 175 $_POST['hour'] = date('H'); 176 $_POST['minute'] = 0; 177 178 if (isset($_GET['pid'])) { 179 $pid = intval($_GET['pid']); 180 $_POST['pid'] = 0; 181 $_POST['new_pid'] = $pid; 182 $_POST['ordering'] = count($contentManager->getContent(0))+1; 183 $_POST['new_ordering'] = count($contentManager->getContent($pid))+1; 184 } else { 185 $_POST['pid'] = $_POST['new_pid'] = 0; 186 $_POST['ordering'] = $_POST['new_ordering'] = count($contentManager->getContent($pid))+1; 187 } 188 $pid = 0; 189 } 190 //$changes_made = check_for_changes($content_row); 191 } 192 193 194 echo '<input type="hidden" name="cid" value="'.$cid.'" />'; 195 echo '<input type="hidden" name="title" value="'.htmlspecialchars(stripslashes($_POST['title'])).'" />'; 196 if ($current_tab != 0) { 197 echo '<input type="hidden" name="body_text" value="'.htmlspecialchars(stripslashes($_POST['body_text'])).'" />'; 198 echo '<input type="hidden" name="setvisual" value="'.$_POST['setvisual'].'" />'; 199 echo '<input type="hidden" name="settext" value="'.$_POST['settext'].'" />'; 200 echo '<input type="hidden" name="formatting" value="'.$_POST['formatting'].'" />'; 201 } 202 if ($current_tab != 1) { 203 echo '<input type="hidden" name="new_ordering" value="'.$_POST['new_ordering'].'" />'; 204 echo '<input type="hidden" name="new_pid" value="'.$_POST['new_pid'].'" />'; 205 } 206 207 echo '<input type="hidden" name="ordering" value="'.$_POST['ordering'].'" />'; 208 echo '<input type="hidden" name="pid" value="'.$pid.'" />'; 209 210 echo '<input type="hidden" name="day" value="'.$_POST['day'].'" />'; 211 echo '<input type="hidden" name="month" value="'.$_POST['month'].'" />'; 212 echo '<input type="hidden" name="year" value="'.$_POST['year'].'" />'; 213 echo '<input type="hidden" name="hour" value="'.$_POST['hour'].'" />'; 214 echo '<input type="hidden" name="minute" value="'.$_POST['minute'].'" />'; 215 216 echo '<input type="hidden" name="current_tab" value="'.$current_tab.'" />'; 217 218 if (is_array($_POST['related']) && ($current_tab != 1)) { 219 foreach($_POST['related'] as $r_id) { 220 echo '<input type="hidden" name="related[]" value="'.$r_id.'" />'; 221 } 222 } 223 224 echo '<input type="hidden" name="keywords" value="'.htmlspecialchars(stripslashes($_POST['keywords'])).'" />'; 225 226 /* get glossary terms */ 227 $matches = find_terms(stripslashes($_POST['body_text'])); 228 $num_terms = count($matches[0]); 229 $matches = $matches[0]; 230 $word = str_replace(array('[?]', '[/?]'), '', $matches); 231 232 if (is_array($word)) { 233 /* update $_POST['glossary_defs'] with any new/changed terms */ 234 for($i=0; $i<$num_terms; $i++) { 235 $word[$i] = urlencode($word[$i]); 236 if (!isset($_POST['glossary_defs'][$word[$i]])) { 237 $_POST['glossary_defs'][$word[$i]] = $glossary[$word[$i]]; 238 } 239 } 240 } 241 242 if (is_array($_POST['glossary_defs']) && ($current_tab != 2)) { 243 foreach($_POST['glossary_defs'] as $w => $d) { 244 /* this term still exists in the content */ 245 if (!in_array($w, $word)) { 246 unset($_POST['glossary_defs'][$w]); 247 continue; 248 } 249 echo '<input type="hidden" name="glossary_defs['.$w.']" value="'.htmlspecialchars(stripslashes($d)).'" />'; 250 } 251 if (isset($_POST['related_term'])) { 252 foreach($_POST['related_term'] as $w => $d) { 253 echo '<input type="hidden" name="related_term['.$w.']" value="'.$d.'" />'; 254 } 255 } 256 } 257 258 if ($do_check) { 259 $changes_made = check_for_changes($content_row); 260 } 261 262 ?> 263 <div align="center"> 264 <?php output_tabs($current_tab, $changes_made); ?> 265 </div> 266 <div class="input-form" style="width: 95%"> 267 268 <?php if ($changes_made): ?> 269 <div class="unsaved"> 270 <span style="color:red;"><?php echo _AT('save_changes_unsaved'); ?></span> 271 <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;" /> 272 <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"'; } ?> /> 273 <label for="close"><?php echo _AT('close_after_saving'); ?></label> 274 </div> 275 276 <?php else: ?> 277 <div class="saved"> 278 <?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> 279 </div> 280 <?php endif; ?> 281 282 <?php include(AT_INCLUDE_PATH.'html/editor_tabs/'.$tabs[$current_tab][1]); ?> 283 284 </div> 285 </form> 286 287 <?php require (AT_INCLUDE_PATH.'footer.inc.php'); ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| [ Powered by PHPXref - Served by Debian GNU/Linux ] |