/** * Set the wikilog item to query for. Only comments for the given article * is returned. * @param $item Wikilog item to query for (WikilogItem or Title). * Preferably, a WikilogItem object should be passed, but a Title * object is also accepted and automatically converted (no error * checking). */ public function setItem( $item ) { if ( $item instanceof Title ) { $item = WikilogItem::newFromID( $item->getArticleId() ); } $this->mItem = $item; }
/** * Constructor from a page ID. * @param $id Int article ID to load. */ public static function newFromID( $id ) { $t = Title::newFromID( $id ); $i = WikilogItem::newFromID( $id ); return $t == null ? null : new self( $t, $i ); }
/** * TitleMoveComplete hook handler function. * Handles moving articles to and from wikilog namespaces. */ static function TitleMoveComplete( &$oldtitle, &$newtitle, &$user, $pageid, $redirid ) { global $wgWikilogNamespaces; # Check if it was or is now in a wikilog namespace. $oldwl = in_array( ( $oldns = $oldtitle->getNamespace() ), $wgWikilogNamespaces ); $newwl = in_array( ( $newns = $newtitle->getNamespace() ), $wgWikilogNamespaces ); if ( $oldwl && $newwl ) { # Moving title between wikilog namespaces. # Update wikilog data. wfDebug( __METHOD__ . ": Moving title between wikilog namespaces " . "($oldns, $newns). Updating wikilog data.\n" ); $wi = Wikilog::getWikilogInfo( $newtitle ); $item = WikilogItem::newFromID( $pageid ); if ( $wi && $wi->isItem() && !$wi->isTalk() && $item ) { $item->mName = $wi->getItemName(); # FIXME: need to reparse due to {{DISPLAYTITLE:...}}. $item->mTitle = $wi->getItemTitle(); $item->mParentName = $wi->getName(); $item->mParentTitle = $wi->getTitle(); $item->mParent = $item->mParentTitle->getArticleId(); $item->saveData(); } } elseif ( $newwl ) { # Moving from normal namespace to wikilog namespace. # Create wikilog data. wfDebug( __METHOD__ . ": Moving from another namespace to wikilog " . "namespace ($oldns, $newns). Creating wikilog data.\n" ); # FIXME: This needs a reparse of the wiki text in order to # populate wikilog metadata. Or forbid this action. } elseif ( $oldwl ) { # Moving from wikilog namespace to normal namespace. # Purge wikilog data. wfDebug( __METHOD__ . ": Moving from wikilog namespace to another " . "namespace ($oldns, $newns). Purging wikilog data.\n" ); $dbw = wfGetDB( DB_MASTER ); $dbw->delete( 'wikilog_wikilogs', array( 'wlw_page' => $pageid ) ); $dbw->delete( 'wikilog_posts', array( 'wlp_page' => $pageid ) ); $dbw->delete( 'wikilog_posts', array( 'wlp_parent' => $pageid ) ); $dbw->delete( 'wikilog_authors', array( 'wla_page' => $pageid ) ); $dbw->delete( 'wikilog_tags', array( 'wlt_page' => $pageid ) ); // $dbw->delete( 'wikilog_comments', array( 'wlc_post' => $pageid ) ); # FIXME: Decide what to do with the comments. } return true; }