本文整理匯總了PHP中MessageGroups::getParentGroups方法的典型用法代碼示例。如果您正苦於以下問題:PHP MessageGroups::getParentGroups方法的具體用法?PHP MessageGroups::getParentGroups怎麽用?PHP MessageGroups::getParentGroups使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MessageGroups
的用法示例。
在下文中一共展示了MessageGroups::getParentGroups方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testGetParentGroups
/**
* @dataProvider provideGroups
*/
public function testGetParentGroups($expected, $target)
{
$group = MessageGroups::getGroup($target);
$got = MessageGroups::getParentGroups($group);
$this->assertEquals($expected, $got);
}
示例2: execute
public function execute( $parameters ) {
$this->setHeaders();
global $wgRequest, $wgOut, $wgUser;
$this->user = $wgUser;
$request = $wgRequest;
$target = $wgRequest->getText( 'target', $parameters );
$revision = $wgRequest->getInt( 'revision', 0 );
$action = $request->getVal( 'do' );
// No specific page or invalid input
$title = Title::newFromText( $target );
if ( !$title ) {
if ( $target !== '' ) {
$wgOut->addWikiMsg( 'tpt-badtitle' );
} else {
$this->listPages();
}
return;
}
// Check permissions
if ( !$this->user->isAllowed( 'pagetranslation' ) ) {
$wgOut->permissionRequired( 'pagetranslation' );
return;
}
// Check permissions
if ( $wgRequest->wasPosted() && !$this->user->matchEditToken( $wgRequest->getText( 'token' ) ) ) {
self::superDebug( __METHOD__, "token failure", $this->user );
$wgOut->permissionRequired( 'pagetranslation' );
return;
}
// We are processing some specific page
if ( !$title->exists() ) {
$wgOut->addWikiMsg( 'tpt-nosuchpage', $title->getPrefixedText() );
return;
}
if ( $action === 'discourage' || $action === 'encourage' ) {
$id = TranslatablePage::getMessageGroupIdFromTitle( $title );
$dbw = wfGetDB( DB_MASTER );
$table = 'translate_groupreviews';
$row = array(
'tgr_group' => $id,
'tgr_lang' => '*priority',
'tgr_state' => 'discouraged',
);
if ( $action === 'encourage' ) {
$dbw->delete( $table, $row, __METHOD__ );
} else {
$index = array( 'tgr_group', 'tgr_lang' );
$dbw->replace( $table, array( $index ), $row, __METHOD__ );
}
$this->listPages();
$group = MessageGroups::getGroup( $id );
$parents = MessageGroups::getParentGroups( $group );
MessageGroupStats::clearGroup( $parents );
return;
}
if ( $action === 'unmark' ) {
$page = TranslatablePage::newFromTitle( $title );
$page->removeTags();
$page->getTitle()->invalidateCache();
$logger = new LogPage( 'pagetranslation' );
$params = array( 'user' => $wgUser->getName() );
$logger->addEntry( 'unmark', $page->getTitle(), null, array( serialize( $params ) ) );
$wgOut->addWikiMsg( 'tpt-unmarked', $title->getPrefixedText() );
self::superDebug( __METHOD__, "unmarked page", $this->user, $title );
return;
}
if ( $revision === 0 ) {
// Get the latest revision
$revision = intval( $title->getLatestRevID() );
}
$page = TranslatablePage::newFromRevision( $title, $revision );
if ( !$page instanceof TranslatablePage ) {
$wgOut->addWikiMsg( 'tpt-notsuitable', $title->getPrefixedText(), $revision );
return;
}
if ( $revision !== intval( $title->getLatestRevID() ) ) {
// We do want to notify the reviewer if the underlying page changes during review
$target = $title->getFullUrl( array( 'oldid' => $revision ) );
$link = "<span class='plainlinks'>[$target $revision]</span>";
$wgOut->addWikiMsg( 'tpt-oldrevision', $title->getPrefixedText(), $link );
self::superDebug( __METHOD__, "revision mismatch while marking", $this->user, $title, $revision, intval( $title->getLatestRevID() ) );
return;
}
//.........這裏部分代碼省略.........