b195c66d9daf5ad97e892eebad2cda4241feaadf
[acontent.git] / docs / 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 require(TR_INCLUDE_PATH.'../home/classes/ContentUtility.class.php');
18
19 global $_course_id, $_content_id, $contentManager;
20
21 Utility::authenticate(TR_PRIV_ISAUTHOR);
22
23 $cid = $_content_id;
24
25 if ($cid == 0) {
26         require(TR_INCLUDE_PATH.'header.inc.php');
27         $msg->printInfos('NO_PAGE_CONTENT');
28         require (TR_INCLUDE_PATH.'footer.inc.php');
29         exit;
30 }
31
32 if (isset($contentManager)) $content_row = $contentManager->getContentPage($cid);
33
34 if (!$content_row || !isset($contentManager)) {
35         require(TR_INCLUDE_PATH.'header.inc.php');
36         $msg->printErrors('MISSING_CONTENT');
37         require (TR_INCLUDE_PATH.'footer.inc.php');
38         exit;
39 }
40
41 if (defined('TR_FORCE_GET_FILE') && TR_FORCE_GET_FILE) {
42         $course_base_href = 'get.php/';
43 } else {
44         $course_base_href = 'content/' . $_course_id . '/';
45 }
46
47 if ($content_row['content_path']) {
48         $content_base_href .= $content_row['content_path'].'/';
49 }
50
51 $popup = intval($_GET['popup']);
52 require(TR_INCLUDE_PATH.'header.inc.php');
53 ?>
54         <div class="row">
55         <?php 
56                 echo '<h2>'.AT_print($stripslashes($_POST['title']), 'content.title').'</h2>';
57                 if ($_POST['formatting'] == CONTENT_TYPE_WEBLINK) {
58                     $url = $_POST['weblink_text'];
59             $validated_url = isValidURL($url);
60             if (!validated_url || $validated_url !== $url) {
61                 $msg->addError(array('INVALID_INPUT', _AT('weblink')));
62                 $msg->printErrors();
63             } else {
64                   echo ContentUtility::formatContent($url, $_POST['formatting']);
65             }
66         } else {
67             echo ContentUtility::formatContent($stripslashes($_POST['body_text']), $_POST['formatting']);
68         }
69     ?>          
70         </div>
71 <?php 
72 require(TR_INCLUDE_PATH.'footer.inc.php');
73 ?>