/** * * @param type $options */ public function __construct($options = array()) { parent::__construct($options); // schedule disconnect from database Events::add('framework.controller.destruct.after', function ($name) { $database = Registry::get('database'); $database->disconnect(); }); $this->_security = Registry::get('security'); $this->_serverHost = RequestMethods::server('HTTP_HOST'); $this->_cache = Registry::get('cache'); $cfg = Registry::get('configuration'); $links = $this->getCache()->get('links'); if ($links !== null) { $links = $links; } else { $links = \App_Model_Link::all(array('active = ?' => true)); $this->getCache()->set('links', $links); } $metaData = $this->getCache()->get('global_meta_data'); if ($metaData !== null) { $metaData = $metaData; } else { $metaData = array('metadescription' => $cfg->meta_description, 'metarobots' => $cfg->meta_robots, 'metatitle' => $cfg->meta_title, 'metaogurl' => $cfg->meta_og_url, 'metaogtype' => $cfg->meta_og_type, 'metaogimage' => $cfg->meta_og_image, 'metaogsitename' => $cfg->meta_og_site_name); $this->getCache()->set('global_meta_data', $metaData); } $this->getLayoutView()->set('links', $links)->set('metatitle', $metaData['metatitle'])->set('metarobots', $metaData['metarobots'])->set('metadescription', $metaData['metadescription'])->set('metaogurl', $metaData['metaogurl'])->set('metaogtype', $metaData['metaogtype'])->set('metaogimage', $metaData['metaogimage'])->set('metaogsitename', $metaData['metaogsitename']); }
/** * * @param type $tree * @param type $content * @return type */ protected function _partial($tree, $content) { $address = trim($tree["raw"], " /"); if (StringMethods::indexOf($address, "http") != 0) { $host = RequestMethods::server("HTTP_HOST"); $address = "http://{$host}/{$address}"; } $request = new Request(); $response = addslashes(trim($request->get($address))); return "\$_text[] = \"{$response}\";"; }
/** * * @param type $options */ public function __construct($options = array()) { parent::__construct($options); $this->agent = RequestMethods::server('HTTP_USER_AGENT', 'Curl/PHP ' . PHP_VERSION); }
/** * End of application profiling * * @param string $identifier */ public function stop($identifier = 'CORE') { if ($this->isActive()) { Event::fire('framework.profiler.stop.before', array($identifier)); $this->_profiles[$identifier]['requestUri'] = RequestMethods::server('REQUEST_URI'); $this->_profiles[$identifier]['totalTime'] = round(microtime(true) - $this->_profiles[$identifier]['startTime'], 8); $this->_profiles[$identifier]['endMemoryPeakUsage'] = $this->convert(memory_get_peak_usage()); $this->_profiles[$identifier]['endMomoryUsage'] = $this->convert(memory_get_usage()); $this->_profiles[$identifier]['dbProfiles'] = $this->_dbProfiles[$identifier]; $this->_profiles[$identifier]['sessionArr'] = $_SESSION; $this->_profiles[$identifier]['postArr'] = $_POST; $this->_profiles[$identifier]['getArr'] = $_GET; $this->dbStop($identifier); $this->process(); Event::fire('framework.profiler.stop.after', array($identifier)); } }
/** * Static function for redirects * * @param string $url */ public static function redirect($url = null) { $schema = 'http'; $host = RequestMethods::server('HTTP_HOST'); if (NULL === $url) { header("Location: {$schema}://{$host}"); exit; } else { header("Location: {$schema}://{$host}{$url}"); exit; } }
/** * * @return null */ public function getHttpReferer() { if (RequestMethods::server('HTTP_REFERER') === false) { return null; } else { return RequestMethods::server('HTTP_REFERER'); } }