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


PHP ConfigManager::rootdir方法代码示例

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


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

示例1: getLocations

 /**
  * Get the locations for the rest of the site to use.
  */
 public static function getLocations($rootdir = NULL, $basedir = NULL)
 {
     Profiler::StartTimer("ConfigManager::getLocations()", 3);
     if ($rootdir === NULL) {
         $rootdir = self::$rootdir;
     } else {
         self::$rootdir = $rootdir;
     }
     if (empty($rootdir)) {
         return null;
     }
     if (!empty(self::$locations)) {
         $locations = self::$locations;
     } else {
         $cfgfile = NULL;
         if (file_exists("config/locations.cfg")) {
             $cfgfile = "config/locations.cfg";
         } else {
             if (file_exists("/etc/elation/locations.cfg")) {
                 $cfgfile = "/etc/elation/locations.cfg";
             }
         }
         if ($cfgfile !== NULL) {
             $mtime = filemtime($cfgfile);
             $fileid = md5($cfgfile);
             if (!empty($mtime)) {
                 $apcenabled = ini_get("apc.enabled");
                 $apckey = "config.locations.{$fileid}.{$mtime}";
                 if ($apcenabled && ($apccontents = apc_fetch($apckey)) != false) {
                     //print "found in apc, unserialize ($apccontents)<br />";
                     $locations = json_decode($apccontents, true);
                 } else {
                     //print "not found in apc, parse it<br />";
                     $locations = parse_ini_file($cfgfile, true);
                     $locations["root"] = $rootdir;
                     if ($apcenabled) {
                         apc_store($apckey, json_encode($locations));
                     }
                 }
             }
         }
         if (empty($locations)) {
             // If we couldn't load anything from APC or any of the config files, use some hardcoded defaults
             $locations = array("root" => $rootdir, "htdocs" => "{$rootdir}/htdocs", "images" => "{$rootdir}/htdocs/images", "scripts" => "{$rootdir}/htdocs/scripts", "css" => "{$rootdir}/htdocs/css", "resources" => "{$rootdir}/resources", "config" => "{$rootdir}/config", "tmp" => "{$rootdir}/tmp", "templates" => "{$rootdir}/templates", "htdocswww" => "{$basedir}", "imageswww" => "{$basedir}/images", "scriptswww" => "{$basedir}/scripts", "csswww" => "{$basedir}/css");
         }
     }
     if (isset($this) && isset($this->servers["dependencies"]) && $this->servers["dependencies"]["cdn"]["enabled"] == 1 && $this->current["dependencies"]["cdn"]["enabled"] == 1) {
         $cdn_ini = $this->servers["dependencies"]["cdn"];
         $cdn_cobrand = $this->current["dependencies"]["cdn"];
         $cdnhost = any($cdn_cobrand["host"], $cdn_ini["host"], "");
         $cdnscheme = any($cdn_cobrand["scheme"], $cdn_ini["scheme"], "");
         //$cdnscheme = (!empty($cdnhost) ? $webapp->request["scheme"] . "://" : "");
         //$cdnpath = any($cdn_cobrand["path"], $cdn_ini["path"], "/images");
         $cdnprefix = (!empty($cdnscheme) ? $cdnscheme . ":" : "") . "//" . $cdnhost;
         if (any($cdn_cobrand["images"], $cdn_ini["images"]) == 1) {
             $locations["imageswww"] = $cdnprefix . $locations["imageswww"];
         }
         if (any($cdn_cobrand["css"], $cdn_ini["css"]) == 1) {
             $locations["csswww"] = $cdnprefix . $locations["csswww"];
         }
         if (any($cdn_cobrand["scripts"], $cdn_ini["scripts"]) == 1) {
             $locations["scriptswww"] = $cdnprefix . $locations["scriptswww"];
         }
     }
     self::$locations = $locations;
     Profiler::StopTimer("ConfigManager::getLocations()");
     return $locations;
 }
开发者ID:jbaicoianu,项目名称:elation,代码行数:71,代码来源:configmanager_class.php


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