Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 require_once './Services/XHTMLValidator/validator/config.inc';
00026 $GLOBALS["opts"] = $opts;
00027
00028
00029 require_once './Services/XHTMLValidator/validator/Text_Diff/Diff.php';
00030 require_once './Services/XHTMLValidator/validator/Text_Diff/Renderer.php';
00031 require_once './Services/XHTMLValidator/validator/Text_Diff/unified.php';
00032
00033 require_once './Services/XHTMLValidator/validator/include.inc';
00034 require_once './Services/XHTMLValidator/validator/validator.inc';
00035
00036
00046 class ilValidatorAdapter
00047 {
00048
00049 function validate($a_html, $a_mode)
00050 {
00051
00052 if (!defined('UPLOAD_ERR_CANT_WRITE'))
00053 define('UPLOAD_ERR_CANT_WRITE', 7);
00054
00055
00056
00057
00058
00059
00060 define('MOZILLA', (isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'Mozilla/') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Gecko/') !== false));
00061
00062
00063
00064
00065
00066
00067 if (empty($lang)) {
00068 $lang = isset($_REQUEST['lang']) ? $_REQUEST['lang'] : 'en';
00069 } else {
00070 $redir = true;
00071 }
00072
00073
00074
00075
00076
00077
00078
00079
00080 require './Services/XHTMLValidator/validator/local/en.inc';
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091 $options = array();
00092 $options["charset"] = "utf8";
00093 if ($a_mode == "accessibility")
00094 {
00095 $options["accessibility-check"] = 3;
00096 }
00097
00098 $validator = new validator($options);
00099
00100
00101 $result = $validator->parse_string($a_html);
00102
00103
00104 if ($result){
00105
00106 if ($validator->internal_error()) {
00107 $answer.= "<p>$message[13]:<br />\n";
00108 $answer.= nl2br($validator->internal_errors_string()) . "</p>\n";
00109 }
00110
00111 $answer.= '<p>';
00112
00113
00114
00115 if ($detected_version = $validator->detected_version()) {
00116 $answer.= "<strong>$message[14]</strong>: $detected_version<br />\n";
00117 }
00118
00119
00120 $answer.= "<strong>$message[20]</strong>: {$validator->readable_charset()}";
00121
00122
00123 if ($validator->lang)
00124 $answer.= "<br />\n<strong>$message[24]</strong>: {$langs[$validator->lang]}";
00125
00126
00127
00128 if ($errors = $validator->error()) {
00129
00130 $answer.= "<br />\n<strong>$message[21]</strong>: $errors</p>\n".
00131 "<h2>$message[16]</h2>\n";
00132
00133 if (empty($_REQUEST['errors']) || $_REQUEST['errors'] == 'along') {
00134 $answer.= '<code>' . $validator->errors_source() . "</code>\n\n";
00135
00136 } else {
00137 $answer.= '<p>' . $validator->errors_string() . "</p>\n\n";
00138 }
00139
00140
00141 } else {
00142 $answer.= "</p><p>$message[15]</p>\n";
00143 }
00144
00145
00146
00147 if (!isset($_REQUEST['repair']) || $_REQUEST['repair'] == 'full') {
00148 $html = strtr(nl2br(htmlspecialchars($validator->repaired_source(), ENT_QUOTES, 'UTF-8')), array(' ' => ' '));
00149
00150 $answer.= "\n<p> </p>\n<h2>$message[17]</h2>\n";
00151 $answer.= '<div class="code"><code>' . $html . "</code></div>\n";
00152 }
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165 } else {
00166 $answer.= "<p>$message[13]:<br />\n";
00167 $answer.= nl2br($validator->internal_errors_string()) . "</p>\n";
00168 }
00169
00170 return $answer;
00171 }
00172 }
00173 ?>