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

PHP ApiQueryBase类代码示例

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

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



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

示例1: execute

 /**
  * Patrols the article or provides the reason the patrol failed.
  */
 public function execute()
 {
     $params = $this->extractRequestParams();
     $this->requireOnlyOneParameter($params, 'rcid', 'revid');
     if (isset($params['rcid'])) {
         $rc = RecentChange::newFromID($params['rcid']);
         if (!$rc) {
             $this->dieUsageMsg(array('nosuchrcid', $params['rcid']));
         }
     } else {
         $rev = Revision::newFromId($params['revid']);
         if (!$rev) {
             $this->dieUsageMsg(array('nosuchrevid', $params['revid']));
         }
         $rc = $rev->getRecentChange();
         if (!$rc) {
             $this->dieUsage('The revision ' . $params['revid'] . " can't be patrolled as it's too old", 'notpatrollable');
         }
     }
     $retval = $rc->doMarkPatrolled($this->getUser());
     if ($retval) {
         $this->dieUsageMsg(reset($retval));
     }
     $result = array('rcid' => intval($rc->getAttribute('rc_id')));
     ApiQueryBase::addTitleInfo($result, $rc->getTitle());
     $this->getResult()->addValue(null, $this->getModuleName(), $result);
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:30,代码来源:ApiPatrol.php


示例2: execute

 /**
  * Purges the cache of a page
  */
 public function execute()
 {
     global $wgUser;
     $params = $this->extractRequestParams();
     if (!$wgUser->isAllowed('purge')) {
         $this->dieUsageMsg(array('cantpurge'));
     }
     if (!isset($params['titles'])) {
         $this->dieUsageMsg(array('missingparam', 'titles'));
     }
     $result = array();
     foreach ($params['titles'] as $t) {
         $r = array();
         $title = Title::newFromText($t);
         if (!$title instanceof Title) {
             $r['title'] = $t;
             $r['invalid'] = '';
             $result[] = $r;
             continue;
         }
         ApiQueryBase::addTitleInfo($r, $title);
         if (!$title->exists()) {
             $r['missing'] = '';
             $result[] = $r;
             continue;
         }
         $article = new Article($title);
         $article->doPurge();
         // Directly purge and skip the UI part of purge().
         $r['purged'] = '';
         $result[] = $r;
     }
     $this->getResult()->setIndexedTagName($result, 'page');
     $this->getResult()->addValue(null, $this->getModuleName(), $result);
 }
开发者ID:amjadtbssm,项目名称:website,代码行数:38,代码来源:ApiPurge.php


示例3: execute

 /**
  * Patrols the article or provides the reason the patrol failed.
  */
 public function execute()
 {
     global $wgUser, $wgUseRCPatrol, $wgUseNPPatrol;
     $this->getMain()->requestWriteMode();
     $params = $this->extractRequestParams();
     if (!isset($params['token'])) {
         $this->dieUsageMsg(array('missingparam', 'token'));
     }
     if (!isset($params['rcid'])) {
         $this->dieUsageMsg(array('missingparam', 'rcid'));
     }
     if (!$wgUser->matchEditToken($params['token'])) {
         $this->dieUsageMsg(array('sessionfailure'));
     }
     $rc = RecentChange::newFromID($params['rcid']);
     if (!$rc instanceof RecentChange) {
         $this->dieUsageMsg(array('nosuchrcid', $params['rcid']));
     }
     $retval = RecentChange::markPatrolled($params['rcid']);
     if ($retval) {
         $this->dieUsageMsg(current($retval));
     }
     $result = array('rcid' => $rc->getAttribute('rc_id'));
     ApiQueryBase::addTitleInfo($result, $rc->getTitle());
     $this->getResult()->addValue(null, $this->getModuleName(), $result);
 }
开发者ID:amjadtbssm,项目名称:website,代码行数:29,代码来源:ApiPatrol.php


示例4: execute

 /**
  * Purges the cache of a page
  */
 public function execute()
 {
     $params = $this->extractRequestParams();
     $forceLinkUpdate = $params['forcelinkupdate'];
     $pageSet = $this->getPageSet();
     $pageSet->execute();
     $result = array();
     self::addValues($result, $pageSet->getInvalidTitles(), 'invalid', 'title');
     self::addValues($result, $pageSet->getSpecialTitles(), 'special', 'title');
     self::addValues($result, $pageSet->getMissingPageIDs(), 'missing', 'pageid');
     self::addValues($result, $pageSet->getMissingRevisionIDs(), 'missing', 'revid');
     self::addValues($result, $pageSet->getMissingTitles(), 'missing');
     self::addValues($result, $pageSet->getInterwikiTitlesAsResult());
     foreach ($pageSet->getGoodTitles() as $title) {
         $r = array();
         ApiQueryBase::addTitleInfo($r, $title);
         $page = WikiPage::factory($title);
         $page->doPurge();
         // Directly purge and skip the UI part of purge().
         $r['purged'] = '';
         if ($forceLinkUpdate) {
             if (!$this->getUser()->pingLimiter()) {
                 global $wgEnableParserCache;
                 $popts = $page->makeParserOptions('canonical');
                 # Parse content; note that HTML generation is only needed if we want to cache the result.
                 $content = $page->getContent(Revision::RAW);
                 $p_result = $content->getParserOutput($title, $page->getLatest(), $popts, $wgEnableParserCache);
                 # Update the links tables
                 $updates = $content->getSecondaryDataUpdates($title, null, true, $p_result);
                 DataUpdate::runUpdates($updates);
                 $r['linkupdate'] = '';
                 if ($wgEnableParserCache) {
                     $pcache = ParserCache::singleton();
                     $pcache->save($p_result, $page, $popts);
                 }
             } else {
                 $error = $this->parseMsg(array('actionthrottledtext'));
                 $this->setWarning($error['info']);
                 $forceLinkUpdate = false;
             }
         }
         $result[] = $r;
     }
     $apiResult = $this->getResult();
     $apiResult->setIndexedTagName($result, 'page');
     $apiResult->addValue(null, $this->getModuleName(), $result);
     $values = $pageSet->getNormalizedTitlesAsResult($apiResult);
     if ($values) {
         $apiResult->addValue(null, 'normalized', $values);
     }
     $values = $pageSet->getConvertedTitlesAsResult($apiResult);
     if ($values) {
         $apiResult->addValue(null, 'converted', $values);
     }
     $values = $pageSet->getRedirectTitlesAsResult($apiResult);
     if ($values) {
         $apiResult->addValue(null, 'redirects', $values);
     }
 }
开发者ID:Grprashanthkumar,项目名称:ColfusionWeb,代码行数:62,代码来源:ApiPurge.php


示例5: run

 private function run($resultPageSet = null)
 {
     wfProfileIn($this->getModuleProfileName() . '-getDB');
     $db =& $this->getDB();
     wfProfileOut($this->getModuleProfileName() . '-getDB');
     wfProfileIn($this->getModuleProfileName() . '-parseParams');
     $limit = $from = $namespace = $filterredir = $prefix = null;
     extract($this->extractRequestParams());
     $this->addTables('page');
     if (!$this->addWhereIf('page_is_redirect = 1', $filterredir === 'redirects')) {
         $this->addWhereIf('page_is_redirect = 0', $filterredir === 'nonredirects');
     }
     $this->addWhereFld('page_namespace', $namespace);
     if (isset($from)) {
         $this->addWhere('page_title>=' . $db->addQuotes(ApiQueryBase::titleToKey($from)));
     }
     if (isset($prefix)) {
         $this->addWhere("page_title LIKE '{$db->strencode(ApiQueryBase::titleToKey($prefix))}%'");
     }
     if (is_null($resultPageSet)) {
         $this->addFields(array('page_id', 'page_namespace', 'page_title'));
     } else {
         $this->addFields($resultPageSet->getPageTableFields());
     }
     $this->addOption('USE INDEX', 'name_title');
     $this->addOption('LIMIT', $limit + 1);
     $this->addOption('ORDER BY', 'page_namespace, page_title');
     wfProfileOut($this->getModuleProfileName() . '-parseParams');
     $res = $this->select(__METHOD__);
     wfProfileIn($this->getModuleProfileName() . '-saveResults');
     $data = array();
     $count = 0;
     while ($row = $db->fetchObject($res)) {
         if (++$count > $limit) {
             // We've reached the one extra which shows that there are additional pages to be had. Stop here...
             $this->setContinueEnumParameter('from', ApiQueryBase::keyToTitle($row->page_title));
             break;
         }
         if (is_null($resultPageSet)) {
             $vals = $this->addRowInfo('page', $row);
             if ($vals) {
                 $data[intval($row->page_id)] = $vals;
             }
         } else {
             $resultPageSet->processDbRow($row);
         }
     }
     $db->freeResult($res);
     if (is_null($resultPageSet)) {
         $result = $this->getResult();
         $result->setIndexedTagName($data, 'p');
         $result->addValue('query', $this->getModuleName(), $data);
     }
     wfProfileOut($this->getModuleProfileName() . '-saveResults');
 }
开发者ID:negabaro,项目名称:alfresco,代码行数:55,代码来源:ApiQueryAllpages.php


示例6: execute

 /**
  * Purges the cache of a page
  */
 public function execute()
 {
     global $wgUser;
     $params = $this->extractRequestParams();
     if (!$wgUser->isAllowed('purge') && !$this->getMain()->isInternalMode() && !$this->getMain()->getRequest()->wasPosted()) {
         $this->dieUsageMsg(array('mustbeposted', $this->getModuleName()));
     }
     $forceLinkUpdate = $params['forcelinkupdate'];
     $result = array();
     foreach ($params['titles'] as $t) {
         $r = array();
         $title = Title::newFromText($t);
         if (!$title instanceof Title) {
             $r['title'] = $t;
             $r['invalid'] = '';
             $result[] = $r;
             continue;
         }
         ApiQueryBase::addTitleInfo($r, $title);
         if (!$title->exists()) {
             $r['missing'] = '';
             $result[] = $r;
             continue;
         }
         $context = $this->createContext();
         $context->setTitle($title);
         $article = Article::newFromTitle($title, $context);
         $article->doPurge();
         // Directly purge and skip the UI part of purge().
         $r['purged'] = '';
         if ($forceLinkUpdate) {
             if (!$wgUser->pingLimiter()) {
                 global $wgParser, $wgEnableParserCache;
                 $popts = new ParserOptions();
                 $p_result = $wgParser->parse($article->getContent(), $title, $popts);
                 # Update the links tables
                 $u = new LinksUpdate($title, $p_result);
                 $u->doUpdate();
                 $r['linkupdate'] = '';
                 if ($wgEnableParserCache) {
                     $pcache = ParserCache::singleton();
                     $pcache->save($p_result, $article, $popts);
                 }
             } else {
                 $this->setWarning($this->parseMsg(array('actionthrottledtext')));
                 $forceLinkUpdate = false;
             }
         }
         $result[] = $r;
     }
     $apiResult = $this->getResult();
     $apiResult->setIndexedTagName($result, 'page');
     $apiResult->addValue(null, $this->getModuleName(), $result);
 }
开发者ID:tuxmania87,项目名称:GalaxyAdventures,代码行数:57,代码来源:ApiPurge.php


示例7: run

 private function run($resultPageSet = null)
 {
     $limit = $from = $namespace = $filterredir = null;
     extract($this->extractRequestParams());
     $db = $this->getDB();
     $where = array('page_namespace' => $namespace);
     if (isset($from)) {
         $where[] = 'page_title>=' . $db->addQuotes(ApiQueryBase::titleToKey($from));
     }
     if ($filterredir === 'redirects') {
         $where['page_is_redirect'] = 1;
     } elseif ($filterredir === 'nonredirects') {
         $where['page_is_redirect'] = 0;
     }
     if (is_null($resultPageSet)) {
         $fields = array('page_id', 'page_namespace', 'page_title');
     } else {
         $fields = $resultPageSet->getPageTableFields();
     }
     $this->profileDBIn();
     $res = $db->select('page', $fields, $where, __CLASS__ . '::' . __METHOD__, array('USE INDEX' => 'name_title', 'LIMIT' => $limit + 1, 'ORDER BY' => 'page_namespace, page_title'));
     $this->profileDBOut();
     $data = array();
     $count = 0;
     while ($row = $db->fetchObject($res)) {
         if (++$count > $limit) {
             // We've reached the one extra which shows that there are additional pages to be had. Stop here...
             $msg = array('continue' => $this->encodeParamName('from') . '=' . ApiQueryBase::keyToTitle($row->page_title));
             $this->getResult()->addValue('query-status', 'allpages', $msg);
             break;
         }
         $title = Title::makeTitle($row->page_namespace, $row->page_title);
         // skip any pages that user has no rights to read
         if ($title->userCanRead()) {
             if (is_null($resultPageSet)) {
                 $id = intval($row->page_id);
                 $data[] = $id;
                 // in generator mode, just assemble a list of page IDs.
             } else {
                 $resultPageSet->processDbRow($row);
             }
         }
     }
     $db->freeResult($res);
     if (is_null($resultPageSet)) {
         ApiResult::setIndexedTagName($data, 'p');
         $this->getResult()->addValue('query', 'allpages', $data);
     }
 }
开发者ID:puring0815,项目名称:OpenKore,代码行数:49,代码来源:ApiQueryAllpages.php


示例8: execute

 /**
  * Patrols the article or provides the reason the patrol failed.
  */
 public function execute()
 {
     $params = $this->extractRequestParams();
     $rc = RecentChange::newFromID($params['rcid']);
     if (!$rc instanceof RecentChange) {
         $this->dieUsageMsg(array('nosuchrcid', $params['rcid']));
     }
     $retval = $rc->doMarkPatrolled($this->getUser());
     if ($retval) {
         $this->dieUsageMsg(reset($retval));
     }
     $result = array('rcid' => intval($rc->getAttribute('rc_id')));
     ApiQueryBase::addTitleInfo($result, $rc->getTitle());
     $this->getResult()->addValue(null, $this->getModuleName(), $result);
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:18,代码来源:ApiPatrol.php


示例9: run

 private function run($resultPageSet = null)
 {
     $db = $this->getDB();
     $params = $this->extractRequestParams();
     $this->addTables('page');
     if (!$this->addWhereIf('page_is_redirect = 1', $params['filterredir'] === 'redirects')) {
         $this->addWhereIf('page_is_redirect = 0', $params['filterredir'] === 'nonredirects');
     }
     $this->addWhereFld('page_namespace', $params['namespace']);
     if (!is_null($params['from'])) {
         $this->addWhere('page_title>=' . $db->addQuotes(ApiQueryBase::titleToKey($params['from'])));
     }
     if (isset($params['prefix'])) {
         $this->addWhere("page_title LIKE '" . $db->escapeLike(ApiQueryBase::titleToKey($params['prefix'])) . "%'");
     }
     if (is_null($resultPageSet)) {
         $this->addFields(array('page_id', 'page_namespace', 'page_title'));
     } else {
         $this->addFields($resultPageSet->getPageTableFields());
     }
     $this->addOption('USE INDEX', 'name_title');
     $limit = $params['limit'];
     $this->addOption('LIMIT', $limit + 1);
     $this->addOption('ORDER BY', 'page_namespace, page_title');
     $res = $this->select(__METHOD__);
     $data = array();
     $count = 0;
     while ($row = $db->fetchObject($res)) {
         if (++$count > $limit) {
             // We've reached the one extra which shows that there are additional pages to be had. Stop here...
             // TODO: Security issue - if the user has no right to view next title, it will still be shown
             $this->setContinueEnumParameter('from', ApiQueryBase::keyToTitle($row->page_title));
             break;
         }
         if (is_null($resultPageSet)) {
             $title = Title::makeTitle($row->page_namespace, $row->page_title);
             $data[] = array('pageid' => intval($row->page_id), 'ns' => intval($title->getNamespace()), 'title' => $title->getPrefixedText());
         } else {
             $resultPageSet->processDbRow($row);
         }
     }
     $db->freeResult($res);
     if (is_null($resultPageSet)) {
         $result = $this->getResult();
         $result->setIndexedTagName($data, 'p');
         $result->addValue('query', $this->getModuleName(), $data);
     }
 }
开发者ID:mediawiki-extensions,项目名称:bizzwiki,代码行数:48,代码来源:ApiQueryAllpages.php


示例10: addValues

 /**
  * Add all items from $values into the result
  * @param array $result Output
  * @param array $values Values to add
  * @param string $flag The name of the boolean flag to mark this element
  * @param string $name If given, name of the value
  */
 private static function addValues(array &$result, $values, $flag = null, $name = null)
 {
     foreach ($values as $val) {
         if ($val instanceof Title) {
             $v = array();
             ApiQueryBase::addTitleInfo($v, $val);
         } elseif ($name !== null) {
             $v = array($name => $val);
         } else {
             $v = $val;
         }
         if ($flag !== null) {
             $v[$flag] = '';
         }
         $result[] = $v;
     }
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:24,代码来源:ApiPageSet.php


示例11: reportPage

	function reportPage( $title, $origTitle, $revisionCount, $successCount, $pageInfo = '' ) {
		// Add a result entry
		$r = array();
		ApiQueryBase::addTitleInfo($r, $title);
		$r['revisions'] = intval($successCount);
		$this->mResultArr[] = $r;

		# call the parent to do the logging
		# avoid bug in 1.15.4 Special:Import (new file page text without the file uploaded)
		# PHP Fatal error:  Call to a member function insertOn() on a non-object in E:\www\psychologos\includes\specials\SpecialImport.php on line 334
		// do not create informational null revisions
		// because they are placed on top of real user made revisions,
		// making the binary search algorithm used to compare local and remote revs to fail
		// TODO: change the binary search algorithm to two/three level hashes
		if ( WikiSyncSetup::$report_null_revisions && $title->getArticleId() !== 0 ) {
			parent::reportPage( $title, $origTitle, $revisionCount, $successCount, $pageInfo );
		}
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:18,代码来源:WikiSyncExporter.php


示例12: run

 private function run($resultPageSet = null)
 {
     $db = $this->getDB();
     $params = $this->extractRequestParams();
     $this->addTables('categorylinks');
     $this->addFields('cl_to');
     if (!is_null($params['from'])) {
         $this->addWhere('cl_to>=' . $db->addQuotes(ApiQueryBase::titleToKey($params['from'])));
     }
     if (isset($params['prefix'])) {
         $this->addWhere("cl_to LIKE '" . $db->escapeLike(ApiQueryBase::titleToKey($params['prefix'])) . "%'");
     }
     $this->addOption('LIMIT', $params['limit'] + 1);
     $this->addOption('ORDER BY', 'cl_to' . ($params['dir'] == 'descending' ? ' DESC' : ''));
     $this->addOption('DISTINCT');
     $res = $this->select(__METHOD__);
     $pages = array();
     $count = 0;
     while ($row = $db->fetchObject($res)) {
         if (++$count > $params['limit']) {
             // We've reached the one extra which shows that there are additional cats to be had. Stop here...
             // TODO: Security issue - if the user has no right to view next title, it will still be shown
             $this->setContinueEnumParameter('from', ApiQueryBase::keyToTitle($row->cl_to));
             break;
         }
         // Normalize titles
         $titleObj = Title::makeTitle(NS_CATEGORY, $row->cl_to);
         if (!is_null($resultPageSet)) {
             $pages[] = $titleObj->getPrefixedText();
         } else {
             // Don't show "Category:" everywhere in non-generator mode
             $pages[] = $titleObj->getText();
         }
     }
     $db->freeResult($res);
     if (is_null($resultPageSet)) {
         $result = $this->getResult();
         $result->setIndexedTagName($pages, 'c');
         $result->addValue('query', $this->getModuleName(), $pages);
     } else {
         $resultPageSet->populateFromTitles($pages);
     }
 }
开发者ID:ErdemA,项目名称:wikihow,代码行数:43,代码来源:ApiQueryAllCategories.php


示例13: run

 private function run($resultPageSet = null)
 {
     if ($this->getPageSet()->getGoodTitleCount() == 0) {
         return;
     }
     // nothing to do
     $this->addFields(array('il_from', 'il_to'));
     $this->addTables('imagelinks');
     $this->addWhereFld('il_from', array_keys($this->getPageSet()->getGoodTitles()));
     $this->addOption('ORDER BY', "il_from, il_to");
     $db = $this->getDB();
     $res = $this->select(__METHOD__);
     if (is_null($resultPageSet)) {
         $data = array();
         $lastId = 0;
         // database has no ID 0
         while ($row = $db->fetchObject($res)) {
             if ($lastId != $row->il_from) {
                 if ($lastId != 0) {
                     $this->addPageSubItems($lastId, $data);
                     $data = array();
                 }
                 $lastId = $row->il_from;
             }
             $vals = array();
             ApiQueryBase::addTitleInfo($vals, Title::makeTitle(NS_IMAGE, $row->il_to));
             $data[] = $vals;
         }
         if ($lastId != 0) {
             $this->addPageSubItems($lastId, $data);
         }
     } else {
         $titles = array();
         while ($row = $db->fetchObject($res)) {
             $titles[] = Title::makeTitle(NS_IMAGE, $row->il_to);
         }
         $resultPageSet->populateFromTitles($titles);
     }
     $db->freeResult($res);
 }
开发者ID:BackupTheBerlios,项目名称:shoutwiki-svn,代码行数:40,代码来源:ApiQueryImages.php


示例14: execute

 /**
  * Patrols the article or provides the reason the patrol failed.
  */
 public function execute()
 {
     $params = $this->extractRequestParams();
     $this->requireOnlyOneParameter($params, 'rcid', 'revid');
     if (isset($params['rcid'])) {
         $rc = RecentChange::newFromId($params['rcid']);
         if (!$rc) {
             $this->dieUsageMsg(['nosuchrcid', $params['rcid']]);
         }
     } else {
         $rev = Revision::newFromId($params['revid']);
         if (!$rev) {
             $this->dieUsageMsg(['nosuchrevid', $params['revid']]);
         }
         $rc = $rev->getRecentChange();
         if (!$rc) {
             $this->dieUsage('The revision ' . $params['revid'] . " can't be patrolled as it's too old", 'notpatrollable');
         }
     }
     $user = $this->getUser();
     $tags = $params['tags'];
     // Check if user can add tags
     if (!is_null($tags)) {
         $ableToTag = ChangeTags::canAddTagsAccompanyingChange($tags, $user);
         if (!$ableToTag->isOK()) {
             $this->dieStatus($ableToTag);
         }
     }
     $retval = $rc->doMarkPatrolled($user, false, $tags);
     if ($retval) {
         $this->dieUsageMsg(reset($retval));
     }
     $result = ['rcid' => intval($rc->getAttribute('rc_id'))];
     ApiQueryBase::addTitleInfo($result, $rc->getTitle());
     $this->getResult()->addValue(null, $this->getModuleName(), $result);
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:39,代码来源:ApiPatrol.php


示例15: run

 /**
  * @param $resultPageSet ApiPageSet
  * @return void
  */
 private function run($resultPageSet = null)
 {
     $params = $this->extractRequestParams();
     $this->addTables('protected_titles');
     $this->addFields(array('pt_namespace', 'pt_title', 'pt_timestamp'));
     $prop = array_flip($params['prop']);
     $this->addFieldsIf('pt_user', isset($prop['user']) || isset($prop['userid']));
     $this->addFieldsIf('pt_reason', isset($prop['comment']) || isset($prop['parsedcomment']));
     $this->addFieldsIf('pt_expiry', isset($prop['expiry']));
     $this->addFieldsIf('pt_create_perm', isset($prop['level']));
     $this->addTimestampWhereRange('pt_timestamp', $params['dir'], $params['start'], $params['end']);
     $this->addWhereFld('pt_namespace', $params['namespace']);
     $this->addWhereFld('pt_create_perm', $params['level']);
     if (isset($prop['user'])) {
         $this->addTables('user');
         $this->addFields('user_name');
         $this->addJoinConds(array('user' => array('LEFT JOIN', 'user_id=pt_user')));
     }
     $this->addOption('LIMIT', $params['limit'] + 1);
     $res = $this->select(__METHOD__);
     $count = 0;
     $result = $this->getResult();
     $titles = array();
     foreach ($res as $row) {
         if (++$count > $params['limit']) {
             // We've reached the one extra which shows that there are additional pages to be had. Stop here...
             $this->setContinueEnumParameter('start', wfTimestamp(TS_ISO_8601, $row->pt_timestamp));
             break;
         }
         $title = Title::makeTitle($row->pt_namespace, $row->pt_title);
         if (is_null($resultPageSet)) {
             $vals = array();
             ApiQueryBase::addTitleInfo($vals, $title);
             if (isset($prop['timestamp'])) {
                 $vals['timestamp'] = wfTimestamp(TS_ISO_8601, $row->pt_timestamp);
             }
             if (isset($prop['user']) && !is_null($row->user_name)) {
                 $vals['user'] = $row->user_name;
             }
             if (isset($prop['user'])) {
                 $vals['userid'] = $row->pt_user;
             }
             if (isset($prop['comment'])) {
                 $vals['comment'] = $row->pt_reason;
             }
             if (isset($prop['parsedcomment'])) {
                 global $wgUser;
                 $vals['parsedcomment'] = $wgUser->getSkin()->formatComment($row->pt_reason, $title);
             }
             if (isset($prop['expiry'])) {
                 global $wgContLang;
                 $vals['expiry'] = $wgContLang->formatExpiry($row->pt_expiry, TS_ISO_8601);
             }
             if (isset($prop['level'])) {
                 $vals['level'] = $row->pt_create_perm;
             }
             $fit = $result->addValue(array('query', $this->getModuleName()), null, $vals);
             if (!$fit) {
                 $this->setContinueEnumParameter('start', wfTimestamp(TS_ISO_8601, $row->pt_timestamp));
                 break;
             }
         } else {
             $titles[] = $title;
         }
     }
     if (is_null($resultPageSet)) {
         $result->setIndexedTagName_internal(array('query', $this->getModuleName()), $this->getModulePrefix());
     } else {
         $resultPageSet->populateFromTitles($titles);
     }
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:75,代码来源:ApiQueryProtectedTitles.php


示例16: run

 private function run($resultPageSet = null)
 {
     if ($this->getPageSet()->getGoodTitleCount() == 0) {
         return;
     }
     // nothing to do
     $params = $this->extractRequestParams();
     $prop = array_flip((array) $params['prop']);
     $show = array_flip((array) $params['show']);
     $this->addFields(array('cl_from', 'cl_to'));
     $this->addFieldsIf('cl_sortkey', isset($prop['sortkey']));
     $this->addFieldsIf('cl_timestamp', isset($prop['timestamp']));
     $this->addTables('categorylinks');
     $this->addWhereFld('cl_from', array_keys($this->getPageSet()->getGoodTitles()));
     if (!is_null($params['categories'])) {
         $cats = array();
         foreach ($params['categories'] as $cat) {
             $title = Title::newFromText($cat);
             if (!$title || $title->getNamespace() != NS_CATEGORY) {
                 $this->setWarning("``{$cat}'' is not a category");
             } else {
                 $cats[] = $title->getDBkey();
             }
         }
         $this->addWhereFld('cl_to', $cats);
     }
     if (!is_null($params['continue'])) {
         $cont = explode('|', $params['continue']);
         if (count($cont) != 2) {
             $this->dieUsage("Invalid continue param. You should pass the " . "original value returned by the previous query", "_badcontinue");
         }
         $clfrom = intval($cont[0]);
         $clto = $this->getDB()->strencode($this->titleToKey($cont[1]));
         $this->addWhere("cl_from > {$clfrom} OR " . "(cl_from = {$clfrom} AND " . "cl_to >= '{$clto}')");
     }
     if (isset($show['hidden']) && isset($show['!hidden'])) {
         $this->dieUsageMsg(array('show'));
     }
     if (isset($show['hidden']) || isset($show['!hidden']) || isset($prop['hidden'])) {
         $this->addOption('STRAIGHT_JOIN');
         $this->addTables(array('page', 'page_props'));
         $this->addFieldsIf('pp_propname', isset($prop['hidden']));
         $this->addJoinConds(array('page' => array('LEFT JOIN', array('page_namespace' => NS_CATEGORY, 'page_title = cl_to')), 'page_props' => array('LEFT JOIN', array('pp_page=page_id', 'pp_propname' => 'hiddencat'))));
         if (isset($show['hidden'])) {
             $this->addWhere(array('pp_propname IS NOT NULL'));
         } else {
             if (isset($show['!hidden'])) {
                 $this->addWhere(array('pp_propname IS NULL'));
             }
         }
     }
     $this->addOption('USE INDEX', array('categorylinks' => 'cl_from'));
     // Don't order by cl_from if it's constant in the WHERE clause
     if (count($this->getPageSet()->getGoodTitles()) == 1) {
         $this->addOption('ORDER BY', 'cl_to');
     } else {
         $this->addOption('ORDER BY', "cl_from, cl_to");
     }
     $db = $this->getDB();
     $res = $this->select(__METHOD__);
     if (is_null($resultPageSet)) {
         $count = 0;
         while ($row = $db->fetchObject($res)) {
             if (++$count > $params['limit']) {
                 // We've reached the one extra which shows that
                 // there are additional pages to be had. Stop here...
                 $this->setContinueEnumParameter('continue', $row->cl_from . '|' . $this->keyToTitle($row->cl_to));
                 break;
             }
             $title = Title::makeTitle(NS_CATEGORY, $row->cl_to);
             $vals = array();
             ApiQueryBase::addTitleInfo($vals, $title);
             if (isset($prop['sortkey'])) {
                 $vals['sortkey'] = $row->cl_sortkey;
             }
             if (isset($prop['timestamp'])) {
                 $vals['timestamp'] = wfTimestamp(TS_ISO_8601, $row->cl_timestamp);
             }
             if (isset($prop['hidden']) && !is_null($row->pp_propname)) {
                 $vals['hidden'] = '';
             }
             $fit = $this->addPageSubItem($row->cl_from, $vals);
             if (!$fit) {
                 $this->setContinueEnumParameter('continue', $row->cl_from . '|' . $this->keyToTitle($row->cl_to));
                 break;
             }
         }
     } else {
         $titles = array();
         while ($row = $db->fetchObject($res)) {
             if (++$count > $params['limit']) {
                 // We've reached the one extra which shows that
                 // there are additional pages to be had. Stop here...
                 $this->setContinueEnumParameter('continue', $row->cl_from . '|' . $this->keyToTitle($row->cl_to));
                 break;
             }
             $titles[] = Title::makeTitle(NS_CATEGORY, $row->cl_to);
         }
         $resultPageSet->populateFromTitles($titles);
     }
//.........这里部分代码省略.........
开发者ID:rocLv,项目名称:conference,代码行数:101,代码来源:ApiQueryCategories.php


示例17: extractRowInfo

 private function extractRowInfo($row)
 {
     $vals = array();
     $type = intval($row->rc_type);
     /* Determine what kind of change this was. */
     switch ($type) {
         case RC_EDIT:
             $vals['type'] = 'edit';
             break;
         case RC_NEW:
             $vals['type'] = 'new';
             break;
         case RC_MOVE:
             $vals['type'] = 'move';
             break;
         case RC_LOG:
             $vals['type'] = 'log';
             break;
         case RC_EXTERNAL:
             $vals['type'] = 'external';
             break;
         case RC_MOVE_OVER_REDIRECT:
             $vals['type'] = 'move over redirect';
             break;
         default:
             $vals['type'] = $type;
     }
     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);
     }
     $title = Title::makeTitle($row->rc_namespace, $row->rc_title);
     if ($this->fld_title) {
         ApiQueryBase::addTitleInfo($vals, $title);
     }
     if ($this->fld_user || $this->fld_userid) {
         if ($this->fld_userid) {
             $vals['userid'] = $row->rc_user;
             // for backwards compatibility
             $vals['user'] = $row->rc_user;
         }
         if ($this->fld_user) {
             $vals['user'] = $row->rc_user_text;
         }
         if (!$row->rc_user) {
             $vals['anon'] = '';
         }
     }
     if ($this->fld_flags) {
         if ($row->rc_type == RC_NEW) {
             $vals['new'] = '';
         }
         if ($row->rc_minor) {
             $vals['minor'] = '';
         }
         if ($row->rc_bot) {
             $vals['bot'] = '';
         }
     }
     if ($this->fld_patrol && isset($row->rc_patrolled)) {
         $vals['patrolled'] = '';
     }
     if ($this->fld_timestamp) {
         $vals['timestamp'] = wfTimestamp(TS_ISO_8601, $row->rc_timestamp);
     }
     if ($this->fld_sizes) {
         $vals['oldlen'] = intval($row->rc_old_len);
         $vals['newlen'] = intval($row->rc_new_len);
     }
     if ($this->fld_notificationtimestamp) {
         $vals['notificationtimestamp'] = $row->wl_notificationtimestamp == null ? '' : wfTimestamp(TS_ISO_8601, $row->wl_notificationtimestamp);
     }
     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_loginfo && $row->rc_type == RC_LOG) {
         $vals['logid'] = intval($row->rc_logid);
         $vals['logtype'] = $row->rc_log_type;
         $vals['logaction'] = $row->rc_log_action;
         $logEntry = DatabaseLogEntry::newFromRow((array) $row);
         ApiQueryLogEvents::addLogParams($this->getResult(), $vals, $logEntry->getParameters(), $logEntry->getType(), $logEntry->getSubtype(), $logEntry->getTimestamp());
     }
     return $vals;
 }
开发者ID:mangowi,项目名称:mediawiki,代码行数:88,代码来源:ApiQueryWatchlist.php


示例18: 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


示例19: run

该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP ApiQueryGeneratorBase类代码示例发布时间:2022-05-23
下一篇:
PHP ApiPageSet类代码示例发布时间: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