[Mediawiki-l] Passing and dispalying interwiki links

Jama Poulsen jama at debianlinux.net
Fri Mar 24 00:40:41 UTC 2006


On Thu, Mar 23, 2006 at 05:22:32PM -0500, Amruta Lonkar wrote:
> Hi,
> 
> I am using the following code to create pages in a given namespace and am
> passing some text as links, and i want them to be shown as links however the
> mediawiki code is not parsing the <a href></a> tags. Is there some other wau
> to do this?
> 
> function createWikiPage($pageTitle,$pageText,$refid)
> {
> $pageText = $pageText."<h1>".text."</h1>"."<a href=some http>".text."</a>";
> 
> 	$dbw =& wfGetDB(DB_MASTER);
> 
> 	//Process each message
> 	$title = new Title();
> 	$title = $title->newFromText($pageTitle,102);
> 
> 	$article = new Article($title);
> 	$newid = $article->insertOn($dbw);
> 
> 	$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();
> 
> }

You are creating new _Wiki_ text articles using these functions. HTML is not
Wiki text. You can just use normal Wiki syntax, like [[myinternallink foo]] or
[myexternallink bar].

Its also a good idea to check the return status of some functions (and report
it when problems do happen), eg:

  $ok = $article->updateRevisionOn( $dbw, $revision );

  $dbw->commit();

  if( !$ok ) {
    $dbw->rollback();
    // report problem
  }
  } else {
    ...
    $dbw->commit();
  }

Jama Poulsen



More information about the MediaWiki-l mailing list