[Mediawiki-l] Page Table

Hugh Prior mediawiki at localpin.com
Fri Feb 17 17:02:47 UTC 2006


I have created a little function (I think based on the same stuff Rob Church 
suggested a while back) which does what I need in terms of creating a page 
calling other existing stuff.  I offer it here for whatever use you can make 
of it:

 /**
  * Create a wiki page
  */
 function createWikiPage($wikiPageName, $pageText="(Page text default in 
createWikiPage)") {
  $dbw =& wfGetDB( DB_MASTER );

  # Process each message
  $title = new Title();
  $title = $title->newFromText($wikiPageName);

  $article = new Article( $title );
  $newid = $article->insertOn( $dbw );
  # FIXME: set restrictions
  $revision = new Revision( array(
  'page'      => $newid,
  'text'      => $pageText,
  'user'      => 0,
  'user_text' => "This page automatically created by ".__FILE__,
  'comment'   => '',
  ) );
  $revid = $revision->insertOn( $dbw );
  $article->updateRevisionOn( $dbw, $revision );

  $dbw->commit();

  return $revid;
 }
 






More information about the MediaWiki-l mailing list