• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP WatchAction类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中WatchAction的典型用法代码示例。如果您正苦于以下问题:PHP WatchAction类的具体用法?PHP WatchAction怎么用?PHP WatchAction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了WatchAction类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: execute

 public function execute()
 {
     global $wgUser;
     if (!$wgUser->isLoggedIn()) {
         $this->dieUsage('You must be logged-in to have a watchlist', 'notloggedin');
     }
     $params = $this->extractRequestParams();
     $title = Title::newFromText($params['title']);
     if (!$title || $title->getNamespace() < 0) {
         $this->dieUsageMsg(array('invalidtitle', $params['title']));
     }
     $article = new Article($title, 0);
     $res = array('title' => $title->getPrefixedText());
     if ($params['unwatch']) {
         $res['unwatched'] = '';
         $res['message'] = wfMsgExt('removedwatchtext', array('parse'), $title->getPrefixedText());
         $success = WatchAction::doUnwatch($title, $wgUser);
     } else {
         $res['watched'] = '';
         $res['message'] = wfMsgExt('addedwatchtext', array('parse'), $title->getPrefixedText());
         $success = UnwatchAction::doWatch($title, $wgUser);
     }
     if (!$success) {
         $this->dieUsageMsg('hookaborted');
     }
     $this->getResult()->addValue(null, $this->getModuleName(), $res);
 }
开发者ID:tuxmania87,项目名称:GalaxyAdventures,代码行数:27,代码来源:ApiWatch.php


示例2: 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);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:15,代码来源:SpecialUnwatchedpages.php


示例3: 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);
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:18,代码来源:SpecialUnwatchedpages.php


示例4: execute

	public function execute() {
		$user = $this->getUser();
		if ( !$user->isLoggedIn() ) {
			$this->dieUsage( 'You must be logged-in to have a watchlist', 'notloggedin' );
		}
		if ( !$user->isAllowed( 'editmywatchlist' ) ) {
			$this->dieUsage( 'You don\'t have permission to edit your watchlist', 'permissiondenied' );
		}

		$params = $this->extractRequestParams();
		$title = Title::newFromText( $params['title'] );

		if ( !$title || $title->isExternal() || !$title->canExist() ) {
			$this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) );
		}

		$res = array( 'title' => $title->getPrefixedText() );

		// Currently unnecessary, code to act as a safeguard against any change in current behavior of uselang
		// Copy from ApiParse
		$oldLang = null;
		if ( isset( $params['uselang'] ) && $params['uselang'] != $this->getContext()->getLanguage()->getCode() ) {
			$oldLang = $this->getContext()->getLanguage(); // Backup language
			$this->getContext()->setLanguage( Language::factory( $params['uselang'] ) );
		}

		if ( $params['unwatch'] ) {
			$res['unwatched'] = '';
			$res['message'] = $this->msg( 'removedwatchtext', $title->getPrefixedText() )->title( $title )->parseAsBlock();
			$status = UnwatchAction::doUnwatch( $title, $user );
		} else {
			$res['watched'] = '';
			$res['message'] = $this->msg( 'addedwatchtext', $title->getPrefixedText() )->title( $title )->parseAsBlock();
			$status = WatchAction::doWatch( $title, $user );
		}

		if ( !is_null( $oldLang ) ) {
			$this->getContext()->setLanguage( $oldLang ); // Reset language to $oldLang
		}

		if ( !$status->isOK() ) {
			$this->dieStatus( $status );
		}
		$this->getResult()->addValue( null, $this->getModuleName(), $res );
	}
开发者ID:nahoj,项目名称:mediawiki_ynh,代码行数:45,代码来源:ApiWatch.php


