AC_4897, AC_4898, AC_4899: Multifile uploader fixes.
[acontent.git] / home / editor / preview.php
1 <?php
2 /************************************************************************/
3 /* AContent                                                             */
4 /************************************************************************/
5 /* Copyright (c) 2010                                                   */
6 /* Inclusive Design Institute                                           */
7 /*                                                                      */
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 /************************************************************************/
12
13 define('TR_INCLUDE_PATH', '../../include/');
14
15 require(TR_INCLUDE_PATH.'vitals.inc.php');
16 require(TR_INCLUDE_PATH.'../home/editor/editor_tab_functions.inc.php');
17
18 // commented out this require which was causing the a redeclare error #4846
19 // delete the following line when its confirmed the require is not needed
20 // require(TR_INCLUDE_PATH.'../home/classes/ContentUtility.class.php');
21
22 global $_course_id, $_content_id, $contentManager;
23
24 Utility::authenticate(TR_PRIV_ISAUTHOR);
25
26 $cid = $_content_id;
27
28 if ($cid == 0) {
29         require(TR_INCLUDE_PATH.'header.inc.php');
30         $msg->printInfos('NO_PAGE_CONTENT');
31         require (TR_INCLUDE_PATH.'footer.inc.php');
32         exit;
33 }
34
35 if (isset($contentManager)) $content_row = $contentManager->getContentPage($cid);
36
37 if (!$content_row || !isset($contentManager)) {
38         require(TR_INCLUDE_PATH.'header.inc.php');
39         $msg->printErrors('MISSING_CONTENT');
40         require (TR_INCLUDE_PATH.'footer.inc.php');
41         exit;
42 }
43
44 if (defined('TR_FORCE_GET_FILE') && TR_FORCE_GET_FILE) {
45         $course_base_href = 'get.php/';
46 } else {
47         $course_base_href = 'content/' . $_course_id . '/';
48 }
49
50 if ($content_row['content_path']) {
51         $content_base_href .= $content_row['content_path'].'/';
52 }
53
54 $popup = intval($_GET['popup']);
55 require(TR_INCLUDE_PATH.'header.inc.php');
56 ?>
57         <div class="row">
58         <?php 
59                 echo '<h2>'.AT_print($stripslashes($_POST['title']), 'content.title').'</h2>';
60                 if ($_POST['formatting'] == CONTENT_TYPE_WEBLINK) {
61                     $url = $_POST['weblink_text'];
62             $validated_url = isValidURL($url);
63             if (!validated_url || $validated_url !== $url) {
64                 $msg->addError(array('INVALID_INPUT', _AT('weblink')));
65                 $msg->printErrors();
66             } else {
67                   echo ContentUtility::formatContent($url, $_POST['formatting']);
68             }
69         } else {
70             echo ContentUtility::formatContent($stripslashes($_POST['body_text']), $_POST['formatting']);
71         }
72     ?>          
73         </div>
74 <?php 
75 require(TR_INCLUDE_PATH.'footer.inc.php');
76 ?>