/** * Returns a Wikilog query object given the form options. * @param $opts Form options. * @return Wikilog query object. */ public static function getQuery( $opts ) { global $wgWikilogNamespaces; $query = new WikilogItemQuery(); $query->setPubStatus( $opts['show'] ); if ( $opts['wikilog'] ) { $t = Title::newFromText( $opts['wikilog'] ); if ( $t && in_array( $t->getNamespace(), $wgWikilogNamespaces ) ) { if ( $t->getText() == '*' ) { $query->setNamespace( $t->getNamespace() ); } else { $query->setWikilogTitle( $t ); } } else { $query->setEmpty(); } } if ( ( $t = $opts['category'] ) ) { $query->setCategory( $t ); } if ( ( $t = $opts['author'] ) ) { $query->setAuthor( $t ); } if ( ( $t = $opts['tag'] ) ) { $query->setTag( $t ); } $query->setDate( $opts['year'], $opts['month'], $opts['day'] ); return $query; }
/** * View action handler. */ public function view() { global $wgRequest, $wgOut, $wgMimeType; $query = new WikilogItemQuery( $this->mTitle ); $query->setPubStatus( $wgRequest->getVal( 'show' ) ); # RSS or Atom feed requested. Ignore all other options. if ( ( $feedFormat = $wgRequest->getVal( 'feed' ) ) ) { global $wgWikilogNumArticles; $feed = new WikilogItemFeed( $this->mTitle, $feedFormat, $query, $wgRequest->getInt( 'limit', $wgWikilogNumArticles ) ); return $feed->execute(); } # View selection. $view = $wgRequest->getVal( 'view', 'summary' ); # Query filter options. $query->setCategory( $wgRequest->getVal( 'category' ) ); $query->setAuthor( $wgRequest->getVal( 'author' ) ); $query->setTag( $wgRequest->getVal( 'tag' ) ); $year = $wgRequest->getIntOrNull( 'year' ); $month = $wgRequest->getIntOrNull( 'month' ); $day = $wgRequest->getIntOrNull( 'day' ); $query->setDate( $year, $month, $day ); # Display wiki text page contents. parent::view(); # Create pager object, according to the type of listing. if ( $view == 'archives' ) { $pager = new WikilogArchivesPager( $query ); } else { $pager = new WikilogSummaryPager( $query ); } # Display list of wikilog posts. $body = $pager->getBody(); $body .= $pager->getNavigationBar(); $wgOut->addHTML( Xml::openElement( 'div', array( 'class' => 'wl-wrapper' ) ) ); $wgOut->addHTML( $body ); $wgOut->addHTML( Xml::closeElement( 'div' ) ); # Get query parameter array, for the following links. $qarr = $query->getDefaultQuery(); # Add feed links. $wgOut->setSyndicated(); if ( isset( $qarr['show'] ) ) { $altquery = wfArrayToCGI( array_intersect_key( $qarr, WikilogItemFeed::$paramWhitelist ) ); $wgOut->setFeedAppendQuery( $altquery ); } # Add links for alternate views. foreach ( self::$views as $alt ) { if ( $alt != $view ) { $altquery = wfArrayToCGI( array( 'view' => $alt ), $qarr ); $wgOut->addLink( array( 'rel' => 'alternate', 'href' => $this->mTitle->getLocalURL( $altquery ), 'type' => $wgMimeType, 'title' => wfMsgExt( "wikilog-view-{$alt}", array( 'content', 'parsemag' ) ) ) ); } } }