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


PHP LinkBatch::constructSet方法代码示例

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


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

示例1: getQueryInfo

 function getQueryInfo()
 {
     $dbr = wfGetDB(DB_SLAVE);
     $dMsgText = wfMsgForContent('disambiguationspage');
     $linkBatch = new LinkBatch();
     # If the text can be treated as a title, use it verbatim.
     # Otherwise, pull the titles from the links table
     $dp = Title::newFromText($dMsgText);
     if ($dp) {
         if ($dp->getNamespace() != NS_TEMPLATE) {
             # @todo FIXME: We assume the disambiguation message is a template but
             # the page can potentially be from another namespace :/
             wfDebug("Mediawiki:disambiguationspage message does not refer to a template!\n");
         }
         $linkBatch->addObj($dp);
     } else {
         # Get all the templates linked from the Mediawiki:Disambiguationspage
         $disPageObj = Title::makeTitleSafe(NS_MEDIAWIKI, 'disambiguationspage');
         $res = $dbr->select(array('pagelinks', 'page'), 'pl_title', array('page_id = pl_from', 'pl_namespace' => NS_TEMPLATE, 'page_namespace' => $disPageObj->getNamespace(), 'page_title' => $disPageObj->getDBkey()), __METHOD__);
         foreach ($res as $row) {
             $linkBatch->addObj(Title::makeTitle(NS_TEMPLATE, $row->pl_title));
         }
     }
     $set = $linkBatch->constructSet('tl', $dbr);
     if ($set === false) {
         # We must always return a valid SQL query, but this way
         # the DB will always quickly return an empty result
         $set = 'FALSE';
         wfDebug("Mediawiki:disambiguationspage message does not link to any templates!\n");
     }
     // @todo FIXME: What are pagelinks and p2 doing here?
     return array('tables' => array('templatelinks', 'p1' => 'page', 'pagelinks', 'p2' => 'page'), 'fields' => array('p1.page_namespace AS namespace', 'p1.page_title AS title', 'pl_from AS value'), 'conds' => array($set, 'p1.page_id = tl_from', 'pl_namespace = p1.page_namespace', 'pl_title = p1.page_title', 'p2.page_id = pl_from', 'p2.page_namespace' => MWNamespace::getContentNamespaces()));
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:33,代码来源:SpecialDisambiguations.php

示例2: getSQL

 function getSQL()
 {
     $dbr =& wfGetDB(DB_SLAVE);
     list($page, $pagelinks, $templatelinks) = $dbr->tableNamesN('page', 'pagelinks', 'templatelinks');
     $dMsgText = wfMsgForContent('disambiguationspage');
     $linkBatch = new LinkBatch();
     # If the text can be treated as a title, use it verbatim.
     # Otherwise, pull the titles from the links table
     $dp = Title::newFromText($dMsgText);
     if ($dp) {
         if ($dp->getNamespace() != NS_TEMPLATE) {
             # FIXME we assume the disambiguation message is a template but
             # the page can potentially be from another namespace :/
             wfDebug("Mediawiki:disambiguationspage message does not refer to a template!\n");
         }
         $linkBatch->addObj($dp);
     } else {
         # Get all the templates linked from the Mediawiki:Disambiguationspage
         $disPageObj = $this->getDisambiguationPageObj();
         $res = $dbr->select(array('pagelinks', 'page'), 'pl_title', array('page_id = pl_from', 'pl_namespace' => NS_TEMPLATE, 'page_namespace' => $disPageObj->getNamespace(), 'page_title' => $disPageObj->getDBkey()), 'DisambiguationsPage::getSQL');
         while ($row = $dbr->fetchObject($res)) {
             $linkBatch->addObj(Title::makeTitle(NS_TEMPLATE, $row->pl_title));
         }
         $dbr->freeResult($res);
     }
     $set = $linkBatch->constructSet('lb.tl', $dbr);
     if ($set === false) {
         $set = 'FALSE';
         # We must always return a valid sql query, but this way DB will always quicly return an empty result
         wfDebug("Mediawiki:disambiguationspage message does not link to any templates!\n");
     }
     $sql = "SELECT 'Disambiguations' AS \"type\", pb.page_namespace AS namespace," . " pb.page_title AS title, la.pl_from AS value" . " FROM {$templatelinks} AS lb, {$page} AS pb, {$pagelinks} AS la, {$page} AS pa" . " WHERE {$set}" . ' AND pa.page_id = la.pl_from' . ' AND pa.page_namespace = ' . NS_MAIN . ' AND pb.page_id = lb.tl_from' . ' AND pb.page_namespace = la.pl_namespace' . ' AND pb.page_title = la.pl_title' . ' ORDER BY lb.tl_namespace, lb.tl_title';
     return $sql;
 }
开发者ID:negabaro,项目名称:alfresco,代码行数:34,代码来源:SpecialDisambiguations.php

示例3: wfMsgForContent

	/**
	 * Return a clause with the list of disambiguation templates.
	 * This function was copied verbatim from specials/SpecialDisambiguations.php
	 */
	function disambiguation_templates( $dbr ) {
		$dMsgText = wfMsgForContent('disambiguationspage');

		$linkBatch = new LinkBatch;

		# If the text can be treated as a title, use it verbatim.
		# Otherwise, pull the titles from the links table
		$dp = Title::newFromText($dMsgText);
		if( $dp ) {
			if($dp->getNamespace() != NS_TEMPLATE) {
				# FIXME we assume the disambiguation message is a template but
				# the page can potentially be from another namespace :/
				wfDebug("Mediawiki:disambiguationspage message does not refer to a template!\n");
			}
			$linkBatch->addObj( $dp );
		} else {
			# Get all the templates linked from the Mediawiki:Disambiguationspage
			$disPageObj = Title::makeTitleSafe( NS_MEDIAWIKI, 'disambiguationspage' );
			$res = $dbr->select(
				array('pagelinks', 'page'),
				'pl_title',
				array('page_id = pl_from', 'pl_namespace' => NS_TEMPLATE,
					'page_namespace' => $disPageObj->getNamespace(), 'page_title' => $disPageObj->getDBkey()),
				__METHOD__ );

			foreach ( $res as $row ) {
				$linkBatch->addObj( Title::makeTitle( NS_TEMPLATE, $row->pl_title ));
			}
		}
		return $linkBatch->constructSet( 'tl', $dbr );
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:35,代码来源:SpecialPagesWithoutScans.php

示例4: reallyGetTitleMtimes

 protected function reallyGetTitleMtimes(ResourceLoaderContext $context)
 {
     wfProfileIn(__METHOD__);
     $dbr = $this->getDB();
     if (!$dbr) {
         // We're dealing with a subclass that doesn't have a DB
         wfProfileOut(__METHOD__);
         return array();
     }
     $mtimes = array();
     $local = array();
     $byWiki = array();
     $pages = $this->getPages($context);
     foreach ($pages as $titleText => $options) {
         $title = $this->createTitle($titleText, $options);
         if ($title instanceof GlobalTitle) {
             $byWiki[$title->getCityId()][] = array($title, $titleText, $options);
         } else {
             $local[] = array($title, $titleText, $options);
         }
     }
     if (!empty($local)) {
         $batch = new LinkBatch();
         foreach ($local as $page) {
             list($title, $titleText, $options) = $page;
             $batch->addObj($title);
         }
         if (!$batch->isEmpty()) {
             $res = $dbr->select('page', array('page_namespace', 'page_title', 'page_touched'), $batch->constructSet('page', $dbr), __METHOD__);
             foreach ($res as $row) {
                 $title = Title::makeTitle($row->page_namespace, $row->page_title);
                 $mtimes[$title->getPrefixedDBkey()] = wfTimestamp(TS_UNIX, $row->page_touched);
             }
         }
     }
     foreach ($byWiki as $cityId => $pages) {
         // $pages[0][0] has to be GlobalTitle
         $dbName = $pages[0][0]->getDatabaseName();
         $dbr = wfGetDB(DB_SLAVE, array(), $dbName);
         $pagesData = array();
         foreach ($pages as $page) {
             list($title, $titleText, $options) = $page;
             /** @var $title GlobalTitle */
             $pagesData[$title->getNamespace()][$title->getDBkey()] = true;
         }
         $res = $dbr->select('page', array('page_namespace', 'page_title', 'page_touched'), $dbr->makeWhereFrom2d($pagesData, 'page_namespace', 'page_title'), __METHOD__);
         foreach ($res as $row) {
             $title = GlobalTitle::newFromTextCached($row->page_title, $row->page_namespace, $cityId);
             $mtimes[$dbName . '::' . $title->getPrefixedDBkey()] = wfTimestamp(TS_UNIX, $row->page_touched);
         }
     }
     wfProfileOut(__METHOD__);
     return $mtimes;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:54,代码来源:ResourceLoaderGlobalWikiModule.class.php

示例5: getTitleMtimes

 /**
  * Get the modification times of all titles that would be loaded for
  * a given context.
  * @param $context ResourceLoaderContext: Context object
  * @return array( prefixed DB key => UNIX timestamp ), nonexistent titles are dropped
  */
 protected function getTitleMtimes(ResourceLoaderContext $context)
 {
     $dbr = $this->getDB();
     if (!$dbr) {
         // We're dealing with a subclass that doesn't have a DB
         return array();
     }
     $hash = $context->getHash();
     if (isset($this->titleMtimes[$hash])) {
         return $this->titleMtimes[$hash];
     }
     $this->titleMtimes[$hash] = array();
     $batch = new LinkBatch();
     foreach ($this->getPages($context) as $titleText => $options) {
         $batch->addObj(Title::newFromText($titleText));
     }
     if (!$batch->isEmpty()) {
         $res = $dbr->select('page', array('page_namespace', 'page_title', 'page_touched'), $batch->constructSet('page', $dbr), __METHOD__);
         foreach ($res as $row) {
             $title = Title::makeTitle($row->page_namespace, $row->page_title);
             $this->titleMtimes[$hash][$title->getPrefixedDBkey()] = wfTimestamp(TS_UNIX, $row->page_touched);
         }
     }
     return $this->titleMtimes[$hash];
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:31,代码来源:ResourceLoaderWikiModule.php

示例6: getWatchedInfo

 /**
  * Get information about watched status and put it in $this->watched
  */
 private function getWatchedInfo()
 {
     global $wgUser;
     if ($wgUser->isAnon() || count($this->titles) == 0) {
         return;
     }
     $this->watched = array();
     $db = $this->getDB();
     $lb = new LinkBatch($this->titles);
     $this->resetQueryParams();
     $this->addTables(array('page', 'watchlist'));
     $this->addFields(array('page_title', 'page_namespace'));
     $this->addWhere(array($lb->constructSet('page', $db), 'wl_namespace=page_namespace', 'wl_title=page_title', 'wl_user' => $wgUser->getID()));
     $res = $this->select(__METHOD__);
     while ($row = $db->fetchObject($res)) {
         $this->watched[$row->page_namespace][$row->page_title] = true;
     }
 }
开发者ID:rocLv,项目名称:conference,代码行数:21,代码来源:ApiQueryInfo.php

示例7: execute

 public function execute()
 {
     global $wgUser;
     // Before doing anything at all, let's check permissions
     if (!$wgUser->isAllowed('deletedhistory')) {
         $this->dieUsage('You don\'t have permission to view deleted revision information', 'permissiondenied');
     }
     $db = $this->getDB();
     $params = $this->extractRequestParams(false);
     $prop = array_flip($params['prop']);
     $fld_revid = isset($prop['revid']);
     $fld_user = isset($prop['user']);
     $fld_comment = isset($prop['comment']);
     $fld_minor = isset($prop['minor']);
     $fld_len = isset($prop['len']);
     $fld_content = isset($prop['content']);
     $fld_token = isset($prop['token']);
     $result = $this->getResult();
     $pageSet = $this->getPageSet();
     $titles = $pageSet->getTitles();
     $data = array();
     $this->addTables('archive');
     $this->addFields(array('ar_title', 'ar_namespace', 'ar_timestamp'));
     if ($fld_revid) {
         $this->addFields('ar_rev_id');
     }
     if ($fld_user) {
         $this->addFields('ar_user_text');
     }
     if ($fld_comment) {
         $this->addFields('ar_comment');
     }
     if ($fld_minor) {
         $this->addFields('ar_minor_edit');
     }
     if ($fld_len) {
         $this->addFields('ar_len');
     }
     if ($fld_content) {
         $this->addTables('text');
         $this->addFields(array('ar_text', 'ar_text_id', 'old_text', 'old_flags'));
         $this->addWhere('ar_text_id = old_id');
         // This also means stricter restrictions
         if (!$wgUser->isAllowed('undelete')) {
             $this->dieUsage('You don\'t have permission to view deleted revision content', 'permissiondenied');
         }
     }
     // Check limits
     $userMax = $fld_content ? ApiBase::LIMIT_SML1 : ApiBase::LIMIT_BIG1;
     $botMax = $fld_content ? ApiBase::LIMIT_SML2 : ApiBase::LIMIT_BIG2;
     if ($limit == 'max') {
         $limit = $this->getMain()->canApiHighLimits() ? $botMax : $userMax;
         $this->getResult()->addValue('limits', 'limit', $limit);
     }
     $this->validateLimit('limit', $params['limit'], 1, $userMax, $botMax);
     if ($fld_token) {
         // Undelete tokens are identical for all pages, so we cache one here
         $token = $wgUser->editToken();
     }
     // We need a custom WHERE clause that matches all titles.
     if (count($titles) > 0) {
         $lb = new LinkBatch($titles);
         $where = $lb->constructSet('ar', $db);
         $this->addWhere($where);
     }
     $this->addOption('LIMIT', $params['limit'] + 1);
     $this->addWhereRange('ar_timestamp', $params['dir'], $params['start'], $params['end']);
     if (isset($params['namespace'])) {
         $this->addWhereFld('ar_namespace', $params['namespace']);
     }
     $res = $this->select(__METHOD__);
     $pages = array();
     $count = 0;
     // First populate the $pages array
     while ($row = $db->fetchObject($res)) {
         if ($count++ == $params['limit']) {
             // We've had enough
             $this->setContinueEnumParameter('start', wfTimestamp(TS_ISO_8601, $row->ar_timestamp));
             break;
         }
         $rev = array();
         $rev['timestamp'] = wfTimestamp(TS_ISO_8601, $row->ar_timestamp);
         if ($fld_revid) {
             $rev['revid'] = $row->ar_rev_id;
         }
         if ($fld_user) {
             $rev['user'] = $row->ar_user_text;
         }
         if ($fld_comment) {
             $rev['comment'] = $row->ar_comment;
         }
         if ($fld_minor) {
             if ($row->ar_minor_edit == 1) {
                 $rev['minor'] = '';
             }
         }
         if ($fld_len) {
             $rev['len'] = $row->ar_len;
         }
         if ($fld_content) {
//.........这里部分代码省略.........
开发者ID:ErdemA,项目名称:wikihow,代码行数:101,代码来源:ApiQueryDeletedrevs.php

示例8: run

 protected function run(ApiPageSet $resultPageSet = null)
 {
     $user = $this->getUser();
     // Before doing anything at all, let's check permissions
     if (!$user->isAllowed('deletedhistory')) {
         $this->dieUsage('You don\'t have permission to view deleted revision information', 'permissiondenied');
     }
     $result = $this->getResult();
     $pageSet = $this->getPageSet();
     $pageMap = $pageSet->getGoodAndMissingTitlesByNamespace();
     $pageCount = count($pageSet->getGoodAndMissingTitles());
     $revCount = $pageSet->getRevisionCount();
     if ($revCount === 0 && $pageCount === 0) {
         // Nothing to do
         return;
     }
     if ($revCount !== 0 && count($pageSet->getDeletedRevisionIDs()) === 0) {
         // Nothing to do, revisions were supplied but none are deleted
         return;
     }
     $params = $this->extractRequestParams(false);
     $db = $this->getDB();
     if (!is_null($params['user']) && !is_null($params['excludeuser'])) {
         $this->dieUsage('user and excludeuser cannot be used together', 'badparams');
     }
     $this->addTables('archive');
     if ($resultPageSet === null) {
         $this->parseParameters($params);
         $this->addFields(Revision::selectArchiveFields());
         $this->addFields(array('ar_title', 'ar_namespace'));
     } else {
         $this->limit = $this->getParameter('limit') ?: 10;
         $this->addFields(array('ar_title', 'ar_namespace', 'ar_timestamp', 'ar_rev_id', 'ar_id'));
     }
     if ($this->fld_tags) {
         $this->addTables('tag_summary');
         $this->addJoinConds(array('tag_summary' => array('LEFT JOIN', array('ar_rev_id=ts_rev_id'))));
         $this->addFields('ts_tags');
     }
     if (!is_null($params['tag'])) {
         $this->addTables('change_tag');
         $this->addJoinConds(array('change_tag' => array('INNER JOIN', array('ar_rev_id=ct_rev_id'))));
         $this->addWhereFld('ct_tag', $params['tag']);
     }
     if ($this->fetchContent) {
         // Modern MediaWiki has the content for deleted revs in the 'text'
         // table using fields old_text and old_flags. But revisions deleted
         // pre-1.5 store the content in the 'archive' table directly using
         // fields ar_text and ar_flags, and no corresponding 'text' row. So
         // we have to LEFT JOIN and fetch all four fields.
         $this->addTables('text');
         $this->addJoinConds(array('text' => array('LEFT JOIN', array('ar_text_id=old_id'))));
         $this->addFields(array('ar_text', 'ar_flags', 'old_text', 'old_flags'));
         // This also means stricter restrictions
         if (!$user->isAllowedAny('undelete', 'deletedtext')) {
             $this->dieUsage('You don\'t have permission to view deleted revision content', 'permissiondenied');
         }
     }
     $dir = $params['dir'];
     if ($revCount !== 0) {
         $this->addWhere(array('ar_rev_id' => array_keys($pageSet->getDeletedRevisionIDs())));
     } else {
         // We need a custom WHERE clause that matches all titles.
         $lb = new LinkBatch($pageSet->getGoodAndMissingTitles());
         $where = $lb->constructSet('ar', $db);
         $this->addWhere($where);
     }
     if (!is_null($params['user'])) {
         $this->addWhereFld('ar_user_text', $params['user']);
     } elseif (!is_null($params['excludeuser'])) {
         $this->addWhere('ar_user_text != ' . $db->addQuotes($params['excludeuser']));
     }
     if (!is_null($params['user']) || !is_null($params['excludeuser'])) {
         // Paranoia: avoid brute force searches (bug 17342)
         // (shouldn't be able to get here without 'deletedhistory', but
         // check it again just in case)
         if (!$user->isAllowed('deletedhistory')) {
             $bitmask = Revision::DELETED_USER;
         } elseif (!$user->isAllowedAny('suppressrevision', 'viewsuppressed')) {
             $bitmask = Revision::DELETED_USER | Revision::DELETED_RESTRICTED;
         } else {
             $bitmask = 0;
         }
         if ($bitmask) {
             $this->addWhere($db->bitAnd('ar_deleted', $bitmask) . " != {$bitmask}");
         }
     }
     if (!is_null($params['continue'])) {
         $cont = explode('|', $params['continue']);
         $op = $dir == 'newer' ? '>' : '<';
         if ($revCount !== 0) {
             $this->dieContinueUsageIf(count($cont) != 2);
             $rev = intval($cont[0]);
             $this->dieContinueUsageIf(strval($rev) !== $cont[0]);
             $ar_id = (int) $cont[1];
             $this->dieContinueUsageIf(strval($ar_id) !== $cont[1]);
             $this->addWhere("ar_rev_id {$op} {$rev} OR " . "(ar_rev_id = {$rev} AND " . "ar_id {$op}= {$ar_id})");
         } else {
             $this->dieContinueUsageIf(count($cont) != 4);
             $ns = intval($cont[0]);
//.........这里部分代码省略.........
开发者ID:D66Ha,项目名称:mediawiki,代码行数:101,代码来源:ApiQueryDeletedRevisions.php

示例9: addCategoryLinks

 /**
  * Add an array of categories, with names in the keys
  */
 public function addCategoryLinks($categories)
 {
     global $wgUser, $wgContLang;
     if (!is_array($categories) || count($categories) == 0) {
         return;
     }
     # Add the links to a LinkBatch
     $arr = array(NS_CATEGORY => $categories);
     $lb = new LinkBatch();
     $lb->setArray($arr);
     # Fetch existence plus the hiddencat property
     $dbr = wfGetDB(DB_SLAVE);
     $pageTable = $dbr->tableName('page');
     $where = $lb->constructSet('page', $dbr);
     $propsTable = $dbr->tableName('page_props');
     $sql = "SELECT page_id, page_namespace, page_title, page_len, page_is_redirect, pp_value\n\t\t\tFROM {$pageTable} LEFT JOIN {$propsTable} ON pp_propname='hiddencat' AND pp_page=page_id WHERE {$where}";
     $res = $dbr->query($sql, __METHOD__);
     # Add the results to the link cache
     $lb->addResultToCache(LinkCache::singleton(), $res);
     # Set all the values to 'normal'. This can be done with array_fill_keys in PHP 5.2.0+
     $categories = array_combine(array_keys($categories), array_fill(0, count($categories), 'normal'));
     # Mark hidden categories
     foreach ($res as $row) {
         if (isset($row->pp_value)) {
             $categories[$row->page_title] = 'hidden';
         }
     }
     # Add the remaining categories to the skin
     if (wfRunHooks('OutputPageMakeCategoryLinks', array(&$this, $categories, &$this->mCategoryLinks))) {
         $sk = $wgUser->getSkin();
         foreach ($categories as $category => $type) {
             $title = Title::makeTitleSafe(NS_CATEGORY, $category);
             $text = $wgContLang->convertHtml($title->getText());
             $this->mCategoryLinks[$type][] = $sk->makeLinkObj($title, $text);
         }
     }
 }
开发者ID:amjadtbssm,项目名称:website,代码行数:40,代码来源:OutputPage.php

示例10: replaceLinkHolders


//.........这里部分代码省略.........
                 $titleText = $title->getText();
                 // generate all variants of the link title text
                 $allTextVariants = $wgContLang->convertLinkToAllVariants($titleText);
                 // if link was not found (in first query), add all variants to query
                 if (!isset($colours[$pdbk])) {
                     foreach ($allTextVariants as $textVariant) {
                         if ($textVariant != $titleText) {
                             $variantTitle = Title::makeTitle($ns, $textVariant);
                             if (is_null($variantTitle)) {
                                 continue;
                             }
                             $linkBatch->addObj($variantTitle);
                             $variantMap[$variantTitle->getPrefixedDBkey()][] = $key;
                         }
                     }
                 }
             }
             // process categories, check if a category exists in some variant
             foreach ($categories as $category) {
                 $variants = $wgContLang->convertLinkToAllVariants($category);
                 foreach ($variants as $variant) {
                     if ($variant != $category) {
                         $variantTitle = Title::newFromDBkey(Title::makeName(NS_CATEGORY, $variant));
                         if (is_null($variantTitle)) {
                             continue;
                         }
                         $linkBatch->addObj($variantTitle);
                         $categoryMap[$variant] = $category;
                     }
                 }
             }
             if (!$linkBatch->isEmpty()) {
                 // construct query
                 $titleClause = $linkBatch->constructSet('page', $dbr);
                 $variantQuery = "SELECT page_id, page_namespace, page_title, page_is_redirect";
                 if ($threshold > 0) {
                     $variantQuery .= ', page_len';
                 }
                 $variantQuery .= " FROM {$page} WHERE {$titleClause}";
                 if ($options & RLH_FOR_UPDATE) {
                     $variantQuery .= ' FOR UPDATE';
                 }
                 $varRes = $dbr->query($variantQuery, $fname);
                 // for each found variants, figure out link holders and replace
                 while ($s = $dbr->fetchObject($varRes)) {
                     $variantTitle = Title::makeTitle($s->page_namespace, $s->page_title);
                     $varPdbk = $variantTitle->getPrefixedDBkey();
                     $vardbk = $variantTitle->getDBkey();
                     $holderKeys = array();
                     if (isset($variantMap[$varPdbk])) {
                         $holderKeys = $variantMap[$varPdbk];
                         $linkCache->addGoodLinkObj($s->page_id, $variantTitle);
                         $this->mOutput->addLink($variantTitle, $s->page_id);
                     }
                     // loop over link holders
                     foreach ($holderKeys as $key) {
                         $title = $this->mLinkHolders['titles'][$key];
                         if (is_null($title)) {
                             continue;
                         }
                         $pdbk = $title->getPrefixedDBkey();
                         if (!isset($colours[$pdbk])) {
                             // found link in some of the variants, replace the link holder data
                             $this->mLinkHolders['titles'][$key] = $variantTitle;
                             $this->mLinkHolders['dbkeys'][$key] = $variantTitle->getDBkey();
                             // set pdbk and colour
开发者ID:renemilk,项目名称:spring-website,代码行数:67,代码来源:Parser.php

示例11: getVisitingWatcherInfo

 /**
  * Get the count of watchers who have visited recent edits and put it in
  * $this->visitingwatchers
  *
  * Based on InfoAction::pageCounts
  */
 private function getVisitingWatcherInfo()
 {
     $config = $this->getConfig();
     $user = $this->getUser();
     $db = $this->getDB();
     $canUnwatchedpages = $user->isAllowed('unwatchedpages');
     $unwatchedPageThreshold = $this->getConfig()->get('UnwatchedPageThreshold');
     if (!$canUnwatchedpages && !is_int($unwatchedPageThreshold)) {
         return;
     }
     $this->showZeroWatchers = $canUnwatchedpages;
     $titlesWithThresholds = [];
     if ($this->titles) {
         $lb = new LinkBatch($this->titles);
         // Fetch last edit timestamps for pages
         $this->resetQueryParams();
         $this->addTables(['page', 'revision']);
         $this->addFields(['page_namespace', 'page_title', 'rev_timestamp']);
         $this->addWhere(['page_latest = rev_id', $lb->constructSet('page', $db)]);
         $this->addOption('GROUP BY', ['page_namespace', 'page_title']);
         $timestampRes = $this->select(__METHOD__);
         $age = $config->get('WatchersMaxAge');
         $timestamps = [];
         foreach ($timestampRes as $row) {
             $revTimestamp = wfTimestamp(TS_UNIX, (int) $row->rev_timestamp);
             $timestamps[$row->page_namespace][$row->page_title] = $revTimestamp - $age;
         }
         $titlesWithThresholds = array_map(function (LinkTarget $target) use($timestamps) {
             return [$target, $timestamps[$target->getNamespace()][$target->getDBkey()]];
         }, $this->titles);
     }
     if ($this->missing) {
         $titlesWithThresholds = array_merge($titlesWithThresholds, array_map(function (LinkTarget $target) {
             return [$target, null];
         }, $this->missing));
     }
     $store = MediaWikiServices::getInstance()->getWatchedItemStore();
     $this->visitingwatchers = $store->countVisitingWatchersMultiple($titlesWithThresholds, !$canUnwatchedpages ? $unwatchedPageThreshold : null);
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:45,代码来源:ApiQueryInfo.php

示例12: getTitleInfo

 /**
  * Get the information about the wiki pages for a given context.
  * @param ResourceLoaderContext $context
  * @return array Keyed by page name. Contains arrays with 'rev_len' and 'rev_sha1' keys
  */
 protected function getTitleInfo(ResourceLoaderContext $context)
 {
     $dbr = $this->getDB();
     if (!$dbr) {
         // We're dealing with a subclass that doesn't have a DB
         return array();
     }
     $pages = $this->getPages($context);
     $key = implode('|', array_keys($pages));
     if (!isset($this->titleInfo[$key])) {
         $this->titleInfo[$key] = array();
         $batch = new LinkBatch();
         foreach ($pages as $titleText => $options) {
             $batch->addObj(Title::newFromText($titleText));
         }
         if (!$batch->isEmpty()) {
             $res = $dbr->select(array('page', 'revision'), array('page_namespace', 'page_title', 'rev_len', 'rev_sha1'), $batch->constructSet('page', $dbr), __METHOD__, array(), array('revision' => array('INNER JOIN', array('page_latest=rev_id'))));
             foreach ($res as $row) {
                 // Avoid including ids or timestamps of revision/page tables so
                 // that versions are not wasted
                 $title = Title::makeTitle($row->page_namespace, $row->page_title);
                 $this->titleInfo[$key][$title->getPrefixedText()] = array('rev_len' => $row->rev_len, 'rev_sha1' => $row->rev_sha1);
             }
         }
     }
     return $this->titleInfo[$key];
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:32,代码来源:ResourceLoaderWikiModule.php

示例13: execute


//.........这里部分代码省略.........
     }
     if ($fld_content) {
         // Modern MediaWiki has the content for deleted revs in the 'text'
         // table using fields old_text and old_flags. But revisions deleted
         // pre-1.5 store the content in the 'archive' table directly using
         // fields ar_text and ar_flags, and no corresponding 'text' row. So
         // we have to LEFT JOIN and fetch all four fields, plus ar_text_id
         // to be able to tell the difference.
         $this->addTables('text');
         $this->addJoinConds(array('text' => array('LEFT JOIN', array('ar_text_id=old_id'))));
         $this->addFields(array('ar_text', 'ar_flags', 'ar_text_id', 'old_text', 'old_flags'));
         // This also means stricter restrictions
         if (!$user->isAllowedAny('undelete', 'deletedtext')) {
             $this->dieUsage('You don\'t have permission to view deleted revision content', 'permissiondenied');
         }
     }
     // Check limits
     $userMax = $fld_content ? ApiBase::LIMIT_SML1 : ApiBase::LIMIT_BIG1;
     $botMax = $fld_content ? ApiBase::LIMIT_SML2 : ApiBase::LIMIT_BIG2;
     $limit = $params['limit'];
     if ($limit == 'max') {
         $limit = $this->getMain()->canApiHighLimits() ? $botMax : $userMax;
         $this->getResult()->addParsedLimit($this->getModuleName(), $limit);
     }
     $this->validateLimit('limit', $limit, 1, $userMax, $botMax);
     if ($fld_token) {
         // Undelete tokens are identical for all pages, so we cache one here
         $token = $user->getEditToken('', $this->getMain()->getRequest());
     }
     $dir = $params['dir'];
     // We need a custom WHERE clause that matches all titles.
     if ($mode == 'revs') {
         $lb = new LinkBatch($titles);
         $where = $lb->constructSet('ar', $db);
         $this->addWhere($where);
     } elseif ($mode == 'all') {
         $this->addWhereFld('ar_namespace', $params['namespace']);
         $from = $params['from'] === null ? null : $this->titlePartToKey($params['from'], $params['namespace']);
         $to = $params['to'] === null ? null : $this->titlePartToKey($params['to'], $params['namespace']);
         $this->addWhereRange('ar_title', $dir, $from, $to);
         if (isset($params['prefix'])) {
             $this->addWhere('ar_title' . $db->buildLike($this->titlePartToKey($params['prefix'], $params['namespace']), $db->anyString()));
         }
     }
     if (!is_null($params['user'])) {
         $this->addWhereFld('ar_user_text', $params['user']);
     } elseif (!is_null($params['excludeuser'])) {
         $this->addWhere('ar_user_text != ' . $db->addQuotes($params['excludeuser']));
     }
     if (!is_null($params['user']) || !is_null($params['excludeuser'])) {
         // Paranoia: avoid brute force searches (bug 17342)
         // (shouldn't be able to get here without 'deletedhistory', but
         // check it again just in case)
         if (!$user->isAllowed('deletedhistory')) {
             $bitmask = Revision::DELETED_USER;
         } elseif (!$user->isAllowedAny('suppressrevision', 'viewsuppressed')) {
             $bitmask = Revision::DELETED_USER | Revision::DELETED_RESTRICTED;
         } else {
             $bitmask = 0;
         }
         if ($bitmask) {
             $this->addWhere($db->bitAnd('ar_deleted', $bitmask) . " != {$bitmask}");
         }
     }
     if (!is_null($params['continue'])) {
         $cont = explode('|', $params['continue']);
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:67,代码来源:ApiQueryDeletedrevs.php

示例14: execute

 public function execute()
 {
     $user = $this->getUser();
     // Before doing anything at all, let's check permissions
     if (!$user->isAllowed('deletedhistory')) {
         $this->dieUsage('You don\'t have permission to view deleted revision information', 'permissiondenied');
     }
     $db = $this->getDB();
     $params = $this->extractRequestParams(false);
     $prop = array_flip($params['prop']);
     $fld_parentid = isset($prop['parentid']);
     $fld_revid = isset($prop['revid']);
     $fld_user = isset($prop['user']);
     $fld_userid = isset($prop['userid']);
     $fld_comment = isset($prop['comment']);
     $fld_parsedcomment = isset($prop['parsedcomment']);
     $fld_minor = isset($prop['minor']);
     $fld_len = isset($prop['len']);
     $fld_sha1 = isset($prop['sha1']);
     $fld_content = isset($prop['content']);
     $fld_token = isset($prop['token']);
     $result = $this->getResult();
     $pageSet = $this->getPageSet();
     $titles = $pageSet->getTitles();
     // This module operates in three modes:
     // 'revs': List deleted revs for certain titles (1)
     // 'user': List deleted revs by a certain user (2)
     // 'all': List all deleted revs in NS (3)
     $mode = 'all';
     if (count($titles) > 0) {
         $mode = 'revs';
     } elseif (!is_null($params['user'])) {
         $mode = 'user';
     }
     if ($mode == 'revs' || $mode == 'user') {
         // Ignore namespace and unique due to inability to know whether they were purposely set
         foreach (array('from', 'to', 'prefix') as $p) {
             if (!is_null($params[$p])) {
                 $this->dieUsage("The '{$p}' parameter cannot be used in modes 1 or 2", 'badparams');
             }
         }
     } else {
         foreach (array('start', 'end') as $p) {
             if (!is_null($params[$p])) {
                 $this->dieUsage("The {$p} parameter cannot be used in mode 3", 'badparams');
             }
         }
     }
     if (!is_null($params['user']) && !is_null($params['excludeuser'])) {
         $this->dieUsage('user and excludeuser cannot be used together', 'badparams');
     }
     $this->addTables('archive');
     $this->addWhere('ar_deleted = 0');
     $this->addFields(array('ar_title', 'ar_namespace', 'ar_timestamp'));
     $this->addFieldsIf('ar_parent_id', $fld_parentid);
     $this->addFieldsIf('ar_rev_id', $fld_revid);
     $this->addFieldsIf('ar_user_text', $fld_user);
     $this->addFieldsIf('ar_user', $fld_userid);
     $this->addFieldsIf('ar_comment', $fld_comment || $fld_parsedcomment);
     $this->addFieldsIf('ar_minor_edit', $fld_minor);
     $this->addFieldsIf('ar_len', $fld_len);
     $this->addFieldsIf('ar_sha1', $fld_sha1);
     if ($fld_content) {
         $this->addTables('text');
         $this->addFields(array('ar_text', 'ar_text_id', 'old_text', 'old_flags'));
         $this->addWhere('ar_text_id = old_id');
         // This also means stricter restrictions
         if (!$user->isAllowed('undelete')) {
             $this->dieUsage('You don\'t have permission to view deleted revision content', 'permissiondenied');
         }
     }
     // Check limits
     $userMax = $fld_content ? ApiBase::LIMIT_SML1 : ApiBase::LIMIT_BIG1;
     $botMax = $fld_content ? ApiBase::LIMIT_SML2 : ApiBase::LIMIT_BIG2;
     $limit = $params['limit'];
     if ($limit == 'max') {
         $limit = $this->getMain()->canApiHighLimits() ? $botMax : $userMax;
         $this->getResult()->setParsedLimit($this->getModuleName(), $limit);
     }
     $this->validateLimit('limit', $limit, 1, $userMax, $botMax);
     if ($fld_token) {
         // Undelete tokens are identical for all pages, so we cache one here
         $token = $user->getEditToken('', $this->getMain()->getRequest());
     }
     $dir = $params['dir'];
     // We need a custom WHERE clause that matches all titles.
     if ($mode == 'revs') {
         $lb = new LinkBatch($titles);
         $where = $lb->constructSet('ar', $db);
         $this->addWhere($where);
     } elseif ($mode == 'all') {
         $this->addWhereFld('ar_namespace', $params['namespace']);
         $from = is_null($params['from']) ? null : $this->titleToKey($params['from']);
         $to = is_null($params['to']) ? null : $this->titleToKey($params['to']);
         $this->addWhereRange('ar_title', $dir, $from, $to);
         if (isset($params['prefix'])) {
             $this->addWhere('ar_title' . $db->buildLike($this->titlePartToKey($params['prefix']), $db->anyString()));
         }
     }
     if (!is_null($params['user'])) {
//.........这里部分代码省略.........
开发者ID:Grprashanthkumar,项目名称:ColfusionWeb,代码行数:101,代码来源:ApiQueryDeletedrevs.php

示例15: doVariants

 /**
  * Modify $this->internals and $colours according to language variant linking rules
  */
 protected function doVariants(&$colours)
 {
     global $wgContLang;
     $linkBatch = new LinkBatch();
     $variantMap = array();
     // maps $pdbkey_Variant => $keys (of link holders)
     $output = $this->parent->getOutput();
     $linkCache = LinkCache::singleton();
     $sk = $this->parent->getOptions()->getSkin();
     $threshold = $this->getStubThreshold();
     // Add variants of links to link batch
     foreach ($this->internals as $ns => $entries) {
         foreach ($entries as $index => $entry) {
             $key = "{$ns}:{$index}";
             $pdbk = $entry['pdbk'];
             $title = $entry['title'];
             $titleText = $title->getText();
             // generate all variants of the link title text
             $allTextVariants = $wgContLang->convertLinkToAllVariants($titleText);
             // if link was not found (in first query), add all variants to query
             if (!isset($colours[$pdbk])) {
                 foreach ($allTextVariants as $textVariant) {
                     if ($textVariant != $titleText) {
                         $variantTitle = Title::makeTitle($ns, $textVariant);
                         if (is_null($variantTitle)) {
                             continue;
                         }
                         $linkBatch->addObj($variantTitle);
                         $variantMap[$variantTitle->getPrefixedDBkey()][] = $key;
                     }
                 }
             }
         }
     }
     // process categories, check if a category exists in some variant
     $categoryMap = array();
     // maps $category_variant => $category (dbkeys)
     $varCategories = array();
     // category replacements oldDBkey => newDBkey
     foreach ($output->getCategoryLinks() as $category) {
         $variants = $wgContLang->convertLinkToAllVariants($category);
         foreach ($variants as $variant) {
             if ($variant != $category) {
                 $variantTitle = Title::newFromDBkey(Title::makeName(NS_CATEGORY, $variant));
                 if (is_null($variantTitle)) {
                     continue;
                 }
                 $linkBatch->addObj($variantTitle);
                 $categoryMap[$variant] = $category;
             }
         }
     }
     if (!$linkBatch->isEmpty()) {
         // construct query
         $dbr = wfGetDB(DB_SLAVE);
         $page = $dbr->tableName('page');
         $titleClause = $linkBatch->constructSet('page', $dbr);
         $variantQuery = "SELECT page_id, page_namespace, page_title, page_is_redirect, page_len";
         $variantQuery .= " FROM {$page} WHERE {$titleClause}";
         $varRes = $dbr->query($variantQuery, __METHOD__);
         $linkcolour_ids = array();
         // for each found variants, figure out link holders and replace
         while ($s = $dbr->fetchObject($varRes)) {
             $variantTitle = Title::makeTitle($s->page_namespace, $s->page_title);
             $varPdbk = $variantTitle->getPrefixedDBkey();
             $vardbk = $variantTitle->getDBkey();
             $holderKeys = array();
             if (isset($variantMap[$varPdbk])) {
                 $holderKeys = $variantMap[$varPdbk];
                 $linkCache->addGoodLinkObj($s->page_id, $variantTitle, $s->page_len, $s->page_is_redirect);
                 $output->addLink($variantTitle, $s->page_id);
             }
             // loop over link holders
             foreach ($holderKeys as $key) {
                 list($ns, $index) = explode(':', $key, 2);
                 $entry =& $this->internals[$ns][$index];
                 $pdbk = $entry['pdbk'];
                 if (!isset($colours[$pdbk])) {
                     // found link in some of the variants, replace the link holder data
                     $entry['title'] = $variantTitle;
                     $entry['pdbk'] = $varPdbk;
                     // set pdbk and colour
                     # FIXME: convoluted data flow
                     # The redirect status and length is passed to getLinkColour via the LinkCache
                     # Use formal parameters instead
                     $colours[$varPdbk] = $sk->getLinkColour($variantTitle, $threshold);
                     $linkcolour_ids[$s->page_id] = $pdbk;
                 }
             }
             // check if the object is a variant of a category
             if (isset($categoryMap[$vardbk])) {
                 $oldkey = $categoryMap[$vardbk];
                 if ($oldkey != $vardbk) {
                     $varCategories[$oldkey] = $vardbk;
                 }
             }
         }
//.........这里部分代码省略.........
开发者ID:amjadtbssm,项目名称:website,代码行数:101,代码来源:LinkHolderArray.php


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