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


PHP RecentChange::parseFromRCType方法代码示例

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


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

示例1: 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')) {
                 wfSuppressWarnings();
                 $params = unserialize($rc->getAttribute('rc_params'));
                 wfRestoreWarnings();
                 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:eliagbayani,项目名称:LiteratureEditor,代码行数:62,代码来源:MachineReadableRCFeedFormatter.php

示例2: extractRowInfo

 /**
  * Extracts from a single sql row the data needed to describe one recent change.
  *
  * @param stdClass $row The row from which to extract the data.
  * @return array An array mapping strings (descriptors) to their respective string values.
  * @access public
  */
 public function extractRowInfo($row)
 {
     /* Determine the title of the page that has been changed. */
     $title = Title::makeTitle($row->rc_namespace, $row->rc_title);
     $user = $this->getUser();
     /* Our output data. */
     $vals = array();
     $type = intval($row->rc_type);
     $vals['type'] = RecentChange::parseFromRCType($type);
     $anyHidden = false;
     /* Create a new entry in the result for the title. */
     if ($this->fld_title || $this->fld_ids) {
         if ($type === RC_LOG && $row->rc_deleted & LogPage::DELETED_ACTION) {
             $vals['actionhidden'] = true;
             $anyHidden = true;
         }
         if ($type !== RC_LOG || LogEventsList::userCanBitfield($row->rc_deleted, LogPage::DELETED_ACTION, $user)) {
             if ($this->fld_title) {
                 ApiQueryBase::addTitleInfo($vals, $title);
             }
             if ($this->fld_ids) {
                 $vals['pageid'] = intval($row->rc_cur_id);
                 $vals['revid'] = intval($row->rc_this_oldid);
                 $vals['old_revid'] = intval($row->rc_last_oldid);
             }
         }
     }
     if ($this->fld_ids) {
         $vals['rcid'] = intval($row->rc_id);
     }
     /* Add user data and 'anon' flag, if user is anonymous. */
     if ($this->fld_user || $this->fld_userid) {
         if ($row->rc_deleted & Revision::DELETED_USER) {
             $vals['userhidden'] = true;
             $anyHidden = true;
         }
         if (Revision::userCanBitfield($row->rc_deleted, Revision::DELETED_USER, $user)) {
             if ($this->fld_user) {
                 $vals['user'] = $row->rc_user_text;
             }
             if ($this->fld_userid) {
                 $vals['userid'] = $row->rc_user;
             }
             if (!$row->rc_user) {
                 $vals['anon'] = true;
             }
         }
     }
     /* Add flags, such as new, minor, bot. */
     if ($this->fld_flags) {
         $vals['bot'] = (bool) $row->rc_bot;
         $vals['new'] = $row->rc_type == RC_NEW;
         $vals['minor'] = (bool) $row->rc_minor;
     }
     /* Add sizes of each revision. (Only available on 1.10+) */
     if ($this->fld_sizes) {
         $vals['oldlen'] = intval($row->rc_old_len);
         $vals['newlen'] = intval($row->rc_new_len);
     }
     /* Add the timestamp. */
     if ($this->fld_timestamp) {
         $vals['timestamp'] = wfTimestamp(TS_ISO_8601, $row->rc_timestamp);
     }
     /* Add edit summary / log summary. */
     if ($this->fld_comment || $this->fld_parsedcomment) {
         if ($row->rc_deleted & Revision::DELETED_COMMENT) {
             $vals['commenthidden'] = true;
             $anyHidden = true;
         }
         if (Revision::userCanBitfield($row->rc_deleted, Revision::DELETED_COMMENT, $user)) {
             if ($this->fld_comment && isset($row->rc_comment)) {
                 $vals['comment'] = $row->rc_comment;
             }
             if ($this->fld_parsedcomment && isset($row->rc_comment)) {
                 $vals['parsedcomment'] = Linker::formatComment($row->rc_comment, $title);
             }
         }
     }
     if ($this->fld_redirect) {
         $vals['redirect'] = (bool) $row->page_is_redirect;
     }
     /* Add the patrolled flag */
     if ($this->fld_patrolled) {
         $vals['patrolled'] = $row->rc_patrolled == 1;
         $vals['unpatrolled'] = ChangesList::isUnpatrolled($row, $user);
     }
     if ($this->fld_loginfo && $row->rc_type == RC_LOG) {
         if ($row->rc_deleted & LogPage::DELETED_ACTION) {
             $vals['actionhidden'] = true;
             $anyHidden = true;
         }
         if (LogEventsList::userCanBitfield($row->rc_deleted, LogPage::DELETED_ACTION, $user)) {
             $vals['logid'] = intval($row->rc_logid);
//.........这里部分代码省略.........
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:101,代码来源:ApiQueryRecentChanges.php

示例3: extractRowInfo

 private function extractRowInfo($row)
 {
     /* Determine the title of the page that has been changed. */
     $title = Title::makeTitle($row->rc_namespace, $row->rc_title);
     $user = $this->getUser();
     /* Our output data. */
     $vals = [];
     $type = intval($row->rc_type);
     $vals['type'] = RecentChange::parseFromRCType($type);
     $anyHidden = false;
     /* Create a new entry in the result for the title. */
     if ($this->fld_title || $this->fld_ids) {
         // These should already have been filtered out of the query, but just in case.
         if ($type === RC_LOG && $row->rc_deleted & LogPage::DELETED_ACTION) {
             $vals['actionhidden'] = true;
             $anyHidden = true;
         }
         if ($type !== RC_LOG || LogEventsList::userCanBitfield($row->rc_deleted, LogPage::DELETED_ACTION, $user)) {
             if ($this->fld_title) {
                 ApiQueryBase::addTitleInfo($vals, $title);
             }
             if ($this->fld_ids) {
                 $vals['pageid'] = intval($row->rc_cur_id);
                 $vals['revid'] = intval($row->rc_this_oldid);
                 $vals['old_revid'] = intval($row->rc_last_oldid);
             }
         }
     }
     /* Add user data and 'anon' flag, if user is anonymous. */
     if ($this->fld_user || $this->fld_userid) {
         if ($row->rc_deleted & Revision::DELETED_USER) {
             $vals['userhidden'] = true;
             $anyHidden = true;
         }
         if (Revision::userCanBitfield($row->rc_deleted, Revision::DELETED_USER, $user)) {
             if ($this->fld_userid) {
                 $vals['userid'] = (int) $row->rc_user;
                 // for backwards compatibility
                 $vals['user'] = (int) $row->rc_user;
             }
             if ($this->fld_user) {
                 $vals['user'] = $row->rc_user_text;
             }
             if (!$row->rc_user) {
                 $vals['anon'] = true;
             }
         }
     }
     /* Add flags, such as new, minor, bot. */
     if ($this->fld_flags) {
         $vals['bot'] = (bool) $row->rc_bot;
         $vals['new'] = $row->rc_type == RC_NEW;
         $vals['minor'] = (bool) $row->rc_minor;
     }
     /* Add sizes of each revision. (Only available on 1.10+) */
     if ($this->fld_sizes) {
         $vals['oldlen'] = intval($row->rc_old_len);
         $vals['newlen'] = intval($row->rc_new_len);
     }
     /* Add the timestamp. */
     if ($this->fld_timestamp) {
         $vals['timestamp'] = wfTimestamp(TS_ISO_8601, $row->rc_timestamp);
     }
     if ($this->fld_notificationtimestamp) {
         $vals['notificationtimestamp'] = $row->wl_notificationtimestamp == null ? '' : wfTimestamp(TS_ISO_8601, $row->wl_notificationtimestamp);
     }
     /* Add edit summary / log summary. */
     if ($this->fld_comment || $this->fld_parsedcomment) {
         if ($row->rc_deleted & Revision::DELETED_COMMENT) {
             $vals['commenthidden'] = true;
             $anyHidden = true;
         }
         if (Revision::userCanBitfield($row->rc_deleted, Revision::DELETED_COMMENT, $user)) {
             if ($this->fld_comment && isset($row->rc_comment)) {
                 $vals['comment'] = $row->rc_comment;
             }
             if ($this->fld_parsedcomment && isset($row->rc_comment)) {
                 $vals['parsedcomment'] = Linker::formatComment($row->rc_comment, $title);
             }
         }
     }
     /* Add the patrolled flag */
     if ($this->fld_patrol) {
         $vals['patrolled'] = $row->rc_patrolled == 1;
         $vals['unpatrolled'] = ChangesList::isUnpatrolled($row, $user);
     }
     if ($this->fld_loginfo && $row->rc_type == RC_LOG) {
         if ($row->rc_deleted & LogPage::DELETED_ACTION) {
             $vals['actionhidden'] = true;
             $anyHidden = true;
         }
         if (LogEventsList::userCanBitfield($row->rc_deleted, LogPage::DELETED_ACTION, $user)) {
             $vals['logid'] = intval($row->rc_logid);
             $vals['logtype'] = $row->rc_log_type;
             $vals['logaction'] = $row->rc_log_action;
             $vals['logparams'] = LogFormatter::newFromRow($row)->formatParametersForApi();
         }
     }
     if ($anyHidden && $row->rc_deleted & Revision::DELETED_RESTRICTED) {
         $vals['suppressed'] = true;
//.........这里部分代码省略.........
开发者ID:claudinec,项目名称:galan-wiki,代码行数:101,代码来源:ApiQueryWatchlist.php

示例4: testParseFromRCType

 /**
  * @dataProvider provideRCTypes
  * @covers RecentChange::parseFromRCType
  */
 public function testParseFromRCType($rcType, $type)
 {
     $this->assertEquals($type, RecentChange::parseFromRCType($rcType));
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:8,代码来源:RecentChangeTest.php


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