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


PHP ConfigManager::singleton方法代码示例

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


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

示例1: init

 public static function init()
 {
     if (!self::$initialized) {
         Profiler::StartTimer("DNSResolver::Init()", 3);
         $cfg = ConfigManager::singleton();
         if (isset($cfg->servers["dnsresolver"]["ttl"])) {
             self::$ttl = $cfg->servers["dnsresolver"]["ttl"];
         }
         if (isset($cfg->servers["dnsresolver"]["cache"])) {
             self::$cache = $cfg->servers["dnsresolver"]["cache"];
         }
         // parse /etc/resolv.conf to get domain/search suffixes
         if (file_exists("/etc/resolv.conf")) {
             $resolv = file("/etc/resolv.conf");
             for ($i = 0; $i < count($resolv); $i++) {
                 if (preg_match("/^\\s*(.*?)\\s+(.*)\\s*\$/", $resolv[$i], $m)) {
                     switch ($m[1]) {
                         case 'domain':
                             self::$domain = $m[2];
                             array_unshift(self::$search, self::$domain);
                             break;
                         case 'search':
                             self::$search[] = $m[2];
                             break;
                     }
                 }
             }
             self::$search[] = "";
         }
         self::$initialized = true;
         Profiler::StopTimer("DNSResolver::Init()");
     }
 }
开发者ID:jbaicoianu,项目名称:elation,代码行数:33,代码来源:dnsresolver_class.php

示例2: smarty_block_config

function smarty_block_config($params, $content, &$smarty)
{
    global $webapp;
    static $initialized = false;
    if (empty($params->skipcobrand)) {
        // FIXME - this should also apply to page_component's getCobrandContent() somehow...
        $cfgmgr = ConfigManager::singleton();
        if (!$initialized) {
            $heirarchy = $cfgmgr->GetConfigHeirarchy("cobrand." . $webapp->cobrand);
            foreach (array_reverse($heirarchy) as $cfgname) {
                // Walk heirarchy from bottom up
                if (preg_match("/^cobrand\\.(.*)\$/", $cfgname, $m) || $cfgname == "base") {
                    // FIXME - most general-purpose would be to use the cobrand key as imagedir (s/\./\//g?)
                    $cobrandname = $cfgname == "base" ? $cfgname : $m[1];
                    if (!empty($cobrandname)) {
                        DependencyManager::add(array("type" => "component", "name" => "cobrands." . $cobrandname, "priority" => 4));
                        //DependencyManager::add(array("type"=>"component", "name"=>"cobrands.".$cobrandname."-fixes", "priority"=>4));
                    }
                }
            }
            $initialized = true;
        }
    }
    return trim($content);
}
开发者ID:ameyer430,项目名称:elation,代码行数:25,代码来源:block.config.php

示例3: GenerateURL

 function GenerateURL($dimensions, $args = NULL)
 {
     //Profiler::StartTimer("TFProductImage::GenerateURL()");
     $urlhash = md5($this->realurl);
     $dimensions = $this->ParseDimensions($dimensions);
     $dim = reset($dimensions);
     // Get first item and reset array pointer
     $dimensionstr = $dim[0] . "x" . $dim[1];
     if (!empty(self::$cache[$urlhash]) && !empty(self::$cache[$urlhash][$dimensionstr])) {
         $ret = self::$cache[$urlhash][$dimensionstr];
         if (!is_array($this->urls)) {
             $this->urls = array();
         }
         $this->urls = array_merge($this->urls, self::$cache[$urlhash]);
     } else {
         $cfg = ConfigManager::singleton();
         $sitecfg = $cfg->current["dependencies"]["image"];
         $servercfg = $cfg->servers["image"];
         $host = any($args["host"], $sitecfg["host"], $servercfg["host"]);
         $skipcache = any($args["skipcache"], $sitecfg["skipcache"], $servercfg["skipcache"], false);
         $ssl = any($args["ssl"], $sitecfg["ssl"], $servercfg["ssl"], false);
         $direct = any($args["direct"], $sitecfg["direct"], $servercfg["direct"], false);
         $matte = any($args["matte"], $sitecfg["matte"], $servercfg["matte"], true);
         $resize = any($args["resize"], $sitecfg["resize"], $servercfg["resize"], 1.0);
         $siteid = any($args["siteid"], 0);
         $category = any($args["category"], "miscellaneous");
         foreach ($dimensions as $dimstr => $dim) {
             $img = $this->FixOriginURL($this->realurl, $dim);
             if ($direct) {
                 $this->urls[$dimstr] = $img;
             } else {
                 $imgURL = "http" . ($ssl ? "s" : "") . "://" . $host . "/images/" . $this->encodeImageUrl($img, $dim[0], $dim[1], $siteid, $category);
                 $imgURLExtras = array();
                 if (!empty($skipcache)) {
                     $imgURLExtras[] = "bypass=1";
                 }
                 if (isset($matte)) {
                     $imgURLExtras[] = "m=" . (any($dim[2]["m"], $matte) ? 1 : 0);
                 }
                 if (!empty($resize)) {
                     $imgURLExtras[] = "g=" . any($dim[2]["g"], $resize);
                 }
                 $imgArgs = implode("&", $imgURLExtras);
                 $fullURL = $imgURL . (!empty($imgArgs) ? "?" . $imgArgs : "");
                 $this->urls[$dimstr] = $fullURL;
             }
         }
         $ret = $this->urls[$dimensionstr];
         self::$cache[$urlhash][$dimensionstr] = $ret;
     }
     //Profiler::StopTimer("TFProductImage::GenerateURL()");
     return $ret;
 }
