TranslatablePage Class Reference
[Page Translation]

Class to parse translatable wiki pages. More...

List of all members.

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

Detailed Description

Class to parse translatable wiki pages.

Definition at line 15 of file TranslatablePage.php.


Constructor & Destructor Documentation

TranslatablePage::__construct ( Title $  title  )  [protected]
Parameters:
Title $title Title object for the page

Definition at line 54 of file TranslatablePage.php.


Member Function Documentation

TranslatablePage::addMarkedTag ( revision,
value = null 
)

Adds a tag which indicates that this page is suitable for translation.

Parameters:
integer $revision
null|string $value

Definition at line 446 of file TranslatablePage.php.

Here is the call graph for this function:

TranslatablePage::addReadyTag ( revision  ) 

Adds a tag which indicates that this page source is ready for marking for translation.

Parameters:
integer $revision

Definition at line 456 of file TranslatablePage.php.

Here is the call graph for this function:

TranslatablePage::addTag ( tag,
revision,
value = null 
) [protected]
Parameters:
string $tag Tag name
int $revision Revision ID to add tag for
mixed $value Optional. Value to be stored as serialized with | as separator
Exceptions:
MWException 

Definition at line 466 of file TranslatablePage.php.

Referenced by addMarkedTag(), and addReadyTag().

Here is the call graph for this function:

static TranslatablePage::armourNowiki ( &$  holders,
text 
) [static]
Parameters:
array $holders
string $text
Returns:
string

Definition at line 324 of file TranslatablePage.php.

Referenced by getParse().

Here is the call graph for this function:

static TranslatablePage::changeTitleText ( Title $  title,
text 
) [static, protected]

Definition at line 792 of file TranslatablePage.php.

Referenced by isTranslationPage().

TranslatablePage::getMarkedRevs (  ) 

Definition at line 580 of file TranslatablePage.php.

Here is the call graph for this function:

TranslatablePage::getMarkedTag (  ) 

Returns the latest revision which has marked tag, if any.

Returns:
integer|bool false

Definition at line 495 of file TranslatablePage.php.

Referenced by getText().

Here is the call graph for this function:

TranslatablePage::getMessageGroup (  ) 

Returns MessageGroup used for translating this page.

It may still be empty if the page has not been ever marked.

Returns:
WikiPageMessageGroup

Definition at line 206 of file TranslatablePage.php.

Referenced by getPageDisplayTitle(), and getTranslationPercentages().

Here is the call graph for this function:

TranslatablePage::getMessageGroupId (  ) 
static TranslatablePage::getMessageGroupIdFromTitle ( Title $  title  )  [static]

Constructs MessageGroup id for any title.

Parameters:
Title $title
Returns:
string

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.

Parameters:
string $code Language code.
Returns:
string|null

Definition at line 215 of file TranslatablePage.php.

Here is the call graph for this function:

TranslatablePage::getParse (  ) 

Returns a TPParse object which represents the parsed page.

Exceptions:
TPException 
Returns:
TPParse

Definition at line 228 of file TranslatablePage.php.

Referenced by SpecialPageTranslation::checkInput(), and SpecialPageTranslation::showSuccess().

Here is the call graph for this function:

TranslatablePage::getReadyTag (  ) 

Returns the latest revision which has ready tag, if any.

Returns:
int|bool false

Definition at line 503 of file TranslatablePage.php.

Here is the call graph for this function:

TranslatablePage::getRevision (  ) 

Revision is null if object was constructed using newFromText.

Returns:
null or integer

Definition at line 158 of file TranslatablePage.php.

TranslatablePage::getSections (  )  [protected]

Returns a list section ids.

Returns:
string[] List of string
Since:
2012-08-06

Definition at line 636 of file TranslatablePage.php.

Referenced by getTranslationUnitPages().

Here is the call graph for this function:

TranslatablePage::getSourceLanguageCode (  ) 

Returns the source language of this translatable page.

In other words the language in which the page without language code is written.

Returns:
string
Since:
2013-01-28

Definition at line 180 of file TranslatablePage.php.

