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

Revision: 90064
Author:   ankitgarg833
Date:     2011-06-14 18:02:56 +0000 (Tue, 14 Jun 2011)
Log Message:
-----------
Adding the Create page Job class.

Added Paths:
-----------
    trunk/extensions/PageSchemas/PS_CreatePageJob.php

Added: trunk/extensions/PageSchemas/PS_CreatePageJob.php
===================================================================
--- trunk/extensions/PageSchemas/PS_CreatePageJob.php                           
(rev 0)
+++ trunk/extensions/PageSchemas/PS_CreatePageJob.php   2011-06-14 18:02:56 UTC 
(rev 90064)
@@ -0,0 +1,47 @@
+<?php
+
+/**
+ * Background job to create a new property page,
+ *
+ * @author ankit garg
+ */
+class PSCreatePageJob extends Job {
+
+       function __construct( $title, $params = '', $id = 0 ) {
+               parent::__construct( 'createPage', $title, $params, $id );
+       }
+
+       /**
+        * Run a createPage job
+        * @return boolean success
+        */
+       function run() {
+               wfProfileIn( __METHOD__ );
+
+               if ( is_null( $this->title ) ) {
+                       $this->error = "createPage: Invalid title";
+                       wfProfileOut( __METHOD__ );
+                       return false;
+               }
+                $article = new Article( $this->title );
+                if ( !$article ) {
+                        $this->error = 'createPage: Article not found "' . 
$this->title->getPrefixedDBkey() . '"';
+                        wfProfileOut( __METHOD__ );
+                        return false;
+                }
+
+               $page_text = $this->params['page_text'];
+               // change global $wgUser variable to the one
+               // specified by the job only for the extent of this
+               // replacement
+               global $wgUser;
+               $actual_user = $wgUser;
+               $wgUser = User::newFromId( $this->params['user_id'] );
+               $edit_summary = ''; // $this->params['edit_summary'];
+               $article->doEdit( $page_text, $edit_summary );
+               $wgUser = $actual_user;
+               wfProfileOut( __METHOD__ );
+               return true;
+       }
+}
+


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

Reply via email to