开发者ID:ameyer430,项目名称:elation,代码行数:53,代码来源:productimage_class.php

示例4: controller_header

 public function controller_header($args)
 {
     if (empty($this->shown["header"])) {
         // Only allow header once per page
         $cfg = ConfigManager::singleton();
         $vars["tracking"] = any(ConfigManager::get("tracking"), $cfg->servers["tracking"], array());
         $this->shown["header"] = true;
         $vars["theme"] = any(ConfigManager::get("page.theme"), array_get($cfg->servers, "page.theme"));
         return $this->GetTemplate("./header.tpl", $vars);
     }
     return "";
 }
开发者ID:jbaicoianu,项目名称:elation,代码行数:12,代码来源:html.php

示例5: GetModels

 function GetModels()
 {
     $models = array();
     $cfg = ConfigManager::singleton();
     if ($modeldir = opendir($cfg->locations["config"] . "/model")) {
         while ($file = readdir($modeldir)) {
             if (preg_match("/(.*?)\\.model\$/", $file, $m)) {
                 $models[] = $m[1];
             }
         }
     }
     sort($models);
     return $models;
 }
开发者ID:jbaicoianu,项目名称:elation,代码行数:14,代码来源:ormmanager_class.php

示例6: smarty_function_img

/**
 * Smarty {img} plugin
 *
 * Type:     function<br>
 * Name:     img<br>
 * Purpose:  Get the correct image (cobranded, server, etc)
 *
 * @author Ben HOLLAND!!!
 * @param array
 * @param Smarty
 * @return string|null if the assign parameter is passed, Smarty assigns the
 *                     result to a template variable
 */
function smarty_function_img($args, &$smarty)
{
    global $webapp;
    static $heirarchy;
    static $imgcache;
    Profiler::StartTimer("smarty_function_img", 2);
    if ($heirarchy === null) {
        $cfgmgr = ConfigManager::singleton();
        $heirarchy = $cfgmgr->GetConfigHeirarchy("cobrand." . $webapp->cobrand);
    }
    $imagedir = any(DependencyManager::$locations["images"], "htdocs/images");
    $imagedirwww = any(DependencyManager::$locations["imageswww"], "/images");
    if (!empty($args["src"]) && !preg_match("/^https?:/", $args["src"])) {
        if (isset($imgcache[$args["src"]])) {
            $args["src"] = $imgcache[$args["src"]];
        } else {
            $origsrc = $args["src"];
            $found = false;
            foreach ($heirarchy as $cfgname) {
                if (preg_match("/^cobrand\\.(.*)\$/", $cfgname, $m)) {
                    // FIXME - most general-purpose would be to use the cobrand key as imagedir (s/\./\//g?)
                    if (file_exists($imagedir . "/cobrands/{$m[1]}/{$args["src"]}")) {
                        $args["src"] = $imagedirwww . "/cobrands/{$m[1]}/{$args["src"]}";
                        $found = true;
                        break;
                    }
                }
            }
            if (!$found) {
                $args["src"] = $imagedirwww . "/" . $args["src"];
            }
            $imgcache[$origsrc] = $args["src"];
        }
    }
    $ret = "<img ";
    foreach ($args as $k => $v) {
        $ret .= "{$k}=\"{$v}\" ";
    }
    $ret .= "/>";
    Profiler::StopTimer("smarty_function_img");
    if (!empty($args["src"])) {
        return $ret;
    }
}
开发者ID:jbaicoianu,项目名称:elation,代码行数:57,代码来源:function.img.php

