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


PHP WikiFactory::IDtoDB方法代码示例

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


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

示例1: getWikisList

 public function getWikisList()
 {
     $this->wf->profileIn(__METHOD__);
     $cacheKey = $this->getGlobalCacheKey(self::MEMCACHE_GLOBAL_KEY_TOKEN);
     $ret = $this->loadFromCache($cacheKey);
     if (empty($ret)) {
         $ret = array();
         $wikiFactoryRecommendVar = WikiFactory::getVarByName(self::WF_SWITCH_NAME, null);
         if (!empty($wikiFactoryRecommendVar)) {
             $gamesIds = WikiFactory::getCityIDsFromVarValue($wikiFactoryRecommendVar->cv_variable_id, true, '=');
             foreach ($gamesIds as $wikiId) {
                 $game = $this->getSettings($wikiId);
                 if (!empty($game)) {
                     $wikiName = WikiFactory::getVarValueByName('wgSitename', $wikiId);
                     $wikiThemeSettings = WikiFactory::getVarValueByName('wgOasisThemeSettings', $wikiId);
                     $game->name = !empty($wikiThemeSettings['wordmark-text']) ? $wikiThemeSettings['wordmark-text'] : $wikiName;
                     $game->id = WikiFactory::IDtoDB($wikiId);
                     $game->domain = str_replace('http://', '', WikiFactory::getVarValueByName('wgServer', $wikiId));
                     $ret[$game->id] = $game;
                 }
             }
         } else {
             $this->wf->profileOut(__METHOD__);
             throw new WikiaException('WikiFactory variable \'' . self::WF_SWITCH_NAME . '\' not found');
         }
         $this->storeInCache($cacheKey, $ret);
     }
     $this->app->wf->profileOut(__METHOD__);
     return $ret;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:30,代码来源:PhotoPopModel.class.php

示例2: getDBName

 public function getDBName()
 {
     if (empty($this->dbName) and !empty($this->cityId)) {
         $this->dbName = WikiFactory::IDtoDB($this->cityId);
     }
     return $this->dbName;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:7,代码来源:PromoImage.class.php

示例3: __construct

 public function __construct($id = null)
 {
     parent::__construct();
     if (is_null($id)) {
         $id = $this->wg->CityId;
     }
     $this->id = $id;
     if ($this->wg->CityId == $id) {
         $this->db = wfGetDB(DB_SLAVE);
         $this->dbname = $this->wg->DBname;
     } else {
         // find db name
         $dbname = WikiFactory::IDtoDB($this->id);
         if (empty($dbname)) {
             throw new Exception("Could not find wiki with ID {$this->id}");
         }
         // open db connection (and check if db really exists)
         $db = wfGetDB(DB_SLAVE, array(), $dbname);
         if (!is_object($db)) {
             throw new Exception("Could not connect to wiki database {$dbname}");
         }
         $this->db = $db;
         $this->dbname = $dbname;
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:25,代码来源:WikiDataSource.php

示例4: execute

 public function execute()
 {
     $this->test = $this->hasOption('test') ? true : false;
     $this->verbose = $this->hasOption('verbose') ? true : false;
     $this->clear = $this->hasOption('clear') ? true : false;
     $this->refresh = $this->hasOption('refresh') ? true : false;
     if ($this->test) {
         echo "== TEST MODE ==\n";
     }
     $this->debug("(debugging output enabled)\n");
     $startTime = time();
     // Clear existing suggestions if we are forcing a rebuild
     if ($this->clear) {
         $this->clearSuggestions();
     }
     $this->processVideoList();
     $delta = $this->formatDuration(time() - $startTime);
     $stats = $this->usageStats();
     $wgDBName = WikiFactory::IDtoDB($_ENV['SERVER_ID']);
     echo "[{$wgDBName}] Finished in {$delta}.\n";
     echo "[{$wgDBName}] Usage Stats: Total videos before swapping videos=" . ($stats['totalVids'] + $stats['swapTypes'][2] + $stats['swapTypes'][3]) . ", ";
     echo "Total videos=" . $stats['totalVids'] . " (Videos with suggestions=" . $stats['vidsWithSuggestions'] . "), ";
     echo "Total suggestions=" . $stats['numSuggestions'] . ", Avg per video=" . sprintf("%.1f", $stats['avgSuggestions']) . ", ";
     echo "Total kept videos=" . $stats['swapTypes'][1] . ", Total swapped videos=" . ($stats['swapTypes'][2] + $stats['swapTypes'][3]) . " (Exact title=" . $stats['swapTypes'][3] . ")\n";
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:25,代码来源:lvsUpdateSuggestions.php

示例5: performQueryTest

 /**
  * @param $wikiId
  * @param $query
  * @return float
  */
 public function performQueryTest($wikiId, $query)
 {
     $wgLinkSuggestLimit = 6;
     $dbName = WikiFactory::IDtoDB($wikiId);
     $db = wfGetDB(DB_SLAVE, [], $dbName);
     $namespaces = WikiFactory::getVarValueByName("wgContentNamespaces", $wikiId);
     $namespaces = $namespaces ? $namespaces : [0];
     $query = addslashes($query);
     $queryLower = strtolower($query);
     if (count($namespaces) > 0) {
         $commaJoinedNamespaces = count($namespaces) > 1 ? array_shift($namespaces) . ', ' . implode(', ', $namespaces) : $namespaces[0];
     }
     $pageNamespaceClause = isset($commaJoinedNamespaces) ? 'page_namespace IN (' . $commaJoinedNamespaces . ') AND ' : '';
     $pageTitlePrefilter = "";
     if (strlen($queryLower) >= 2) {
         $pageTitlePrefilter = "(\n\t\t\t\t\t\t\t( page_title " . $db->buildLike(strtoupper($queryLower[0]) . strtolower($queryLower[1]), $db->anyString()) . " ) OR\n\t\t\t\t\t\t\t( page_title " . $db->buildLike(strtoupper($queryLower[0]) . strtoupper($queryLower[1]), $db->anyString()) . " ) ) AND ";
     } else {
         if (strlen($queryLower) >= 1) {
             $pageTitlePrefilter = "( page_title " . $db->buildLike(strtoupper($queryLower[0]), $db->anyString()) . " ) AND ";
         }
     }
     $sql = "SELECT page_len, page_id, page_title, rd_title, page_namespace, page_is_redirect\n\t\t\t\t\t\tFROM page\n\t\t\t\t\t\tLEFT JOIN redirect ON page_is_redirect = 1 AND page_id = rd_from\n\t\t\t\t\t\tLEFT JOIN querycache ON qc_title = page_title AND qc_type = 'BrokenRedirects'\n\t\t\t\t\t\tWHERE  {$pageTitlePrefilter} {$pageNamespaceClause} (LOWER(page_title) LIKE '{$queryLower}%')\n\t\t\t\t\t\t\tAND qc_type IS NULL\n\t\t\t\t\t\tORDER BY page_id\n\t\t\t\t\t\tLIMIT " . $wgLinkSuggestLimit * 3;
     // we fetch 3 times more results to leave out redirects to the same page
     $start = microtime(true);
     $res = $db->query($sql, __METHOD__);
     while ($res->fetchRow()) {
     }
     return microtime(true) - $start;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:34,代码来源:Query_B.class.php

示例6: loadData

 /**
  * Lazy-loads file meta data from another wiki
  */
 private function loadData()
 {
     if (!isset($this->mData)) {
         $dbname = WikiFactory::IDtoDB($this->mTitle->mCityId);
         $dbr = wfGetDB(DB_SLAVE, array(), $dbname);
         $this->mData = $dbr->selectRow('image', ['img_width', 'img_height', 'img_timestamp', 'img_major_mime', 'img_minor_mime'], ['img_name' => $this->mTitle->getDBkey()], __METHOD__);
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:11,代码来源:GlobalFile.class.php

示例7: clearLocalWatchlists

 /**
  * Clears the local watchlist tables for a given user.
  * @param int $userID
  */
 public function clearLocalWatchlists($userID)
 {
     $wikiIDs = $this->getWikisWithWatchedPagesForUser($userID);
     foreach ($wikiIDs as $wikiID) {
         $db = wfGetDB(DB_MASTER, [], WikiFactory::IDtoDB($wikiID));
         (new WikiaSQL())->UPDATE('watchlist')->SET('wl_notificationtimestamp', null)->WHERE('wl_user')->EQUAL_TO($userID)->run($db);
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:12,代码来源:GlobalWatchlistBot.class.php

示例8: getImageOriginalUrl

 public static function getImageOriginalUrl($wikiId, $pageId)
 {
     $app = F::app();
     $app->wf->ProfileIn(__METHOD__);
     $dbname = WikiFactory::IDtoDB($wikiId);
     $title = GlobalTitle::newFromId($pageId, $wikiId);
     $param = array('action' => 'query', 'prop' => 'imageinfo', 'iiprop' => 'url', 'titles' => $title->getPrefixedText());
     $response = ApiService::foreignCall($dbname, $param);
     $app->wf->ProfileOut(__METHOD__);
     return array('src' => $imageSrc, 'page' => $imagePage);
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:11,代码来源:ImagesService.class.php

示例9: execute

 /**
  * execute
  *
  * entry point for TaskExecutor
  *
  * @access public
  * @author eloy@wikia
  *
  * @param mixed $params default null - task data from wikia_tasks table
  *
  * @return boolean - status of operation
  */
 public function execute($params = null)
 {
     global $IP, $wgWikiaLocalSettingsPath, $wgWikiaAdminSettingsPath, $wgExtensionMessagesFiles;
     $this->mTaskID = $params->task_id;
     $this->mParams = unserialize($params->task_arguments);
     $city_id = $this->mParams["city_id"];
     $command = $this->mParams["command"];
     $type = $this->mParams["type"];
     $server = $this->mParams["server"];
     $this->addLog("wgServer for this site is: {$server}");
     if ($city_id && $command) {
         $this->mWikiId = $city_id;
         /**
          * execute maintenance script
          */
         $cmd = sprintf("SERVER_ID={$city_id} php {$IP}/{$command} --server={$server} --conf {$wgWikiaLocalSettingsPath} --aconf {$wgWikiaAdminSettingsPath}");
         $this->addLog("Running {$cmd}");
         $retval = wfShellExec($cmd, $status);
         $this->addLog($retval);
         if ($type == "ACWLocal" || $type == "CWLocal") {
             $cmd = sprintf("SERVER_ID={$city_id} php {$IP}/maintenance/update.php --server={$server} --quick --nopurge --conf {$wgWikiaLocalSettingsPath} --aconf {$wgWikiaAdminSettingsPath}");
             $this->addLog("Running {$cmd}");
             $retval = wfShellExec($cmd, $status);
             $this->addLog($retval);
             $cmd = sprintf("SERVER_ID={$city_id} php {$IP}/maintenance/initStats.php --server={$server} --conf {$wgWikiaLocalSettingsPath} --aconf {$wgWikiaAdminSettingsPath}");
             $this->addLog("Running {$cmd}");
             $retval = wfShellExec($cmd, $status);
             $this->addLog($retval);
             $cmd = sprintf("SERVER_ID={$city_id} php {$IP}/maintenance/refreshLinks.php --server={$server} --new-only --conf {$wgWikiaLocalSettingsPath} --aconf {$wgWikiaAdminSettingsPath}");
             $this->addLog("Running {$cmd}");
             $retval = wfShellExec($cmd, $status);
             $this->addLog($retval);
             $this->addLog("Remove edit lock");
             $oVariable = WikiFactory::getVarByName('wgReadOnly', $city_id);
             if (isset($oVariable->cv_variable_id)) {
                 WikiFactory::removeVarById($oVariable->cv_variable_id, $city_id);
                 WikiFactory::clearCache($city_id);
             }
         }
         $dbname = WikiFactory::IDtoDB($city_id);
         $cmd = sprintf("perl /usr/wikia/backend/bin/scribe/events_local_users.pl --usedb={$dbname} ");
         $this->addLog("Running {$cmd}");
         $retval = wfShellExec($cmd, $status);
         $this->addLog($retval);
         /**
          * once again clear cache at the very end
          */
         $wgMemc = wfGetMainCache();
         $wgMemc->delete(WikiFactory::getVarsKey($city_id));
     }
     return true;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:64,代码来源:LocalMaintenanceTask.php

示例10: execute

 public function execute()
 {
     $this->dryRun = $this->hasOption('dry-run');
     $this->verbose = $this->hasOption('verbose');
     $wikiId = $this->getOption('wikiId', '');
     if (empty($wikiId)) {
         die("Error: Empty wiki id.\n");
     }
     $dbname = WikiFactory::IDtoDB($wikiId);
     if (empty($dbname)) {
         die("Error: Cannot find dbname.\n");
     }
     $pageLimit = 20000;
     $totalLimit = $this->getOption('limit', $pageLimit);
     if (empty($totalLimit) || $totalLimit < -1) {
         die("Error: invalid limit.\n");
     }
     if ($totalLimit == -1) {
         $totalLimit = $this->getTotalPages($dbname);
     }
     $maxSet = ceil($totalLimit / $pageLimit);
     $limit = $totalLimit > $pageLimit ? $pageLimit : $totalLimit;
     $totalPages = 0;
     for ($set = 1; $set <= $maxSet; $set++) {
         $cnt = 0;
         if ($set == $maxSet) {
             $limit = $totalLimit - $pageLimit * ($set - 1);
         }
         $offset = ($set - 1) * $pageLimit;
         $pages = $this->getAllPages($dbname, $limit, $offset);
         $total = count($pages);
         foreach ($pages as $page) {
             $cnt++;
             echo "Wiki {$wikiId} - Page {$page['id']} [{$cnt} of {$total}, set {$set} of {$maxSet}]: ";
             $title = GlobalTitle::newFromId($page['id'], $wikiId);
             if ($title instanceof GlobalTitle) {
                 $url = $title->getFullURL();
                 echo "{$url}\n";
                 if (!$this->dryRun) {
                     SquidUpdate::purge([$url]);
                 }
                 $this->success++;
             } else {
                 echo "ERROR: Cannot find global title for {$page['title']}\n";
             }
         }
         $totalPages = $totalPages + $total;
     }
     echo "\nWiki {$wikiId}: Total pages: {$totalPages}, Success: {$this->success}, Failed: " . ($totalPages - $this->success) . "\n\n";
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:50,代码来源:purgeArticlePages.php

示例11: getCityLink

 public static function getCityLink($cityId)
 {
     global $wgCityId, $wgSitename;
     $domains = WikiFactory::getDomains($cityId);
     if ($wgCityId == $cityId) {
         // Hack based on the fact we should only ask for current wiki's sitename
         $text = $wgSitename;
     } else {
         // The fallback to return anything
         $text = "[" . WikiFactory::IDtoDB($cityId) . ":{$cityId}]";
     }
     if (!empty($domains)) {
         $text = Xml::tags('a', array("href" => "http://" . $domains[0]), $text);
     }
     return $text;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:16,代码来源:RenameUserLogFormatter.class.php

示例12: emailFollowNotifications

 public function emailFollowNotifications($initiatingUser, $aWatchers, $iUserId, $iNamespace, $sMessage, $sAction)
 {
     $wg = F::app()->wg;
     $wg->DBname = WikiFactory::IDtoDB($this->getWikiId());
     $wg->Server = trim(WikiFactory::DBtoUrl(F::app()->wg->DBname), '/');
     if (!empty($wg->DevelEnvironment)) {
         $wg->Server = WikiFactory::getLocalEnvURL($wg->Server);
     }
     $wg->User = User::newFromId($initiatingUser);
     $targetUser = User::newFromId($iUserId);
     $this->logWatchers($aWatchers, $sAction);
     foreach ($aWatchers as $sKey => $sValue) {
         $oTitle = Title::makeTitle($iNamespace, $sKey);
         $oEmailNotification = new EmailNotification($targetUser, $oTitle, wfTimestampNow(), $sMessage, false, $currentRevId = 0, $previousRevId = 0, $sAction, ['notisnull' => 1, 'childTitle' => $this->title]);
         $oEmailNotification->notifyOnPageChange();
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:17,代码来源:FollowEmailTask.class.php

示例13: getArticleDetails

 public function getArticleDetails($wikiId, $articleId, $url)
 {
     $domain = WikiFactory::DBtoUrl(WikiFactory::IDtoDB($wikiId));
     //TODO: REFACTOR THE HACK
     if ($domain) {
         $callUrl = sprintf('%sapi/v1/Articles/Details?ids=%u', $domain, $articleId);
         $details = Http::get($callUrl);
         if (empty($details)) {
             $details = file_get_contents($callUrl);
         }
         $data = json_decode($details);
         if ($data) {
             return $data;
         }
         return false;
     }
     return false;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:18,代码来源:RssFeedService.class.php

示例14: getImageOriginalUrl

 public static function getImageOriginalUrl($wikiId, $pageId)
 {
     wfProfileIn(__METHOD__);
     $dbname = WikiFactory::IDtoDB($wikiId);
     $title = GlobalTitle::newFromId($pageId, $wikiId);
     $param = array('action' => 'query', 'prop' => 'imageinfo', 'iiprop' => 'url', 'titles' => $title->getPrefixedText());
     $imagePage = $title->getFullUrl();
     $response = ApiService::foreignCall($dbname, $param, ApiService::API, true);
     if (!empty($response['query']['pages'])) {
         $imagePageData = array_shift($response['query']['pages']);
         $imageInfo = array_shift($imagePageData['imageinfo']);
         $imageSrc = empty($imageInfo['url']) ? '' : $imageInfo['url'];
     } else {
         $imageSrc = '';
     }
     wfProfileOut(__METHOD__);
     return array('src' => $imageSrc, 'page' => $imagePage);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:18,代码来源:ImagesService.class.php

示例15: getRecentAdminEdits

 function getRecentAdminEdits($fromWikiId = null, $toWikiId = null)
 {
     global $wgStatsDB, $wgStatsDBEnabled;
     $recentAdminEdit = array();
     if (!empty($wgStatsDBEnabled) && !empty($fromWikiId) && !empty($toWikiId)) {
         $dbrStats = wfGetDB(DB_SLAVE, array(), $wgStatsDB);
         //get wikis with edits < 1000 and admins not active in last 45 days
         //260000 = ID of wiki created on 2011-05-01 so it will work for wikis created after this project has been deployed
         $res = $dbrStats->query('select e1.wiki_id, sum(e1.edits) as sum_edits from specials.events_local_users e1 ' . 'where e1.wiki_id > ' . $fromWikiId . ' and e1.wiki_id <= ' . $toWikiId . ' ' . 'group by e1.wiki_id ' . 'having sum_edits < 1000 and (' . 'select count(0) from specials.events_local_users e2 ' . 'where e1.wiki_id = e2.wiki_id and ' . 'all_groups like "%sysop%" and ' . 'editdate > now() - interval 45 day ' . ') = 0', __METHOD__);
         while ($row = $dbrStats->fetchObject($res)) {
             $wikiDbname = WikiFactory::IDtoDB($row->wiki_id);
             if ($wikiDbname === false) {
                 //check if wiki exists in city_list
                 continue;
             }
             if (WikiFactory::isPublic($row->wiki_id) === false) {
                 //check if wiki is closed
                 continue;
             }
             if (self::isFlagSet($row->wiki_id, WikiFactory::FLAG_ADOPTABLE)) {
                 // check if adoptable flag is set
                 continue;
             }
             $res2 = $dbrStats->query("select user_id, max(editdate) as lastedit from specials.events_local_users where wiki_id = {$row->wiki_id} and all_groups like '%sysop%' group by 1 order by null;", __METHOD__);
             $recentAdminEdit[$row->wiki_id] = array('recentEdit' => time(), 'admins' => array());
             while ($row2 = $dbrStats->fetchObject($res2)) {
                 if (($lastedit = wfTimestamp(TS_UNIX, $row2->lastedit)) < $recentAdminEdit[$row->wiki_id]['recentEdit']) {
                     $recentAdminEdit[$row->wiki_id]['recentEdit'] = $lastedit;
                 } else {
                     if ($row2->lastedit == '0000-00-00 00:00:00') {
                         // use city_created if no lastedit
                         $wiki = WikiFactory::getWikiByID($row->wiki_id);
                         if (!empty($wiki)) {
                             $recentAdminEdit[$row->wiki_id]['recentEdit'] = wfTimestamp(TS_UNIX, $wiki->city_created);
                         }
                     }
                 }
                 $recentAdminEdit[$row->wiki_id]['admins'][] = $row2->user_id;
             }
         }
     }
     return $recentAdminEdit;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:43,代码来源:AutomaticWikiAdoptionGatherData.php


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