Beispiel #1
0
 public function __construct()
 {
     $ret = parent::__construct();
     $config = Pfw_Config::getConfig();
     $this->assignSiteTitle($config['site_title']);
     $this->setupPaths();
     return $ret;
 }
 public function testReset()
 {
     Pfw_Config::init();
     $conf = Pfw_Config::getConfig();
     $this->assertEquals('My Web Host', Pfw_Config::get('webhost'));
     Pfw_Config::setConfig(array('test' => 'ok'));
     $this->assertEquals('ok', Pfw_Config::get('test'));
     $this->assertEquals(null, Pfw_Config::get('webhost'));
     Pfw_Config::reset();
     Pfw_Config::init();
     $this->assertEquals(null, Pfw_Config::get('test'));
     $this->assertEquals('My Web Host', Pfw_Config::get('webhost'));
 }
Beispiel #3
0
 /**
  * Starts a new session. Generally happens in prj_startup.php.
  * Should happen once per request. 
  */
 public static function start()
 {
     if (self::isStarted()) {
         return false;
     }
     $config = Pfw_Config::getConfig();
     if (!isset($config['session'])) {
         $config['session'] = array();
     }
     // maybe accept ini params in args and set here?
     // ...
     if (ini_get('session.auto_start')) {
         // reset session if autostarted in ini
         error_log("A session handler is configured, but session was autostarted in " . "ini with session.auto_start, resetting for normal session handling.");
         session_write_close();
     }
     if (isset($config['session']['handler_class'])) {
         self::setupHandler($config['session']['handler_class']);
     } else {
         if (isset($config['session']['save_path'])) {
             session_save_path($config['session']['save_path']);
         }
     }
     if (isset($config['session']['lifetime_s'])) {
         $lifetime_s = intval($config['session']['lifetime_s']);
         ini_set('session.cookie_lifetime', $lifetime_s);
         if (isset($config['session']['renew']) and false == $config['session']['renew']) {
             // not renewing, absolute max lifetime
             self::$is_renewing = false;
         } else {
             // renewing
             self::$is_renewing = true;
         }
     }
     session_start();
     // if you're going to mess with the cookies, its gotta be
     // after the session as started
     if (self::$is_renewing) {
         self::renew($lifetime_s);
     }
     self::$initialized = true;
 }
Beispiel #4
0
 public function getReadRoute()
 {
     $config = Pfw_Config::getConfig();
     $route_name = $this->getRouteName();
     return $config['database'][$route_name]['params'];
 }