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