function outputMVD(&$mvd_page, $absolute_links = false) { global $wgOut, $wgUser, $wgEnableParserCache; // $mvdTile = Title::makeTitle(MV_NS_MVD, $mvd_page->wiki_title ); $mvdTitle = new MV_Title($mvd_page->wiki_title); // print "mw.log('outputMVD: ".$mvdTitle->getText()."');\n"; $mvdArticle = new Article($mvdTitle); if (!$mvdArticle->exists()) { // print "mw.log('missing: " .$mvd_page->wiki_title."');\n"; return; } // use the cache by default: // $usepCache = (isset($mvd_page->usePcache))?$mvd_page->usePcache:true; /*try to pull from cache: separate out cache for internal links vs external links cache*/ if ($wgEnableParserCache) { $MvParserCache = ParserCache::singleton(); $popts = ParserOptions::newFromUser($wgUser); if ($absolute_links) { $popts->addExtraKey('Metavid-absolutelinks'); } // FIXME: add the dbKey since I don't know how to easy purge the cache and we are getting cache missmatch $popts->addExtraKey($mvdTitle->getDBkey()); $parserOutput = $MvParserCache->get($mvdArticle, $popts); } else { $parserOutput = false; } if ($parserOutput !== false) { // print "mw.log('found in cache: with hash: " . $MvParserCache->getKey( $mvdArticle, $wgUser )."');\n"; // found in cache output and be done with it: $wgOut->addParserOutput($parserOutput); } else { // print "mw.log('not found in cache');\n"; // print "mw.log('titleDB: ".$tsTitle->getDBkey() ."');\n"; if ($mvdTitle->exists()) { // grab the article text: $curRevision = Revision::newFromTitle($mvdTitle); $wikiText = $curRevision->getText(); } else { if (isset($this->preMoveArtileText)) { $wikiText =& $this->preMoveArtileText; } else { // @@todo throw error: // print "error article: " . $mvd_page->wiki_title . " not there \n"; print "mw.log('missing: " . $mvd_page->wiki_title . "');\n"; return; } } $parserOutput = $this->parse_format_text($wikiText, $mvdTitle, $mvd_page, $absolute_links); // if absolute_links set preg_replace with the server for every relative link: if ($absolute_links == true) { global $wgServer; $parserOutput->mText = str_replace(array('href="/', 'src="/'), array('href="' . $wgServer . '/', 'src="' . $wgServer . '/'), $parserOutput->mText); } // output the page and save to cache $wgOut->addParserOutput($parserOutput); if ($wgEnableParserCache) { $MvParserCache->save($parserOutput, $mvdArticle, $popts); } } }