本文整理汇总了PHP中SkinTemplate::getRelevantTitle方法的典型用法代码示例。如果您正苦于以下问题:PHP SkinTemplate::getRelevantTitle方法的具体用法?PHP SkinTemplate::getRelevantTitle怎么用?PHP SkinTemplate::getRelevantTitle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkinTemplate
的用法示例。
在下文中一共展示了SkinTemplate::getRelevantTitle方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addMarkButton
public static function addMarkButton(SkinTemplate &$sktemplate, array &$links)
{
$title = $sktemplate->getRelevantTitle();
$user = $sktemplate->getUser();
if ($user->isAllowedAll('changetags', 'markmajorchange')) {
$urlParams = array('action' => 'markmajorchange');
$links['actions']['markmajorchange'] = array('text' => $sktemplate->msg('markmajorchanges-mark-btn')->text(), 'href' => $title->getLocalURL($urlParams));
}
}
示例2: SkinTemplateNavigation
/**
* Hook to <ul>
* <li>correct the action menu that displays "delete" a bit too much.
* A direct correction would be to change the logic directly in SkinTemplate::buildContentNavigationUrls.
* The menu builder now uses if( $wgUser->isAllowed( 'delete' ) ) ...
* A better builder would use if( $$title->quickUserCan( 'delete' ) ) ...</li>
* <li>add a "Set as background" action for files</li>
* </ul>
* @param SkinTemplate $skinTemplate
* @param Array $content_navigation
* @return Boolean True (=continue hook)
*
*/
public static function SkinTemplateNavigation(&$skinTemplate, &$content_navigation)
{
$title = $skinTemplate->getRelevantTitle();
// removes "delete" action if necessary
if (isset($content_navigation['actions']['delete']) && !$title->quickUserCan('delete')) {
unset($content_navigation['actions']['delete']);
}
// adds a "Set as background" action for files
global $wgUser;
if (in_array(WP_SUBSCRIBERS_USER_GROUP, $wgUser->getGroups()) && WpWikiplace::isTitleValidForBackground($title) && count(WpWikiplace::factoryAllOwnedByUserId($wgUser->getId())) != 0) {
$content_navigation['actions']['background'] = array('class' => false, 'text' => wfMessage('wp-background-action')->text(), 'href' => SpecialWikiplaces::getLocalUrlForSetAsBackground($title->getPrefixedDBkey()));
}
return true;
}
示例3: onSkinTemplateNavigation
/**
* Changes the Edit tab and adds the VisualEditor tab.
*
* This is attached to the MediaWiki 'SkinTemplateNavigation' hook.
*
* @param SkinTemplate $skin
* @param array $links Navigation links
* @return boolean
*/
public static function onSkinTemplateNavigation(SkinTemplate &$skin, array &$links)
{
// Only do this if the user has VE enabled
if (!$skin->getUser()->getOption('visualeditor-enable') || $skin->getUser()->getOption('visualeditor-betatempdisable')) {
return true;
}
$config = ConfigFactory::getDefaultInstance()->makeConfig('visualeditor');
if (!isset($links['views']['edit'])) {
// There's no edit link, nothing to do
return true;
}
$title = $skin->getRelevantTitle();
if (defined('EP_NS') && $title->inNamespace(EP_NS)) {
return true;
}
$tabMessages = $config->get('VisualEditorTabMessages');
// Rebuild the $links['views'] array and inject the VisualEditor tab before or after
// the edit tab as appropriate. We have to rebuild the array because PHP doesn't allow
// us to splice into the middle of an associative array.
$newViews = array();
foreach ($links['views'] as $action => $data) {
if ($action === 'edit') {
// Build the VisualEditor tab
$existing = $title->exists() || $title->inNamespace(NS_MEDIAWIKI) && $title->getDefaultMessageText() !== false;
$action = $existing ? 'edit' : 'create';
$veParams = $skin->editUrlOptions();
unset($veParams['action']);
// Remove action=edit
$veParams['veaction'] = 'edit';
// Set veaction=edit
$veTabMessage = $tabMessages[$action];
$veTabText = $veTabMessage === null ? $data['text'] : $skin->msg($veTabMessage)->text();
$veTab = array('href' => $title->getLocalURL($veParams), 'text' => $veTabText, 'primary' => true, 'class' => '');
// Alter the edit tab
$editTab = $data;
if ($title->inNamespace(NS_FILE) && WikiPage::factory($title) instanceof WikiFilePage && !WikiPage::factory($title)->isLocal()) {
$editTabMessage = $tabMessages[$action . 'localdescriptionsource'];
} else {
$editTabMessage = $tabMessages[$action . 'source'];
}
if ($editTabMessage !== null) {
$editTab['text'] = $skin->msg($editTabMessage)->text();
}
// Inject the VE tab before or after the edit tab
if ($config->get('VisualEditorTabPosition') === 'before') {
$editTab['class'] .= ' collapsible';
$newViews['ve-edit'] = $veTab;
$newViews['edit'] = $editTab;
} else {
$veTab['class'] .= ' collapsible';
$newViews['edit'] = $editTab;
$newViews['ve-edit'] = $veTab;
}
} else {
// Just pass through
$newViews[$action] = $data;
}
}
$links['views'] = $newViews;
return true;
}
示例4: onSkinTemplateNavigation
/**
* Changes the Edit tab and adds the VisualEditor tab.
*
* This is attached to the MediaWiki 'SkinTemplateNavigation' hook.
*
* @param SkinTemplate $skin
* @param array $links Navigation links
* @return boolean
*/
public static function onSkinTemplateNavigation(SkinTemplate &$skin, array &$links)
{
$config = ConfigFactory::getDefaultInstance()->makeConfig('visualeditor');
// Exit if the user doesn't have VE enabled
if (!$skin->getUser()->getOption('visualeditor-enable') || $skin->getUser()->getOption('visualeditor-betatempdisable') || $config->get('VisualEditorDisableForAnons') && $skin->getUser()->isAnon()) {
return true;
}
// Exit if there's no edit link for whatever reason (e.g. protected page)
if (!isset($links['views']['edit'])) {
return true;
}
$availableNamespaces = $config->get('VisualEditorAvailableNamespaces');
$title = $skin->getRelevantTitle();
$namespaceEnabled = $title->inNamespaces(array_keys(array_filter($availableNamespaces)));
$pageContentModel = $title->getContentModel();
// Don't exit if this page isn't VE-enabled, since we should still
// change "Edit" to "Edit source".
$isAvailable = $namespaceEnabled && $pageContentModel === CONTENT_MODEL_WIKITEXT;
// HACK: Exit if we're in the Education Program namespace (even though it's content)
if (defined('EP_NS') && $title->inNamespace(EP_NS)) {
return true;
}
$tabMessages = $config->get('VisualEditorTabMessages');
// Rebuild the $links['views'] array and inject the VisualEditor tab before or after
// the edit tab as appropriate. We have to rebuild the array because PHP doesn't allow
// us to splice into the middle of an associative array.
$newViews = array();
foreach ($links['views'] as $action => $data) {
if ($action === 'edit') {
// Build the VisualEditor tab
$existing = $title->exists() || $title->inNamespace(NS_MEDIAWIKI) && $title->getDefaultMessageText() !== false;
$action = $existing ? 'edit' : 'create';
$veParams = $skin->editUrlOptions();
unset($veParams['action']);
// Remove action=edit
$veParams['veaction'] = 'edit';
// Set veaction=edit
$veTabMessage = $tabMessages[$action];
$veTabText = $veTabMessage === null ? $data['text'] : $skin->msg($veTabMessage)->text();
$veTab = array('href' => $title->getLocalURL($veParams), 'text' => $veTabText, 'primary' => true, 'class' => '');
// Alter the edit tab
$editTab = $data;
if ($title->inNamespace(NS_FILE) && WikiPage::factory($title) instanceof WikiFilePage && !WikiPage::factory($title)->isLocal()) {
$editTabMessage = $tabMessages[$action . 'localdescriptionsource'];
} else {
$editTabMessage = $tabMessages[$action . 'source'];
}
if ($editTabMessage !== null) {
$editTab['text'] = $skin->msg($editTabMessage)->text();
}
if ($isAvailable) {
// Inject the VE tab before or after the edit tab
if ($config->get('VisualEditorTabPosition') === 'before') {
$editTab['class'] .= ' collapsible';
$newViews['ve-edit'] = $veTab;
$newViews['edit'] = $editTab;
} else {
$veTab['class'] .= ' collapsible';
$newViews['edit'] = $editTab;
$newViews['ve-edit'] = $veTab;
}
} else {
// Don't add ve-edit, but do update the edit tab (e.g. "Edit source").
$newViews['edit'] = $editTab;
}
} else {
// Just pass through
$newViews[$action] = $data;
}
}
$links['views'] = $newViews;
return true;
}
示例5: addApprovalButton
public static function addApprovalButton(SkinTemplate &$sktemplate, array &$links)
{
$title = $sktemplate->getRelevantTitle();
$user = $sktemplate->getUser();
if ($sktemplate->isRevisionCurrent() && ApprovedRevs::isAssignedToProject($title) && ApprovedRevs::userCanApprovePage($title, $user) && !ApprovedRevs::isLatestRevisionApproved($title)) {
/* This is somewhat a replication of code from SkinTemplate::buildContentNavigationUrls() */
$onPage = $title->equals($sktemplate->getTitle());
$request = $sktemplate->getRequest();
$action = $request->getVal('action', 'view');
/* /Code Replication */
$isInAction = $onPage && $action == 'approveprojectpage';
$links['actions']['approveprojectpage'] = array('text' => 'אישור הדף', 'href' => $title->getLocalURL('action=approveprojectpage'), 'class' => $isInAction ? 'selected' : '');
}
return true;
}
示例6: wfPolyglotAddVariantsToTemplate
/**
* Replaces the language variant menu by the Polyglot one.
*
* @global type $wgOut
* @global type $wgContLang
* @param SkinTemplate $skin
* @param QuickTemplate $tpl
* @return type
*/
function wfPolyglotAddVariantsToTemplate($skin, $tpl)
{
global $wgOut, $wgContLang;
$variants = wfPolyglotGetVariantTitles($skin->getRelevantTitle());
$language_urls = array();
foreach ($variants as $lang => $title) {
$language_urls[] = array('href' => $title->getFullURL(), 'text' => $wgContLang->getLanguageName($lang), 'class' => 'interwiki-' . $lang);
}
if (count($language_urls)) {
$tpl->setRef('language_urls', $language_urls);
} else {
$tpl->set('language_urls', false);
}
return true;
}