当前位置: 首页>>代码示例>>PHP>>正文


PHP RecentChange::getAttribute方法代码示例

本文整理汇总了PHP中RecentChange::getAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP RecentChange::getAttribute方法的具体用法?PHP RecentChange::getAttribute怎么用?PHP RecentChange::getAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RecentChange的用法示例。


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

示例1: getPatrolToken

 /**
  * @deprecated since 1.24
  * @param int $pageid
  * @param Title $title
  * @param RecentChange|null $rc
  * @return bool|string
  */
 public static function getPatrolToken($pageid, $title, $rc = null)
 {
     global $wgUser;
     $validTokenUser = false;
     if ($rc) {
         if ($wgUser->useRCPatrol() && $rc->getAttribute('rc_type') == RC_EDIT || $wgUser->useNPPatrol() && $rc->getAttribute('rc_type') == RC_NEW) {
             $validTokenUser = true;
         }
     } elseif ($wgUser->useRCPatrol() || $wgUser->useNPPatrol()) {
         $validTokenUser = true;
     }
     if ($validTokenUser) {
         // The patrol token is always the same, let's exploit that
         static $cachedPatrolToken = null;
         if (is_null($cachedPatrolToken)) {
             $cachedPatrolToken = $wgUser->getEditToken('patrol');
         }
         return $cachedPatrolToken;
     }
     return false;
 }
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:28,代码来源:ApiQueryRecentChanges.php

示例2: isCategorizationWithoutRevision

 /**
  * Determines whether a revision is linked to this change; this may not be the case
  * when the categorization wasn't done by an edit but a conditional parser function
  *
  * @since 1.27
  *
  * @param RecentChange|RCCacheEntry $rcObj
  * @return bool
  */
 protected function isCategorizationWithoutRevision($rcObj)
 {
     return intval($rcObj->getAttribute('rc_type')) === RC_CATEGORIZE && intval($rcObj->getAttribute('rc_this_oldid')) === 0;
 }
开发者ID:junjiemars,项目名称:mediawiki,代码行数:13,代码来源:ChangesList.php

示例3: onRecentChange_save

 /**
  * RecentChange_save hook handler that tags mobile changes
  * @see https://www.mediawiki.org/wiki/Manual:Hooks/RecentChange_save
  *
  * @param RecentChange $rc
  * @return bool
  */
 public static function onRecentChange_save(RecentChange $rc)
 {
     $context = MobileContext::singleton();
     $userAgent = $context->getRequest()->getHeader("User-agent");
     $logType = $rc->getAttribute('rc_log_type');
     // Only log edits and uploads
     if ($context->shouldDisplayMobileView() && ($logType === 'upload' || is_null($logType))) {
         $rcId = $rc->getAttribute('rc_id');
         $revId = $rc->getAttribute('rc_this_oldid');
         $logId = $rc->getAttribute('rc_logid');
         ChangeTags::addTags('mobile edit', $rcId, $revId, $logId);
         // Tag as mobile web edit specifically, if it isn't coming from the apps
         if (strpos($userAgent, 'WikipediaApp/') !== 0) {
             ChangeTags::addTags('mobile web edit', $rcId, $revId, $logId);
         }
     }
     return true;
 }
开发者ID:micha6554,项目名称:mediawiki-extensions-MobileFrontend,代码行数:25,代码来源:MobileFrontend.hooks.php

