コード例 #1
0
	public function execute() {
		$pageSet = $this->getPageSet();
		$pages = $pageSet->getGoodTitles();
		if ( !count( $pages ) ) {
			return true;
		}

		$pageNamespaceId = ProofreadPage::getPageNamespaceId();
		$pageIds = array();
		foreach ( $pages AS $pageId => $title ) {
			if ( $title->getNamespace() == $pageNamespaceId ) {
				$pageIds[] = $pageId;
			}
		}

		if ( !count( $pageIds ) ) {
			return true;
		}

		// Determine the categories defined in MediaWiki: pages
		$qualityCategories = $qualityText = array();
		for ( $i = 0; $i < 5; $i++ ) {
			$cat = Title::makeTitleSafe( NS_CATEGORY, wfMsgForContent( "proofreadpage_quality{$i}_category" ) );
			if ( $cat ) {
				$qualityCategories[$i] = $cat->getPrefixedText();
				$qualityText[$i] = $cat->getText();
			}
		}
		$qualityLevels = array_flip( $qualityCategories );

		// <Reedy> johnduhart, it'd seem sane rather than duplicating the functionality
		$params = new FauxRequest(array(
			'action' => 'query',
			'prop' => 'categories',
			'pageids' => implode( '|', $pageIds ),
			'clcategories' => implode( '|', $qualityCategories ),
			'cllimit' => 'max'
		));

		$api = new ApiMain($params);
		$api->execute();
		$data = $api->getResultData();
		unset( $api );

		$result = $this->getResult();
		foreach ( $data['query']['pages'] as $pageid => $data) {
			$title = $data['categories'][0]['title'];
			if ( !isset( $qualityLevels[ $title ] ) ) {
				continue;
			}

			$pageQuality = $qualityLevels[ $title ];
			$val =  array( 'quality' => $pageQuality, 'quality_text' => $qualityText[ $pageQuality ] );
			$result->addValue( array( 'query', 'pages', $pageid ), 'proofread', $val );
		}
	}
コード例 #2
0
	protected function appendNamespaces() {
		$data = array();

		$index = ProofreadPage::getIndexNamespaceId();
		if ( $index != null ) {
			$data['index']['id'] = $index;
		}

		$page = ProofreadPage::getPageNamespaceId();
		if ( $page != null ) {
			$data['page']['id'] = $page;
		}

		return $this->getResult()->addValue( 'query', 'proofreadnamespaces', $data );
	}
コード例 #3
0
	/**
	 * Return the ordered list of links to ns-0 from an index page
	 */
	private static function parse_index_links( $index_title ) {
		// Instanciate a new parser object to avoid side effects of $parser->replaceVariables
		if( is_null( self::$index_parser ) ) {
			self::$index_parser = new Parser;
		}
		$rev = Revision::newFromTitle( $index_title );
		$text =	$rev->getText();
		$options = new ParserOptions();
		$rtext = self::$index_parser->preprocess( $text, $index_title, $options );
		$text_links_pattern = "/\[\[\s*([^:\|]*?)\s*(\|(.*?)|)\]\]/i";
		preg_match_all( $text_links_pattern, $rtext, $text_links, PREG_PATTERN_ORDER );
		return $text_links;
	}