Update of /cvsroot/php-blog/serendipity/plugins/serendipity_event_htmlvalidator
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9112/plugins/serendipity_event_htmlvalidator
Modified Files:
serendipity_event_htmlvalidator.php
Log Message:
list="`find . -name \*.php`"
list="$list `find . -name \*.txt`"
perl -i -pe 's=^M==g' $list
cvs tag pre-control-m-removal
cvs commit
cvs tag post-control-m-removal
Index: serendipity_event_htmlvalidator.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/plugins/serendipity_event_htmlvalidator/serendipity_event_htmlvalidator.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- serendipity_event_htmlvalidator.php 10 Feb 2004 16:04:27 -0000 1.2
+++ serendipity_event_htmlvalidator.php 3 Apr 2004 17:36:17 -0000 1.3
@@ -1,5 +1,5 @@
<?php # $Id$
-
+
switch ($serendipity['lang']) {
case 'de':
@define('PLUGIN_EVENT_HTMLVALIDATOR_NAME', 'HTML Validator');
@@ -16,7 +16,7 @@
case 'es':
default:
@define('PLUGIN_EVENT_HTMLVALIDATOR_NAME', 'HTML Validator');
- @define('PLUGIN_EVENT_HTMLVALIDATOR_DESC', 'Validates entries on their XML-conformity');
+ @define('PLUGIN_EVENT_HTMLVALIDATOR_DESC', 'Validates entries on their XML-conformity');
@define('PLUGIN_EVENT_HTMLVALIDATOR_CHARSET', 'Charset');
@define('PLUGIN_EVENT_HTMLVALIDATOR_CHARSETDESC', 'The usual charset of your articles');
@define('PLUGIN_EVENT_HTMLVALIDATOR_DOCTYPE', 'Doctype');
@@ -33,18 +33,18 @@
global $serendipity;
$propbag->add('name', PLUGIN_EVENT_HTMLVALIDATOR_NAME);
- $propbag->add('description', PLUGIN_EVENT_HTMLVALIDATOR_DESC);
- $propbag->add('event_hooks', array(
+ $propbag->add('description', PLUGIN_EVENT_HTMLVALIDATOR_DESC);
+ $propbag->add('event_hooks', array(
'backend_preview' => true,
- 'backend_display' => true,
- ));
-
- $propbag->add('configuration', array('charset', 'doctype', 'default_validate'));
-
+ 'backend_display' => true,
+ ));
+
+ $propbag->add('configuration', array('charset', 'doctype', 'default_validate'));
+
}
function introspect_config_item($name, &$propbag)
- {
+ {
switch($name) {
case 'default_validate':
$propbag->add('type', 'boolean');
@@ -53,68 +53,68 @@
break;
case 'charset':
- $propbag->add('type', 'select');
+ $propbag->add('type', 'select');
$propbag->add('name', PLUGIN_EVENT_HTMLVALIDATOR_CHARSET);
$propbag->add('description', PLUGIN_EVENT_HTMLVALIDATOR_CHARSETDESC);
- $propbag->add('select_values', array(
- '(detect automatically)' => '(detect automatically)',
- 'utf-8 (Unicode, worldwide)' => 'utf-8 (Unicode, worldwide)',
- 'utf-16 (Unicode, worldwide)' => 'utf-16 (Unicode, worldwide)',
- 'iso-8859-1 (Western Europe)' => 'iso-8859-1 (Western Europe)',
- 'iso-8859-2 (Central Europe)' => 'iso-8859-2 (Central Europe)',
- 'iso-8859-3 (Southern Europe)' => 'iso-8859-3 (Southern Europe)',
- 'iso-8859-4 (Baltic Rim)' => 'iso-8859-4 (Baltic Rim)',
- 'iso-8859-5 (Cyrillic)' => 'iso-8859-5 (Cyrillic)',
- 'iso-8859-6-i (Arabic)' => 'iso-8859-6-i (Arabic)',
- 'iso-8859-7 (Greek)' => 'iso-8859-7 (Greek)',
- 'iso-8859-8-i (Hebrew)' => 'so-8859-8-i (Hebrew)',
- 'iso-8859-9 (Turkish)' => 'iso-8859-9 (Turkish)',
- 'iso-8859-10 (Latin 6)' => 'iso-8859-10 (Latin 6)',
- 'iso-8859-13 (Latin 7)' => 'iso-8859-13 (Latin 7)',
- 'iso-8859-14 (Celtic)' => 'iso-8859-14 (Celtic)',
- 'iso-8859-15 (Latin 9)' => 'iso-8859-15 (Latin 9)',
- 'us-ascii (basic English)' => 'us-ascii (basic English)',
- 'euc-jp (Japanese, Unix)' => 'euc-jp (Japanese, Unix)',
- 'shift_jis (Japanese, Win/Mac)' => 'shift_jis (Japanese, Win/Mac)',
- 'iso-2022-jp (Japanese, email)' => 'iso-2022-jp (Japanese, email)',
- 'euc-kr (Korean)' => 'euc-kr (Korean)',
- 'gb2312 (Chinese, simplified)' => 'gb2312 (Chinese, simplified)',
- 'gb18030 (Chinese, simplified)' => 'gb18030 (Chinese, simplified)',
- 'big5 (Chinese, traditional)' => 'big5 (Chinese, traditional)',
- 'tis-620 (Thai)' => 'tis-620 (Thai)',
- 'koi8-r (Russian)' => 'koi8-r (Russian)',
- 'koi8-u (Ukrainian)' => 'koi8-u (Ukrainian)',
- 'macintosh (MacRoman)' => 'macintosh (MacRoman)',
- 'windows-1250 (Central Europe)' => 'windows-1250 (Central Europe)',
- 'windows-1251 (Cyrillic)' => 'windows-1251 (Cyrillic)',
- 'windows-1252 (Western Europe)' => 'windows-1252 (Western Europe)',
- 'windows-1253 (Greek)' => 'windows-1253 (Greek)',
- 'windows-1254 (Turkish)' => 'windows-1254 (Turkish)',
- 'windows-1255 (Hebrew)' => 'windows-1255 (Hebrew)',
- 'windows-1256 (Arabic)' => 'windows-1256 (Arabic)',
- 'windows-1257 (Baltic Rim)' => 'windows-1257 (Baltic Rim)'
+ $propbag->add('select_values', array(
+ '(detect automatically)' => '(detect automatically)',
+ 'utf-8 (Unicode, worldwide)' => 'utf-8 (Unicode, worldwide)',
+ 'utf-16 (Unicode, worldwide)' => 'utf-16 (Unicode, worldwide)',
+ 'iso-8859-1 (Western Europe)' => 'iso-8859-1 (Western Europe)',
+ 'iso-8859-2 (Central Europe)' => 'iso-8859-2 (Central Europe)',
+ 'iso-8859-3 (Southern Europe)' => 'iso-8859-3 (Southern Europe)',
+ 'iso-8859-4 (Baltic Rim)' => 'iso-8859-4 (Baltic Rim)',
+ 'iso-8859-5 (Cyrillic)' => 'iso-8859-5 (Cyrillic)',
+ 'iso-8859-6-i (Arabic)' => 'iso-8859-6-i (Arabic)',
+ 'iso-8859-7 (Greek)' => 'iso-8859-7 (Greek)',
+ 'iso-8859-8-i (Hebrew)' => 'so-8859-8-i (Hebrew)',
+ 'iso-8859-9 (Turkish)' => 'iso-8859-9 (Turkish)',
+ 'iso-8859-10 (Latin 6)' => 'iso-8859-10 (Latin 6)',
+ 'iso-8859-13 (Latin 7)' => 'iso-8859-13 (Latin 7)',
+ 'iso-8859-14 (Celtic)' => 'iso-8859-14 (Celtic)',
+ 'iso-8859-15 (Latin 9)' => 'iso-8859-15 (Latin 9)',
+ 'us-ascii (basic English)' => 'us-ascii (basic English)',
+ 'euc-jp (Japanese, Unix)' => 'euc-jp (Japanese, Unix)',
+ 'shift_jis (Japanese, Win/Mac)' => 'shift_jis (Japanese, Win/Mac)',
+ 'iso-2022-jp (Japanese, email)' => 'iso-2022-jp (Japanese, email)',
+ 'euc-kr (Korean)' => 'euc-kr (Korean)',
+ 'gb2312 (Chinese, simplified)' => 'gb2312 (Chinese, simplified)',
+ 'gb18030 (Chinese, simplified)' => 'gb18030 (Chinese, simplified)',
+ 'big5 (Chinese, traditional)' => 'big5 (Chinese, traditional)',
+ 'tis-620 (Thai)' => 'tis-620 (Thai)',
+ 'koi8-r (Russian)' => 'koi8-r (Russian)',
+ 'koi8-u (Ukrainian)' => 'koi8-u (Ukrainian)',
+ 'macintosh (MacRoman)' => 'macintosh (MacRoman)',
+ 'windows-1250 (Central Europe)' => 'windows-1250 (Central Europe)',
+ 'windows-1251 (Cyrillic)' => 'windows-1251 (Cyrillic)',
+ 'windows-1252 (Western Europe)' => 'windows-1252 (Western Europe)',
+ 'windows-1253 (Greek)' => 'windows-1253 (Greek)',
+ 'windows-1254 (Turkish)' => 'windows-1254 (Turkish)',
+ 'windows-1255 (Hebrew)' => 'windows-1255 (Hebrew)',
+ 'windows-1256 (Arabic)' => 'windows-1256 (Arabic)',
+ 'windows-1257 (Baltic Rim)' => 'windows-1257 (Baltic Rim)'
));
break;
case 'doctype':
$propbag->add('type', 'select');
$propbag->add('name', PLUGIN_EVENT_HTMLVALIDATOR_DOCTYPE);
- $propbag->add('description', PLUGIN_EVENT_HTMLVALIDATOR_DOCTYPEDESC);
- $propbag->add('select_values', array(
- 'Inline' => '(detect automatically)',
- 'XHTML 1.1' => 'XHTML 1.1',
- 'XHTML Basic 1.0' => 'XHTML Basic 1.0',
- 'XHTML 1.0 Strict' => 'XHTML 1.0 Strict',
- 'XHTML 1.0 Transitional' => 'XHTML 1.0 Transitional',
- 'XHTML 1.0 Frameset' => 'XHTML 1.0 Frameset',
- 'HTML 4.01 Strict' => 'HTML 4.01 Strict',
- 'HTML 4.01 Transitional' => 'HTML 4.01 Transitional',
- 'HTML 4.01 Frameset' => 'HTML 4.01 Frameset',
- 'HTML 3.2' => 'HTML 3.2',
- 'HTML 2.0' => 'HTML 2.0'
+ $propbag->add('description', PLUGIN_EVENT_HTMLVALIDATOR_DOCTYPEDESC);
+ $propbag->add('select_values', array(
+ 'Inline' => '(detect automatically)',
+ 'XHTML 1.1' => 'XHTML 1.1',
+ 'XHTML Basic 1.0' => 'XHTML Basic 1.0',
+ 'XHTML 1.0 Strict' => 'XHTML 1.0 Strict',
+ 'XHTML 1.0 Transitional' => 'XHTML 1.0 Transitional',
+ 'XHTML 1.0 Frameset' => 'XHTML 1.0 Frameset',
+ 'HTML 4.01 Strict' => 'HTML 4.01 Strict',
+ 'HTML 4.01 Transitional' => 'HTML 4.01 Transitional',
+ 'HTML 4.01 Frameset' => 'HTML 4.01 Frameset',
+ 'HTML 3.2' => 'HTML 3.2',
+ 'HTML 2.0' => 'HTML 2.0'
));
break;
-
+
default:
return false;
}
@@ -130,7 +130,7 @@
$hooks = &$bag->get('event_hooks');
- if (isset($hooks[$event])) {
+ if (isset($hooks[$event])) {
switch($event) {
case 'backend_display':
?>
@@ -142,111 +142,111 @@
<input style="margin: 0px; padding: 0px; vertical-align: bottom;" type="checkbox" name="serendipity[default_validate]" id="serendipity[default_validate]" value="true" <?php echo $selected; ?> />
<label style="vertical-align: bottom; margin: 0px; padding: 0px;" for="serendipity[default_validate]"> <?php echo PLUGIN_EVENT_HTMLVALIDATOR_GOVALIDATE; ?> </label>
</fieldset>
-<?php
+<?php
break;
-
+
case 'backend_preview':
if (!$serendipity['POST']['default_validate']) {
return true;
}
-
- $url = 'validator.w3.org';
- $path = '/check';
- $fp = fsockopen($url, 80, $errno, $errstr, 30);
-
- $doctype = $this->get_config('doctype');
- $charset = $this->get_config('charset');
-
- if (empty($doctype)) {
- $doctype = 'XHTML 1.1';
- }
-
- if (empty($charset)) {
- $charset = 'iso-8859-1 (Western Europe)';
- }
-
- $data = '<html><head><title>s9y</title></head><body><div>'
- . $eventData
- . '</div></body></html>';
- $request_data .= '-----------------------------24464570528145
-Content-Disposition: form-data; name="uploaded_file"; filename="s9y.htm"
-Content-Type: text/html
-
-' . $data . '
------------------------------24464570528145
-Content-Disposition: form-data; name="charset"
-
-' . $charset . '
------------------------------24464570528145
-Content-Disposition: form-data; name="doctype"
-
-' . $doctype . '
------------------------------24464570528145
-Content-Disposition: form-data; name="verbose"
-
-1
------------------------------24464570528145--';
-
- $request_length = strlen($request_data);
- $REQUEST = array();
- $REQUEST[] = 'POST ' . $path . ' HTTP/1.0';
- $REQUEST[] = 'Host: ' . $url;
- $REQUEST[] = 'User-Agent: serendipity/' . $serendipity['version'];
- $REQUEST[] = 'Referer: http://validator.w3.org/';
- $REQUEST[] = 'Content-Type: multipart/form-data; boundary=---------------------------24464570528145';
- $REQUEST[] = 'Content-Length: ' . $request_length;
- $REQUEST[] = 'Connection: close' . "\n";
- $REQUEST[] = $request_data;
-
- $REQUEST_STRING = implode("\n", $REQUEST);
- fputs($fp, $REQUEST_STRING);
-
- $line = fgets($fp, 1024);
- if (preg_match('@^HTTP/1\.. (2|3)0(2|0)@', $line)) {
- $out = '';
- $inheader = 1;
- while(!feof($fp) && strlen($out) < 200000) {
- $line = fgets($fp,1024);
- if ($inheader && ($line == "\n" || $line == "\r\n")) {
- $inheader = 0;
- } elseif (!$inheader) {
- $out .= $line;
- }
- }
- }
- fclose($fp);
-
- preg_match('@<table class="header">.+</table>.+</div>.+(<h2 .+)</body>@ms', $out, $html);
-
- // Cut the waste
- $html[1] = preg_replace(
- array(
- '@<address>.+</address>@ms',
- '@<dl class="tip">.+</dl>@ms',
- '@<div id="source".+>.+</div>@msU'
- ),
-
- array(
- '',
- '',
- ''
- ),
-
- $html[1]
- );
-
- echo '<div style="border: 1px solid red; margin: 10px; padding: 5px; "><div>' . $html[1] . '</div>';
+
+ $url = 'validator.w3.org';
+ $path = '/check';
+ $fp = fsockopen($url, 80, $errno, $errstr, 30);
+
+ $doctype = $this->get_config('doctype');
+ $charset = $this->get_config('charset');
+
+ if (empty($doctype)) {
+ $doctype = 'XHTML 1.1';
+ }
+
+ if (empty($charset)) {
+ $charset = 'iso-8859-1 (Western Europe)';
+ }
+
+ $data = '<html><head><title>s9y</title></head><body><div>'
+ . $eventData
+ . '</div></body></html>';
+ $request_data .= '-----------------------------24464570528145
+Content-Disposition: form-data; name="uploaded_file"; filename="s9y.htm"
+Content-Type: text/html
+
+' . $data . '
+-----------------------------24464570528145
+Content-Disposition: form-data; name="charset"
+
+' . $charset . '
+-----------------------------24464570528145
+Content-Disposition: form-data; name="doctype"
+
+' . $doctype . '
+-----------------------------24464570528145
+Content-Disposition: form-data; name="verbose"
+
+1
+-----------------------------24464570528145--';
+
+ $request_length = strlen($request_data);
+ $REQUEST = array();
+ $REQUEST[] = 'POST ' . $path . ' HTTP/1.0';
+ $REQUEST[] = 'Host: ' . $url;
+ $REQUEST[] = 'User-Agent: serendipity/' . $serendipity['version'];
+ $REQUEST[] = 'Referer: http://validator.w3.org/';
+ $REQUEST[] = 'Content-Type: multipart/form-data; boundary=---------------------------24464570528145';
+ $REQUEST[] = 'Content-Length: ' . $request_length;
+ $REQUEST[] = 'Connection: close' . "\n";
+ $REQUEST[] = $request_data;
+
+ $REQUEST_STRING = implode("\n", $REQUEST);
+ fputs($fp, $REQUEST_STRING);
+
+ $line = fgets($fp, 1024);
+ if (preg_match('@^HTTP/1\.. (2|3)0(2|0)@', $line)) {
+ $out = '';
+ $inheader = 1;
+ while(!feof($fp) && strlen($out) < 200000) {
+ $line = fgets($fp,1024);
+ if ($inheader && ($line == "\n" || $line == "\r\n")) {
+ $inheader = 0;
+ } elseif (!$inheader) {
+ $out .= $line;
+ }
+ }
+ }
+ fclose($fp);
+
+ preg_match('@<table class="header">.+</table>.+</div>.+(<h2 .+)</body>@ms', $out, $html);
+
+ // Cut the waste
+ $html[1] = preg_replace(
+ array(
+ '@<address>.+</address>@ms',
+ '@<dl class="tip">.+</dl>@ms',
+ '@<div id="source".+>.+</div>@msU'
+ ),
+
+ array(
+ '',
+ '',
+ ''
+ ),
+
+ $html[1]
+ );
+
+ echo '<div style="border: 1px solid red; margin: 10px; padding: 5px; "><div>' . $html[1] . '</div>';
return true;
- break;
-
- default:
- return false;
- break;
- }
- } else {
- return false;
- }
- }
+ break;
+
+ default:
+ return false;
+ break;
+ }
+ } else {
+ return false;
+ }
+ }
}
/* vim: set sts=4 ts=4 expandtab : */
|