示例7: __construct

 public function __construct($name = NULL, $role = NULL)
 {
     if ($role === NULL) {
         $cfg = ConfigManager::singleton();
         $role = isset($cfg->servers["role"]) ? $cfg->servers["role"] : "dev";
     }
     if ($name !== NULL) {
         $this->Load($name, $role);
     }
 }
开发者ID:jbaicoianu,项目名称:elation,代码行数:10,代码来源:configmanager_class.php

示例8: contents

 static function contents($type, $args, $extra = NULL)
 {
     $ret = array("content" => "", "lastmodified" => 0, "loaded" => array());
     $url = '';
     $argsep = '/';
     $valsep = '-';
     $cfg = ConfigManager::singleton();
     $typemap = array("javascript" => array("dir" => $cfg->locations["scripts"], "extension" => "js"), "css" => array("dir" => $cfg->locations["css"], "extension" => "css"));
     $extension = $typemap[$type]["extension"];
     $extensionlen = strlen($extension);
     foreach ($args as $k => $v) {
         if ($k[0] != '_') {
             $componentdir = realpath($typemap[$type]["dir"] . "/{$k}");
             $files = explode(" ", $v);
             foreach ($files as $file) {
                 if (substr($file, -($extensionlen + 1), $extensionlen + 1) == ".{$extension}") {
                     $file = substr($file, 0, -($extensionlen + 1));
                 }
                 $fname = $componentdir . "/" . $file . "." . $extension;
                 $realfname = realpath($fname);
                 if (file_exists($fname) && $fname == $realfname) {
                     $modtime = filemtime($fname);
                     if ($modtime > $ret["lastmodified"]) {
                         $ret["lastmodified"] = $modtime;
                     }
                     //$ret["content"] .= "\n/* ### File: " . $fname . " ### */\n";
                     $ret["content"] .= file_get_contents($fname);
                     $ret["loaded"][$k][] = $file;
                     //$ret["content"] .= "\n/* ### This code has been appended via DependencyCombiner ### */\n";
                     if (!empty($extra)) {
                         $ret["content"] .= $extra;
                     }
                 }
             }
         }
     }
     return $ret;
 }
开发者ID:ameyer430,项目名称:elation,代码行数:38,代码来源:dependencymanager_class.php

