move code up one directory
[atutor.git] / mods / _core / editor / preview.php
1 <?php
2 /****************************************************************/
3 /* ATutor                                                                                                               */
4 /****************************************************************/
5 /* Copyright (c) 2002-2010                                      */
6 /* Inclusive Design Institute                                   */
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$
14
15 define('AT_INCLUDE_PATH', '../../../include/');
16
17 require(AT_INCLUDE_PATH.'vitals.inc.php');
18 require(AT_INCLUDE_PATH.'../mods/_core/editor/editor_tab_functions.inc.php');
19
20 $cid = intval($_POST['cid']);
21
22 if ($cid == 0) {
23         require(AT_INCLUDE_PATH.'header.inc.php');
24         $missing_fields[] = _AT('content_id');
25         $msg->addError(array('EMPTY_FIELDS', $missing_fields));
26         require (AT_INCLUDE_PATH.'footer.inc.php');
27         exit;
28 }
29
30 $result = $contentManager->getContentPage($cid);
31
32 if (!($content_row = @mysql_fetch_assoc($result))) {
33         require(AT_INCLUDE_PATH.'header.inc.php');
34         $msg->printErrors('PAGE_NOT_FOUND');
35         require (AT_INCLUDE_PATH.'footer.inc.php');
36         exit;
37 }
38
39 if (defined('AT_FORCE_GET_FILE') && AT_FORCE_GET_FILE) {
40         $course_base_href = 'get.php/';
41 } else {
42         $course_base_href = 'content/' . $_SESSION['course_id'] . '/';
43 }
44
45 if ($content_row['content_path']) {
46         $content_base_href .= $content_row['content_path'].'/';
47 }
48
49 require(AT_INCLUDE_PATH.'header.inc.php');
50
51 ?>
52         <div class="row">
53         <?php 
54                 echo '<h2>'.AT_print($stripslashes($_POST['title']), 'content.title').'</h2>';
55                 if ($_POST['formatting'] == CONTENT_TYPE_WEBLINK) {
56                     $url = $_POST['weblink_text'];
57             $validated_url = isValidURL($url);
58             if (!validated_url || $validated_url !== $url) {
59                 $msg->addError(array('INVALID_INPUT', _AT('weblink')));
60                 $msg->printErrors();
61             } else {
62                   echo format_content($url, $_POST['formatting'], array());
63             }
64         } else {
65             echo format_content($stripslashes($_POST['body_text']), $_POST['formatting'], $_POST['glossary_defs']);
66         }
67     ?>          
68         </div>
69 <?php 
70 require(AT_INCLUDE_PATH.'footer.inc.php');
71 ?>