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

Revision: 72193
Author:   jeroendedauw
Date:     2010-09-02 10:33:56 +0000 (Thu, 02 Sep 2010)

Log Message:
-----------
Changes for 0.4 - added listerrors parser hooks

Modified Paths:
--------------
    trunk/extensions/Validator/Validator.php
    trunk/extensions/Validator/Validator_Settings.php
    trunk/extensions/Validator/includes/ParserHook.php

Added Paths:
-----------
    trunk/extensions/Validator/includes/parserHooks/
    trunk/extensions/Validator/includes/parserHooks/Validator_ListErrors.php

Modified: trunk/extensions/Validator/Validator.php
===================================================================
--- trunk/extensions/Validator/Validator.php    2010-09-02 10:18:32 UTC (rev 
72192)
+++ trunk/extensions/Validator/Validator.php    2010-09-02 10:33:56 UTC (rev 
72193)
@@ -33,9 +33,6 @@
 define( 'Validator_ERRORS_SHOW', 3 );
 define( 'Validator_ERRORS_STRICT', 4 );
 
-// Include the settings file.
-require_once 'Validator_Settings.php';
-
 // Register the internationalization file.
 $wgExtensionMessagesFiles['Validator'] = dirname( __FILE__ ) . 
'/Validator.i18n.php';
 
@@ -56,4 +53,8 @@
 $wgAutoloadClasses['ValidationFormats']        = $incDir . 
'ValidationFormats.php';
 $wgAutoloadClasses['ValidationManager']        = $incDir . 
'ValidationManager.php';
 $wgAutoloadClasses['TopologicalSort']          = $incDir . 
'TopologicalSort.php';
-unset( $incDir );
\ No newline at end of file
+$wgAutoloadClasses['ValidatorListErrors']      = $incDir . 
'parserHooks/Validator_ListErrors.php';
+unset( $incDir );
+
+// Include the settings file.
+require_once 'Validator_Settings.php';
\ No newline at end of file

Modified: trunk/extensions/Validator/Validator_Settings.php
===================================================================
--- trunk/extensions/Validator/Validator_Settings.php   2010-09-02 10:18:32 UTC 
(rev 72192)
+++ trunk/extensions/Validator/Validator_Settings.php   2010-09-02 10:33:56 UTC 
(rev 72193)
@@ -17,6 +17,9 @@
        die( 'Not an entry point.' );
 }
 
+# Registration of the listerrors parser hooks.
+$wgHooks['ParserFirstCallInit'][] = 'ValidatorListErrors::staticInit';
+
 # Integer. The strictness of the parameter validation and resulting error 
report when using the ValidatorManager class.
 # This value also affects the error messages native to extensions that 
integrate Validator correctly.
 # Validator_ERRORS_NONE        : Validator will not show any errors, and make 
the best of the input it got.

Modified: trunk/extensions/Validator/includes/ParserHook.php
===================================================================
--- trunk/extensions/Validator/includes/ParserHook.php  2010-09-02 10:18:32 UTC 
(rev 72192)
+++ trunk/extensions/Validator/includes/ParserHook.php  2010-09-02 10:33:56 UTC 
(rev 72193)
@@ -116,8 +116,10 @@
                $manager = new ValidationManager();
                
                if ( $parsed ) {
-                       $validator->setParameters( $arguments, 
$this->getParameterInfo() );
-                       $validator->validateAndFormatParameters();              
        
+                       $doRender = $manager->manageParsedParameters(
+                               $arguments,
+                               $this->getParameterInfo()
+                       );                      
                }
                else {
                        $doRender = $manager->manageParameters(

Added: trunk/extensions/Validator/includes/parserHooks/Validator_ListErrors.php
===================================================================
--- trunk/extensions/Validator/includes/parserHooks/Validator_ListErrors.php    
                        (rev 0)
+++ trunk/extensions/Validator/includes/parserHooks/Validator_ListErrors.php    
2010-09-02 10:33:56 UTC (rev 72193)
@@ -0,0 +1,88 @@
+<?php
+
+/**
+ * Class for the 'listerrors' parser hooks.
+ * 
+ * @since 0.4
+ * 
+ * @file Validator_ListErrors.php
+ * @ingroup Validator
+ * 
+ * @author Jeroen De Dauw
+ */
+class ValidatorListErrors extends ParserHook {
+       
+       /**
+        * No LST in pre-5.3 PHP *sigh*.
+        * This is to be refactored as soon as php >=5.3 becomes acceptable.
+        */
+       public static function staticMagic( array &$magicWords, $langCode ) {
+               $className = __CLASS__;
+               $instance = new $className();
+               return $instance->magic( $magicWords, $langCode );
+       }
+       
+       /**
+        * No LST in pre-5.3 PHP *sigh*.
+        * This is to be refactored as soon as php >=5.3 becomes acceptable.
+        */     
+       public static function staticInit( Parser &$wgParser ) {
+               $className = __CLASS__;
+               $instance = new $className();
+               return $instance->init( $wgParser );
+       }       
+       
+       /**
+        * Gets the name of the parser hook.
+        * @see ParserHook::getName
+        * 
+        * @since 0.4
+        * 
+        * @return string
+        */
+       protected function getName() {
+               return 'listerrors';
+       }
+       
+       /**
+        * Returns an array containing the parameter info.
+        * @see ParserHook::getParameterInfo
+        * 
+        * @since 0.4
+        * 
+        * @return array
+        */
+       protected function getParameterInfo() {
+               return array(
+               );
+       }
+       
+       /**
+        * Returns the list of default parameters.
+        * @see ParserHook::getDefaultParameters
+        * 
+        * @since 0.4
+        * 
+        * @return array
+        */
+       protected function getDefaultParameters() {
+               return array( );
+       }
+       
+       /**
+        * Renders and returns the output.
+        * @see ParserHook::render
+        * 
+        * @since 0.4
+        * 
+        * @param array $parameters
+        * 
+        * @return string
+        */
+       public function render( array $parameters ) {
+               $output = ''; // TODO
+               
+               return $output;         
+       }
+       
+}
\ No newline at end of file


Property changes on: 
trunk/extensions/Validator/includes/parserHooks/Validator_ListErrors.php
___________________________________________________________________
Added: svn:eol-style
   + native



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

Reply via email to