示例9: commitCommands

 /**
  * LocalConfigManager::commitCommands
  * 
  * Given a set of indexes to commit, commit them using ConfigManager then delete them from the stored commands
  * @param $indexes array [1,4,5]
  * @return bool success
  **/
 public function commitCommands($indexes)
 {
     $cfg = ConfigManager::singleton();
     $status = true;
     $commandsToRun = array();
     if (!empty($indexes)) {
         foreach ($this->storedCommands as $key => $value) {
             if (in_array($key, $indexes)) {
                 $commandsToRun[] = $this->storedCommands[$key];
             }
         }
         foreach ($commandsToRun as $cmd) {
             $setcurrent = true;
             $skipcache = true;
             $skipLocalConfig = true;
             //load an unmodified version of the cobrand, otherwise the localconfig changes will have already been applied
             //and committing the commands won't work outside of this session, as they'll already have been
             //temporarily applied by the localconfig calls in getConfig()/Load(). To make the commits
             //be applied to the db pass the $skipLocalConfig flag
             $cfg->GetConfig($cmd['cobrand'], $setcurrent, $cmd['role'], $skipcache, $skipLocalConfig);
             switch ($cmd['action']) {
                 case 'update':
                     $skipLocalConfig = true;
                     $newcfg = array($cmd['name'] => array('value' => $cmd['val'], 'type' => $cmd['type']));
                     $status = $cfg->Update($cmd['cobrand'], $newcfg, $cmd['role'], null, $skipLocalConfig);
                     if (!$status) {
                         print_pre('Update failed for ' . print_r($cmd, true));
                     }
                     break;
                 case 'delete':
                     $keys = explode('.', $cmd['name']);
                     $depth = count($keys);
                     $currentDepth = 1;
                     $deleteConfig = array();
                     $arrayPtr =& $deleteConfig;
                     foreach ($keys as $key) {
                         if ($currentDepth == $depth) {
                             $arrayPtr[$key] = 1;
                         } else {
                             $arrayPtr[$key] = array();
                         }
                         $arrayPtr =& $arrayPtr[$key];
                         $currentDepth++;
                     }
                     unset($arrayPtr);
                     $status = $cfg->Update($cmd['cobrand'], array(), $cmd['role'], $deleteConfig, $skipLocalConfig);
                     if (!$status) {
                         print_pre('Delete failed for ' . print_r($cmd, true));
                     }
                     break;
                 case 'create':
                     $skipLocalConfig = true;
                     $status = $cfg->AddConfigValue($cmd['cobrand'], array('key' => $cmd['name'], 'value' => $cmd['val'], 'type' => $cmd['type']), $cmd['role'], $skipLocalConfig);
                     if (!$status) {
                         print_pre('create failed for ' . print_r($cmd, true));
                     }
                     break;
             }
         }
         $this->deleteCommands($indexes);
     } else {
         $status = false;
     }
     return $status;
 }
开发者ID:ameyer430,项目名称:elation,代码行数:72,代码来源:configmanager_class.php

示例10: ApplySingleOverride

 function ApplySingleOverride(&$final, $param_key, $param_value = NULL, $param_args = NULL, $applysettings = true)
 {
     $cfg = ConfigManager::singleton();
     $logmsg = "Applying URL map for {$param_key} ({$param_value})";
     if (!empty($param_args["override"])) {
         $cfg->ConfigMerge($cfg->current, $param_args["override"]);
         $param_args = ConfigManager::get("search.request.override.{$param_key}");
     }
     $new_value = NULL;
     if (!empty($param_args["values"][$param_value])) {
         $valuemap = $param_args["values"][$param_value];
         if (is_array($valuemap)) {
             if (!empty($valuemap["override"])) {
                 $cfg->ConfigMerge($cfg->current, $valuemap["override"]);
                 $param_args = ConfigManager::get("search.request.override.{$param_key}");
             }
             if (isset($valuemap["newvalue"])) {
                 $new_value = $valuemap["newvalue"];
                 $logmsg .= " (newvalue: '{$new_value}')";
             } else {
                 $new_value = $param_value;
             }
         } else {
             $new_value = $param_args["values"][$param_value];
         }
     } else {
         $new_value = $param_value;
     }
     if (!empty($param_args["key"]) && $new_value !== NULL) {
         array_set($final, $param_args["key"], $new_value);
         //array_unset($final,$param_key);
     }
     if (!empty($param_args["alsooverride"])) {
         $alsolog = "";
         //print_pre($param_values["alsooverride"]);
         foreach ($param_args["alsooverride"] as $also_key => $also_value) {
             $also_params = ConfigManager::get("search.request.override.{$also_key}");
             if (!empty($also_params)) {
                 $alsolog .= (!empty($alsolog) ? "; " : "") . "{$also_key}={$also_value}";
                 $this->ApplySingleOverride($final, $also_key, $also_value, $also_params, $applyoverrides);
             }
         }
         if (!empty($alsolog)) {
             $logmsg .= "(ALSO: {$alsolog})";
         }
     }
     if ($applysettings && !empty($param_args["settings"])) {
         $settingslog = "";
         $updated_settings = ConfigManager::get("search.request.override.{$param_key}.settings");
         if (!empty($updated_settings)) {
             $flattened_settings = array_flatten($updated_settings);
             $user = User::singleton();
             foreach ($flattened_settings as $setting_key => $setting_value) {
                 $settingslog .= (!empty($settingslog) ? "; " : "") . "{$setting_key}={$setting_value}";
                 $user->SetPreference($setting_key, $setting_value, "temporary");
             }
         }
         if (!empty($settingslog)) {
             $logmsg .= " (SETTINGS: {$settingslog})";
         }
     }
     Logger::Info($logmsg);
 }
