* If you want to parse rules, try to use convert() or
* convertTo().
*
- * @param $text String: the text to be converted
- * @param $toVariant String: the target language code
- * @return String: the converted text
+ * @param $text String the text to be converted
+ * @param $toVariant bool|string the target language code
+ * @return String the converted text
*/
public function autoConvert( $text, $toVariant = false ) {
wfProfileIn( __METHOD__ );
}
}
- if( $this->guessVariant( $text, $toVariant ) ) {
- return $text;
- }
-
/* we convert everything except:
1. HTML markups (anything between < and >)
2. HTML entities
*
* @param $text String: the text to be converted
* @return Array: variant => converted text
- * @deprecated Use autoConvertToAllVariants() instead
+ * @deprecated since 1.17 Use autoConvertToAllVariants() instead
*/
public function convertLinkToAllVariants( $text ) {
return $this->autoConvertToAllVariants( $text );
/**
* Apply manual conversion rules.
*
- * @param $convRule Object: Object of ConverterRule
+ * @param $convRule ConverterRule Object of ConverterRule
*/
protected function applyManualConv( $convRule ) {
// Use syntax -{T|zh-cn:TitleCN; zh-tw:TitleTw}- to custom
* Auto convert a Title object to a readable string in the
* preferred variant.
*
- * @param $title Object: a object of Title
+ * @param $title Title a object of Title
* @return String: converted title text
*/
public function convertTitle( $title ) {
$text = '';
} else {
// first let's check if a message has given us a converted name
- $nsConvKey = 'conversion-ns' . $index;
- if ( !wfEmptyMsg( $nsConvKey ) ) {
- $text = wfMsgForContentNoTrans( $nsConvKey );
+ $nsConvMsg = wfMessage( 'conversion-ns' . $index )->inContentLanguage();
+ if ( $nsConvMsg->exists() ) {
+ $text = $nsConvMsg->plain();
} else {
// the message does not exist, try retrieve it from the current
// variant's namespace names.
*/
public function convertTo( $text, $variant ) {
global $wgDisableLangConversion;
- if ( $wgDisableLangConversion || $this->guessVariant( $text, $variant ) ) {
+ if ( $wgDisableLangConversion ) {
return $text;
}
return $this->recursiveConvertTopLevel( $text, $variant );
*
* @param $text String: text to be converted
* @param $variant String: the target variant code
+ * @param $startPos int
* @param $depth Integer: depth of recursion
+ *
* @return String: converted text
*/
protected function recursiveConvertRule( $text, $variant, &$startPos, $depth = 0 ) {
/**
* Returns language specific hash options.
+ *
+ * @return string
*/
public function getExtraHashOptions() {
$variant = $this->getPreferredVariant();
return '!' . $variant;
}
- /**
- * Guess if a text is written in a variant. This should be implemented in subclasses.
- *
- * @param string $text the text to be checked
- * @param string $variant language code of the variant to be checked for
- * @return bool true if $text appears to be written in $variant, false if not
- *
- * @author Nikola Smolenski <smolensk@eunet.rs>
- * @since 1.18
- */
- public function guessVariant($text, $variant) {
- return false;
- }
-
/**
* Load default conversion tables.
* This method must be implemented in derived class.
*/
function loadDefaultTables() {
$name = get_class( $this );
- wfDie( "Must implement loadDefaultTables() method in class $name" );
+ throw new MWException( "Must implement loadDefaultTables() method in class $name" );
}
/**
* @param $code String: language code
* @param $subpage String: subpage name
* @param $recursive Boolean: parse subpages recursively? Defaults to true.
+ *
+ * @return array
*/
function parseCachedTable( $code, $subpage = '', $recursive = true ) {
static $parsed = array();
if ( strpos( $code, '/' ) === false ) {
$txt = MessageCache::singleton()->get( 'Conversiontable', true, $code );
if ( $txt === false ) {
- # FIXME: this method doesn't seem to be expecting
+ # @todo FIXME: This method doesn't seem to be expecting
# this possible outcome...
$txt = '<Conversiontable>';
}
/**
* Convert the sorting key for category links. This should make different
* keys that are variants of each other map to the same key.
+ *
+ * @param $key string
+ *
+ * @return string
*/
function convertCategoryKey( $key ) {
return $key;
* MediaWiki:Conversiontable* is updated.
* @private
*
- * @param $article Object: Article object
+ * @param $article Article object
* @param $user Object: User object for the current user
* @param $text String: article text (?)
* @param $summary String: edit summary of the edit
/**
* @private
+ *
+ * @return string
*/
function getRulesDesc() {
$codesep = $this->mConverter->mDescCodeSep;
/**
* Parse rules conversion.
* @private
+ *
+ * @param $variant
+ *
+ * @return string
*/
function getRuleConvertedStr( $variant ) {
$bidtable = $this->mBidtable;
/**
* Get display text on markup -{...}-
+ * @return string
*/
public function getDisplay() {
return $this->mRuleDisplay;
/**
* Get converted title.
+ * @return string
*/
public function getTitle() {
return $this->mRuleTitle;
/**
* Return how deal with conversion rules.
+ * @return string
*/
public function getRulesAction() {
return $this->mRulesAction;
/**
* Get conversion table. (bidirectional and unidirectional
* conversion table)
+ * @return array
*/
public function getConvTable() {
return $this->mConvTable;
/**
* Get conversion rules string.
+ * @return string
*/
public function getRules() {
return $this->mRules;
/**
* Get conversion flags.
+ * @return array
*/
public function getFlags() {
return $this->mFlags;