當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Wikia::getAllHeaders方法代碼示例

本文整理匯總了PHP中Wikia::getAllHeaders方法的典型用法代碼示例。如果您正苦於以下問題:PHP Wikia::getAllHeaders方法的具體用法?PHP Wikia::getAllHeaders怎麽用?PHP Wikia::getAllHeaders使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Wikia的用法示例。


在下文中一共展示了Wikia::getAllHeaders方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: execute


//.........這裏部分代碼省略.........
     wfRunHooks('WikiFactory::executeBeforeTransferToGlobals', array(&$this));
     /**
      * transfer configuration variables from database to GLOBALS
      */
     if (is_array($this->mVariables)) {
         foreach ($this->mVariables as $key => $value) {
             $tValue = $value;
             #--- check, maybe there are variables in variable
             if (is_string($tValue)) {
                 preg_match_all('/(\\$\\w+)[^\\w]*/', $tValue, $aMatches);
                 if (is_array($aMatches[1])) {
                     foreach ($aMatches[1] as $tKey) {
                         /**
                          * dolar sign in key should be removed
                          * (str_replace is faster than regexp)
                          */
                         $tKeyParsed = str_replace('$', '', $tKey);
                         if (!is_numeric($tKeyParsed)) {
                             #--- replace only if key is not $1, $2 etc.
                             if (array_key_exists($tKeyParsed, $this->mVariables)) {
                                 $tValue = str_replace($tKey, $this->mVariables[$tKeyParsed], $tValue);
                             } else {
                                 if (isset($GLOBALS[$tKeyParsed])) {
                                     $tValue = str_replace($tKey, $GLOBALS[$tKeyParsed], $tValue);
                                 }
                             }
                         }
                     }
                 }
             }
             /**
              * merge local values with global
              */
             switch ($key) {
                 case "wgNamespacesWithSubpagesLocal":
                     $this->LocalToGlobalArray($tValue, $GLOBALS["wgNamespacesWithSubpages"]);
                     break;
                 case "wgExtraNamespacesLocal":
                     $this->LocalToGlobalArray($tValue, $GLOBALS["wgExtraNamespaces"]);
                     break;
                 case "wgFileExtensionsLocal":
                     $this->LocalToGlobalArray($tValue, $GLOBALS["wgFileExtensions"], true);
                     break;
                 case "wgTrustedMediaFormatsLocal":
                     $this->LocalToGlobalArray($tValue, $GLOBALS["wgTrustedMediaFormats"]);
                     break;
                 case "wgFileBlacklistLocal":
                     $this->LocalToGlobalArray($tValue, $GLOBALS["wgFileBlacklist"]);
                     break;
             }
             if ($key == 'wgServer') {
                 $headers = Wikia::getAllHeaders();
                 if (array_key_exists('X-Original-Host', $headers) && !empty($headers['X-Original-Host'])) {
                     global $wgConf;
                     $tValue = 'http://' . $headers['X-Original-Host'];
                     $wgConf->localVHosts = array_merge($wgConf->localVHosts, array($headers['X-Original-Host']));
                 }
             }
             try {
                 if ($this->mSaveDefaults) {
                     $GLOBALS['wgPreWikiFactoryValues'][$key] = $tValue;
                 }
                 $GLOBALS[$key] = $tValue;
             } catch (Exception $e) {
                 #--- so far do nothing
             }
         }
     }
     $wgCityId = $this->mWikiID;
     /**
      * set/replace $wgDBname in $wgDBservers
      */
     if (isset($wgDBservers) && is_array($wgDBservers) && isset($this->mVariables["wgDBname"])) {
         foreach ($wgDBservers as $index => $server) {
             $wgDBservers[$index]["dbname"] = $this->mVariables["wgDBname"];
         }
     }
     if (isset($wgLBFactoryConf) && is_array($wgLBFactoryConf) && isset($this->mVariables["wgDBname"])) {
         $wgLBFactoryConf['serverTemplate']['dbname'] = $this->mVariables["wgDBname"];
         /**
          * set wgDBserver for cluster based on $wgLBFactoryConf
          */
         $cluster = isset($this->mVariables["wgDBcluster"]) ? $this->mVariables["wgDBcluster"] : "DEFAULT";
         if (isset($wgLBFactoryConf["sectionLoads"][$cluster])) {
             $keys = array_keys($wgLBFactoryConf["sectionLoads"][$cluster]);
             $db = array_shift($keys);
             if (isset($wgLBFactoryConf["hostsByName"][$db])) {
                 $wgDBserver = $wgLBFactoryConf["hostsByName"][$db];
                 $this->debug("wgDBserver for cluster {$cluster} set to {$wgDBserver}");
             }
         }
     }
     wfRunHooks('WikiFactory::onExecuteComplete', array(&$this));
     wfProfileOut(__METHOD__);
     /**
      * cleanup and finally return wiki id
      */
     LBFactory::destroyInstance();
     return $this->mWikiID;
 }
開發者ID:Tjorriemorrie,項目名稱:app,代碼行數:101,代碼來源:WikiFactoryLoader.php


注:本文中的Wikia::getAllHeaders方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。