开发者ID:ameyer430,项目名称:elation,代码行数:63,代码来源:componentmanager_class.php

示例11: App

 function App($rootdir, $args)
 {
     Profiler::StartTimer("WebApp", 1);
     Profiler::StartTimer("WebApp::Init", 1);
     Profiler::StartTimer("WebApp::TimeToDisplay", 1);
     $GLOBALS["webapp"] = $this;
     register_shutdown_function(array('Logger', 'processShutdown'));
     ob_start();
     $this->rootdir = $rootdir;
     $this->debug = !empty($args["debug"]);
     $this->getAppVersion();
     Logger::Info("WebApp Initializing (" . $this->appversion . ")");
     Logger::Info("Path: " . get_include_path());
     $this->initAutoLoaders();
     Logger::Info("Turning Pandora flag on");
     if (class_exists("PandoraLog")) {
         $pandora = PandoraLog::singleton();
         $pandora->setFlag(true);
     }
     $this->locations = array("scripts" => "htdocs/scripts", "css" => "htdocs/css", "tmp" => "tmp", "config" => "config");
     $this->request = $this->ParseRequest(NULL, $args);
     $this->locations["basedir"] = $this->request["basedir"];
     $this->locations["scriptswww"] = $this->request["basedir"] . "/scripts";
     $this->locations["csswww"] = $this->request["basedir"] . "/css";
     $this->locations["imageswww"] = $this->request["basedir"] . "/images";
     $this->InitProfiler();
     $this->cfg = ConfigManager::singleton($rootdir);
     $this->InitProfiler();
     // reinitialize after loading the config
     $this->locations = array_merge($this->locations, $this->cfg->locations);
     $this->data = DataManager::singleton($this->cfg);
     set_error_handler(array($this, "HandleError"), error_reporting());
     DependencyManager::init($this->locations);
     if ($this->initialized()) {
         try {
             $this->session = SessionManager::singleton();
             // Set sticky debug flag
             if (isset($this->request["args"]["debug"])) {
                 $this->debug = $_SESSION["debug"] = $this->request["args"]["debug"] == 1;
             } else {
                 if (!empty($_SESSION["debug"])) {
                     $this->debug = $_SESSION["debug"];
                 }
             }
             $this->cobrand = $this->GetRequestedConfigName($this->request);
             $this->cfg->GetConfig($this->cobrand, true, $this->cfg->role);
             $this->ApplyConfigOverrides();
             $this->locations = DependencyManager::$locations = $this->cfg->locations;
             // And the google analytics flag
             if (isset($this->request["args"]["GAalerts"])) {
                 $this->GAalerts = $this->session->temporary["GAalerts"] = $this->request["args"]["GAalerts"] == 1 ? 1 : 0;
             } else {
                 if (!empty($this->session->temporary["GAalerts"])) {
                     $this->GAalerts = $this->session->temporary["GAalerts"];
                 } else {
                     $this->GAalerts = 0;
                 }
             }
             $this->apiversion = any($this->request["args"]["apiversion"], ConfigManager::get("api.version.default"), 0);
             $this->tplmgr = TemplateManager::singleton($this->rootdir);
             $this->tplmgr->assign_by_ref("webapp", $this);
             $this->components = ComponentManager::singleton($this);
             $this->orm = OrmManager::singleton();
             //$this->tplmgr->SetComponents($this->components);
         } catch (Exception $e) {
             print $this->HandleException($e);
         }
     } else {
         $fname = "./templates/uninitialized.tpl";
         if (($path = file_exists_in_path($fname, true)) !== false) {
             print file_get_contents($path . "/" . $fname);
         }
     }
     $this->user = User::singleton();
     $this->user->InitActiveUser($this->request);
     // Merge permanent user settings from the URL
     if (!empty($this->request["args"]["settings"])) {
         foreach ($this->request["args"]["settings"] as $k => $v) {
             $this->user->SetPreference($k, $v, "user");
         }
     }
     // ...and then do the same for session settings
     if (!empty($this->request["args"]["sess"])) {
         foreach ($this->request["args"]["sess"] as $k => $v) {
             $this->user->SetPreference($k, $v, "temporary");
         }
     }
     // And finally, initialize abtests
     if (class_exists(ABTestManager)) {
         Profiler::StartTimer("WebApp::Init - abtests", 2);
         $this->abtests = ABTestmanager::singleton(array("cobrand" => $this->cobrand, "v" => $this->request["args"]["v"]));
         Profiler::StopTimer("WebApp::Init - abtests");
     }
     Profiler::StopTimer("WebApp::Init");
 }
