svn: /web/doc-editor/trunk/ error_type.php php/ToolsError.php
[email protected] (Yannick Torres)
| Newsgroups | php.doc.web |
|---|---|
| Message-ID | <[email protected]> |
yannick Sun, 28 Mar 2010 21:37:12 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=297025
Log:
Mark an error for file who aren't UTF-8 encoding
Changed paths:
U web/doc-editor/trunk/error_type.php
U web/doc-editor/trunk/php/ToolsError.php
Modified: web/doc-editor/trunk/error_type.php
===================================================================
--- web/doc-editor/trunk/error_type.php 2010-03-28 20:33:56 UTC (rev 297024)
+++ web/doc-editor/trunk/error_type.php 2010-03-28 21:37:12 UTC (rev 297025)
@@ -265,6 +265,9 @@
$error['missingInitializer']['head'] = 'Missing <initializer> tag';
$error['missingInitializer']['desc'] = 'A missing <initializer> tag was found.';
+$error['documentNotUTF8']['head'] = 'Document encoding is not UTF-8';
+$error['documentNotUTF8']['desc'] = 'We recommand to set your document in UTF-8 encoding.';
+
$to_display = array();
// If $error_to_display is an empty array, we add it all errors (default page)
Modified: web/doc-editor/trunk/php/ToolsError.php
===================================================================
--- web/doc-editor/trunk/php/ToolsError.php 2010-03-28 20:33:56 UTC (rev 297024)
+++ web/doc-editor/trunk/php/ToolsError.php 2010-03-28 21:37:12 UTC (rev 297025)
@@ -327,6 +327,7 @@
$this->missingInitializer();
$this->spaceOrPeriodRefpurposeTag($this->lang);
$this->tabCharacterInDocument($this->lang);
+ $this->documentNotUTF8($this->lang);
}
// Check Error specific to LANG files
@@ -353,6 +354,7 @@
$this->nbTag();
$this->spaceOrPeriodRefpurposeTag($this->lang);
$this->tabCharacterInDocument($this->lang);
+ $this->documentNotUTF8($this->lang);
}
}
@@ -1180,6 +1182,32 @@
}
/**
+ * Check for tabs into the document
+ * Add an entry into the error's stack if a tab is found in the document
+ *
+ */
+ function documentNotUTF8($lang)
+ {
+ if( $lang == 'en' ) {
+ $content = $this->en_content;
+ } else {
+ $content = $this->lang_content;
+ }
+
+ $matches = array();
+ preg_match('!<\?xml(.+)\s?encoding=("|\')(.*)("|\')\s?\?>!U', $content, $matches);
+
+ if ( !isset($matches[3]) || strtoupper($matches[3]) != 'UTF-8') {
+
+ $this->addError(array(
+ 'value_en' => 'N/A',
+ 'value_lang' => 'N/A',
+ 'type' => 'documentNotUTF8'
+ ));
+ }
+ }
+
+ /**
* Check Nb <![CDATA tag
* Add an entry into the error's stack if an error is found
*