alterations to allow a command-line wikitext processor
authorTim Starling <tstarling@users.mediawiki.org>
Sat, 27 Mar 2004 22:47:25 +0000 (22:47 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Sat, 27 Mar 2004 22:47:25 +0000 (22:47 +0000)
includes/Parser.php
includes/User.php

index e420445..d44ce17 100644 (file)
@@ -1627,7 +1627,7 @@ class Parser
        function preSaveTransform( $text, &$title, &$user, $options, $clearState = true )
        {
                $this->mOptions = $options;
-               $this->mTitle = $title;
+               $this->mTitle =& $title;
                $this->mOutputType = OT_WIKI;
                
                if ( $clearState ) {
@@ -1713,7 +1713,17 @@ class Parser
                return $text;
        }
 
-
+       # Set up some variables which are usually set up in parse()
+       # so that an external function can call some class members with confidence
+       function startExternalParse( &$title, $options, $outputType, $clearState = true ) 
+       {
+               $this->mTitle =& $title;
+               $this->mOptions = $options;
+               $this->mOutputType = $outputType;
+               if ( $clearState ) {
+                       $this->clearState();
+               }
+       }
 }
 
 class ParserOutput
index 1f6ff8f..a6f1fb5 100644 (file)
@@ -424,7 +424,9 @@ class User {
        function isBot()
        {
                $this->loadFromDatabase();
-               if ( 0 == $this->mId ) { return false; }
+
+               # Why was this here? I need a UID=0 conversion script [TS]
+               # if ( 0 == $this->mId ) { return false; }
 
                return in_array( "bot", $this->mRights );
        }
@@ -669,8 +671,12 @@ class User {
                return $allowed;
        }
 
-
-
+       # Set mDataLoaded, return previous value
+       # Use this to prevent DB access in command-line scripts or similar situations
+       function setLoaded( $loaded ) 
+       {
+               wfSetVar( $this->mDataLoaded, $loaded );
+       }
 }
 
 ?>