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


PHP RecentChange::parseToRCType方法代码示例

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


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

示例1: run

 /**
  * Generates and outputs the result of this query based upon the provided parameters.
  *
  * @param ApiPageSet $resultPageSet
  */
 public function run($resultPageSet = null)
 {
     $user = $this->getUser();
     /* Get the parameters of the request. */
     $params = $this->extractRequestParams();
     /* Build our basic query. Namely, something along the lines of:
      * SELECT * FROM recentchanges WHERE rc_timestamp > $start
      * 		AND rc_timestamp < $end AND rc_namespace = $namespace
      */
     $this->addTables('recentchanges');
     $index = array('recentchanges' => 'rc_timestamp');
     // May change
     $this->addTimestampWhereRange('rc_timestamp', $params['dir'], $params['start'], $params['end']);
     if (!is_null($params['continue'])) {
         $cont = explode('|', $params['continue']);
         $this->dieContinueUsageIf(count($cont) != 2);
         $db = $this->getDB();
         $timestamp = $db->addQuotes($db->timestamp($cont[0]));
         $id = intval($cont[1]);
         $this->dieContinueUsageIf($id != $cont[1]);
         $op = $params['dir'] === 'older' ? '<' : '>';
         $this->addWhere("rc_timestamp {$op} {$timestamp} OR " . "(rc_timestamp = {$timestamp} AND " . "rc_id {$op}= {$id})");
     }
     $order = $params['dir'] === 'older' ? 'DESC' : 'ASC';
     $this->addOption('ORDER BY', array("rc_timestamp {$order}", "rc_id {$order}"));
     $this->addWhereFld('rc_namespace', $params['namespace']);
     if (!is_null($params['type'])) {
         try {
             $this->addWhereFld('rc_type', RecentChange::parseToRCType($params['type']));
         } catch (Exception $e) {
             ApiBase::dieDebug(__METHOD__, $e->getMessage());
         }
     }
     if (!is_null($params['show'])) {
         $show = array_flip($params['show']);
         /* Check for conflicting parameters. */
         if (isset($show['minor']) && isset($show['!minor']) || isset($show['bot']) && isset($show['!bot']) || isset($show['anon']) && isset($show['!anon']) || isset($show['redirect']) && isset($show['!redirect']) || isset($show['patrolled']) && isset($show['!patrolled']) || isset($show['patrolled']) && isset($show['unpatrolled']) || isset($show['!patrolled']) && isset($show['unpatrolled'])) {
             $this->dieUsageMsg('show');
         }
         // Check permissions
         if (isset($show['patrolled']) || isset($show['!patrolled']) || isset($show['unpatrolled'])) {
             if (!$user->useRCPatrol() && !$user->useNPPatrol()) {
                 $this->dieUsage('You need the patrol right to request the patrolled flag', 'permissiondenied');
             }
         }
         /* Add additional conditions to query depending upon parameters. */
         $this->addWhereIf('rc_minor = 0', isset($show['!minor']));
         $this->addWhereIf('rc_minor != 0', isset($show['minor']));
         $this->addWhereIf('rc_bot = 0', isset($show['!bot']));
         $this->addWhereIf('rc_bot != 0', isset($show['bot']));
         $this->addWhereIf('rc_user = 0', isset($show['anon']));
         $this->addWhereIf('rc_user != 0', isset($show['!anon']));
         $this->addWhereIf('rc_patrolled = 0', isset($show['!patrolled']));
         $this->addWhereIf('rc_patrolled != 0', isset($show['patrolled']));
         $this->addWhereIf('page_is_redirect = 1', isset($show['redirect']));
         if (isset($show['unpatrolled'])) {
             // See ChangesList:isUnpatrolled
             if ($user->useRCPatrol()) {
                 $this->addWhere('rc_patrolled = 0');
             } elseif ($user->useNPPatrol()) {
                 $this->addWhere('rc_patrolled = 0');
                 $this->addWhereFld('rc_type', RC_NEW);
             }
         }
         // Don't throw log entries out the window here
         $this->addWhereIf('page_is_redirect = 0 OR page_is_redirect IS NULL', isset($show['!redirect']));
     }
     if (!is_null($params['user']) && !is_null($params['excludeuser'])) {
         $this->dieUsage('user and excludeuser cannot be used together', 'user-excludeuser');
     }
     if (!is_null($params['user'])) {
         $this->addWhereFld('rc_user_text', $params['user']);
         $index['recentchanges'] = 'rc_user_text';
     }
     if (!is_null($params['excludeuser'])) {
         // We don't use the rc_user_text index here because
         // * it would require us to sort by rc_user_text before rc_timestamp
         // * the != condition doesn't throw out too many rows anyway
         $this->addWhere('rc_user_text != ' . $this->getDB()->addQuotes($params['excludeuser']));
     }
     /* Add the fields we're concerned with to our query. */
     $this->addFields(array('rc_id', 'rc_timestamp', 'rc_namespace', 'rc_title', 'rc_cur_id', 'rc_type', 'rc_deleted'));
     $showRedirects = false;
     /* Determine what properties we need to display. */
     if (!is_null($params['prop'])) {
         $prop = array_flip($params['prop']);
         /* Set up internal members based upon params. */
         $this->initProperties($prop);
         if ($this->fld_patrolled && !$user->useRCPatrol() && !$user->useNPPatrol()) {
             $this->dieUsage('You need the patrol right to request the patrolled flag', 'permissiondenied');
         }
         /* Add fields to our query if they are specified as a needed parameter. */
         $this->addFieldsIf(array('rc_this_oldid', 'rc_last_oldid'), $this->fld_ids);
         $this->addFieldsIf('rc_comment', $this->fld_comment || $this->fld_parsedcomment);
         $this->addFieldsIf('rc_user', $this->fld_user || $this->fld_userid);
//.........这里部分代码省略.........
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:101,代码来源:ApiQueryRecentChanges.php

示例2: parseToRCType

 /**
  * Parsing text to RC_* constants
  * @since 1.24
  * @param string|array $type
  * @throws MWException
  * @return int|array RC_TYPE
  */
 public static function parseToRCType($type)
 {
     if (is_array($type)) {
         $retval = array();
         foreach ($type as $t) {
             $retval[] = RecentChange::parseToRCType($t);
         }
         return $retval;
     }
     if (!array_key_exists($type, self::$changeTypes)) {
         throw new MWException("Unknown type '{$type}'");
     }
     return self::$changeTypes[$type];
 }
开发者ID:kolzchut,项目名称:mediawiki-molsa-new,代码行数:21,代码来源:RecentChange.php

示例3: parseToRCType

 /**
  * Parsing text to RC_* constants
  * @since 1.24
  * @param string|array $type
  * @throws MWException
  * @return int|array RC_TYPE
  */
 public static function parseToRCType($type)
 {
     if (is_array($type)) {
         $retval = array();
         foreach ($type as $t) {
             $retval[] = RecentChange::parseToRCType($t);
         }
         return $retval;
     }
     switch ($type) {
         case 'edit':
             return RC_EDIT;
         case 'new':
             return RC_NEW;
         case 'log':
             return RC_LOG;
         case 'external':
             return RC_EXTERNAL;
         default:
             throw new MWException("Unknown type '{$type}'");
     }
 }
开发者ID:natebrunette,项目名称:sphericalcow,代码行数:29,代码来源:RecentChange.php

示例4: run

 /**
  * @param ApiPageSet $resultPageSet
  * @return void
  */
 private function run($resultPageSet = null)
 {
     $this->selectNamedDB('watchlist', DB_SLAVE, 'watchlist');
     $params = $this->extractRequestParams();
     $user = $this->getUser();
     $wlowner = $this->getWatchlistUser($params);
     if (!is_null($params['prop']) && is_null($resultPageSet)) {
         $prop = array_flip($params['prop']);
         $this->fld_ids = isset($prop['ids']);
         $this->fld_title = isset($prop['title']);
         $this->fld_flags = isset($prop['flags']);
         $this->fld_user = isset($prop['user']);
         $this->fld_userid = isset($prop['userid']);
         $this->fld_comment = isset($prop['comment']);
         $this->fld_parsedcomment = isset($prop['parsedcomment']);
         $this->fld_timestamp = isset($prop['timestamp']);
         $this->fld_sizes = isset($prop['sizes']);
         $this->fld_patrol = isset($prop['patrol']);
         $this->fld_notificationtimestamp = isset($prop['notificationtimestamp']);
         $this->fld_loginfo = isset($prop['loginfo']);
         if ($this->fld_patrol) {
             if (!$user->useRCPatrol() && !$user->useNPPatrol()) {
                 $this->dieUsage('patrol property is not available', 'patrol');
             }
         }
     }
     $this->addFields(['rc_id', 'rc_namespace', 'rc_title', 'rc_timestamp', 'rc_type', 'rc_deleted']);
     if (is_null($resultPageSet)) {
         $this->addFields(['rc_cur_id', 'rc_this_oldid', 'rc_last_oldid']);
         $this->addFieldsIf(['rc_type', 'rc_minor', 'rc_bot'], $this->fld_flags);
         $this->addFieldsIf('rc_user', $this->fld_user || $this->fld_userid);
         $this->addFieldsIf('rc_user_text', $this->fld_user);
         $this->addFieldsIf('rc_comment', $this->fld_comment || $this->fld_parsedcomment);
         $this->addFieldsIf(['rc_patrolled', 'rc_log_type'], $this->fld_patrol);
         $this->addFieldsIf(['rc_old_len', 'rc_new_len'], $this->fld_sizes);
         $this->addFieldsIf('wl_notificationtimestamp', $this->fld_notificationtimestamp);
         $this->addFieldsIf(['rc_logid', 'rc_log_type', 'rc_log_action', 'rc_params'], $this->fld_loginfo);
     } elseif ($params['allrev']) {
         $this->addFields('rc_this_oldid');
     } else {
         $this->addFields('rc_cur_id');
     }
     $this->addTables(['recentchanges', 'watchlist']);
     $userId = $wlowner->getId();
     $this->addJoinConds(['watchlist' => ['INNER JOIN', ['wl_user' => $userId, 'wl_namespace=rc_namespace', 'wl_title=rc_title']]]);
     $db = $this->getDB();
     $this->addTimestampWhereRange('rc_timestamp', $params['dir'], $params['start'], $params['end']);
     // Include in ORDER BY for uniqueness
     $this->addWhereRange('rc_id', $params['dir'], null, null);
     if (!is_null($params['continue'])) {
         $cont = explode('|', $params['continue']);
         $this->dieContinueUsageIf(count($cont) != 2);
         $op = $params['dir'] === 'newer' ? '>' : '<';
         $continueTimestamp = $db->addQuotes($db->timestamp($cont[0]));
         $continueId = (int) $cont[1];
         $this->dieContinueUsageIf($continueId != $cont[1]);
         $this->addWhere("rc_timestamp {$op} {$continueTimestamp} OR " . "(rc_timestamp = {$continueTimestamp} AND " . "rc_id {$op}= {$continueId})");
     }
     $this->addWhereFld('wl_namespace', $params['namespace']);
     if (!$params['allrev']) {
         $this->addTables('page');
         $this->addJoinConds(['page' => ['LEFT JOIN', 'rc_cur_id=page_id']]);
         $this->addWhere('rc_this_oldid=page_latest OR rc_type=' . RC_LOG);
     }
     if (!is_null($params['show'])) {
         $show = array_flip($params['show']);
         /* Check for conflicting parameters. */
         if (isset($show['minor']) && isset($show['!minor']) || isset($show['bot']) && isset($show['!bot']) || isset($show['anon']) && isset($show['!anon']) || isset($show['patrolled']) && isset($show['!patrolled']) || isset($show['unread']) && isset($show['!unread'])) {
             $this->dieUsageMsg('show');
         }
         // Check permissions.
         if (isset($show['patrolled']) || isset($show['!patrolled'])) {
             if (!$user->useRCPatrol() && !$user->useNPPatrol()) {
                 $this->dieUsage('You need the patrol right to request the patrolled flag', 'permissiondenied');
             }
         }
         /* Add additional conditions to query depending upon parameters. */
         $this->addWhereIf('rc_minor = 0', isset($show['!minor']));
         $this->addWhereIf('rc_minor != 0', isset($show['minor']));
         $this->addWhereIf('rc_bot = 0', isset($show['!bot']));
         $this->addWhereIf('rc_bot != 0', isset($show['bot']));
         $this->addWhereIf('rc_user = 0', isset($show['anon']));
         $this->addWhereIf('rc_user != 0', isset($show['!anon']));
         $this->addWhereIf('rc_patrolled = 0', isset($show['!patrolled']));
         $this->addWhereIf('rc_patrolled != 0', isset($show['patrolled']));
         $this->addWhereIf('rc_timestamp >= wl_notificationtimestamp', isset($show['unread']));
         $this->addWhereIf('wl_notificationtimestamp IS NULL OR rc_timestamp < wl_notificationtimestamp', isset($show['!unread']));
     }
     if (!is_null($params['type'])) {
         try {
             $this->addWhereFld('rc_type', RecentChange::parseToRCType($params['type']));
         } catch (Exception $e) {
             ApiBase::dieDebug(__METHOD__, $e->getMessage());
         }
     }
     if (!is_null($params['user']) && !is_null($params['excludeuser'])) {
//.........这里部分代码省略.........
开发者ID:claudinec,项目名称:galan-wiki,代码行数:101,代码来源:ApiQueryWatchlist.php

示例5: testParseToRCType

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

示例6: run

 /**
  * @param ApiPageSet $resultPageSet
  * @return void
  */
 private function run($resultPageSet = null)
 {
     $this->selectNamedDB('watchlist', DB_REPLICA, 'watchlist');
     $params = $this->extractRequestParams();
     $user = $this->getUser();
     $wlowner = $this->getWatchlistUser($params);
     if (!is_null($params['prop']) && is_null($resultPageSet)) {
         $prop = array_flip($params['prop']);
         $this->fld_ids = isset($prop['ids']);
         $this->fld_title = isset($prop['title']);
         $this->fld_flags = isset($prop['flags']);
         $this->fld_user = isset($prop['user']);
         $this->fld_userid = isset($prop['userid']);
         $this->fld_comment = isset($prop['comment']);
         $this->fld_parsedcomment = isset($prop['parsedcomment']);
         $this->fld_timestamp = isset($prop['timestamp']);
         $this->fld_sizes = isset($prop['sizes']);
         $this->fld_patrol = isset($prop['patrol']);
         $this->fld_notificationtimestamp = isset($prop['notificationtimestamp']);
         $this->fld_loginfo = isset($prop['loginfo']);
         if ($this->fld_patrol) {
             if (!$user->useRCPatrol() && !$user->useNPPatrol()) {
                 $this->dieUsage('patrol property is not available', 'patrol');
             }
         }
     }
     $options = ['dir' => $params['dir'] === 'older' ? WatchedItemQueryService::DIR_OLDER : WatchedItemQueryService::DIR_NEWER];
     if (is_null($resultPageSet)) {
         $options['includeFields'] = $this->getFieldsToInclude();
     } else {
         $options['usedInGenerator'] = true;
     }
     if ($params['start']) {
         $options['start'] = $params['start'];
     }
     if ($params['end']) {
         $options['end'] = $params['end'];
     }
     if (!is_null($params['continue'])) {
         $cont = explode('|', $params['continue']);
         $this->dieContinueUsageIf(count($cont) != 2);
         $continueTimestamp = $cont[0];
         $continueId = (int) $cont[1];
         $this->dieContinueUsageIf($continueId != $cont[1]);
         $options['startFrom'] = [$continueTimestamp, $continueId];
     }
     if ($wlowner !== $user) {
         $options['watchlistOwner'] = $wlowner;
         $options['watchlistOwnerToken'] = $params['token'];
     }
     if (!is_null($params['namespace'])) {
         $options['namespaceIds'] = $params['namespace'];
     }
     if ($params['allrev']) {
         $options['allRevisions'] = true;
     }
     if (!is_null($params['show'])) {
         $show = array_flip($params['show']);
         /* Check for conflicting parameters. */
         if ($this->showParamsConflicting($show)) {
             $this->dieUsageMsg('show');
         }
         // Check permissions.
         if (isset($show[WatchedItemQueryService::FILTER_PATROLLED]) || isset($show[WatchedItemQueryService::FILTER_NOT_PATROLLED])) {
             if (!$user->useRCPatrol() && !$user->useNPPatrol()) {
                 $this->dieUsage('You need the patrol right to request the patrolled flag', 'permissiondenied');
             }
         }
         $options['filters'] = array_keys($show);
     }
     if (!is_null($params['type'])) {
         try {
             $options['rcTypes'] = RecentChange::parseToRCType($params['type']);
         } catch (Exception $e) {
             ApiBase::dieDebug(__METHOD__, $e->getMessage());
         }
     }
     if (!is_null($params['user']) && !is_null($params['excludeuser'])) {
         $this->dieUsage('user and excludeuser cannot be used together', 'user-excludeuser');
     }
     if (!is_null($params['user'])) {
         $options['onlyByUser'] = $params['user'];
     }
     if (!is_null($params['excludeuser'])) {
         $options['notByUser'] = $params['excludeuser'];
     }
     $options['limit'] = $params['limit'] + 1;
     $ids = [];
     $count = 0;
     $watchedItemQuery = MediaWikiServices::getInstance()->getWatchedItemQueryService();
     $items = $watchedItemQuery->getWatchedItemsWithRecentChangeInfo($wlowner, $options);
     foreach ($items as list($watchedItem, $recentChangeInfo)) {
         /** @var WatchedItem $watchedItem */
         if (++$count > $params['limit']) {
             // We've reached the one extra which shows that there are
             // additional pages to be had. Stop here...
//.........这里部分代码省略.........
开发者ID:paladox,项目名称:mediawiki,代码行数:101,代码来源:ApiQueryWatchlist.php


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