示例5: move

 public function move($params)
 {
     global $wgUser;
     $currentUser = $wgUser;
     $wgUser = User::newFromId($this->createdBy);
     $currentPageName = $this->title->getText();
     if ($params['use_regex']) {
         $newPageName = preg_replace("/{$params['target_str']}/U", $params['replacement_str'], $currentPageName);
     } else {
         $newPageName = str_replace($params['target_str'], $params['replacement_str'], $currentPageName);
     }
     $newTitle = Title::newFromText($newPageName, $this->title->getNamespace());
     $result = $this->title->moveTo($newTitle, true, $params['edit_summary'], $params['create_redirect']);
     if ($result == true && $params['watch_page']) {
         WatchAction::doWatch($newTitle, $wgUser);
     }
     $wgUser = $currentUser;
     return $result;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:19,代码来源:ReplaceTextTask.php


示例6: addUserToDefaultWatchlistTask

 /**
  * Adds a user to watchlists of all articles defined in the
  * global $wgAutoFollowWatchlist variable.
  * @param integer $iUserId The user's ID
  */
 public function addUserToDefaultWatchlistTask($iUserId)
 {
     global $wgAutoFollowWatchlist;
     if (!empty($wgAutoFollowWatchlist)) {
         $oUser = \User::newFromId($iUserId);
         $aWatchSuccess = $aWatchFail = [];
         foreach ($wgAutoFollowWatchlist as $sTitleText) {
             $oTitle = \Title::newFromText($sTitleText);
             if ($oTitle instanceof \Title) {
                 \WatchAction::doWatch($oTitle, $oUser);
                 $aWatchSuccess[] = $sTitleText;
             } else {
                 $aWatchFail[] = $sTitleText;
             }
         }
         if (count($aWatchFail) === 0) {
             $this->setFlag($oUser);
         }
         $this->logResults($oUser, $aWatchSuccess, $aWatchFail);
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:26,代码来源:AutoFollowTask.class.php


示例7: delete

 function delete()
 {
     global $wgUser, $wgOut, $wgRequest;
     $confirm = $wgRequest->wasPosted() && $wgUser->matchEditToken($wgRequest->getVal('wpEditToken'));
     $reason = $wgRequest->getText('wpReason');
     # This code desperately needs to be totally rewritten
     # Check permissions
     $permission_errors = $this->mTitle->getUserPermissionsErrors('mv_delete_mvd', $wgUser);
     if (count($permission_errors) > 0) {
         $wgOut->showPermissionsErrorPage($permission_errors);
         return;
     }
     $wgOut->setPagetitle(wfMsg('confirmdelete'));
     # Better double-check that it hasn't been deleted yet!
     $dbw = wfGetDB(DB_MASTER);
     $conds = $this->mTitle->pageCond();
     $latest = $dbw->selectField('page', 'page_latest', $conds, __METHOD__);
     if ($latest === false) {
         $wgOut->showFatalError(wfMsg('cannotdelete'));
         return;
     }
     if ($confirm) {
         $this->doDelete($reason);
         if ($wgRequest->getCheck('wpWatch')) {
             WatchAction::doWatch($this->mTitle, $wgUser);
         } elseif ($this->mTitle->userIsWatching()) {
             WatchAction::doUnwatch($this->mTitle, $wgUser);
         }
         return;
     }
     // Generate deletion reason
     $hasHistory = false;
     $reason = $this->generateReason($hasHistory);
     // If the page has a history, insert a warning
     if ($hasHistory && !$confirm) {
         $skin = $wgUser->getSkin();
         $wgOut->addHTML('<strong>' . wfMsg('historywarning') . ' ' . $skin->historyLink() . '</strong>');
     }
     return $this->confirmDelete('', $reason);
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:40,代码来源:MV_DataPage.php


示例8: performUpload

 /**
  * Really perform the upload. Stores the file in the local repo, watches
  * if necessary and runs the UploadComplete hook.
  *
  * @param $comment
  * @param $pageText
  * @param $watch
  * @param $user User
  *
  * @return Status indicating the whether the upload succeeded.
  */
 public function performUpload($comment, $pageText, $watch, $user)
 {
     wfProfileIn(__METHOD__);
     $status = $this->getLocalFile()->upload($this->mTempPath, $comment, $pageText, File::DELETE_SOURCE, $this->mFileProps, false, $user);
     if ($status->isGood()) {
         if ($watch) {
             WatchAction::doWatch($this->getLocalFile()->getTitle(), $user, WatchedItem::IGNORE_USER_RIGHTS);
         }
         wfRunHooks('UploadComplete', array(&$this));
     }
     wfProfileOut(__METHOD__);
     return $status;
 }
开发者ID:elf-pavlik,项目名称:web-payments.org,代码行数:24,代码来源:UploadBase.php


示例9: 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');
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:67,代码来源:SkinTemplate.php


示例10: doUnwatch

 /**
  * Stop watching a page
  * @return bool true on successful unwatch
  * @deprecated since 1.18
  */
 public function doUnwatch()
 {
     wfDeprecated(__METHOD__, '1.18');
     return WatchAction::doUnwatch($this->getTitle(), $this->getContext()->getUser());
 }
开发者ID:nischayn22,项目名称:mediawiki-core,代码行数:10,代码来源:Article.php


示例11: doSubmit


//.........这里部分代码省略.........
     $out->addWikiMsg($msgName);
     Hooks::run('SpecialMovepageAfterMove', array(&$this, &$ot, &$nt));
     # Now we move extra pages we've been asked to move: subpages and talk
     # pages.  First, if the old page or the new page is a talk page, we
     # can't move any talk pages: cancel that.
     if ($ot->isTalkPage() || $nt->isTalkPage()) {
         $this->moveTalk = false;
     }
     if (count($ot->getUserPermissionsErrors('move-subpages', $user))) {
         $this->moveSubpages = false;
     }
     # Next make a list of id's.  This might be marginally less efficient
     # than a more direct method, but this is not a highly performance-cri-
     # tical code path and readable code is more important here.
     #
     # Note: this query works nicely on MySQL 5, but the optimizer in MySQL
     # 4 might get confused.  If so, consider rewriting as a UNION.
     #
     # If the target namespace doesn't allow subpages, moving with subpages
     # would mean that you couldn't move them back in one operation, which
     # is bad.
     # @todo FIXME: A specific error message should be given in this case.
     // @todo FIXME: Use Title::moveSubpages() here
     $dbr = wfGetDB(DB_MASTER);
     if ($this->moveSubpages && (MWNamespace::hasSubpages($nt->getNamespace()) || $this->moveTalk && MWNamespace::hasSubpages($nt->getTalkPage()->getNamespace()))) {
         $conds = array('page_title' . $dbr->buildLike($ot->getDBkey() . '/', $dbr->anyString()) . ' OR page_title = ' . $dbr->addQuotes($ot->getDBkey()));
         $conds['page_namespace'] = array();
         if (MWNamespace::hasSubpages($nt->getNamespace())) {
             $conds['page_namespace'][] = $ot->getNamespace();
         }
         if ($this->moveTalk && MWNamespace::hasSubpages($nt->getTalkPage()->getNamespace())) {
             $conds['page_namespace'][] = $ot->getTalkPage()->getNamespace();
         }
     } elseif ($this->moveTalk) {
         $conds = array('page_namespace' => $ot->getTalkPage()->getNamespace(), 'page_title' => $ot->getDBkey());
     } else {
         # Skip the query
         $conds = null;
     }
     $extraPages = array();
     if (!is_null($conds)) {
         $extraPages = TitleArray::newFromResult($dbr->select('page', array('page_id', 'page_namespace', 'page_title'), $conds, __METHOD__));
     }
     $extraOutput = array();
     $count = 1;
     foreach ($extraPages as $oldSubpage) {
         if ($ot->equals($oldSubpage) || $nt->equals($oldSubpage)) {
             # Already did this one.
             continue;
         }
         $newPageName = preg_replace('#^' . preg_quote($ot->getDBkey(), '#') . '#', StringUtils::escapeRegexReplacement($nt->getDBkey()), $oldSubpage->getDBkey());
         if ($oldSubpage->isSubpage() && ($ot->isTalkPage() xor $nt->isTalkPage())) {
             // Moving a subpage from a subject namespace to a talk namespace or vice-versa
             $newNs = $nt->getNamespace();
         } elseif ($oldSubpage->isTalkPage()) {
             $newNs = $nt->getTalkPage()->getNamespace();
         } else {
             $newNs = $nt->getSubjectPage()->getNamespace();
         }
         # Bug 14385: we need makeTitleSafe because the new page names may
         # be longer than 255 characters.
         $newSubpage = Title::makeTitleSafe($newNs, $newPageName);
         if (!$newSubpage) {
             $oldLink = Linker::linkKnown($oldSubpage);
             $extraOutput[] = $this->msg('movepage-page-unmoved')->rawParams($oldLink)->params(Title::makeName($newNs, $newPageName))->escaped();
             continue;
         }
         # This was copy-pasted from Renameuser, bleh.
         if ($newSubpage->exists() && !$oldSubpage->isValidMoveTarget($newSubpage)) {
             $link = Linker::linkKnown($newSubpage);
             $extraOutput[] = $this->msg('movepage-page-exists')->rawParams($link)->escaped();
         } else {
             $success = $oldSubpage->moveTo($newSubpage, true, $this->reason, $createRedirect);
             if ($success === true) {
                 if ($this->fixRedirects) {
                     DoubleRedirectJob::fixRedirects('move', $oldSubpage, $newSubpage);
                 }
                 $oldLink = Linker::link($oldSubpage, null, array(), array('redirect' => 'no'));
                 $newLink = Linker::linkKnown($newSubpage);
                 $extraOutput[] = $this->msg('movepage-page-moved')->rawParams($oldLink, $newLink)->escaped();
                 ++$count;
                 $maximumMovedPages = $this->getConfig()->get('MaximumMovedPages');
                 if ($count >= $maximumMovedPages) {
                     $extraOutput[] = $this->msg('movepage-max-pages')->numParams($maximumMovedPages)->escaped();
                     break;
                 }
             } else {
                 $oldLink = Linker::linkKnown($oldSubpage);
                 $newLink = Linker::link($newSubpage);
                 $extraOutput[] = $this->msg('movepage-page-unmoved')->rawParams($oldLink, $newLink)->escaped();
             }
         }
     }
     if ($extraOutput !== array()) {
         $out->addHTML("<ul>\n<li>" . implode("</li>\n<li>", $extraOutput) . "</li>\n</ul>");
     }
     # Deal with watches (we don't watch subpages)
     WatchAction::doWatchOrUnwatch($this->watch, $ot, $user);
     WatchAction::doWatchOrUnwatch($this->watch, $nt, $user);
 }
开发者ID:ngertrudiz,项目名称:mediawiki,代码行数:101,代码来源:SpecialMovepage.php


示例12: commitWatch

 /**
  * Commit the change of watch status
  */
 protected function commitWatch()
 {
     global $wgUser;
     if ($this->watchthis xor $this->mTitle->userIsWatching()) {
         $dbw = wfGetDB(DB_MASTER);
         $dbw->begin();
         if ($this->watchthis) {
             WatchAction::doWatch($this->mTitle, $wgUser);
         } else {
             WatchAction::doUnwatch($this->mTitle, $wgUser);
         }
         $dbw->commit();
     }
 }
开发者ID:slackfaith,项目名称:deadbrain_site,代码行数:17,代码来源:EditPage.php


示例13: 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;
 }
开发者ID:Grprashanthkumar,项目名称:ColfusionWeb,代码行数:22,代码来源:SkinLegacy.php


示例14: doUnwatch

 /**
  * Stop watching a page
  * @return bool true on successful unwatch
  * @deprecated since 1.18
  */
 public function doUnwatch()
 {
     global $wgUser;
     wfDeprecated(__METHOD__, '1.18');
     return WatchAction::doUnwatch($this->getTitle(), $wgUser);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:11,代码来源:Article.php


示例15: 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;
 }
开发者ID:Rikuforever,项目名称:wiki,代码行数:33,代码来源:View.php


示例16: save

 /**
  * Save submitted protection form
  *
  * @return Boolean: success
  */
 function save()
 {
     global $wgRequest, $wgUser, $wgOut;
     # Permission check!
     if ($this->disabled) {
         $this->show();
         return false;
     }
     $token = $wgRequest->getVal('wpEditToken');
     if (!$wgUser->matchEditToken($token, array('protect', $this->mTitle->getPrefixedDBkey()))) {
         $this->show(array('sessionfailure'));
         return false;
     }
     # Create reason string. Use list and/or custom string.
     $reasonstr = $this->mReasonSelection;
     if ($reasonstr != 'other' && $this->mReason != '') {
         // Entry from drop down menu + additional comment
         $reasonstr .= wfMessage('colon-separator')->text() . $this->mReason;
     } elseif ($reasonstr == 'other') {
         $reasonstr = $this->mReason;
     }
     $expiry = array();
     foreach ($this->mApplicableTypes as $action) {
         $expiry[$action] = $this->getExpiry($action);
         if (empty($this->mRestrictions[$action])) {
             continue;
             // unprotected
         }
         if (!$expiry[$action]) {
             $this->show(array('protect_expiry_invalid'));
             return false;
         }
         if ($expiry[$action] < wfTimestampNow()) {
             $this->show(array('protect_expiry_old'));
             return false;
         }
     }
     $this->mCascade = $wgRequest->getBool('mwProtect-cascade');
     $status = $this->mArticle->doUpdateRestrictions($this->mRestrictions, $expiry, $this->mCascade, $reasonstr, $wgUser);
     if (!$status->isOK()) {
         $this->show($wgOut->parseInline($status->getWikiText()));
         return false;
     }
     /**
      * Give extensions a change to handle added form items
      *
      * @since 1.19 you can (and you should) return false to abort saving;
      *             you can also return an array of message name and its parameters
      */
     $errorMsg = '';
     if (!wfRunHooks('ProtectionForm::save', array($this->mArticle, &$errorMsg, $reasonstr))) {
         if ($errorMsg == '') {
             $errorMsg = array('hookaborted');
         }
     }
     if ($errorMsg != '') {
         $this->show($errorMsg);
         return false;
     }
     WatchAction::doWatchOrUnwatch($wgRequest->getCheck('mwProtectWatch'), $this->mTitle, $wgUser);
     return true;
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:67,代码来源:ProtectionForm.php


示例17: create

 static function create($root, $article, $superthread = null, $type = Threads::TYPE_NORMAL, $subject = '', $summary = '', $bump = null, $signature = null)
 {
     $thread = new Thread(null);
     if (!in_array($type, self::$VALID_TYPES)) {
         throw new MWException(__METHOD__ . ": invalid change type {$type}.");
     }
     if ($superthread) {
         $change_type = Threads::CHANGE_REPLY_CREATED;
     } else {
         $change_type = Threads::CHANGE_NEW_THREAD;
     }
     global $wgUser;
     $thread->setAuthor($wgUser);
     if (is_object($root)) {
         $thread->setRoot($root);
     } else {
         $thread->setRootId($root);
     }
     $thread->setSuperthread($superthread);
     $thread->setArticle($article);
     $thread->setSubject($subject);
     $thread->setType($type);
     if (!is_null($signature)) {
         $thread->setSignature($signature);
     }
     $thread->insert();
     if ($superthread) {
         $superthread->addReply($thread);
         $superthread->commitRevision($change_type, $thread, $summary, $bump);
     } else {
         $hthread = ThreadRevision::create($thread, $change_type);
     }
     // Create talk page
     Threads::createTalkpageIfNeeded($article);
     // Notifications
     NewMessages::writeMessageStateForUpdatedThread($thread, $change_type, $wgUser);
     if ($wgUser->getOption('lqt-watch-threads', false)) {
         WatchAction::doWatch($thread->topmostThread()->root()->getTitle(), $wgUser);
     }
     return $thread;
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:41,代码来源:Thread.php


示例18: updateWatchlist

 /**
  * Register the change of watch status
  */
 protected function updateWatchlist()
 {
     global $wgUser;
     if ($wgUser->isLoggedIn() && $this->watchthis != $wgUser->isWatched($this->mTitle, WatchedItem::IGNORE_USER_RIGHTS)) {
         $fname = __METHOD__;
         $title = $this->mTitle;
         $watch = $this->watchthis;
         // Do this in its own transaction to reduce contention...
         $dbw = wfGetDB(DB_MASTER);
         $dbw->onTransactionIdle(function () use($dbw, $title, $watch, $wgUser, $fname) {
             WatchAction::doWatchOrUnwatch($watch, $title, $wgUser);
         });
     }
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:17,代码来源:EditPage.php


示例19: updateWatchlist

 /**
  * Register the change of watch status
  */
 protected function updateWatchlist()
 {
     global $wgUser;
     if (!$wgUser->isLoggedIn()) {
         return;
     }
     $user = $wgUser;
     $title = $this->mTitle;
     $watch = $this->watchthis;
     // Do this in its own transaction to reduce contention...
     DeferredUpdates::addCallableUpdate(function () use($user, $title, $watch) {
         if ($watch == $user->isWatched($title, WatchedItem::IGNORE_USER_RIGHTS)) {
             return;
             // nothing to change
         }
         WatchAction::doWatchOrUnwatch($watch, $title, $user);
     });
 }
开发者ID:OrBin,项目名称:mediawiki,代码行数:21,代码来源:EditPage.php


示例20: performUpload

 /**
  * Really perform the upload. Stores the file in the local repo, watches
  * if necessary and runs the UploadComplete hook.
  *
  * @param string $comment
  * @param string $pageText
  * @param bool $watch Whether the file page should be added to user's watchlist.
  *   (This doesn't check $user's permissions.)
  * @param User $user
  * @param string[] $tags Change tags to add to the log entry and page revision.
  *   (This doesn't check $user's permissions.)
  * @return Status Indicating the whether the upload succeeded.
  */
 public function performUpload($comment, $pageText, $watch, $user, $tags = [])
 {
     $this->getLocalFile()->load(File::READ_LATEST);
     $props = $this->mFileProps;
     $error = null;
     Hooks::run('UploadVerifyUpload', [$this, $user, $props, $comment, $pageText, &$error]);
     if ($error) {
         if (!is_array($error)) {
             $error = [$error];
         }
         return call_user_func_array('Status::newFatal', $error);
     }
     $status = $this->getLocalFile()->upload($this->mTempPath, $comment, $pageText, File::DELETE_SOURCE, $props, false, $user, $tags);
     if ($status->isGood()) {
         if ($watch) {
             WatchAction::doWatch($this->getLocalFile()->getTitle(), $user, User::IGNORE_USER_RIGHTS);
         }
         Hooks::run('UploadComplete', [&$this]);
         $this->postProcessUpload();
     }
     return $status;
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:35,代码来源:UploadBase.php



注:本文中的WatchAction类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP WatchedItem类代码示例发布时间:2022-05-23
下一篇:
PHP Warp类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap