function call_snippet() { $args = func_get_args(); if (!is_object(Znap::$snippets_controller)) { Znap::$snippets_controller = new SnippetController(); } return call_user_func_array(array(Znap::$snippets_controller, 'call_snippet'), $args); }
function dispatch() { try { Session::start(); Znap::$action_controller = new ActionController(); Znap::$action_controller->process_route(); } catch (Exception $e) { Znap::$action_controller->process_exception($e); } }
function check_paths() { if (is_array($this->url_path)) { $controllers_path = $this->controllers_path; $extra_path = array(); $new_path = array(); foreach ($this->url_path as $key => $path) { if (is_dir($controllers_path . '/' . $path)) { $extra_path[] = $path; $controllers_path .= '/' . $path; } else { $new_path[] = $path; } } if (!empty($extra_path)) { $extra_path = implode('/', $extra_path); $this->added_path = $extra_path; Znap::$added_path = $this->added_path; $this->controllers_path .= '/' . $extra_path; $this->helpers_path .= '/' . $extra_path; $this->layouts_path .= '/' . $extra_path; $this->views_path .= '/_' . $extra_path; } if (!empty($new_path)) { $this->url_path = $new_path; } } }
// include environment specific settings if (is_file(dirname(__FILE__) . '/environments/' . ZNAP_ENV . '.php')) { include_once dirname(__FILE__) . '/environments/' . ZNAP_ENV . '.php'; } // set url prefix if needed if (!empty($url_prefix)) { define('URL_PREFIX', $url_prefix); } // php error logging define('ZNAP_ENABLE_LOGGING', $enable_logging); define('ZNAP_INTERNAL_LOGGING', $internal_logging); // include and initialize main zynapse class require_once ZNAP_LIB_ROOT . '/zynapse.php'; Znap::initialize(); if (!empty($timer_enabled) || ZNAP_ENV != 'production') { Znap::start_timer(); } // function to get all matched host settings function match_host($list = array()) { if (is_array($list) && !empty($list)) { $new_config = array(); foreach ($list as $host => $settings) { $regex = preg_quote($host, '/'); $regex = str_replace('\\*', '.*', $regex); $http_host = substr($_SERVER['HTTP_HOST'], 0, 4) == 'www.' ? substr($_SERVER['HTTP_HOST'], 4) : $_SERVER['HTTP_HOST']; if (preg_match('/^' . $regex . '$/i', $http_host)) { foreach ($settings as $key => $value) { if (!array_key_exists($key, $new_config)) { $new_config[$key] = $value; }
function start_timer() { Timer::start(); self::$timer_enabled = true; }
function render_file($file, $locals = array(), $use_full_path = false) { if ($use_full_path) { $file = $this->views_path . '/' . $file . '.' . Znap::$views_extension; } if (is_file($file)) { if (is_object($this)) { foreach ($this as $tmp_key => $tmp_value) { ${$tmp_key} =& $this->{$tmp_key}; } unset($tmp_key, $tmp_value); } if ($this->content_for_layout !== null) { $content_for_layout =& $this->content_for_layout; } if (count($locals)) { foreach ($locals as $tmp_key => $tmp_value) { ${$tmp_key} =& $locals[$tmp_key]; } unset($tmp_key, $tmp_value); } unset($use_full_path, $locals); Znap::$currently_rendering_snippet = $this->snippet; $this->currently_rendering_file = $file; include $file; Znap::$currently_rendering_snippet = null; return true; } return false; }