MediaWiki  master
ConverterRule Class Reference

The rules used for language conversion, this processes the rules extracted by Parser from the -{ }- wikitext syntax. More...

Collaboration diagram for ConverterRule:

Public Member Functions

 __construct ( $text, LanguageConverter $converter)
 
 getConvTable ()
 Get conversion table. More...
 
 getDisplay ()
 Get display text on markup -{...}-. More...
 
 getFlags ()
 Get conversion flags. More...
 
 getRules ()
 Get conversion rules string. More...
 
 getRulesAction ()
 Return how deal with conversion rules. More...
 
 getTextInBidtable ( $variants)
 Check if variants array in convert array. More...
 
 getTitle ()
 Get converted title. More...
 
 hasRules ()
 Checks if there are conversion rules. More...
 
 parse ( $variant=null)
 Parse rules and flags. More...
 

Public Attributes

array $mBidtable = []
 of the translation in each variant More...
 
LanguageConverter $mConverter
 
 $mConvTable = []
 
 $mFlags = []
 
 $mRuleDisplay = ''
 
string $mRules = ''
 the text of the rules More...
 
 $mRulesAction = 'none'
 
 $mRuleTitle = false
 
string $mText
 original text in -{text}- More...
 
array $mUnidtable = []
 of the translation in each variant More...
 
 $mVariantFlags = []
 