Referenced by getTranslationPercentages(), and SpecialPageTranslation::getTranslationUnitJobs().

Here is the call graph for this function:

TranslatablePage::getTag ( tag,
dbt = DB_SLAVE 
) [protected]
Parameters:
$tag 
int $dbt
Returns:
array|bool False if tag is not found

Definition at line 533 of file TranslatablePage.php.

Referenced by getMarkedTag(), and getReadyTag().

Here is the call graph for this function:

TranslatablePage::getText (  ) 

Returns the text for this translatable page.

Exceptions:
MWException 
Returns:
string

Definition at line 130 of file TranslatablePage.php.

Referenced by getParse().

Here is the call graph for this function:

TranslatablePage::getTitle (  ) 
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().

Here is the call graph for this function:

TranslatablePage::getTranslationPercentages (  ) 
Returns:
array

Definition at line 709 of file TranslatablePage.php.

Referenced by PageTranslationHooks::updateTranslationPage().

Here is the call graph for this function:

TranslatablePage::getTranslationUnitPages ( set = 'active',
code = false 
)

Returns a list of translation unit pages.

Parameters:
string $set Can be either 'all', or 'active'
string|bool $code Only list unit pages in given language.
Returns:
Title[] List of Titles.
Since:
2012-08-06

Definition at line 656 of file TranslatablePage.php.

Here is the call graph for this function:

TranslatablePage::getTranslationUrl ( code = false  ) 

Produces a link to translation view of a translation page.

Parameters:
string|bool $code MediaWiki language code. Default: false.
Returns:
string Relative url

Definition at line 567 of file TranslatablePage.php.

Here is the call graph for this function:

TranslatablePage::getTransRev ( suffix  ) 

Definition at line 741 of file TranslatablePage.php.

Here is the call graph for this function:

static TranslatablePage::index_replace ( string,
rep,
start,
end 
) [static, protected]
Parameters:
string $string
string $rep
int $start
int $end
Returns:
string

Definition at line 356 of file TranslatablePage.php.

Referenced by getParse().

static TranslatablePage::isSourcePage ( Title $  title  )  [static]
Parameters:
Title $title
Returns:
bool

Definition at line 800 of file TranslatablePage.php.

Referenced by PageTranslationHooks::disableDelete(), SpecialPageTranslationDeletePage::execute(), PageTranslationHooks::injectCss(), TranslateEditAddons::intro(), and PageTranslationHooks::replaceSubtitle().

Here is the call graph for this function:

static TranslatablePage::isTranslationPage ( Title $  title  )  [static]
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.

Parameters:
Title $title
integer $revision Revision number
Exceptions:
MWException 
Returns:
TranslatablePage

Definition at line 88 of file TranslatablePage.php.

Referenced by SpecialPageTranslation::execute(), and PageTranslationTaggingText::testTranslationPageRestrictions().

Here is the call graph for this function:

static TranslatablePage::newFromText ( Title $  title,
text 
) [static]

Constructs a translatable page from given text.

Some functions will fail unless you set revision parameter manually.

Parameters:
Title $title
string $text
Returns:
TranslatablePage

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]
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.

Parameters:
array $sections Array of placeholder => TPSection.
string $text Contents of one pair of <translate> tags.
Returns:
string Template with placeholders for sections, which itself are added to $sections.

Definition at line 368 of file TranslatablePage.php.

Referenced by getParse().

Here is the call graph for this function:

TranslatablePage::setRevision ( revision  ) 

Manually set a revision number to use loading page text.

Parameters:
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.

Parameters:
string $content Content of one section
Exceptions:
TPException 
Returns:
TPSection

Definition at line 398 of file TranslatablePage.php.

Referenced by sectionise().

static TranslatablePage::unArmourNowiki ( holders,
text 
) [static]
Parameters:
$holders 
string $text
Returns:
mixed

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.

Here is the call graph for this function:


Member Data Documentation

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.


The documentation for this class was generated from the following file:
Generated on Tue Oct 29 00:00:55 2013 for MediaWiki Translate Extension by  doxygen 1.6.3