MediaWiki REL1_37
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.
 
 getDisplay ()
 Get display text on markup -{...}-.
 
 getFlags ()
 Get conversion flags.
 
 getRules ()
 Get conversion rules string.
 
 getRulesAction ()
 Return how deal with conversion rules.
 
 getTextInBidtable ( $variants)
 Check if variants array in convert array.
 
 getTitle ()
 Get converted title.
 
 hasRules ()
 Checks if there are conversion rules.
 
 parse ( $variant=null)
 Parse rules and flags.
 

Public Attributes

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

Private Member Functions

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

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->getMainCode() 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: