Translate extension for MediaWiki
 
Loading...
Searching...
No Matches
MediaWiki\Extension\Translate\PageTranslation\Hooks Class Reference

Hooks for page translation. More...

Static Public Member Functions

static renderTagPage ( $wikitextParser, &$text, $state)
 Hook: ParserBeforeInternalParse.
 
static preprocessTagPage ( $wikitextParser, &$text, $state)
 Hook: ParserBeforePreprocess.
 
static onParserOutputPostCacheTransform (ParserOutput $out, &$text, array &$options)
 Hook: ParserOutputPostCacheTransform.
 
static fetchTranslatableTemplateAndTitle (?LinkTarget $contextLink, ?LinkTarget $templateLink, bool &$skip, ?RevisionRecord &$revRecord)
 This sets &$revRecord to the revision of transcluded page translation if it exists, or sets it to the source language if the page translation does not exist.
 
static onPageContentLanguage (Title $title, &$pageLang)
 Set the right page content language for translated pages ("Page/xx").
 
static onTitleGetEditNotices (Title $title, int $oldid, array &$notices)
 Display an edit notice for translatable source pages if it's enabled Hook: TitleGetEditNotices.
 
static onBeforePageDisplay (OutputPage $out, Skin $skin)
 Hook: BeforePageDisplay.
 
static onVisualEditorBeforeEditor (OutputPage $out, Skin $skin)
 Hook: onVisualEditorBeforeEditor.
 
static onSectionSave (WikiPage $wikiPage, User $user, TextContent $content, $summary, $minor, $flags, MessageHandle $handle)
 This is triggered after an edit to translation unit page.
 
static languages ( $data, $params, $parser)
 
static addLanguageLinks (Title $title, array &$languageLinks)
 Hooks: LanguageLinks.
 
static formatLanguageLink (array &$link, Title $linkTitle, Title $pageTitle, OutputPage $out)
 Hooks: SkinTemplateGetLanguageLink.
 
static tpSyntaxCheckForEditContent ( $context, $content, $status, $summary)
 Display nice error when editing content.
 
static tpSyntaxCheck (RenderedRevision $renderedRevision, UserIdentity $user, CommentStoreComment $summary, $flags, Status $hookStatus)
 When attempting to save, last resort.
 
static addTranstagAfterSave (WikiPage $wikiPage, UserIdentity $userIdentity, string $summary, int $flags, RevisionRecord $revisionRecord, EditResult $editResult)
 Hook: PageSaveComplete.
 
static updateTranstagOnNullRevisions (RevisionRecord $rev)
 Page moving and page protection (and possibly other things) creates null revisions.
 
static onGetUserPermissionsErrorsExpensive (Title $title, User $user, $action, &$result)
 Prevent creation of orphan translation units in Translations namespace.
 
static preventDirectEditing (Title $title, User $user, $action, &$result)
 Prevent editing of translation pages directly.
 
static disableDelete ( $article, $out, &$reason)
 Redirects the delete action to our own for translatable pages.
 
static translatablePageHeader ( $article, &$outputDone, &$pcache)
 Hook: ArticleViewHeader.
 
static replaceMovePage (&$list)
 Hook: SpecialPage_initList.
 
static lockedPagesCheck (Title $title, User $user, $action, &$result)
 Hook: getUserPermissionsErrorsExpensive.
 
static replaceSubtitle (&$subpages, ?Skin $skin, OutputPage $out)
 Hook: SkinSubPageSubtitle.
 
static translateTab (Skin $skin, array &$tabs)
 Converts the edit tab (if exists) for translation pages to translate tab.
 
static onMovePageTranslationUnits (LinkTarget $oldLinkTarget, LinkTarget $newLinkTarget, UserIdentity $userIdentity, int $oldid, int $newid, string $reason, RevisionRecord $revisionRecord)
 Hook to update source and destination translation pages on moving translation units Hook: PageMoveComplete.
 
static onDeleteTranslationUnit (WikiPage $unit, User $user, $reason, $id, $content, $logEntry)
 Hook to update translation page on deleting a translation unit Hook: ArticleDeleteComplete.
 

Static Public Attributes

static $allowTargetEdit = false
 
static $jobQueueRunning = false
 
static $renderingContext = false
 

Detailed Description

Hooks for page translation.

Author
Niklas Laxström @license GPL-2.0-or-later

Definition at line 55 of file Hooks.php.

Member Function Documentation

◆ addLanguageLinks()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::addLanguageLinks ( Title $title,
array & $languageLinks )
static

Hooks: LanguageLinks.

Parameters
Title$titleTitle of the page for which links are needed.
array&$languageLinksList of language links to modify.

Definition at line 676 of file Hooks.php.

◆ addTranstagAfterSave()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::addTranstagAfterSave ( WikiPage $wikiPage,
UserIdentity $userIdentity,
string $summary,
int $flags,
RevisionRecord $revisionRecord,
EditResult $editResult )
static

Hook: PageSaveComplete.

Parameters
WikiPage$wikiPage
UserIdentity$userIdentity
string$summary
int$flags
RevisionRecord$revisionRecord
EditResult$editResult
Returns
true

Definition at line 883 of file Hooks.php.

◆ disableDelete()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::disableDelete ( $article,
$out,
& $reason )
static

Redirects the delete action to our own for translatable pages.

Hook: ArticleConfirmDelete

Parameters
Article$article
OutputPage$out
string&$reason
Returns
bool

Definition at line 1134 of file Hooks.php.

◆ fetchTranslatableTemplateAndTitle()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::fetchTranslatableTemplateAndTitle ( ?LinkTarget $contextLink,
?LinkTarget $templateLink,
bool & $skip,
?RevisionRecord & $revRecord )
static

This sets &$revRecord to the revision of transcluded page translation if it exists, or sets it to the source language if the page translation does not exist.

The page translation is chosen based on language of the source page.

Hook: BeforeParserFetchTemplateRevisionRecord

Parameters
LinkTarget | null$contextLink
LinkTarget | null$templateLink
bool&$skip
RevisionRecord | null&$revRecord

Definition at line 208 of file Hooks.php.

◆ formatLanguageLink()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::formatLanguageLink ( array & $link,
Title $linkTitle,
Title $pageTitle,
OutputPage $out )
static

Hooks: SkinTemplateGetLanguageLink.

Parameters
array&$link
Title$linkTitle
Title$pageTitle
OutputPage$out

Definition at line 765 of file Hooks.php.

◆ languages()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::languages ( $data,
$params,
$parser )
static
Parameters
string$data
array$params
Parser$parser
Returns
string

Definition at line 461 of file Hooks.php.

◆ lockedPagesCheck()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::lockedPagesCheck ( Title $title,
User $user,
$action,
& $result )
static

Hook: getUserPermissionsErrorsExpensive.

Parameters
Title$title
User$user
string$action
mixed&$result
Returns
bool

Definition at line 1362 of file Hooks.php.

◆ onBeforePageDisplay()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::onBeforePageDisplay ( OutputPage $out,
Skin $skin )
static

Hook: BeforePageDisplay.

Parameters
OutputPage$out
Skin$skin
Returns
true

Definition at line 327 of file Hooks.php.

◆ onDeleteTranslationUnit()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::onDeleteTranslationUnit ( WikiPage $unit,
User $user,
$reason,
$id,
$content,
$logEntry )
static

Hook to update translation page on deleting a translation unit Hook: ArticleDeleteComplete.

Parameters
WikiPage$unit
User$user
string$reason
int$id
Content$content
ManualLogEntry$logEntry

Definition at line 1553 of file Hooks.php.

◆ onGetUserPermissionsErrorsExpensive()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::onGetUserPermissionsErrorsExpensive ( Title $title,
User $user,
$action,
& $result )
static

Prevent creation of orphan translation units in Translations namespace.

Hook: getUserPermissionsErrorsExpensive

Parameters
Title$title
User$user
string$action
mixed&$result
Returns
bool

Definition at line 962 of file Hooks.php.

◆ onMovePageTranslationUnits()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::onMovePageTranslationUnits ( LinkTarget $oldLinkTarget,
LinkTarget $newLinkTarget,
UserIdentity $userIdentity,
int $oldid,
int $newid,
string $reason,
RevisionRecord $revisionRecord )
static

Hook to update source and destination translation pages on moving translation units Hook: PageMoveComplete.

Parameters
LinkTarget$oldLinkTarget
LinkTarget$newLinkTarget
UserIdentity$userIdentity
int$oldid
int$newid
string$reason
RevisionRecord$revisionRecord

Definition at line 1489 of file Hooks.php.

◆ onPageContentLanguage()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::onPageContentLanguage ( Title $title,
& $pageLang )
static

Set the right page content language for translated pages ("Page/xx").

Hook: PageContentLanguage

Parameters
Title$title
Language | StubUserLang | string&$pageLang

Definition at line 277 of file Hooks.php.

◆ onParserOutputPostCacheTransform()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::onParserOutputPostCacheTransform ( ParserOutput $out,
& $text,
array & $options )
static

Hook: ParserOutputPostCacheTransform.

Parameters
ParserOutput$out
string&$text
array&$options

Definition at line 187 of file Hooks.php.

◆ onSectionSave()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::onSectionSave ( WikiPage $wikiPage,
User $user,
TextContent $content,
$summary,
$minor,
$flags,
MessageHandle $handle )
static

This is triggered after an edit to translation unit page.

Parameters
WikiPage$wikiPage
User$user
TextContent$content
string$summary
bool$minor
int$flags
MessageHandle$handle
Returns
true

Definition at line 379 of file Hooks.php.

◆ onTitleGetEditNotices()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::onTitleGetEditNotices ( Title $title,
int $oldid,
array & $notices )
static

