Class to parse translatable wiki pages. More...
Public Member Functions | |
getTitle () | |
Returns the title for this translatable page. | |
getText () | |
Returns the text for this translatable page. | |
getRevision () | |
Revision is null if object was constructed using newFromText. | |
setRevision ($revision) | |
Manually set a revision number to use loading page text. | |
getSourceLanguageCode () | |
Returns the source language of this translatable page. | |
getMessageGroupId () | |
Returns MessageGroup id (to be) used for translating this page. | |
getMessageGroup () | |
Returns MessageGroup used for translating this page. | |
getPageDisplayTitle ($code) | |
Get translated page title. | |
getParse () | |
Returns a TPParse object which represents the parsed page. | |
addMarkedTag ($revision, $value=null) | |
Adds a tag which indicates that this page is suitable for translation. | |
addReadyTag ($revision) | |
Adds a tag which indicates that this page source is ready for marking for translation. | |
getMarkedTag () | |
Returns the latest revision which has marked tag, if any. | |
getReadyTag () | |
Returns the latest revision which has ready tag, if any. | |
unmarkTranslatablePage () | |
Removes all page translation feature data from the database. | |
getTranslationUrl ($code=false) | |
Produces a link to translation view of a translation page. | |
getMarkedRevs () | |
getTranslationUnitPages ($set= 'active', $code=false) | |
Returns a list of translation unit pages. | |
getTranslationPercentages () | |
getTransRev ($suffix) | |
Static Public Member Functions | |
static | newFromText (Title $title, $text) |
Constructs a translatable page from given text. | |
static | newFromRevision (Title $title, $revision) |
Constructs a translatable page from given revision. | |
static | newFromTitle (Title $title) |
Constructs a translatable page from title. | |
static | getMessageGroupIdFromTitle (Title $title) |
Constructs MessageGroup id for any title. | |
static | armourNowiki (&$holders, $text) |
static | unArmourNowiki ($holders, $text) |
static | isTranslationPage (Title $title) |
static | isSourcePage (Title $title) |
static | getTranslatablePages () |
Get a list of page ids where the latest revision is either tagged or marked. | |
Protected Member Functions | |
__construct (Title $title) | |
sectionise (&$sections, $text) | |
Splits the content marked with <translate> tags into sections, which are separated with with two or more newlines. | |
shakeSection ($content) | |
Checks if this section already contains a section marker. | |
addTag ($tag, $revision, $value=null) | |
getTag ($tag, $dbt=DB_SLAVE) | |
getSections () | |
Returns a list section ids. | |
Static Protected Member Functions | |
static | index_replace ($string, $rep, $start, $end) |
static | changeTitleText (Title $title, $text) |
Protected Attributes | |
$title = null | |
Title of the page. | |
$text = null | |
Text contents of the page. | |
$revision = null | |
$source = null | |
From which source this object was constructed. | |
$init = false | |
Whether the page contents is already loaded. | |
$displayTitle = 'Page display title' | |
Name of the section which contains the translated page title. | |
$cachedParse | |
Static Protected Attributes | |
static | $tagCache = array() |
Class to parse translatable wiki pages.
Definition at line 15 of file TranslatablePage.php.
TranslatablePage::__construct | ( | Title $ | title | ) | [protected] |
Title | $title Title object for the page |
Definition at line 54 of file TranslatablePage.php.
TranslatablePage::addMarkedTag | ( | $ | revision, | |
$ | value = null | |||
) |
Adds a tag which indicates that this page is suitable for translation.
integer | $revision | |
null|string | $value |
Definition at line 446 of file TranslatablePage.php.
TranslatablePage::addReadyTag | ( | $ | revision | ) |
Adds a tag which indicates that this page source is ready for marking for translation.
integer | $revision |
Definition at line 456 of file TranslatablePage.php.
TranslatablePage::addTag | ( | $ | tag, | |
$ | revision, | |||
$ | value = null | |||
) | [protected] |
string | $tag Tag name | |
int | $revision Revision ID to add tag for | |
mixed | $value Optional. Value to be stored as serialized with | as separator |
MWException |
Definition at line 466 of file TranslatablePage.php.
Referenced by addMarkedTag(), and addReadyTag().
static TranslatablePage::armourNowiki | ( | &$ | holders, | |
$ | text | |||
) | [static] |
array | $holders | |
string | $text |
Definition at line 324 of file TranslatablePage.php.
Referenced by getParse().
static TranslatablePage::changeTitleText | ( | Title $ | title, | |
$ | text | |||
) | [static, protected] |
Definition at line 792 of file TranslatablePage.php.
Referenced by isTranslationPage().
TranslatablePage::getMarkedRevs | ( | ) |
TranslatablePage::getMarkedTag | ( | ) |
Returns the latest revision which has marked tag, if any.
Definition at line 495 of file TranslatablePage.php.
Referenced by getText().
TranslatablePage::getMessageGroup | ( | ) |
Returns MessageGroup used for translating this page.
It may still be empty if the page has not been ever marked.
Definition at line 206 of file TranslatablePage.php.
Referenced by getPageDisplayTitle(), and getTranslationPercentages().
TranslatablePage::getMessageGroupId | ( | ) |
Returns MessageGroup id (to be) used for translating this page.
Definition at line 188 of file TranslatablePage.php.
Referenced by SpecialPageTranslation::checkInput(), getMessageGroup(), getTranslationPercentages(), getTranslationUrl(), SpecialPageTranslation::handlePriorityLanguages(), SpecialPageTranslation::priorityLanguagesForm(), and SpecialPageTranslation::showSuccess().
static TranslatablePage::getMessageGroupIdFromTitle | ( | Title $ | title | ) | [static] |
Constructs MessageGroup id for any title.
Title | $title |
Definition at line 197 of file TranslatablePage.php.
Referenced by SpecialPageTranslation::classifyPages(), SpecialPageTranslation::execute(), getMessageGroupId(), and MessageGroups::loadGroupDefinitions().
TranslatablePage::getPageDisplayTitle | ( | $ | code | ) |
Get translated page title.
string | $code Language code. |
Definition at line 215 of file TranslatablePage.php.
TranslatablePage::getParse | ( | ) |
Returns a TPParse object which represents the parsed page.
TPException |
Definition at line 228 of file TranslatablePage.php.
Referenced by SpecialPageTranslation::checkInput(), and SpecialPageTranslation::showSuccess().
TranslatablePage::getReadyTag | ( | ) |
Returns the latest revision which has ready tag, if any.
Definition at line 503 of file TranslatablePage.php.
TranslatablePage::getRevision | ( | ) |
Revision is null if object was constructed using newFromText.
Definition at line 158 of file TranslatablePage.php.
TranslatablePage::getSections | ( | ) | [protected] |
Returns a list section ids.
Definition at line 636 of file TranslatablePage.php.
Referenced by getTranslationUnitPages().
TranslatablePage::getSourceLanguageCode | ( | ) |
Returns the source language of this translatable page.
In other words the language in which the page without language code is written.
Definition at line 180 of file TranslatablePage.php.
Referenced by getTranslationPercentages(), and SpecialPageTranslation::getTranslationUnitJobs().
TranslatablePage::getTag | ( | $ | tag, | |
$ | dbt = DB_SLAVE | |||
) | [protected] |
$tag | ||
int | $dbt |
Definition at line 533 of file TranslatablePage.php.
Referenced by getMarkedTag(), and getReadyTag().
TranslatablePage::getText | ( | ) |
Returns the text for this translatable page.
MWException |
Definition at line 130 of file TranslatablePage.php.
Referenced by getParse().
TranslatablePage::getTitle | ( | ) |
Returns the title for this translatable page.
Definition at line 121 of file TranslatablePage.php.
Referenced by addTag(), getMarkedRevs(), getMessageGroupId(), getPageDisplayTitle(), getParse(), getSections(), getSourceLanguageCode(), getTag(), getText(), SpecialPageTranslation::getTranslationUnitJobs(), getTranslationUnitPages(), SpecialPageTranslation::handlePriorityLanguages(), SpecialPageTranslation::showSuccess(), unmarkTranslatablePage(), and PageTranslationHooks::updateTranslationPage().
static TranslatablePage::getTranslatablePages | ( | ) | [static] |
Get a list of page ids where the latest revision is either tagged or marked.
Definition at line 820 of file TranslatablePage.php.
Referenced by isSourcePage().
TranslatablePage::getTranslationPercentages | ( | ) |
Definition at line 709 of file TranslatablePage.php.
Referenced by PageTranslationHooks::updateTranslationPage().
TranslatablePage::getTranslationUnitPages | ( | $ | set = 'active' , |
|
$ | code = false | |||
) |
Returns a list of translation unit pages.
string | $set Can be either 'all', or 'active' | |
string|bool | $code Only list unit pages in given language. |
Definition at line 656 of file TranslatablePage.php.
TranslatablePage::getTranslationUrl | ( | $ | code = false |
) |
Produces a link to translation view of a translation page.
string|bool | $code MediaWiki language code. Default: false. |
Definition at line 567 of file TranslatablePage.php.
TranslatablePage::getTransRev | ( | $ | suffix | ) |
static TranslatablePage::index_replace | ( | $ | string, | |
$ | rep, | |||
$ | start, | |||
$ | end | |||
) | [static, protected] |
string | $string | |
string | $rep | |
int | $start | |
int | $end |
Definition at line 356 of file TranslatablePage.php.
Referenced by getParse().
static TranslatablePage::isSourcePage | ( | Title $ | title | ) | [static] |
Title | $title |
Definition at line 800 of file TranslatablePage.php.
Referenced by PageTranslationHooks::disableDelete(), SpecialPageTranslationDeletePage::execute(), PageTranslationHooks::injectCss(), TranslateEditAddons::intro(), and PageTranslationHooks::replaceSubtitle().
static TranslatablePage::isTranslationPage | ( | Title $ | title | ) | [static] |
Title | $title |
Definition at line 760 of file TranslatablePage.php.
Referenced by SpecialPageTranslationMovePage::checkMoveBlockers(), PageTranslationHooks::disableDelete(), SpecialPageTranslationDeletePage::execute(), PageTranslationHooks::injectCss(), PageTranslationHooks::languages(), PageTranslationHooks::onPageContentLanguage(), SpecialPageTranslationMovePage::performAction(), SpecialPageTranslationDeletePage::performAction(), PageTranslationHooks::preventDirectEditing(), PageTranslationHooks::renderTagPage(), PageTranslationHooks::replaceSubtitle(), TranslateRenderJob::run(), SpecialPageTranslationMovePage::showConfirmation(), SpecialPageTranslationDeletePage::showConfirmation(), PageTranslationHooks::translatablePageHeader(), PageTranslationHooks::translateTab(), and PageTranslationHooks::translationPageHeader().
static TranslatablePage::newFromRevision | ( | Title $ | title, | |
$ | revision | |||
) | [static] |
Constructs a translatable page from given revision.
The revision must belong to the title given or unspecified behavior will happen.
Title | $title | |
integer | $revision Revision number |
MWException |
Definition at line 88 of file TranslatablePage.php.
Referenced by SpecialPageTranslation::execute(), and PageTranslationTaggingText::testTranslationPageRestrictions().
static TranslatablePage::newFromText | ( | Title $ | title, | |
$ | text | |||
) | [static] |
Constructs a translatable page from given text.
Some functions will fail unless you set revision parameter manually.
Title | $title | |
string | $text |
Definition at line 70 of file TranslatablePage.php.
Referenced by PageTranslationHooks::renderTagPage(), TPParseTest::testGetTranslationPageText(), PageTranslationParserTest::testParsing(), PageTranslationHooks::tpSyntaxCheck(), and PageTranslationHooks::tpSyntaxError().
static TranslatablePage::newFromTitle | ( | Title $ | title | ) | [static] |
Constructs a translatable page from title.
The text of last marked revision is loaded when neded.
Title | $title |
Definition at line 108 of file TranslatablePage.php.
Referenced by PageTranslationHooks::addTranstag(), SpecialPageTranslationMovePage::execute(), SpecialPageTranslationDeletePage::execute(), SpecialPageTranslation::execute(), getText(), isTranslationPage(), PageTranslationHooks::languages(), newFromRevision(), PageTranslationHooks::onSectionSave(), SpecialPageTranslationMovePage::performAction(), TranslateDeleteJob::run(), PageTranslationHooks::sourceExport(), PageTranslationHooks::sourcePageHeader(), PageTranslationTaggingText::testNormalPage(), PageTranslationTaggingText::testTranslatablePage(), PageTranslationTaggingText::testTranslatablePageWithMarked(), and PageTranslationHooks::updateTranstagOnNullRevisions().
TranslatablePage::sectionise | ( | &$ | sections, | |
$ | text | |||
) | [protected] |
Splits the content marked with <translate> tags into sections, which are separated with with two or more newlines.
Extra whitespace is captured in the template and not included in the sections.
array | $sections Array of placeholder => TPSection. | |
string | $text Contents of one pair of <translate> tags. |
Definition at line 368 of file TranslatablePage.php.
Referenced by getParse().
TranslatablePage::setRevision | ( | $ | revision | ) |
Manually set a revision number to use loading page text.
integer | $revision |
Definition at line 166 of file TranslatablePage.php.
TranslatablePage::shakeSection | ( | $ | content | ) | [protected] |
Checks if this section already contains a section marker.
If there is not, a new one will be created. Marker will have the value of -1, which will later be replaced with a real value.
May throw a TPException if there is error with existing section markers.
string | $content Content of one section |
TPException |
Definition at line 398 of file TranslatablePage.php.
Referenced by sectionise().
static TranslatablePage::unArmourNowiki | ( | $ | holders, | |
$ | text | |||
) | [static] |
$holders | ||
string | $text |
Definition at line 341 of file TranslatablePage.php.
Referenced by getParse().
TranslatablePage::unmarkTranslatablePage | ( | ) |
Removes all page translation feature data from the database.
Does not remove translated sections or translation pages.
Definition at line 511 of file TranslatablePage.php.
TranslatablePage::$cachedParse [protected] |
Definition at line 49 of file TranslatablePage.php.
TranslatablePage::$displayTitle = 'Page display title' [protected] |
Name of the section which contains the translated page title.
Definition at line 47 of file TranslatablePage.php.
TranslatablePage::$init = false [protected] |
Whether the page contents is already loaded.
Definition at line 42 of file TranslatablePage.php.
TranslatablePage::$revision = null [protected] |
Definition at line 31 of file TranslatablePage.php.
Referenced by addMarkedTag(), addReadyTag(), addTag(), newFromRevision(), and setRevision().
TranslatablePage::$source = null [protected] |
From which source this object was constructed.
Can be: text, revision, title
Definition at line 37 of file TranslatablePage.php.
TranslatablePage::$tagCache = array() [static, protected] |
Definition at line 438 of file TranslatablePage.php.
TranslatablePage::$text = null [protected] |
Text contents of the page.
Definition at line 24 of file TranslatablePage.php.
Referenced by armourNowiki(), changeTitleText(), getParse(), newFromText(), sectionise(), and unArmourNowiki().
TranslatablePage::$title = null [protected] |
Title of the page.
Definition at line 19 of file TranslatablePage.php.