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


PHP WikiFactory::DomainToId方法代码示例

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


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

示例1: getWikiData

 /**
  * getWikiData
  *
  * use subpage as param and try to find wiki which match criteria
  *
  * @access private
  *
  * @param mixed $subpage:
  *
  * @return Database Row from city_list
  */
 private function getWikiData($subpage)
 {
     global $wgRequest;
     $domain = $wgRequest->getVal("wpCityDomain", null);
     $cityid = $wgRequest->getVal("cityid", null);
     $tab = "variables";
     if (is_null($cityid) && (isset($subpage) || isset($domain))) {
         /**
          * if there is # in subpage we are switching tab
          */
         if (strpos($subpage, "/")) {
             $parts = explode("/", $subpage, 3);
             if (is_array($parts) && sizeof($parts) >= 2) {
                 $subpage = $parts[0];
                 $tab = $parts[1];
                 if ($tab === "variables" && isset($parts[2])) {
                     $this->mVariableName = trim($parts[2]);
                 }
                 if (($tab === "tags" || $tab === "findtags") && isset($parts[2])) {
                     $this->mSearchTag = trim($parts[2]);
                 }
             }
         }
         if (is_null($domain)) {
             $domain = $subpage;
         }
         if (ctype_digit($subpage)) {
             $cityid = $subpage;
         } else {
             /**
              * if $domain starts with db: it means that we want to search by database
              * if $domain starts with id: it means that we want to search by city_id
              */
             $cityid = null;
             if (preg_match("/^db\\:/", $domain)) {
                 list($prefix, $name) = explode(":", $domain, 2);
                 $cityid = WikiFactory::DBtoID(strtolower($name));
             } elseif (preg_match("/^id\\:/", $domain)) {
                 list($prefix, $cityid) = explode(":", $domain, 2);
             } else {
                 /**
                  * if there's no dot in cityname we add .wikia.com
                  * or if is only one dot (language.domain.wikia.com)
                  */
                 if (sizeof(explode(".", $domain)) <= 2 && strlen($domain) > 0) {
                     $this->mDomain = $domain;
                     $domain = $domain . ".wikia.com";
                 } else {
                     list($code, $subdomain) = explode(".", $domain, 2);
                     $exists = 0;
                     if (in_array($code, array_keys(Language::getLanguageNames()))) {
                         $exists = 1;
                     } else {
                         $cityid = WikiFactory::DomainToId($domain);
                         if (!is_null($cityid)) {
                             $exists = 1;
                         }
                     }
                     if ($exists == 1) {
                         $this->mDomain = $code . "." . $subdomain;
                         $domain = sprintf("%s.%s", $code, $subdomain);
                     }
                 }
                 if (is_null($cityid)) {
                     $cityid = WikiFactory::DomainToId($domain);
                 }
             }
         }
     }
     $this->mTab = $tab;
     if (!is_null($cityid)) {
         $this->mTitle = Title::makeTitle(NS_SPECIAL, "WikiFactory/{$cityid}/{$tab}");
     }
     if (!isset($this->mVariableName)) {
         $this->mVariableName = "";
     }
     return WikiFactory::getWikiByID($cityid);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:89,代码来源:SpecialWikiFactory_body.php

示例2: execute

 public function execute($subpage)
 {
     global $wgUser, $wgOut, $wgRequest, $wgCityId, $wgDBname, $wgLang;
     if ($wgUser->isBlocked()) {
         throw new UserBlockedError($this->getUser()->mBlock);
     }
     if (wfReadOnly()) {
         $wgOut->readOnlyPage();
         return;
     }
     // Set the current wiki ID, DB name and user from globals
     $this->mCityId = $wgCityId;
     $this->mCityDBName = $wgDBname;
     $this->mUser = $wgUser;
     // Check the current $wgUser against the set of groups WikiStats recognizes
     $this->userIsSpecial = WikiStats::isAllowed();
     $this->mFromDate = $wgRequest->getVal("wsfrom", WIKISTATS_MIN_STATS_YEAR . WIKISTATS_MIN_STATS_MONTH);
     $this->mToDate = $wgRequest->getVal("wsto", date("Ym"));
     $this->mTitle = Title::makeTitle(NS_SPECIAL, "WikiStats");
     $this->mAction = $wgRequest->getVal("action", "");
     $this->mXLS = $wgRequest->getVal("wsxls", false);
     $this->mMonth = $wgRequest->getVal("wsmonth", 0);
     $this->mLimit = $wgRequest->getVal("wslimit", WIKISTATS_WIKIANS_RANK_NBR);
     $this->mAllWikis = 0;
     // Use the first part of the subpage as the action
     if ($subpage) {
         $path = explode("/", $subpage);
         $this->mAction = $path[0];
     }
     // Redirect to the default action if one hasn't been set
     if (empty($this->mAction)) {
         $wgOut->redirect($this->mTitle->getFullURL("action={$this->defaultAction}"));
     }
     // Split out the the from and to month and year for convenience
     if (preg_match("/^([0-9]{4})([0-9]{1,2})/", $this->mFromDate, $m)) {
         list(, $this->fromYear, $this->fromMonth) = $m;
     } else {
         $wgOut->showErrorPage("Bad parameters", "wikistats_error_malformed_date");
         return;
     }
     if (preg_match("/^([0-9]{4})([0-9]{1,2})/", $this->mToDate, $m)) {
         list(, $this->toYear, $this->toMonth) = $m;
     } else {
         $wgOut->showErrorPage("Bad parameters", "wikistats_error_malformed_date");
         return;
     }
     $domain = $all = "";
     if ($this->userIsSpecial) {
         $this->mLang = $wgRequest->getVal("wslang", "");
         $this->mHub = $wgRequest->getVal("wscat", "");
         $this->mNS = $wgRequest->getIntArray("wsns", "");
         $domain = $wgRequest->getVal("wswiki", "");
         $all = $wgRequest->getVal("wsall", 0);
         $this->mNamespaces = $wgLang->getNamespaces();
     }
     // Override some values if we're special and got a domain (or 'all')
     if ($domain == 'all' || $all == 1) {
         $this->mCityId = 0;
         $this->mCityDBName = WIKISTATS_CENTRAL_ID;
         $this->mCityDomain = 'all';
         $this->mAllWikis = 1;
     } elseif (!empty($domain) && $this->userIsSpecial == 1) {
         $this->mCityId = WikiFactory::DomainToId($domain);
         $this->mCityDBName = WikiFactory::IDToDB($this->mCityId);
         $this->mCityDomain = $domain;
     } else {
         $this->mCityDomain = WikiFactory::DBToDomain($this->mCityDBName);
     }
     $this->mStats = WikiStats::newFromId($this->mCityId);
     $this->mPredefinedNamespaces = $this->mStats->getPageNSList();
     $this->mStats->setStatsDate(array('fromMonth' => $this->fromMonth, 'fromYear' => $this->fromYear, 'toMonth' => $this->toMonth, 'toYear' => $this->toYear));
     $this->mStats->setHub($this->mHub);
     $this->mStats->setLang($this->mLang);
     #---
     $this->mSkin = RequestContext::getMain()->getSkin();
     if (is_object($this->mSkin)) {
         $skinname = get_class($this->mSkin);
         $skinname = strtolower(str_replace("Skin", "", $skinname));
         $this->mSkinName = $skinname;
     }
     $this->showForm();
     if ($this->mAction) {
         $func = 'show' . ucfirst(strtolower($this->mAction));
         if (method_exists($this, $func)) {
             $this->{$func}($subpage);
         }
     }
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:88,代码来源:SpecialWikiStats_body.php

示例3: getInterstitial

 /**
  * Get interstitial data.  If format is json, returns data only.  Has template.
  * @requestParam integer wikiId
  * @responseParam array wikiAdminAvatars
  * @responseParam array wikiTopEditorAvatars
  * @responseParam array wikiStats
  * @responseParam array wikiInfo
  */
 public function getInterstitial()
 {
     $this->response->setCacheValidity(WikiaResponse::CACHE_SHORT);
     $wikiId = $this->request->getVal('wikiId', 0);
     $domain = $this->request->getVal('domain', null);
     if ($wikiId == 0 && $domain != null) {
         // This is not guaranteed valid for all domains, but the custom domains in use have aliases set up
         $domain = "{$domain}.wikia.com";
         $wikiId = WikiFactory::DomainToId($domain);
         if ($wikiId == 0) {
             throw new InvalidParameterApiException("domain");
         }
     }
     if ($wikiId == 0) {
         throw new MissingParameterApiException("wikiId or domain");
     }
     $this->wikiAdminAvatars = $this->helper->getWikiAdminAvatars($wikiId);
     $this->wikiTopEditorAvatars = $this->helper->getWikiTopEditorAvatars($wikiId);
     $tempArray = array();
     foreach ($this->helper->getWikiStats($wikiId) as $key => $value) {
         $tempArray[$key] = $this->wg->Lang->formatNum($value);
     }
     $this->wikiStats = $tempArray;
     $this->wikiInfo = $this->helper->getWikiInfoForVisualization($wikiId, $this->wg->contLang->getCode());
     $images = array();
     foreach ($this->wikiInfo['images'] as $image) {
         $images[] = $this->helper->getImageDataForSlider($wikiId, $image);
     }
     if (!empty($images[0])) {
         $this->wikiMainImageUrl = $images[0]['image_url'];
     } else {
         $this->wikiMainImageUrl = $this->wg->blankImgUrl;
     }
     if (!empty($this->app->wg->EnableWAMPageExt)) {
         $wamModel = new WAMPageModel();
         $this->wamUrl = $wamModel->getWAMMainPageUrl();
         $this->wikiWamScore = $this->helper->getWamScore($wikiId);
     }
     $this->imagesSlider = $this->sendRequest('WikiaMediaCarouselController', 'renderSlider', array('data' => $images));
     $wordmarkUrl = '';
     try {
         $title = GlobalTitle::newFromText('Wiki-wordmark.png', NS_FILE, $wikiId);
         if ($title !== null) {
             $file = new GlobalFile($title);
             if ($file !== null) {
                 $wordmarkUrl = $file->getUrl();
             }
         }
     } catch (Exception $e) {
     }
     $this->wordmark = $wordmarkUrl;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:60,代码来源:WikiaHomePageController.class.php


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