开发者ID:ameyer430,项目名称:elation,代码行数:95,代码来源:app_class.php

示例12: getOutput

 function getOutput($type)
 {
     $ret = array("text/html", NULL);
     $tplmgr = TemplateManager::singleton();
     switch ($type) {
         case 'ajax':
             $ret = array("application/xml", $tplmgr->GenerateXML($this->data));
             break;
         case 'json':
         case 'jsonp':
             $jsonp = any($_REQUEST["jsonp"], "elation.ajax.processResponse");
             //$ret = array("application/javascript", $jsonp . "(" . json_encode($this->data) . ");");
             $ret = array("application/javascript", $tplmgr->GenerateJavascript($this->data, $jsonp));
             break;
         case 'js':
             $ret = array("application/javascript", @json_encode($this) . "\n");
             break;
         case 'jsi':
             $ret = array("application/javascript", json_indent(@json_encode($this)) . "\n");
             break;
         case 'txt':
             $ret = array("text/plain", $tplmgr->GenerateHTML($tplmgr->GetTemplate($this->template, NULL, $this->data)));
             break;
         case 'xml':
             $ret = array("application/xml", object_to_xml($this, "response"));
             break;
         case 'data':
             $ret = array("", $this->data);
             break;
         case 'componentresponse':
             $ret = array("", $this);
             break;
         case 'popup':
             // Popup is same as HTML, but we only use the bare-minimum html.page frame
             $vars["content"] = $this;
             $ret = array("text/html", ComponentManager::fetch("html.page", $vars, "inline"));
             break;
         case 'snip':
         case 'inline':
         case 'commandline':
             $ret = array("text/html", $tplmgr->GetTemplate($this->template, NULL, $this->data));
             break;
         case 'html':
         case 'fhtml':
         default:
             $cfg = ConfigManager::singleton();
             $framecomponent = any(ConfigManager::get("page.frame"), array_get($cfg->servers, "page.frame"), "html.page");
             // If framecomponent is false/0, just return the raw content
             $ret = array("text/html", empty($framecomponent) ? $this->data["content"] : ComponentManager::fetch($framecomponent, array("content" => $this), "inline"));
             //$ret = array("text/html", $tplmgr->GetTemplate($this->template, NULL, $this->data));
             break;
     }
     if (!empty($this->prefix)) {
         $ret[1] = $this->prefix . $ret[1];
     }
     return $ret;
 }
开发者ID:jbaicoianu,项目名称:elation,代码行数:57,代码来源:componentmanager_class.php

