本文整理汇总了PHP中WatchAction::getWatchToken方法的典型用法代码示例。如果您正苦于以下问题:PHP WatchAction::getWatchToken方法的具体用法?PHP WatchAction::getWatchToken怎么用?PHP WatchAction::getWatchToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WatchAction
的用法示例。
在下文中一共展示了WatchAction::getWatchToken方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: formatResult
/**
* @param $skin Skin
* @param $result
* @return string
*/
function formatResult($skin, $result)
{
global $wgContLang;
$nt = Title::makeTitle($result->namespace, $result->title);
$text = $wgContLang->convert($nt->getPrefixedText());
$plink = Linker::linkKnown($nt, htmlspecialchars($text));
$token = WatchAction::getWatchToken($nt, $this->getUser());
$wlink = Linker::linkKnown($nt, wfMsgHtml('watch'), array(), array('action' => 'watch', 'token' => $token));
return $this->getLanguage()->specialList($plink, $wlink);
}
示例2: formatResult
/**
* @param Skin $skin
* @param object $result Result row
* @return string
*/
function formatResult($skin, $result)
{
global $wgContLang;
$nt = Title::makeTitleSafe($result->namespace, $result->title);
if (!$nt) {
return Html::element('span', array('class' => 'mw-invalidtitle'), Linker::getInvalidTitleDescription($this->getContext(), $result->namespace, $result->title));
}
$text = $wgContLang->convert($nt->getPrefixedText());
$plink = Linker::linkKnown($nt, htmlspecialchars($text));
$token = WatchAction::getWatchToken($nt, $this->getUser());
$wlink = Linker::linkKnown($nt, $this->msg('watch')->escaped(), array(), array('action' => 'watch', 'token' => $token));
return $this->getLanguage()->specialList($plink, $wlink);
}
示例3: topLevelThreadCommands
/**
* @param $thread Thread
*/
function topLevelThreadCommands($thread)
{
$commands = array();
$commands['history'] = array('label' => wfMessage('history_short')->parse(), 'href' => self::permalinkUrl($thread, 'thread_history'), 'enabled' => true);
if ($this->user->isAllowed('move')) {
$move_href = SpecialPage::getTitleFor('MoveThread', $thread->title()->getPrefixedText())->getLocalURL();
$commands['move'] = array('label' => wfMessage('lqt-movethread')->parse(), 'href' => $move_href, 'enabled' => true);
}
if ($this->user->isAllowed('protect')) {
$protect_href = $thread->title()->getLocalURL('action=protect');
// Check if it's already protected
if (!$thread->title()->isProtected()) {
$label = wfMessage('protect')->parse();
} else {
$label = wfMessage('unprotect')->parse();
}
$commands['protect'] = array('label' => $label, 'href' => $protect_href, 'enabled' => true);
}
if (!$this->user->isAnon() && !$thread->title()->userIsWatching()) {
$commands['watch'] = array('label' => wfMessage('watch')->parse(), 'href' => self::permalinkUrlWithQuery($thread, array('action' => 'watch', 'token' => WatchAction::getWatchToken($thread->title(), $this->user, 'watch'))), 'enabled' => true);
} elseif (!$this->user->isAnon()) {
$commands['unwatch'] = array('label' => wfMessage('unwatch')->parse(), 'href' => self::permalinkUrlWithQuery($thread, array('action' => 'unwatch', 'token' => WatchAction::getWatchToken($thread->title(), $this->user, 'unwatch'))), 'enabled' => true);
}
if (LqtDispatch::isLqtPage($thread->getTitle())) {
$summarizeUrl = self::permalinkUrl($thread, 'summarize', $thread->id());
$commands['summarize'] = array('label' => wfMessage('lqt_summarize_link')->parse(), 'href' => $summarizeUrl, 'enabled' => true);
}
Hooks::run('LiquidThreadsTopLevelCommands', array($thread, &$commands));
return $commands;
}
示例4: buildContentNavigationUrls
//.........这里部分代码省略.........
if ($title->quickUserCan('move', $user)) {
$moveTitle = SpecialPage::getTitleFor('Movepage', $title->getPrefixedDBkey());
$content_navigation['actions']['move'] = array('class' => $this->getTitle()->isSpecial('Movepage') ? 'selected' : false, 'text' => wfMessageFallback("{$skname}-action-move", 'move')->setContext($this->getContext())->text(), 'href' => $moveTitle->getLocalURL());
}
} else {
// article doesn't exist or is deleted
if ($user->isAllowed('deletedhistory')) {
$n = $title->isDeleted();
if ($n) {
$undelTitle = SpecialPage::getTitleFor('Undelete', $title->getPrefixedDBkey());
// If the user can't undelete but can view deleted
// history show them a "View .. deleted" tab instead.
$msgKey = $user->isAllowed('undelete') ? 'undelete' : 'viewdeleted';
$content_navigation['actions']['undelete'] = array('class' => $this->getTitle()->isSpecial('Undelete') ? 'selected' : false, 'text' => wfMessageFallback("{$skname}-action-{$msgKey}", "{$msgKey}_short")->setContext($this->getContext())->numParams($n)->text(), 'href' => $undelTitle->getLocalURL());
}
}
}
if ($title->quickUserCan('protect', $user) && $title->getRestrictionTypes() && MWNamespace::getRestrictionLevels($title->getNamespace(), $user) !== array('')) {
$mode = $title->isProtected() ? 'unprotect' : 'protect';
$content_navigation['actions'][$mode] = array('class' => $onPage && $action == $mode ? 'selected' : false, 'text' => wfMessageFallback("{$skname}-action-{$mode}", $mode)->setContext($this->getContext())->text(), 'href' => $title->getLocalURL("action={$mode}"));
}
// Checks if the user is logged in
if ($this->loggedin && $user->isAllowedAll('viewmywatchlist', 'editmywatchlist')) {
/**
* The following actions use messages which, if made particular to
* the any specific skins, would break the Ajax code which makes this
* action happen entirely inline. OutputPage::getJSVars
* defines a set of messages in a javascript object - and these
* messages are assumed to be global for all skins. Without making
* a change to that procedure these messages will have to remain as
* the global versions.
*/
$mode = $user->isWatched($title) ? 'unwatch' : 'watch';
$token = WatchAction::getWatchToken($title, $user, $mode);
$content_navigation['actions'][$mode] = array('class' => $onPage && ($action == 'watch' || $action == 'unwatch') ? 'selected' : false, 'text' => $this->msg($mode)->text(), 'href' => $title->getLocalURL(array('action' => $mode, 'token' => $token)));
}
}
Hooks::run('SkinTemplateNavigation', array(&$this, &$content_navigation));
if ($userCanRead && !$wgDisableLangConversion) {
$pageLang = $title->getPageLanguage();
// Gets list of language variants
$variants = $pageLang->getVariants();
// Checks that language conversion is enabled and variants exist
// And if it is not in the special namespace
if (count($variants) > 1) {
// Gets preferred variant (note that user preference is
// only possible for wiki content language variant)
$preferred = $pageLang->getPreferredVariant();
if (Action::getActionName($this) === 'view') {
$params = $request->getQueryValues();
unset($params['title']);
} else {
$params = array();
}
// Loops over each variant
foreach ($variants as $code) {
// Gets variant name from language code
$varname = $pageLang->getVariantname($code);
// Appends variant link
$content_navigation['variants'][] = array('class' => $code == $preferred ? 'selected' : false, 'text' => $varname, 'href' => $title->getLocalURL(array('variant' => $code) + $params), 'lang' => wfBCP47($code), 'hreflang' => wfBCP47($code));
}
}
}
} else {
// If it's not content, it's got to be a special page
$content_navigation['namespaces']['special'] = array('class' => 'selected', 'text' => $this->msg('nstab-special')->text(), 'href' => $request->getRequestURL(), 'context' => 'subject');
示例5: watchThisPage
function watchThisPage()
{
global $wgOut, $wgUser;
++$this->mWatchLinkNum;
// Cache
$title = $this->getSkin()->getTitle();
if ($wgOut->isArticleRelated()) {
if ($wgUser->isWatched($title)) {
$text = wfMessage('unwatchthispage')->text();
$query = array('action' => 'unwatch', 'token' => UnwatchAction::getUnwatchToken($title, $wgUser));
$id = 'mw-unwatch-link' . $this->mWatchLinkNum;
} else {
$text = wfMessage('watchthispage')->text();
$query = array('action' => 'watch', 'token' => WatchAction::getWatchToken($title, $wgUser));
$id = 'mw-watch-link' . $this->mWatchLinkNum;
}
$s = Linker::linkKnown($title, $text, array('id' => $id), $query);
} else {
$s = wfMessage('notanarticle')->text();
}
return $s;
}
示例6: buildContentNavigationUrls
//.........这里部分代码省略.........
}
if ($title->getNamespace() !== NS_MEDIAWIKI && $wgUser->isAllowed('protect')) {
$mode = !$title->isProtected() ? 'protect' : 'unprotect';
$content_navigation['actions'][$mode] = array('class' => $onPage && $action == $mode ? 'selected' : false, 'text' => wfMessageFallback("{$skname}-action-{$mode}", $mode)->text(), 'href' => $title->getLocalURL("action={$mode}"));
}
} else {
// article doesn't exist or is deleted
if ($wgUser->isAllowed('deletedhistory')) {
$n = $title->isDeleted();
if ($n) {
$undelTitle = SpecialPage::getTitleFor('Undelete');
// If the user can't undelete but can view deleted history show them a "View .. deleted" tab instead
$msgKey = $wgUser->isAllowed('undelete') ? 'undelete' : 'viewdeleted';
$content_navigation['actions']['undelete'] = array('class' => $this->getTitle()->isSpecial('Undelete') ? 'selected' : false, 'text' => wfMessageFallback("{$skname}-action-{$msgKey}", "{$msgKey}_short")->params($wgLang->formatNum($n))->text(), 'href' => $undelTitle->getLocalURL(array('target' => $title->getPrefixedDBkey())));
}
}
if ($title->getNamespace() !== NS_MEDIAWIKI && $wgUser->isAllowed('protect')) {
$mode = !$title->getRestrictions('create') ? 'protect' : 'unprotect';
$content_navigation['actions'][$mode] = array('class' => $onPage && $action == $mode ? 'selected' : false, 'text' => wfMessageFallback("{$skname}-action-{$mode}", $mode)->text(), 'href' => $title->getLocalURL("action={$mode}"));
}
}
wfProfileOut(__METHOD__ . '-live');
// Checks if the user is logged in
if ($this->loggedin) {
/**
* The following actions use messages which, if made particular to
* the any specific skins, would break the Ajax code which makes this
* action happen entirely inline. Skin::makeGlobalVariablesScript
* defines a set of messages in a javascript object - and these
* messages are assumed to be global for all skins. Without making
* a change to that procedure these messages will have to remain as
* the global versions.
*/
$mode = $title->userIsWatching() ? 'unwatch' : 'watch';
$token = WatchAction::getWatchToken($title, $wgUser, $mode);
$content_navigation['actions'][$mode] = array('class' => $onPage && ($action == 'watch' || $action == 'unwatch') ? 'selected' : false, 'text' => wfMsg($mode), 'href' => $title->getLocalURL(array('action' => $mode, 'token' => $token)));
}
wfRunHooks('SkinTemplateNavigation', array(&$this, &$content_navigation));
} else {
// If it's not content, it's got to be a special page
$content_navigation['namespaces']['special'] = array('class' => 'selected', 'text' => wfMsg('nstab-special'), 'href' => $wgRequest->getRequestURL(), 'context' => 'subject');
wfRunHooks('SkinTemplateNavigation::SpecialPage', array(&$this, &$content_navigation));
}
// Gets list of language variants
$variants = $wgContLang->getVariants();
// Checks that language conversion is enabled and variants exist
if (!$wgDisableLangConversion && count($variants) > 1) {
// Gets preferred variant
$preferred = $wgContLang->getPreferredVariant();
// Loops over each variant
foreach ($variants as $code) {
// Gets variant name from language code
$varname = $wgContLang->getVariantname($code);
// Checks if the variant is marked as disabled
if ($varname == 'disable') {
// Skips this variant
continue;
}
// Appends variant link
$content_navigation['variants'][] = array('class' => $code == $preferred ? 'selected' : false, 'text' => $varname, 'href' => $title->getLocalURL('', $code));
}
}
// Equiv to SkinTemplateContentActions
wfRunHooks('SkinTemplateNavigation::Universal', array(&$this, &$content_navigation));
// Setup xml ids and tooltip info
foreach ($content_navigation as $section => &$links) {
foreach ($links as $key => &$link) {
$xmlID = $key;
if (isset($link['context']) && $link['context'] == 'subject') {
$xmlID = 'ca-nstab-' . $xmlID;
} elseif (isset($link['context']) && $link['context'] == 'talk') {
$xmlID = 'ca-talk';
} elseif ($section == "variants") {
$xmlID = 'ca-varlang-' . $xmlID;
} else {
$xmlID = 'ca-' . $xmlID;
}
$link['id'] = $xmlID;
}
}
# We don't want to give the watch tab an accesskey if the
# page is being edited, because that conflicts with the
# accesskey on the watch checkbox. We also don't want to
# give the edit tab an accesskey, because that's fairly su-
# perfluous and conflicts with an accesskey (Ctrl-E) often
# used for editing in Safari.
if (in_array($action, array('edit', 'submit'))) {
if (isset($content_navigation['views']['edit'])) {
$content_navigation['views']['edit']['tooltiponly'] = true;
}
if (isset($content_navigation['actions']['watch'])) {
$content_navigation['actions']['watch']['tooltiponly'] = true;
}
if (isset($content_navigation['actions']['unwatch'])) {
$content_navigation['actions']['unwatch']['tooltiponly'] = true;
}
}
wfProfileOut(__METHOD__);
return $content_navigation;
}