remove old readme
[atutor.git] / docs / mods / _core / editor / accessibility.php
1 <?php
2 /************************************************************************/
3 /* ATutor                                                                                                                               */
4 /************************************************************************/
5 /* Copyright (c) 2002-2010                                              */
6 /* Inclusive Design Institute                                           */
7 /* http://atutor.ca                                                     */
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 // $Id$
13
14 define('AT_INCLUDE_PATH', '../../../include/');
15
16 require(AT_INCLUDE_PATH.'vitals.inc.php');
17 require(AT_INCLUDE_PATH.'../mods/_core/editor/editor_tab_functions.inc.php');
18
19 $cid = intval($_POST['cid']);
20
21 if ($cid == 0) {
22         require(AT_INCLUDE_PATH.'header.inc.php');
23         $missing_fields[] = _AT('content_id');
24         $msg->addError(array('EMPTY_FIELDS', $missing_fields));
25         require (AT_INCLUDE_PATH.'footer.inc.php');
26         exit;
27 }
28
29 $result = $contentManager->getContentPage($cid);
30
31 if (!($content_row = @mysql_fetch_assoc($result))) {
32         require(AT_INCLUDE_PATH.'header.inc.php');
33         $msg->printErrors('PAGE_NOT_FOUND');
34         require (AT_INCLUDE_PATH.'footer.inc.php');
35         exit;
36 }
37
38 $course_base_href = '';
39 $content_base_href = '';
40
41 //make decisions
42 if ($_POST['make_decision']) 
43 {
44         //get list of decisions 
45         $desc_query = '';
46         if (is_array($_POST['d'])) {
47                 foreach ($_POST['d'] as $sequenceID => $decision) {
48                         $desc_query .= '&'.$sequenceID.'='.$decision;
49                 }
50         }
51
52         $checker_url = AT_ACHECKER_URL. 'decisions.php?'
53                                 .'uri='.urlencode($_POST['pg_url']).'&id='.AT_ACHECKER_WEB_SERVICE_ID
54                                 .'&session='.$_POST['sessionid'].'&output=html'.$desc_query;
55
56         if (@file_get_contents($checker_url) === false) {
57                 $msg->addInfo('DECISION_NOT_SAVED');
58         }
59
60 else if (isset($_POST['reverse'])) 
61 {
62         $reverse_url = AT_ACHECKER_URL. 'decisions.php?'
63                                 .'uri='.urlencode($_POST['pg_url']).'&id='.AT_ACHECKER_WEB_SERVICE_ID
64                                 .'&session='.$_POST['sessionid'].'&output=html&reverse=true&'.key($_POST['reverse']).'=N';
65         
66         if (@file_get_contents($reverse_url) === false) {
67                 $msg->addInfo('DECISION_NOT_REVERSED');
68         } else {
69                 $msg->addInfo('DECISION_REVERSED');
70         }
71 }
72
73 require(AT_INCLUDE_PATH.'header.inc.php');
74 ?>
75 <form action="<?php echo $_SERVER['PHP_SELF']; ?>?popup=1" method="post" name="form">
76   <div class="row">
77 <?php                                   
78         echo '    <input type="hidden" name="body_text" value="'.htmlspecialchars(stripslashes($_POST['body_text'])).'" />';
79         echo '    <input type="hidden" name="cid" value="'.$_POST['cid'].'" />';
80         
81         if (!$cid) {
82                 $msg->printInfos('SAVE_CONTENT');
83
84                 echo '  </div>';
85
86                 return;
87         }
88
89 $msg->printInfos();
90 if ($_POST['body_text'] != '') {
91         //save temp file
92         $_POST['content_path'] = $content_row['content_path'];
93         write_temp_file();
94
95         $pg_url = AT_BASE_HREF.'get_acheck.php/'.$_POST['cid'] . '.html';
96         $checker_url = AT_ACHECKER_URL.'checkacc.php?uri='.urlencode($pg_url).'&id='.AT_ACHECKER_WEB_SERVICE_ID
97                                         . '&guide=WCAG2-L2&output=html';
98
99         $report = @file_get_contents($checker_url);
100
101         if (stristr($report, '<div id="error">')) {
102                 $msg->printErrors('INVALID_URL');
103         } else if ($report === false) {
104                 $msg->printInfos('SERVICE_UNAVAILABLE');
105         } else {
106                 echo '    <input type="hidden" name="pg_url" value="'.$pg_url.'" />';
107                 echo $report;   
108
109                 echo '    <p>'._AT('access_credit').'</p>';
110         }
111         //delete file
112         @unlink(AT_CONTENT_DIR . $_POST['cid'] . '.html');
113
114 } else {
115         $msg->printInfos('NO_PAGE_CONTENT');
116
117 ?>
118   </div>
119 </form>
120 <?php 
121 require(AT_INCLUDE_PATH.'footer.inc.php');
122 ?>