r80643 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r80642‎ | r80643 | r80644 >
Date:20:20, 20 January 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Attempt to fix i18n issue
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_QueryParser.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QueryParser.php
@@ -21,14 +21,20 @@
2222
2323 protected $m_categoryprefix; // cache label of category namespace . ':'
2424 protected $m_conceptprefix; // cache label of concept namespace . ':'
 25+ protected $m_categoryPrefixCannonical; // cache canonnical label of category namespace . ':'
 26+ protected $m_conceptPrefixCannonical; // cache canonnical label of concept namespace . ':'
2527 protected $m_queryfeatures; // query features to be supported, format similar to $smwgQFeatures
2628
2729 public function __construct( $queryfeatures = false ) {
2830 global $wgContLang, $smwgQFeatures;
 31+
2932 $this->m_categoryprefix = $wgContLang->getNsText( NS_CATEGORY ) . ':';
3033 $this->m_conceptprefix = $wgContLang->getNsText( SMW_NS_CONCEPT ) . ':';
 34+ $this->m_categoryPrefixCannonical = 'Category:';
 35+ $this->m_conceptPrefixCannonical = 'Concept:';
 36+
3137 $this->m_defaultns = null;
32 - $this->m_queryfeatures = $queryfeatures === false ? $smwgQFeatures:$queryfeatures;
 38+ $this->m_queryfeatures = $queryfeatures === false ? $smwgQFeatures : $queryfeatures;
3339 }
3440
3541 /**
@@ -228,9 +234,11 @@
229235 // block could be a Category-statement, fixed object, or property statement.
230236 $chunk = $this->readChunk( '', true, false ); // NOTE: untrimmed, initial " " escapes prop. chains
231237
232 - if ( ( smwfNormalTitleText( $chunk ) == $this->m_categoryprefix ) || // category statement or
233 - ( smwfNormalTitleText( $chunk ) == $this->m_conceptprefix ) ) { // concept statement
234 - return $this->getClassDescription( $setNS, ( smwfNormalTitleText( $chunk ) == $this->m_categoryprefix ) );
 238+ if ( in_array( smwfNormalTitleText( $chunk ),
 239+ array( $this->m_categoryprefix, $this->m_conceptprefix, $this->m_categoryPrefixCannonical, $this->m_conceptPrefixCannonical ) ) ) {
 240+ return $this->getClassDescription( $setNS, (
 241+ smwfNormalTitleText( $chunk ) == $this->m_categoryprefix || smwfNormalTitleText( $chunk ) == $this->m_categoryPrefixCannonical
 242+ ) );
235243 } else { // fixed subject, namespace restriction, property query, or subquery
236244 $sep = $this->readChunk( '', false ); // do not consume hit, "look ahead"
237245
@@ -513,8 +521,10 @@
514522 */
515523 protected function readChunk( $stoppattern = '', $consume = true, $trim = true ) {
516524 if ( $stoppattern == '' ) {
517 - $stoppattern = '\[\[|\]\]|::|:=|<q>|<\/q>|^' . $this->m_categoryprefix .
518 - '|^' . $this->m_conceptprefix . '|\|\||\|';
 525+ $stoppattern = '\[\[|\]\]|::|:=|<q>|<\/q>' .
 526+ '|^' . $this->m_categoryprefix . '|^' . $this->m_categoryPrefixCannonical .
 527+ '|^' . $this->m_conceptprefix . '|^' . $this->m_conceptPrefixCannonical .
 528+ '|\|\||\|';
519529 }
520530 $chunks = preg_split( '/[\s]*(' . $stoppattern . ')/u', $this->m_curstring, 2, PREG_SPLIT_DELIM_CAPTURE );
521531 if ( count( $chunks ) == 1 ) { // no matches anymore, strip spaces and finish

Status & tagging log