示例4: watchlistNotify

 /**
  * Hook
  *
  * @param RecentChange $oRC -- instance of RecentChange class
  *
  * @static
  * @access public
  *
  * @return Bool true -- because it's a hook
  */
 public static function watchlistNotify(RecentChange &$oRC)
 {
     global $wgEnableGroupedArticleCommentsRC;
     wfProfileIn(__METHOD__);
     wfRunHooks('AC_RecentChange_Save', array(&$oRC));
     if (!empty($wgEnableGroupedArticleCommentsRC) && $oRC instanceof RecentChange) {
         $title = $oRC->getAttribute('rc_title');
         $namespace = $oRC->getAttribute('rc_namespace');
         $article_id = $oRC->getAttribute('rc_cur_id');
         $title = Title::newFromText($title, $namespace);
         //TODO: review
         if (MWNamespace::isTalk($namespace) && ArticleComment::isTitleComment($title) && !empty($article_id)) {
             $comment = ArticleComment::newFromId($article_id);
             if ($comment instanceof ArticleComment) {
                 $oArticlePage = $comment->getArticleTitle();
                 $mAttribs = $oRC->mAttribs;
                 $mAttribs['rc_title'] = $oArticlePage->getDBkey();
                 $mAttribs['rc_namespace'] = $oArticlePage->getNamespace();
                 $mAttribs['rc_log_action'] = 'article_comment';
                 $oRC->setAttribs($mAttribs);
             }
         }
     }
     wfProfileOut(__METHOD__);
     return true;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:36,代码来源:ArticleComment.class.php

示例5: buildParams

 /**
  * Prepare log parameters for a patrolled change
  *
  * @param RecentChange $change RecentChange to represent
  * @param bool $auto Whether the patrol event was automatic
  * @return array
  */
 private static function buildParams($change, $auto)
 {
     return array('4::curid' => $change->getAttribute('rc_this_oldid'), '5::previd' => $change->getAttribute('rc_last_oldid'), '6::auto' => (int) $auto);
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:11,代码来源:PatrolLog.php

示例6: getLine

 /**
  * Generates a notification that can be easily interpreted by a machine.
  * @see RCFeedFormatter::getLine
  */
 public function getLine(array $feed, RecentChange $rc, $actionComment)
 {
     global $wgCanonicalServer, $wgServerName, $wgScriptPath;
     $packet = array('id' => $rc->getAttribute('rc_id'), 'type' => RecentChange::parseFromRCType($rc->getAttribute('rc_type')), 'namespace' => $rc->getTitle()->getNamespace(), 'title' => $rc->getTitle()->getPrefixedText(), 'comment' => $rc->getAttribute('rc_comment'), 'timestamp' => (int) wfTimestamp(TS_UNIX, $rc->getAttribute('rc_timestamp')), 'user' => $rc->getAttribute('rc_user_text'), 'bot' => (bool) $rc->getAttribute('rc_bot'));
     if (isset($feed['channel'])) {
         $packet['channel'] = $feed['channel'];
     }
     $type = $rc->getAttribute('rc_type');
     if ($type == RC_EDIT || $type == RC_NEW) {
         global $wgUseRCPatrol, $wgUseNPPatrol;
         $packet['minor'] = (bool) $rc->getAttribute('rc_minor');
         if ($wgUseRCPatrol || $type == RC_NEW && $wgUseNPPatrol) {
             $packet['patrolled'] = (bool) $rc->getAttribute('rc_patrolled');
         }
     }
     switch ($type) {
         case RC_EDIT:
             $packet['length'] = array('old' => $rc->getAttribute('rc_old_len'), 'new' => $rc->getAttribute('rc_new_len'));
             $packet['revision'] = array('old' => $rc->getAttribute('rc_last_oldid'), 'new' => $rc->getAttribute('rc_this_oldid'));
             break;
         case RC_NEW:
             $packet['length'] = array('old' => null, 'new' => $rc->getAttribute('rc_new_len'));
             $packet['revision'] = array('old' => null, 'new' => $rc->getAttribute('rc_this_oldid'));
             break;
         case RC_LOG:
             $packet['log_id'] = $rc->getAttribute('rc_logid');
             $packet['log_type'] = $rc->getAttribute('rc_log_type');
             $packet['log_action'] = $rc->getAttribute('rc_log_action');
             if ($rc->getAttribute('rc_params')) {
                 $params = $rc->parseParams();
                 if ($rc->getAttribute('rc_params') == serialize(false) || $params !== false) {
                     // From ApiQueryLogEvents::addLogParams
                     $logParams = array();
                     // Keys like "4::paramname" can't be used for output so we change them to "paramname"
                     foreach ($params as $key => $value) {
                         if (strpos($key, ':') === false) {
                             $logParams[$key] = $value;
                             continue;
                         }
                         $logParam = explode(':', $key, 3);
                         $logParams[$logParam[2]] = $value;
                     }
                     $packet['log_params'] = $logParams;
                 } else {
                     $packet['log_params'] = explode("\n", $rc->getAttribute('rc_params'));
                 }
             }
             $packet['log_action_comment'] = $actionComment;
             break;
     }
     $packet['server_url'] = $wgCanonicalServer;
     $packet['server_name'] = $wgServerName;
     $packet['server_script_path'] = $wgScriptPath ?: '/';
     $packet['wiki'] = wfWikiID();
     return $this->formatArray($packet);
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:60,代码来源:MachineReadableRCFeedFormatter.php

示例7: onChangesListMakeSecureName

 /**
  * @brief Adjusting blocks on Enhanced Recent Changes page
  *
  * @desc Changes $secureName which is an array key in RC cache by which blocks on enchance RC page are displayed
  *
  * @param ChangesList $changesList
  * @param string $secureName
  * @param RecentChange $rc
  *
  * @author Andrzej 'nAndy' Łukaszewski
  */
 public function onChangesListMakeSecureName($changesList, &$secureName, $rc)
 {
     if (intval($rc->getAttribute('rc_namespace')) === NS_USER_WALL_MESSAGE) {
         $oTitle = $rc->getTitle();
         if ($oTitle instanceof Title) {
             $wm = F::build('WallMessage', array($oTitle));
             $parent = $wm->getTopParentObj();
             $isMain = is_null($parent);
             if (!$isMain) {
                 $wm = $parent;
                 unset($parent);
             }
             $secureName = self::RC_WALL_SECURENAME_PREFIX . $wm->getArticleId();
         }
     }
     return true;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:28,代码来源:WallHooksHelper.class.php

示例8: onChangesListMakeSecureName

 /**
  * @brief Adjusting blocks on Enhanced Recent Changes page
  *
  * Changes $secureName which is an array key in RC cache by which blocks on enchance RC page are displayed
  *
  * @param ChangesList $changesList
  * @param string $secureName
  * @param RecentChange $rc
  *
  * @return bool
  * @author Andrzej 'nAndy' Łukaszewski
  */
 public static function onChangesListMakeSecureName($changesList, &$secureName, $rc)
 {
     if (WallHelper::isWallNamespace(intval($rc->getAttribute('rc_namespace')))) {
         $oTitle = $rc->getTitle();
         if ($oTitle instanceof Title) {
             $wm = new WallMessage($oTitle);
             $parent = $wm->getTopParentObj();
             $isMain = is_null($parent);
             if (!$isMain) {
                 $wm = $parent;
                 unset($parent);
             }
             $secureName = self::RC_WALL_SECURENAME_PREFIX . $wm->getArticleId();
         }
     }
     return true;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:29,代码来源:WallHooksHelper.class.php

示例9: getEventData

 /**
  * Generates and returns data for edit event to be processed
  *
  * @param User $editor
  * @param RecentChange $oRecentChange
  * @param boolean $isRegisteredUser
  * @param boolean $isRegisteredUserFirstEdit
  * @return array
  */
 public static function getEventData($editor, $oRecentChange, $isRegisteredUser, $isRegisteredUserFirstEdit)
 {
     $oTitle = Title::makeTitle($oRecentChange->getAttribute('rc_namespace'), $oRecentChange->getAttribute('rc_title'));
     $eventData = ['titleText' => $oTitle->getText(), 'titleNs' => $oRecentChange->getAttribute('rc_namespace'), 'titleUrl' => $oTitle->getFullUrl(), 'currentRevId' => $oRecentChange->getAttribute('rc_this_oldid'), 'previousRevId' => $oRecentChange->getAttribute('rc_last_oldid'), 'editorName' => $editor->getName(), 'editorPageUrl' => $editor->getUserPage()->getFullUrl(), 'editorTalkPageUrl' => $editor->getTalkPage()->getFullUrl(), 'registeredUser' => $isRegisteredUser, 'registeredUserFirstEdit' => $isRegisteredUserFirstEdit, 'myHomeUrl' => Title::newFromText('WikiActivity', NS_SPECIAL)->getFullUrl()];
     return $eventData;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:15,代码来源:FounderEmailsEditEvent.class.php

示例10: buildParams

 /**
  * Prepare log parameters for a patrolled change
  *
  * @param RecentChange $change RecentChange to represent
  * @param bool $auto Whether the patrol event was automatic
  * @return array
  */
 private static function buildParams($change, $auto)
 {
     return array($change->getAttribute('rc_this_oldid'), $change->getAttribute('rc_last_oldid'), (int) $auto);
 }
开发者ID:ErdemA,项目名称:wikihow,代码行数:11,代码来源:PatrolLog.php

示例11: onIRCLineURL

 public static function onIRCLineURL(&$url, &$query, RecentChange $rc)
 {
     if ($rc->getAttribute('rc_source') !== Flow\Data\Listener\RecentChangesListener::SRC_FLOW) {
         return true;
     }
     set_error_handler(new Flow\RecoverableErrorHandler(), -1);
     $result = null;
     try {
         /** @var Flow\Formatter\IRCLineUrlFormatter $formatter */
         $formatter = Container::get('formatter.irclineurl');
         $result = $formatter->format($rc);
     } catch (Exception $e) {
         $result = null;
         wfDebugLog('Flow', __METHOD__ . ': Failed formatting rc ' . $rc->getAttribute('rc_id') . ': ' . $e->getMessage());
         MWExceptionHandler::logException($e);
     }
     restore_error_handler();
     if ($result !== null) {
         $url = $result;
         $query = '';
     }
     return true;
 }
开发者ID:TarLocesilion,项目名称:mediawiki-extensions-Flow,代码行数:23,代码来源:Hooks.php

示例12: storeInRecentChanges

 /**
  * Store custom data in rc_params field as JSON encoded table prefixed with extra string.
  * To pass in extra key-value pairs, pass in 'data' as an associative array.
  *
  * @see http://www.mediawiki.org/wiki/Logging_table#log_params
  *
  * @author Maciej Brencz <macbre@wikia-inc.com>
  */
 public static function storeInRecentChanges(RecentChange $rc, $data = array())
 {
     wfProfileIn(__METHOD__);
     /* @var $wgParser Parser */
     global $wgParser;
     // If we have existing data packed into rc_params, make sure it is preserved.
     if (isset($rc->mAttribs['rc_params'])) {
         $unpackedData = self::unpackData($rc->mAttribs['rc_params']);
         if (is_array($unpackedData)) {
             foreach ($unpackedData as $key => $val) {
                 // Give preference to the data array that was passed into the function.
                 if (!isset($data[$key])) {
                     $data[$key] = $val;
                 }
             }
         }
     }
     // summary generated by MW: store auto-summary type
     if (Wikia::isVarSet('AutoSummaryType')) {
         $data['autosummaryType'] = Wikia::getVar('AutoSummaryType');
     }
     switch ($rc->getAttribute('rc_type')) {
         // existing article
         case RC_EDIT:
             // rollback: store ID of the revision rollback is made to
             if (Wikia::isVarSet('RollbackedRevId')) {
                 $data['rollback'] = true;
                 $data['revId'] = Wikia::getVar('RollbackedRevId');
             }
             // edit from view mode
             if (Wikia::isVarSet('EditFromViewMode')) {
                 $data['viewMode'] = 1;
                 if (Wikia::isVarSet('EditFromViewMode') == 'CategorySelect') {
                     $data['CategorySelect'] = 1;
                 }
             }
             // section edit: store section name and modified summary
             if (self::$editedSectionName !== false) {
                 // store section name
                 $data['sectionName'] = self::$editedSectionName;
                 // edit summary
                 $comment = trim($rc->getAttribute('rc_comment'));
                 // summary has changed - store modified summary
                 if (!preg_match('#^/\\*(.*)\\*/$#', $comment)) {
                     // remove /* Section title */
                     $comment = preg_replace('#/\\*(.*)\\*/#', '', $comment);
                     // remove all wikitext
                     $comment = trim($wgParser->stripSectionName($comment));
                     if ($comment != '') {
                         $data['summary'] = $comment;
                     }
                 }
             }
             break;
             // new article
         // new article
         case RC_NEW:
             $content = $wgParser->getOutput()->getText();
             // remove [edit] section links
             $content = preg_replace('#<span class="editsection">(.*)</a>]</span>#', '', $content);
             // remove <script> tags (RT #46350)
             $content = preg_replace('#<script[^>]+>(.*)<\\/script>#', '', $content);
             // remove text between tags (RT #141394) and get rid of photo attribution (BugId:23871)
             $content = ActivityFeedHelper::filterTextBetweenTags($content);
             // remove HTML tags
             $content = trim(strip_tags($content));
             // store first 150 characters of parsed content
             $data['intro'] = mb_substr($content, 0, 150);
             $data['intro'] = strtr($data['intro'], array('&nbsp;' => ' ', '&amp;' => '&'));
             break;
     }
     //allow to alter $data by other extensions (eg. Article Comments)
     wfRunHooks('MyHome:BeforeStoreInRC', array(&$rc, &$data));
     // encode data to be stored in rc_params
     if (!empty($data)) {
         $rc->mAttribs['rc_params'] = self::packData($data);
     }
     Wikia::setVar('rc', $rc);
     Wikia::setVar('rc_data', $data);
     wfProfileOut(__METHOD__);
     return true;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:90,代码来源:MyHome.class.php


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