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


PHP WikiFactory::getDomainKey方法代码示例

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


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

示例1: execute

 /**
  * execute
  *
  * Main entry point for class
  *
  * @author Krzysztof Krzyżaniak <eloy@wikia-inc.com>
  *
  * @return integer: wikia id or null if wikia is not handled by WikiFactory
  */
 public function execute()
 {
     wfProfileIn(__METHOD__);
     global $wgCityId, $wgDevelEnvironment, $wgDBservers, $wgLBFactoryConf, $wgDBserver, $wgContLang;
     /**
      * Hook to allow extensions to alter the initialization.  For example,
      * setting the mCityID then returning true will override which wiki
      * to use.
      *
      * @author Sean Colombo
      */
     if (!wfRunHooks('WikiFactory::execute', array(&$this))) {
         wfProfileOut(__METHOD__);
         return $this->mWikiID;
     }
     /**
      * load balancer uses one method which demand wgContLang defined
      * See BugId: 12474
      */
     $wgContLang = new StubObject('wgContLang');
     /**
      * local cache, change to CACHE_ACCEL for local
      */
     global $wgWikiFactoryCacheType;
     $oMemc = wfGetCache($wgWikiFactoryCacheType);
     if (empty($this->mAlwaysFromDB)) {
         /**
          * remember! for http requests we only known $this->mServerName
          * (domain), $this->mCityId is unknown (set to false in constructor)
          */
         wfProfileIn(__METHOD__ . "-domaincache");
         $key = WikiFactory::getDomainKey($this->mServerName);
         $this->mDomain = $oMemc->get($key);
         $this->mDomain = isset($this->mDomain["id"]) ? $this->mDomain : array();
         $this->debug("reading from cache, key {$key}");
         wfProfileOut(__METHOD__ . "-domaincache");
     }
     if (!isset($this->mDomain["id"]) || $this->mAlwaysFromDB) {
         wfProfileIn(__METHOD__ . "-domaindb");
         /**
          * first run or cache expired
          */
         $dbr = $this->getDB();
         /**
          * interactive/cmdline case. We know city_id so we don't have to
          * ask city_domains table
          */
         if ($this->mCityID || $this->mCityDB) {
             $oRow = $dbr->selectRow(array("city_list"), array("city_id", "city_public", "city_factory_timestamp", "city_url", "city_dbname"), $this->mCityID ? array("city_list.city_id" => $this->mCityID) : array("city_list.city_dbname" => $this->mCityDB), __METHOD__ . '::domaindb');
             if (isset($oRow->city_id)) {
                 preg_match("/http[s]*\\:\\/\\/(.+)\$/", $oRow->city_url, $matches);
                 $host = rtrim($matches[1], "/");
                 $this->mCityID = $oRow->city_id;
                 $this->mWikiID = $oRow->city_id;
                 $this->mIsWikiaActive = $oRow->city_public;
                 $this->mCityHost = $host;
                 $this->mCityDB = $oRow->city_dbname;
                 $this->mTimestamp = $oRow->city_factory_timestamp;
                 $this->mDomain = array("id" => $oRow->city_id, "host" => $host, "active" => $oRow->city_public, "time" => $oRow->city_factory_timestamp, "db" => $this->mCityDB);
             }
         } else {
             /**
              * request from HTTPD case. We only know server name so we
              * have to ask city_domains table
              */
             $oRow = $dbr->selectRow(array("city_domains", "city_list"), array("city_list.city_id", "city_public", "city_factory_timestamp", "city_domain", "city_url", "city_dbname"), array("city_domains.city_id = city_list.city_id", "city_domains.city_domain" => $this->mServerName), __METHOD__ . '::servername');
             if (isset($oRow->city_id) && $oRow->city_id > 0) {
                 $oRow->city_domain = strtolower($oRow->city_domain);
                 preg_match("/http[s]*\\:\\/\\/(.+)\$/", $oRow->city_url, $matches);
                 $host = rtrim($matches[1], "/");
                 if ($oRow->city_domain == $this->mServerName && $this->mServerName) {
                     $this->mWikiID = $oRow->city_id;
                     $this->mIsWikiaActive = $oRow->city_public;
                     $this->mCityHost = $host;
                     $this->mCityDB = $oRow->city_dbname;
                     $this->mTimestamp = $oRow->city_factory_timestamp;
                     $this->mDomain = array("id" => $oRow->city_id, "host" => $host, "active" => $oRow->city_public, "time" => $oRow->city_factory_timestamp, "db" => $oRow->city_dbname);
                 }
             }
         }
         if (empty($this->mAlwaysFromDB) && !empty($this->mWikiID)) {
             /**
              * store value in cache
              */
             $oMemc->set(WikiFactory::getDomainKey($this->mServerName), $this->mDomain, $this->mExpireDomainCacheTimeout);
         }
         $this->debug("city_id={$this->mWikiID}, reading from database key {$this->mServerName}");
         wfProfileOut(__METHOD__ . "-domaindb");
     } else {
         /**
          * data taken from cache
//.........这里部分代码省略.........
开发者ID:Tjorriemorrie,项目名称:app,代码行数:101,代码来源:WikiFactoryLoader.php


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