Private Member Functions

 generateConvTable ()
 Generate conversion table for all text. More...
 
 getRuleConvertedStr ( $variant)
 Parse rules conversion. More...
 
 getRuleConvertedTitle ( $variant)
 Similar to getRuleConvertedStr(), but this prefers to use original page title if $variant === $this->mConverter->mMainLanguageCode and may return false in this case (so this title conversion rule will be ignored and the original title is shown). More...
 
 getRulesDesc ()
 
 parseFlags ()
 Parse flags with syntax -{FLAG| ... More...
 
 parseRules ()
 Generate conversion table. More...
 

Detailed Description

The rules used for language conversion, this processes the rules extracted by Parser from the -{ }- wikitext syntax.

Definition at line 28 of file ConverterRule.php.

Constructor & Destructor Documentation

◆ __construct()

ConverterRule::__construct (   $text,
LanguageConverter  $converter 
)
Parameters
string$textThe text between -{ and }-
LanguageConverter$converter

Definition at line 60 of file ConverterRule.php.

Member Function Documentation

◆ generateConvTable()

ConverterRule::generateConvTable ( )
private

Generate conversion table for all text.

Definition at line 292 of file ConverterRule.php.

References $mBidtable, $mUnidtable, and getTextInBidtable().

Referenced by parse().

◆ getConvTable()

ConverterRule::getConvTable ( )

Get conversion table.

(bidirectional and unidirectional conversion table)

Returns
array

Definition at line 492 of file ConverterRule.php.

References $mConvTable.

Referenced by LanguageConverter\applyManualConv().

◆ getDisplay()

ConverterRule::getDisplay ( )

Get display text on markup -{...}-.

Returns
string

Definition at line 467 of file ConverterRule.php.

References $mRuleDisplay.

◆ getFlags()

ConverterRule::getFlags ( )

Get conversion flags.

Returns
array

Definition at line 508 of file ConverterRule.php.

References $mFlags.

◆ getRuleConvertedStr()

ConverterRule::getRuleConvertedStr (   $variant)
private

Parse rules conversion.

Parameters
string$variant
Returns
string

Definition at line 228 of file ConverterRule.php.

References $mBidtable, $mRules, $mUnidtable, and getTextInBidtable().

Referenced by getRuleConvertedTitle(), and parse().

◆ getRuleConvertedTitle()

ConverterRule::getRuleConvertedTitle (   $variant)
private

Similar to getRuleConvertedStr(), but this prefers to use original page title if $variant === $this->mConverter->mMainLanguageCode and may return false in this case (so this title conversion rule will be ignored and the original title is shown).

Since
1.22
Parameters
string$variantThe variant code to display page title in
Returns
string|bool The converted title or false if just page name

Definition at line 269 of file ConverterRule.php.

References getRuleConvertedStr(), and getTextInBidtable().

Referenced by parse().

◆ getRules()

ConverterRule::getRules ( )

Get conversion rules string.

Returns
string

Definition at line 500 of file ConverterRule.php.

References $mRules.

◆ getRulesAction()

ConverterRule::getRulesAction ( )

Return how deal with conversion rules.

Returns
string

Definition at line 483 of file ConverterRule.php.

References $mRulesAction.

Referenced by LanguageConverter\applyManualConv().

◆ getRulesDesc()

ConverterRule::getRulesDesc ( )
private
Returns
string

Definition at line 205 of file ConverterRule.php.

Referenced by parse().

◆ getTextInBidtable()

ConverterRule::getTextInBidtable (   $variants)

Check if variants array in convert array.

Parameters
array | string$variantsVariant language code
Returns
string Translated text

Definition at line 71 of file ConverterRule.php.

Referenced by generateConvTable(), getRuleConvertedStr(), and getRuleConvertedTitle().

◆ getTitle()

ConverterRule::getTitle ( )

Get converted title.

Returns
string

Definition at line 475 of file ConverterRule.php.

References $mRuleTitle.

Referenced by LanguageConverter\applyManualConv().

◆ hasRules()

ConverterRule::hasRules ( )

Checks if there are conversion rules.

Returns
bool

Definition at line 459 of file ConverterRule.php.

◆ parse()

ConverterRule::parse (   $variant = null)

Parse rules and flags.

Parameters
string | null$variantVariant language code

Definition at line 350 of file ConverterRule.php.

References $mFlags, $mRules, generateConvTable(), getRuleConvertedStr(), getRuleConvertedTitle(), getRulesDesc(), parseFlags(), parseRules(), true, and wfMessage().

◆ parseFlags()

ConverterRule::parseFlags ( )
private

Parse flags with syntax -{FLAG| ...

}-

Definition at line 87 of file ConverterRule.php.

References $mText, StringUtils\explode(), and true.

Referenced by parse().

◆ parseRules()

ConverterRule::parseRules ( )
private

Generate conversion table.

Definition at line 152 of file ConverterRule.php.

References $mRules.

Referenced by parse().

Member Data Documentation

◆ $mBidtable

array ConverterRule::$mBidtable = []

of the translation in each variant

Definition at line 50 of file ConverterRule.php.

Referenced by generateConvTable(), and getRuleConvertedStr().

◆ $mConverter

LanguageConverter ConverterRule::$mConverter

Definition at line 36 of file ConverterRule.php.

◆ $mConvTable

ConverterRule::$mConvTable = []

Definition at line 46 of file ConverterRule.php.

Referenced by getConvTable().

◆ $mFlags

ConverterRule::$mFlags = []

Definition at line 44 of file ConverterRule.php.

Referenced by getFlags(), and parse().

◆ $mRuleDisplay

ConverterRule::$mRuleDisplay = ''

Definition at line 37 of file ConverterRule.php.

Referenced by getDisplay().

◆ $mRules

string ConverterRule::$mRules = ''

the text of the rules

Definition at line 42 of file ConverterRule.php.

Referenced by getRuleConvertedStr(), getRules(), parse(), and parseRules().

◆ $mRulesAction

ConverterRule::$mRulesAction = 'none'

Definition at line 43 of file ConverterRule.php.

Referenced by getRulesAction().

◆ $mRuleTitle

ConverterRule::$mRuleTitle = false

Definition at line 38 of file ConverterRule.php.

Referenced by getTitle().

◆ $mText

string ConverterRule::$mText

original text in -{text}-

Definition at line 32 of file ConverterRule.php.

Referenced by parseFlags().

◆ $mUnidtable

array ConverterRule::$mUnidtable = []

of the translation in each variant

Definition at line 54 of file ConverterRule.php.

Referenced by generateConvTable(), and getRuleConvertedStr().

◆ $mVariantFlags

ConverterRule::$mVariantFlags = []

Definition at line 45 of file ConverterRule.php.


The documentation for this class was generated from the following file: