AC_4897, AC_4898, AC_4899: Multifile uploader fixes.
[acontent.git] / docs / home / editor / accessibility.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 global $_course_id, $_content_id, $contentManager;
19
20 Utility::authenticate(TR_PRIV_ISAUTHOR);
21
22 $cid = $_content_id;
23
24 if ($cid == 0) {
25         require(TR_INCLUDE_PATH.'header.inc.php');
26         $msg->printInfos('NO_PAGE_CONTENT');
27         require (TR_INCLUDE_PATH.'footer.inc.php');
28         exit;
29 }
30
31 if (isset($contentManager)) $content_row = $contentManager->getContentPage($cid);
32
33 if (!$content_row || !isset($contentManager)) {
34         require(TR_INCLUDE_PATH.'header.inc.php');
35         $msg->printErrors('MISSING_CONTENT');
36         require (TR_INCLUDE_PATH.'footer.inc.php');
37         exit;
38 }
39
40 $course_base_href = '';
41 $content_base_href = '';
42
43 //make decisions
44 if ($_POST['make_decision']) 
45 {
46         //get list of decisions 
47         $desc_query = '';
48         if (is_array($_POST['d'])) {
49                 foreach ($_POST['d'] as $sequenceID => $decision) {
50                         $desc_query .= '&'.$sequenceID.'='.$decision;
51                 }
52         }
53
54         $checker_url = TR_ACHECKER_URL. 'decisions.php?'
55                                 .'uri='.urlencode($_POST['pg_url']).'&id='.TR_ACHECKER_WEB_SERVICE_ID
56                                 .'&session='.$_POST['sessionid'].'&output=html'.$desc_query;
57
58         if (@file_get_contents($checker_url) === false) {
59                 $msg->addInfo('DECISION_NOT_SAVED');
60         }
61
62 else if (isset($_POST['reverse'])) 
63 {
64         $reverse_url = TR_ACHECKER_URL. 'decisions.php?'
65                                 .'uri='.urlencode($_POST['pg_url']).'&id='.TR_ACHECKER_WEB_SERVICE_ID
66                                 .'&session='.$_POST['sessionid'].'&output=html&reverse=true&'.key($_POST['reverse']).'=N';
67         
68         if (@file_get_contents($reverse_url) === false) {
69                 $msg->addInfo('DECISION_NOT_REVERSED');
70         } else {
71                 $msg->addInfo('DECISION_REVERSED');
72         }
73 }
74
75 $popup = intval($_GET['popup']);
76 require(TR_INCLUDE_PATH.'header.inc.php');
77 ?>
78 <form action="<?php echo $_SERVER['PHP_SELF']; ?>?popup=1" method="post" name="form">
79   <div class="row">
80 <?php                                   
81         echo '    <input type="hidden" name="body_text" value="'.htmlspecialchars(stripslashes($_POST['body_text'])).'" />';
82         echo '    <input type="hidden" name="_cid" value="'.$cid.'" />';
83         
84         if (!$cid) {
85                 $msg->printInfos('SAVE_CONTENT');
86
87                 echo '  </div>';
88
89                 return;
90         }
91
92 $msg->printInfos();
93 if ($_POST['body_text'] != '') {
94         //save temp file
95         $_POST['content_path'] = $content_row['content_path'];
96         write_temp_file();
97
98         $pg_url = TR_BASE_HREF.'get_acheck.php/'.$cid . '.html';
99         $checker_url = TR_ACHECKER_URL.'checkacc.php?uri='.urlencode($pg_url).'&id='.TR_ACHECKER_WEB_SERVICE_ID
100                                         . '&guide=WCAG2-L2&output=html';
101
102         $report = @file_get_contents($checker_url);
103
104         if (stristr($report, '<div id="error">')) {
105                 $msg->printErrors('INVALID_URL');
106         } else if ($report === false) {
107                 $msg->printInfos('SERVICE_UNAVAILABLE');
108         } else {
109                 echo '    <input type="hidden" name="pg_url" value="'.$pg_url.'" />';
110                 echo $report;   
111
112                 echo '    <p>'._AT('access_credit').'</p>';
113         }
114         //delete file
115         @unlink(TR_CONTENT_DIR . $cid . '.html');
116
117 } else {
118         $msg->printInfos('NO_PAGE_CONTENT');
119
120 ?>
121   </div>
122 </form>
123 <?php 
124 require(TR_INCLUDE_PATH.'footer.inc.php');
125 ?>