/**
	 * 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;
	}