示例13: App

 function App($rootdir, $args)
 {
     Profiler::StartTimer("WebApp", 1);
     Profiler::StartTimer("WebApp::Init", 1);
     Profiler::StartTimer("WebApp::TimeToDisplay", 1);
     // disable notices by default.  This should probably be a config option...
     error_reporting(error_reporting() ^ E_NOTICE);
     // FIXME - xdebug recursion limit causes problems in some components...
     ini_set('xdebug.max_nesting_level', 250);
     $GLOBALS["webapp"] = $this;
     register_shutdown_function(array($this, 'shutdown'));
     ob_start();
     $this->rootdir = $rootdir;
     $this->debug = !empty($args["debug"]);
     $this->getAppVersion();
     Logger::Info("WebApp Initializing (" . $this->appversion . ")");
     Logger::Info("Path: " . get_include_path());
     $this->initAutoLoaders();
     if (class_exists("PandoraLog")) {
         Logger::Info("Turning Pandora flag on");
         $pandora = PandoraLog::singleton();
         $pandora->setFlag(true);
     }
     $this->InitProfiler();
     $this->request = $this->ParseRequest(NULL, $args);
     $this->cfg = ConfigManager::singleton(array("rootdir" => $rootdir, "basedir" => $this->request["basedir"]));
     $this->locations = ConfigManager::getLocations();
     $this->InitProfiler();
     // reinitialize after loading the config
     Profiler::StartTimer("WebApp::Init - handleredirects", 1);
     $this->request = $this->ApplyRedirects($this->request);
     Profiler::StopTimer("WebApp::Init - handleredirects");
     $this->data = DataManager::singleton($this->cfg);
     set_error_handler(array($this, "HandleError"), error_reporting());
     DependencyManager::init($this->locations);
     if ($this->initialized()) {
         try {
             $this->session = SessionManager::singleton();
             // Set sticky debug flag
             if (isset($this->request["args"]["debug"])) {
                 $this->debug = $_SESSION["debug"] = $this->request["args"]["debug"] == 1;
             } else {
                 if (!empty($_SESSION["debug"])) {
                     $this->debug = $_SESSION["debug"];
                 }
             }
             $this->cobrand = $this->GetRequestedConfigName($this->request);
             if (isset($this->request["args"]["_role"])) {
                 $this->role = $this->request["args"]["_role"];
             } else {
                 if (isset($this->cfg->servers["role"])) {
                     $this->role = $this->cfg->servers["role"];
                 } else {
                     $this->role = "dev";
                 }
             }
             $this->cfg->GetConfig($this->cobrand, true, $this->role);
             $this->ApplyConfigOverrides();
             $this->locations = DependencyManager::$locations = $this->cfg->locations;
             // And the google analytics flag
             if (isset($this->request["args"]["GAalerts"])) {
                 $this->GAalerts = $this->session->temporary["GAalerts"] = $this->request["args"]["GAalerts"] == 1 ? 1 : 0;
             } else {
                 if (!empty($this->session->temporary["GAalerts"])) {
                     $this->GAalerts = $this->session->temporary["GAalerts"];
                 } else {
                     $this->GAalerts = 0;
                 }
             }
             $this->apiversion = isset($this->request["args"]["apiversion"]) ? $this->request["args"]["apiversion"] : ConfigManager::get("api.version.default", 0);
             $this->tplmgr = TemplateManager::singleton($this->locations);
             $this->tplmgr->assign_by_ref("webapp", $this);
             $this->components = ComponentManager::singleton($this);
             if (class_exists("OrmManager")) {
                 $this->orm = OrmManager::singleton($this->locations);
             }
             //$this->tplmgr->SetComponents($this->components);
         } catch (Exception $e) {
             print $this->HandleException($e);
         }
     } else {
         $fname = "components/elation/templates/uninitialized.html";
         if (($path = file_exists_in_path($fname, true)) !== false) {
             print file_get_contents($path . "/" . $fname);
         }
     }
     $this->user = User::singleton();
     $this->user->InitActiveUser($this->request);
     // Merge permanent user settings from the URL
     if (!empty($this->request["args"]["settings"])) {
         foreach ($this->request["args"]["settings"] as $k => $v) {
             $this->user->SetPreference($k, $v, "user");
         }
     }
     // ...and then do the same for session settings
     if (!empty($this->request["args"]["sess"])) {
         foreach ($this->request["args"]["sess"] as $k => $v) {
             $this->user->SetPreference($k, $v, "temporary");
         }
     }
//.........这里部分代码省略.........
开发者ID:jbaicoianu,项目名称:elation,代码行数:101,代码来源:app_class.php

示例14: init

 /**
  * Initialize the session.
  * Start the session.
  */
 protected function init()
 {
     //some al-qada shit here...
     global $webapp;
     $this->data = DataManager::singleton();
     Profiler::StartTimer("SessionManager::Init()", 2);
     $cfgmgr = ConfigManager::singleton();
     $sessionsource = array_get($cfgmgr->servers, "session.datasource");
     if (!empty($sessionsource)) {
         $this->sessionsource = $sessionsource;
     }
     $sessiontable = array_get($cfgmgr->servers, "session.table");
     if (!empty($sessiontable)) {
         $this->sessiontable = $sessiontable;
     }
     /*
     if ($this->data->caches["memcache"]["session"] !== NULL) {
       $this->cache_obj = $this->data->caches["memcache"]["session"];
       //$this->session_cache_expire = $this->data->caches["memcache"]["session"]->lifetime;
     } else {
       // Continue anyway even if cannot connect to memcache.
       // Point the cache_obj to NoCache object
       //print_pre($this->data);
       Logger::Error("SessionManager::init() - Cannot connect to session memcache - " . $this->data->sources);
       $this->cache_obj =& NoCache::singleton();
     }
     */
     // instantiate the pandora object
     $pandora = PandoraLog::singleton();
     // check to see if there is an existing cookie for flsid
     $has_flsid = isset($_COOKIE['flsid']) || isset($_REQUEST['flsid']);
     $this->is_new_session = $has_flsid == 1 ? 0 : 1;
     // register_shutdown_function('session_write_close');
     // Set session cookie params
     $domain = null;
     $sessioncfg = any($cfgmgr->servers["session"], array());
     $sessionpath = any($sessioncfg["cookiepath"], "/");
     if ($sessioncfg["domaincookie"]) {
         // Determine second-level domain, taking into account any known ccSLDs (.co.uk, etc)
         $FQDN = $webapp->request["host"];
         $knownccSLDs = explode(" ", any($sessioncfg["ccSLDs"], ""));
         $parts = explode(".", $FQDN);
         $TLD = array_pop($parts);
         $SLD = array_pop($parts);
         $domain = $SLD . "." . $TLD;
         if (in_array($domain, $knownccSLDs)) {
             $TLD = $domain;
             $SLD = array_pop($parts);
             $domain = $SLD . "." . $domain;
         }
         $excludeDomains = explode(" ", any($sessioncfg["domaincookie_exception"], ""));
         if (in_array($domain, $excludeDomains)) {
             $domain = null;
         }
     }
     session_set_cookie_params(0, $sessionpath, $domain);
     // if flsid was passed via the URL, set it as a cookie
     if (!empty($_GET['flsid'])) {
         setcookie("flsid", $_GET['flsid'], 0, '/', $domain);
         $this->flsid = $_COOKIE['flsid'] = $_GET['flsid'];
     }
     session_set_save_handler(array(&$this, 'open'), array(&$this, 'close'), array(&$this, 'read'), array(&$this, 'write'), array(&$this, 'destroy'), array(&$this, 'gc'));
     // set the garbage collection lifetime (on the DB persist data)
     ini_set('session.gc_maxlifetime', 31536000);
     // 31536000 = 60 * 60 * 24 * 365
     // set the session cookie name
     session_name($this->cookiename);
     // set the cache limiter to 'private' - keeps us from sending Pragma: no-cache
     session_cache_limiter('private');
     // initiate sessionization
     if (!headers_sent()) {
         session_start();
     }
     /**
      * Read the permanent session ID from cookie.
      * If there isn't one, create one.
      */
     // read the permanent cookie
     if (isset($_REQUEST['fluid'])) {
         $fluid_str = $_REQUEST['fluid'];
     } else {
         if (isset($_COOKIE['fl-uid'])) {
             $fluid_str = $_COOKIE['fl-uid'];
         } else {
             if (isset($_SESSION['fluid'])) {
                 $fluid_str = $_SESSION['fluid'];
             }
         }
     }
     $fluid_data = explode(",", $fluid_str);
     $this->fluid = $fluid_data[0];
     $this->session_count = $fluid_data[1] ? $fluid_data[1] : 0;
     $this->last_access = $fluid_data[2] ? $fluid_data[2] : 0;
     $this->first_session_for_day = 0;
     $this->days_since_last_session = 0;
     $this->is_new_user = 0;
//.........这里部分代码省略.........
开发者ID:ameyer430,项目名称:elation,代码行数:101,代码来源:sessionmanager_class.php

示例15: controller_header

 public function controller_header($args)
 {
     $cfg = ConfigManager::singleton();
     $header = ConfigManager::get("page.header", array_get($cfg->servers, "page.header"), null);
     if (!empty($header)) {
         return ComponentManager::fetch($header);
     } else {
         if ($header !== null) {
             return "";
         }
     }
     return $this->GetComponentResponse("./header.tpl", $vars);
 }
开发者ID:jbaicoianu,项目名称:elation,代码行数:13,代码来源:elation.php


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