<?php
/**
* File for magic words
+ * @package MediaWiki
*/
/**
*
* Please avoid reading the data out of one of these objects and then writing
* special case code. If possible, add another match()-like function here.
+ *
+ * @package MediaWiki
*/
class MagicWord {
- /*private*/ var $mId, $mSynonyms, $mCaseSensitive, $mRegex;
- /*private*/ var $mRegexStart, $mBaseRegex, $mVariableRegex;
- /*private*/ var $mModified;
+ /**#@+
+ * @access private
+ */
+ var $mId, $mSynonyms, $mCaseSensitive, $mRegex;
+ var $mRegexStart, $mBaseRegex, $mVariableRegex;
+ var $mModified;
+ /**#@-*/
function MagicWord($id = 0, $syn = '', $cs = false) {
$this->mId = $id;
# Initialises this object with an ID
function load( $id ) {
- global $wgLang;
+ global $wgContLang;
$this->mId = $id;
- $wgLang->getMagic( $this );
+ $wgContLang->getMagic( $this );
}
/**
$this->mBaseRegex = implode( '|', $escSyn );
$case = $this->mCaseSensitive ? '' : 'i';
$this->mRegex = "/{$this->mBaseRegex}/{$case}";
- $this->mRegexStart = "/^{$this->mBaseRegex}/{$case}";
+ $this->mRegexStart = "/^({$this->mBaseRegex})/{$case}";
$this->mVariableRegex = str_replace( "\\$1", "([$variableClass]*?)", $this->mRegex );
$this->mVariableStartToEndRegex = str_replace( "\\$1", "([$variableClass]*?)",
"/^({$this->mBaseRegex})$/{$case}" );
$matchcount = preg_match( $this->getVariableStartToEndRegex(), $text, $matches );
if ( $matchcount == 0 ) {
return NULL;
- } elseif ( count($matches) == 1 ) {
+ } elseif ( count($matches) == 2 ) {
return $matches[0];
} else {
- return $matches[1];
+ return $matches[2];
}
}