Followup r81583, break some of the long lines and centralize the regex.
authorDaniel Friesen <dantman@users.mediawiki.org>
Tue, 8 Feb 2011 01:31:21 +0000 (01:31 +0000)
committerDaniel Friesen <dantman@users.mediawiki.org>
Tue, 8 Feb 2011 01:31:21 +0000 (01:31 +0000)
includes/parser/ParserOutput.php
includes/parser/Tidy.php

index 80d5343..caac802 100644 (file)
@@ -125,6 +125,8 @@ class ParserOutput extends CacheTime {
        private $mIndexPolicy = '';           # 'index' or 'noindex'?  Any other value will result in no change.
        private $mAccessedOptions = null; # List of ParserOptions (stored in the keys)
 
+       const EDITSECTION_REGEX = '#<(?:mw:)?editsection page="(.*?)" section="(.*?)"(?:/>|>(.*?)(</(?:mw:)?editsection>))#';
+
        function __construct( $text = '', $languageLinks = array(), $categoryLinks = array(),
                $containsOldMagic = false, $titletext = '' )
        {
@@ -137,7 +139,8 @@ class ParserOutput extends CacheTime {
 
        function getText() {
                if ( $this->mEditSectionTokens ) {
-                       return preg_replace_callback( '#<(?:mw:)?editsection page="(.*?)" section="(.*?)"(?:/>|>(.*?)(</(?:mw:)?editsection>))#', array( &$this, 'replaceEditSectionLinksCallback' ), $this->mText );
+                       return preg_replace_callback( ParserOutput::EDITSECTION_REGEX,
+                               array( &$this, 'replaceEditSectionLinksCallback' ), $this->mText );
                }
                return $this->mText;
        }
index 2988f3e..d2b58f6 100644 (file)
@@ -26,9 +26,11 @@ class MWTidyWrapper {
 
        public function getWrapped( $text ) {
                $this->mTokens = new ReplacementArray;
-               $this->mUniqPrefix = "\x7fUNIQ" . dechex( mt_rand( 0, 0x7fffffff ) ) . dechex( mt_rand( 0, 0x7fffffff ) );
+               $this->mUniqPrefix = "\x7fUNIQ" .
+                       dechex( mt_rand( 0, 0x7fffffff ) ) . dechex( mt_rand( 0, 0x7fffffff ) );
                $this->mMarkerIndex = 0;
-               $wrappedtext = preg_replace_callback( '#<(?:mw:)?editsection page="(.*?)" section="(.*?)"(?:/>|>(.*?)(</(?:mw:)?editsection>))#', array( &$this, 'replaceEditSectionLinksCallback' ), $text );
+               $wrappedtext = preg_replace_callback( ParserOutput::EDITSECTION_REGEX,
+                       array( &$this, 'replaceEditSectionLinksCallback' ), $text );
 
                $wrappedtext = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"'.
                        ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html>'.