Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Wikipedia: Mediawiki-CVS

SVN: [59444] trunk/extensions/TemplateInfo/TemplateInfo.hooks.php

 

 

Wikipedia mediawiki-cvs RSS feed   Index | Next | Previous | View Threaded


yaron at svn

Nov 25, 2009, 9:29 PM

Post #1 of 1 (64 views)
Permalink
SVN: [59444] trunk/extensions/TemplateInfo/TemplateInfo.hooks.php

http://www.mediawiki.org/wiki/Special:Code/MediaWiki/59444

Revision: 59444
Author: yaron
Date: 2009-11-26 05:29:38 +0000 (Thu, 26 Nov 2009)

Log Message:
-----------
Error message returned for bad XML is now actual parsing error message

Modified Paths:
--------------
trunk/extensions/TemplateInfo/TemplateInfo.hooks.php

Modified: trunk/extensions/TemplateInfo/TemplateInfo.hooks.php
===================================================================
--- trunk/extensions/TemplateInfo/TemplateInfo.hooks.php 2009-11-26 05:27:24 UTC (rev 59443)
+++ trunk/extensions/TemplateInfo/TemplateInfo.hooks.php 2009-11-26 05:29:38 UTC (rev 59444)
@@ -19,7 +19,7 @@
return true;
}

- public static function validateXML( $xml ) {
+ public static function validateXML( $xml, &$error_msg ) {
$xmlDTD =<<<END
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE template [.
@@ -49,22 +49,27 @@
// hide parsing warnings
libxml_use_internal_errors(true);
$xml_success = simplexml_load_string($xmlDTD . $xml);
+ $errors = libxml_get_errors();
+ $message = $errors[0]->message;
+ //$line = $errors[0]->line;
+ $error_msg = "ERROR: $message";
return $xml_success;
}

// Render the displayed XML, if any
public static function render( $input, $args, $parser, $frame ) {
// if this call is contained in a transcluded page or template,
- // or if the inpur is empty, display nothing
+ // or if the input is empty, display nothing
if ( !$frame->title->equals( $parser->getTitle() ) || $input == '' )
return;

// Store XML in the page_props table
// TODO: Do processing here, like parse to an array
- if ( TemplateInfoHooks::validateXML( $input ) )
+ $error_msg = null;
+ if ( TemplateInfoHooks::validateXML( $input, $error_msg ) )
$parser->getOutput()->setProperty( 'templateinfo', $input );
else
- $parser->getOutput()->setProperty( 'templateinfo', "Error: Invalid XML" );
+ $parser->getOutput()->setProperty( 'templateinfo', $error_msg );

// Return output
$text = "<p>" . wfMsg( 'templateinfo-header' ) . "</p>\n";



_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS [at] lists
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Wikipedia mediawiki-cvs RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.