public function before() { // Setup extra configuration, e.g. Twitter $config = Config::load('notex'); Config::define_constants($config['twitter']); Config::define_constants($config['notes']); // Setup global variables and rendering data $uri = $_SERVER['REQUEST_URI']; $this->render->username = $this->username = $this->username_from_host(); $this->render->screen_name = $this->screen_name = Twitter::screen_name($this->session->access_token); $this->render->is_owner = $this->is_owner = $this->screen_name && $this->screen_name == $this->username; $this->render->copy = ''; $this->render->debug = ''; $this->render->layout = 'notepad'; $this->host_ip = array_key($_SERVER, 'HTTP_X_FORWARDED_FOR', $_SERVER['REMOTE_ADDR']); $title = ($this->username ? $this->username . '.' : '') . 'noted.cc'; $title .= $uri == '/' ? ' | web notepad' : $uri; $this->render->title = $title; // Handle alternative content types, e.g. XML and JSON $type = $this->app->get_content_type(); if ($type != 'html') { $this->respond_with_data_as($type); } }
/** * Load a config file by defining constants in selected sections, namely: * "ini", "testing", "settings", "database" and "content" (in that order) * * @param String $file the file name (without any ".yaml" extension) */ public static function load($file) { try { $config = Config::load($file); } catch (Exception $e) { return; } // Set any ini values by reading the "ini" section of the config file if ($ini = array_key($config, 'ini')) { foreach ($ini as $field => $value) { ini_set($field, $value); } date_default_timezone_set(ini_get('date.timezone')); } // Define config constants beginning with any test-specific constants Config::define_constants(array_key($config, 'testing', array())); Config::define_constants(array_key($config, 'settings', array())); Config::define_constants(array_key($config, 'database', array()), array('prefix' => 'db_')); Config::define_constants(array_key($config, 'content', array())); }