Display an edit notice for translatable source pages if it's enabled Hook: TitleGetEditNotices.

Parameters
Title$title
int$oldid
array&$notices

Definition at line 293 of file Hooks.php.

◆ onVisualEditorBeforeEditor()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::onVisualEditorBeforeEditor ( OutputPage $out,
Skin $skin )
static

Hook: onVisualEditorBeforeEditor.

Parameters
OutputPage$out
Skin$skin
Returns
bool

Definition at line 364 of file Hooks.php.

◆ preprocessTagPage()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::preprocessTagPage ( $wikitextParser,
& $text,
$state )
static

Hook: ParserBeforePreprocess.

Parameters
Parser$wikitextParser
string&$text
-taint$textescapes_htmlnoent
mixed$state

Definition at line 157 of file Hooks.php.

◆ preventDirectEditing()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::preventDirectEditing ( Title $title,
User $user,
$action,
& $result )
static

Prevent editing of translation pages directly.

Hook: getUserPermissionsErrorsExpensive

Parameters
Title$title
User$user
string$action
bool&$result
Returns
bool

Definition at line 1082 of file Hooks.php.

◆ renderTagPage()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::renderTagPage ( $wikitextParser,
& $text,
$state )
static

Hook: ParserBeforeInternalParse.

Parameters
Parser$wikitextParser
null | string&$text
-taint$textescapes_htmlnoent
mixed$state

Definition at line 72 of file Hooks.php.

◆ replaceMovePage()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::replaceMovePage ( & $list)
static

Hook: SpecialPage_initList.

Parameters
array&$list
Returns
true

Definition at line 1330 of file Hooks.php.

◆ replaceSubtitle()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::replaceSubtitle ( & $subpages,
?Skin $skin,
OutputPage $out )
static

Hook: SkinSubPageSubtitle.

Parameters
array&$subpages
?Skin$skin
OutputPage$out
Returns
bool

Definition at line 1385 of file Hooks.php.

◆ tpSyntaxCheck()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::tpSyntaxCheck ( RenderedRevision $renderedRevision,
UserIdentity $user,
CommentStoreComment $summary,
$flags,
Status $hookStatus )
static

When attempting to save, last resort.

Edit page would only display edit conflict if there wasn't tpSyntaxCheckForEditPage. Hook: MultiContentSave

Parameters
RenderedRevision$renderedRevision
UserIdentity$user
CommentStoreComment$summary
int$flags
Status$hookStatus
Returns
bool

Definition at line 850 of file Hooks.php.

◆ tpSyntaxCheckForEditContent()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::tpSyntaxCheckForEditContent ( $context,
$content,
$status,
$summary )
static

Display nice error when editing content.

Hook: EditFilterMergedContent

Parameters
IContextSource$context
Content$content
Status$status
string$summary
Returns
true

Definition at line 800 of file Hooks.php.

◆ translatablePageHeader()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::translatablePageHeader ( $article,
& $outputDone,
& $pcache )
static

Hook: ArticleViewHeader.

Parameters
Article$article
bool | ParserOutput | null&$outputDone
bool&$pcache
Returns
bool

Definition at line 1157 of file Hooks.php.

◆ translateTab()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::translateTab ( Skin $skin,
array & $tabs )
static

Converts the edit tab (if exists) for translation pages to translate tab.

Hook: SkinTemplateNavigation::Universal

Parameters
Skin$skin
array&$tabs
Returns
true

Definition at line 1456 of file Hooks.php.

◆ updateTranstagOnNullRevisions()

static MediaWiki\Extension\Translate\PageTranslation\Hooks::updateTranstagOnNullRevisions ( RevisionRecord $rev)
static

Page moving and page protection (and possibly other things) creates null revisions.

These revisions re-use the previous text already stored in the database. Those however do not trigger re-parsing of the page and thus the ready tag is not updated. This watches for new revisions, checks if they reuse existing text, checks whether the parent version is the latest version and has a ready tag. If that is the case, also adds a ready tag for the new revision (which is safe, because the text hasn't changed). The interface will say that there has been a change, but shows no change in the content. This lets the user to re-mark the translations of the page title as outdated (if enabled for translation). Hook: RevisionRecordInserted

Parameters
RevisionRecord$rev

Definition at line 926 of file Hooks.php.

Member Data Documentation

◆ $allowTargetEdit

MediaWiki\Extension\Translate\PageTranslation\Hooks::$allowTargetEdit = false
static

Definition at line 57 of file Hooks.php.

◆ $jobQueueRunning

MediaWiki\Extension\Translate\PageTranslation\Hooks::$jobQueueRunning = false
static

Definition at line 59 of file Hooks.php.

◆ $renderingContext

MediaWiki\Extension\Translate\PageTranslation\Hooks::$renderingContext = false
static

Definition at line 61 of file Hooks.php.


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