function do_update_wiki_page($wgTitle, $wikiText, $ns = null, $forceUpdate = false) { global $botUserName; if (!is_object($wgTitle)) { //get the title and make sure the first letter is uper case $wgTitle = Title::makeTitle($ns, ucfirst($wgTitle)); } if (trim($wgTitle->getDBKey()) == '') { print "empty title (no insert /update) \n"; return; } //print "INSERT BODY: ".$wikiText; //make sure the text is utf8 encoded: $wikiText = utf8_encode($wikiText); $wgArticle = new Article($wgTitle); if (!mvDoMvPage($wgTitle, $wgArticle, false)) { print "bad title: " . $wgTitle->getNsText() . ':' . $wgTitle->getDBkey() . " no edit"; if ($wgTitle->exists()) { print "remove article"; $wgArticle->doDeleteArticle('bad title'); } //some how mvdIndex and mvd pages got out of sync do a seperate check for the mvd: if (MV_Index::getMVDbyTitle($wgArticle->mTitle->getDBkey()) != null) { print ', rm mvd'; MV_Index::remove_by_wiki_title($wgArticle->mTitle->getDBkey()); } print "\n"; return; } if ($wgTitle->getNamespace() == MV_NS_MVD && MV_Index::getMVDbyTitle($wgTitle->getDBkey()) == null) { //print "missing assoc mvd ...update \n"; } else { if ($wgTitle->exists()) { //if last edit!=mvBot skip (don't overwite peoples improvments') $rev =& Revision::newFromTitle($wgTitle); if ($botUserName != $rev->getRawUserText() && !$forceUpdate) { print ' skiped page ' . $wgTitle->getNsText() . ':' . $wgTitle->getText() . ' edited by user:'******'#REDIRECT')) == '#REDIRECT' && !$forceUpdate) { print ' skiped page moved by user:'******':' . $wgTitle->getText() . " is identical (no update)\n"; //if force update double check the mvd for consistancy? return; } } } //got here do the edit: $sum_txt = 'metavid bot insert'; $wgArticle->doEdit($wikiText, $sum_txt); print "did edit on " . $wgTitle->getNsText() . ':' . $wgTitle->getDBkey() . "\n"; //die; }
function mvDeleteHook(&$article, &$user, &$reason) { global $mvgIP; // print 'mvDeleteHook'."\n"; // only need to update the mvd index when in the mvd namespace: if ($article->mTitle->getNamespace() == MV_NS_MVD) { // remove article with that title: MV_Index::remove_by_wiki_title($article->mTitle->getDBkey()); } elseif ($article->mTitle->getNamespace() == MV_NS_STREAM) { $article->mvTitle->mvStream->deleteDB(); } return true; // always return true, in order not to stop MW's hook processing! }