[ Index ] |
PHP Cross Reference of MediaWiki-1.24.0 |
[Source view] [Print] [Project Stats]
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
File Size: | 1132 lines (32 kb) |
Included or required: | 9 times |
Referenced: | 1 time |
Includes or requires: | 0 files |
LanguageConverter:: (33 methods):
__construct()
getVariants()
getVariantFallbacks()
getConvRuleTitle()
getPreferredVariant()
getDefaultVariant()
validateVariant()
getURLVariant()
getUserVariant()
getHeaderVariant()
autoConvert()
translate()
autoConvertToAllVariants()
applyManualConv()
convertTitle()
convertNamespace()
convert()
convertTo()
recursiveConvertTopLevel()
recursiveConvertRule()
findVariantLink()
getExtraHashOptions()
guessVariant()
loadDefaultTables()
loadTables()
postLoadTables()
reloadTables()
parseCachedTable()
markNoConversion()
convertCategoryKey()
OnPageContentSaveComplete()
armourMath()
getVarSeparatorPattern()
Class: LanguageConverter - X-Ref
Base class for language conversion.__construct( $langobj, $maincode, $variants = array() X-Ref |
Constructor param: Language $langobj param: string $maincode The main language code of this language param: array $variants The supported variants of this language param: array $variantfallbacks The fallback language of each variant param: array $flags Defining the custom strings that maps to the flags param: array $manualLevel Limit for supported variants |
getVariants() X-Ref |
Get all valid variants. Call this instead of using $this->mVariants directly. return: array Contains all valid variants |
getVariantFallbacks( $variant ) X-Ref |
In case some variant is not defined in the markup, we need to have some fallback. For example, in zh, normally people will define zh-hans and zh-hant, but less so for zh-sg or zh-hk. when zh-sg is preferred but not defined, we will pick zh-hans in this case. Right now this is only used by zh. param: string $variant The language code of the variant return: string|array The code of the fallback language or the |
getConvRuleTitle() X-Ref |
Get the title produced by the conversion rule. return: string The converted title text |
getPreferredVariant() X-Ref |
Get preferred language variant. return: string The preferred language code |
getDefaultVariant() X-Ref |
Get default variant. This function would not be affected by user's settings return: string The default variant code |
validateVariant( $variant = null ) X-Ref |
Validate the variant param: string $variant The variant to validate return: mixed Returns the variant if it is valid, null otherwise |
getURLVariant() X-Ref |
Get the variant specified in the URL return: mixed Variant if one found, false otherwise. |
getUserVariant() X-Ref |
Determine if the user has a variant set. return: mixed Variant if one found, false otherwise. |
getHeaderVariant() X-Ref |
Determine the language variant from the Accept-Language header. return: mixed Variant if one found, false otherwise. |
autoConvert( $text, $toVariant = false ) X-Ref |
Dictionary-based conversion. This function would not parse the conversion rules. If you want to parse rules, try to use convert() or convertTo(). param: string $text The text to be converted param: bool|string $toVariant The target language code return: string The converted text |
translate( $text, $variant ) X-Ref |
Translate a string to a variant. Doesn't parse rules or do any of that other stuff, for that use convert() or convertTo(). param: string $text Text to convert param: string $variant Variant language code return: string Translated text |
autoConvertToAllVariants( $text ) X-Ref |
Call translate() to convert text to all valid variants. param: string $text The text to be converted return: array Variant => converted text |
applyManualConv( $convRule ) X-Ref |
Apply manual conversion rules. param: ConverterRule $convRule |
convertTitle( $title ) X-Ref |
Auto convert a Title object to a readable string in the preferred variant. param: Title $title A object of Title return: string Converted title text |
convertNamespace( $index, $variant = null ) X-Ref |
Get the namespace display name in the preferred variant. param: int $index Namespace id param: string|null $variant Variant code or null for preferred variant return: string Namespace name for display |
convert( $text ) X-Ref |
Convert text to different variants of a language. The automatic conversion is done in autoConvert(). Here we parse the text marked with -{}-, which specifies special conversions of the text that can not be accomplished in autoConvert(). Syntax of the markup: -{code1:text1;code2:text2;...}- or -{flags|code1:text1;code2:text2;...}- or -{text}- in which case no conversion should take place for text param: string $text Text to be converted return: string Converted text |
convertTo( $text, $variant ) X-Ref |
Same as convert() except a extra parameter to custom variant. param: string $text Text to be converted param: string $variant The target variant code return: string Converted text |
recursiveConvertTopLevel( $text, $variant, $depth = 0 ) X-Ref |
Recursively convert text on the outside. Allow to use nested markups to custom rules. param: string $text Text to be converted param: string $variant The target variant code param: int $depth Depth of recursion return: string Converted text |
recursiveConvertRule( $text, $variant, &$startPos, $depth = 0 ) X-Ref |
Recursively convert text on the inside. param: string $text Text to be converted param: string $variant The target variant code param: int $startPos param: int $depth Depth of recursion return: string Converted text |
findVariantLink( &$link, &$nt, $ignoreOtherCond = false ) X-Ref |
If a language supports multiple variants, it is possible that non-existing link in one variant actually exists in another variant. This function tries to find it. See e.g. LanguageZh.php The input parameters may be modified upon return param: string &$link The name of the link param: Title &$nt The title object of the link param: bool $ignoreOtherCond To disable other conditions when |
getExtraHashOptions() X-Ref |
Returns language specific hash options. return: string |
guessVariant( $text, $variant ) X-Ref |
Guess if a text is written in a variant. This should be implemented in subclasses. author: Nikola Smolenski <[email protected]> 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 |
loadDefaultTables() X-Ref |
Load default conversion tables. This method must be implemented in derived class. |
loadTables( $fromCache = true ) X-Ref |
Load conversion tables either from the cache or the disk. param: bool $fromCache Load from memcached? Defaults to true. |
postLoadTables() X-Ref |
No description |
reloadTables() X-Ref |
Reload the conversion tables. |
parseCachedTable( $code, $subpage = '', $recursive = true ) X-Ref |
Parse the conversion table stored in the cache. The tables should be in blocks of the following form: -{ word => word ; word => word ; ... }- To make the tables more manageable, subpages are allowed and will be parsed recursively if $recursive == true. param: string $code Language code param: string $subpage Subpage name param: bool $recursive Parse subpages recursively? Defaults to true. return: array |
markNoConversion( $text, $noParse = false ) X-Ref |
Enclose a string with the "no conversion" tag. This is used by various functions in the Parser. param: string $text Text to be tagged for no conversion param: bool $noParse Unused return: string The tagged text |
convertCategoryKey( $key ) X-Ref |
Convert the sorting key for category links. This should make different keys that are variants of each other map to the same key. param: string $key return: string |
OnPageContentSaveComplete( $page, $user, $content, $summary, $isMinor,$isWatch, $section, $flags, $revision ) X-Ref |
Hook to refresh the cache of conversion tables when MediaWiki:Conversiontable* is updated. param: WikiPage $page param: User $user User object for the current user param: Content $content New page content param: string $summary Edit summary of the edit param: bool $isMinor Was the edit marked as minor? param: null $isWatch Unused. param: null $section Unused. param: int $flags Bitfield param: Revision|null $revision New Revision object or null return: bool True |
armourMath( $text ) X-Ref |
Armour rendered math against conversion. Escape special chars in parsed math text. (in most cases are img elements) param: string $text Text to armour against conversion return: string Armoured text where { and } have been converted to |
getVarSeparatorPattern() X-Ref |
Get the cached separator pattern for ConverterRule::parseRules() return: string |
Generated: Fri Nov 28 14:03:12 2014 | Cross-referenced by PHPXref 0.7.1 |