ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilValidatorAdapter Class Reference

Adapter Class for XHTML Validator. More...

+ Collaboration diagram for ilValidatorAdapter:

Static Public Member Functions

static validate ($a_html, $a_mode)
 

Detailed Description

Adapter Class for XHTML Validator.

This service is used in developer mode to validate the current screen against XHTML and Accessibility standards. In developer mode a corresponding link will appear in the footer of the page.

/

Definition at line 26 of file class.ilValidatorAdapter.php.

Member Function Documentation

◆ validate()

static ilValidatorAdapter::validate (   $a_html,
  $a_mode 
)
static

Definition at line 29 of file class.ilValidatorAdapter.php.

References $_SERVER, $errors, $html, $lang, $options, $result, array, and defined.

Referenced by ilTemplate\addILIASFooter().

30  {
31  // while php 5.1 isn't released we must keep compatibility with php 5.0
32  if (!defined('UPLOAD_ERR_CANT_WRITE'))
33  define('UPLOAD_ERR_CANT_WRITE', 7);
34 
35  /*
36  Mozilla, Firefox and friends have an error that lock radio buttons.
37  We use this to disable some feature for these browsers
38  More info at: http://bugzilla.mozilla.org/show_bug.cgi?id=229925
39  */
40  define('MOZILLA', (isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'Mozilla/') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Gecko/') !== false));
41 
42  //function mozilla($txt) {
43  // return MOZILLA ? '' : $txt;
44  //}
45 
46 
47  if (empty($lang)) {
48  $lang = isset($_REQUEST['lang']) ? $_REQUEST['lang'] : 'en';
49  } else {
50  $redir = true;
51  }
52 
53  /*
54  if (empty($_COOKIE['lang']) || $lang != $_COOKIE['lang']) {
55  setcookie('lang', $lang, time()+60*60*24*90, '/', 'validator.aborla.net');
56  }*/
57 
58  //output_add_rewrite_var('lang', $lang);
59 
60  require './Services/XHTMLValidator/validator/local/en.inc'; // fallback for not translated messages
61 
62  //if ($lang != 'en')
63  // require "./local/$lang.inc"; //load localized messages
64 
65  //common_header();
66 
67 
68  /****************** START OF THE VALIDATOR ITSELF *******************/
69 
70  // output: html/xhtml/xml, accessibility-check: 0-3
71  $options = array();
72  $options["charset"] = "utf8";
73  if ($a_mode == "accessibility")
74  {
75  $options["accessibility-check"] = 3;
76  }
77 
78  $validator = new validator($options);
79 
80  //$result = $validator->parse_url((string)$_REQUEST['url']);
81  $result = $validator->parse_string($a_html);
82 
83  /* no fatal errors. continue */
84  if ($result){
85 
86  if ($validator->internal_error()) {
87  $answer.= "<p>$message[13]:<br />\n";
88  $answer.= nl2br($validator->internal_errors_string()) . "</p>\n";
89  }
90 
91  $answer.= '<p>';
92 
93 
94  /* If the document contains too many errors, the version may not be found */
95  if ($detected_version = $validator->detected_version()) {
96  $answer.= "<strong>$message[14]</strong>: $detected_version<br />\n";
97  }
98 
99  // enconding in use
100  $answer.= "<strong>$message[20]</strong>: {$validator->readable_charset()}";
101 
102  // language
103  if ($validator->lang)
104  $answer.= "<br />\n<strong>$message[24]</strong>: {$langs[$validator->lang]}";
105 
106 
107  /* Show HTML/XML errors */
108  if ($errors = $validator->error()) {
109 
110  $answer.= "<br />\n<strong>$message[21]</strong>: $errors</p>\n".
111  "<h2>$message[16]</h2>\n";
112 
113  if (empty($_REQUEST['errors']) || $_REQUEST['errors'] == 'along') {
114  $answer.= '<code>' . $validator->errors_source() . "</code>\n\n";
115 
116  } else { //errors alone
117  $answer.= '<p>' . $validator->errors_string() . "</p>\n\n";
118  }
119 
120  /* no errors found in the document */
121  } else {
122  $answer.= "</p><p>$message[15]</p>\n";
123  }
124 
125 
126  /* show repaired document */
127  if (!isset($_REQUEST['repair']) || $_REQUEST['repair'] == 'full') {
128  $html = strtr(nl2br(htmlspecialchars($validator->repaired_source(), ENT_QUOTES, 'UTF-8')), array(' ' => ' &nbsp;'));
129 
130  $answer.= "\n<p>&nbsp;</p>\n<h2>$message[17]</h2>\n";
131  $answer.= '<div class="code"><code>' . $html . "</code></div>\n";
132  }
133  /* Diff */
134  /*
135  } elseif ($_REQUEST['repair'] == 'diff' && $diff = $validator->repaired_diff()) {
136  $diff = strtr($diff, array(' ' => ' &nbsp;'));
137 
138  echo "\n<p>&nbsp;</p>\n<h2>$message[11]</h2>\n";
139  echo '<div class="code"><code>' . $diff . "</code></div>\n";
140  }
141  */
142 
143 
144  /* there was some error handling the URL/file upload */
145  } else {
146  $answer.= "<p>$message[13]:<br />\n";
147  $answer.= nl2br($validator->internal_errors_string()) . "</p>\n";
148  }
149 
150  return $answer;
151  }
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
$result
if(!is_array($argv)) $options
Create styles array
The data for the language used.
$errors
for($i=1; $i<=count($kw_cases_sel); $i+=1) $lang
Definition: langwiz.php:349
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
Definition: bootstrap.php:27
$html
Definition: example_001.php:87
+ Here is the caller graph for this function:

The documentation for this class was generated from the following file: