/** * A hack to support __construct() on PHP 4 * * Hint: descendant classes have no PHP4 class_name() * constructors, so this one gets called first and calls the * top-layer __construct() which (if present) should call * parent::__construct() * * @access public * @return void */ function AkObject() { Ak::profile('Instantiating ' . get_class($this)); $args = func_get_args(); ____ak_shutdown_function(&$this); call_user_func_array(array(&$this, '__construct'), $args); ____ak_shutdown_function(true); }
function dispatch() { AK_ENABLE_PROFILER && Ak::profile(__CLASS__.'::'.__FUNCTION__.'() call'); $this->Request =& AkRequest(); $this->Response =& AkResponse(); $this->Controller =& $this->Request->recognize(); AK_ENABLE_PROFILER && Ak::profile('Request::recognize() completed'); $this->Controller->process($this->Request, $this->Response); }
function outputResults() { Ak::profile('Started sending response' . __CLASS__ . '::' . __FUNCTION__ . ' ' . __FILE__ . ' on line ' . __LINE__); $this->sendHeaders(); if (is_object($this->body) && method_exists($this->body, 'stream')) { $this->body->stream(); } else { echo $this->body; } }
/** * A hack to support __construct() on PHP 4 * * Hint: descendant classes have no PHP4 class_name() * constructors, so this one gets called first and calls the * top-layer __construct() which (if present) should call * parent::__construct() * * @access public * @return void */ function AkObject() { static $_callback_called; Ak::profile('Instantiating ' . get_class($this)); $args = func_get_args(); // register_shutdown_function(array(&$this, '__destruct')); ____ak_shutdown_function(&$this); call_user_func_array(array(&$this, '__construct'), $args); if (empty($_callback_called)) { $_callback_called = true; register_shutdown_function('____ak_shutdown_function'); } }
function getSettings($namespace, $raise_error_if_config_file_not_found = true, $environment = AK_ENVIRONMENT) { static $_config; if (!in_array($environment, Ak::toArray(AK_AVAILABLE_ENVIRONMENTS))) { trigger_error('The environment ' . $environment . ' is not allowed. Allowed environments: ' . AK_AVAILABLE_ENVIRONMENTS); return false; } if (!isset($_config)) { require_once AK_LIB_DIR . DS . 'AkConfig.php'; $_config = new AkConfig(); } return $_config->get($namespace, $environment, $raise_error_if_config_file_not_found); } function getSetting($namespace, $variable, $default_value = null) { if ($settings = Ak::getSettings($namespace)) { return isset($settings[$variable]) ? $settings[$variable] : $default_value; } return $default_value; } function _parseSettingsConstants($settingsStr) { return preg_replace_callback('/\\$\\{(AK_.*?)\\}/', array('Ak', '_getConstant'), $settingsStr); } function _getConstant($name) { return defined($name[1]) ? constant($name[1]) : ''; } } Ak::profile('Ak.php class included' . __FILE__);
static function getLocalesReady() { Ak::t('Akelos'); TPV_ENABLE_PROFILER && Ak::profile('Got multilingual '); }
function getDefaultLanguageForUser() { Ak::profile(__CLASS__ . '::' . __FUNCTION__); foreach ($this->browser_lang as $k => $browser_lang) { if (isset($this->available_locales[$browser_lang]) && is_array($this->available_locales[$browser_lang])) { return $browser_lang; } } return $this->_getDefaultLocale(); }
/** * Calls all the defined after-filter filters, which are added by using "afterFilter($method)". * If any of the filters return false, no more filters will be executed. */ function afterAction($method = '') { Ak::profile('Running after controller action filters ' . __CLASS__ . '::' . __FUNCTION__ . ' ' . __LINE__); return $this->_callFilters(&$this->_afterFilters, $method); }
function renderPartialCollection($partial_name, $collection, $partial_spacer_template = null, $local_assigns = array()) { Ak::profile('Rendering partial Collection' . $partial_name); $collection_of_partials = array(); $counter_name = $this->_partialCounterName($partial_name); if (empty($local_assigns[$counter_name])) { $local_assigns[$counter_name] = 1; } foreach ($collection as $counter => $element) { $local_assigns[$counter_name] = $counter + 1; $collection_of_partials[] = $this->renderPartial($partial_name, $element, $local_assigns); } Ak::profile('Finished rendering partial Collection' . $partial_name); if (empty($collection_of_partials)) { return ' '; } if (!empty($partial_spacer_template)) { $spacer_path = $this->_partialPathPiece($partial_spacer_template); $spacer_name = $this->_partialPathName($partial_spacer_template); return join((empty($spacer_path) ? '' : $spacer_path . DS) . '_' . $spacer_name, $collection_of_partials); } else { return join('', $collection_of_partials); } }
} function _parseSettingsConstants($settingsStr) { return preg_replace_callback('/\$\{(AK_.*?)\}/',array('Ak','_getConstant'),$settingsStr); } function _getConstant($name) { return defined($name[1])?constant($name[1]):''; } /** * Get a models a model instance. Including and instantiating the model for us. * * This kinds mimics the ideal (new Model())->find() wich does not exist on PHP yet. * * On Akelos we can do Ak::get('Model')->find(); */ function get($model_name, $attributes = array()) { Ak::import($model_name); return new $model_name($attributes); } } AK_ENABLE_PROFILER && Ak::profile(); ?>
function performActionWithFilters($method = '') { if ($this->beforeAction($method) !== false && !$this->_hasPerformed()){ AK_ENABLE_PROFILER && Ak::profile("Called $method before filters"); $this->performActionWithoutFilters($method); AK_ENABLE_PROFILER && Ak::profile("Performed $method action"); $this->afterAction($method); AK_ENABLE_PROFILER && Ak::profile("Called $method after filters"); return true; } return false; }