static function get($name = null, $type = 'REQUEST') { if (!isset(self::$data)) { // I've experienced empty $_GET var for some reason so I'm populating // it here. -c4 $GET = substr(strstr($_SERVER['REQUEST_URI'], '?'), 1); parse_str($GET, $_GET); self::$data = array('REQUEST' => array_merge($_GET, $_POST, $_COOKIE), 'GET' => $_GET, 'POST' => $_POST, 'COOKIE' => $_COOKIE, 'FILES' => $_FILES); foreach (self::$data as $key => &$val) { foreach ($val as $k => &$v) { if (($key == "REQUEST" || $key == "GET") && is_string($v) && (substr_count($v, "script") > 0 && substr_count($v, "/script") > 0)) { $clean = self::strip_only($v, array("script"), true); if (strlen($v) != strlen($clean)) { $v = $clean; } } } } } if (!isset($name)) { return self::$data[$type]; } else { if (isset(self::$data[$type][$name])) { return self::$data[$type][$name]; } else { return null; } } }
public static function session($name, $filter = Request::FILTER_NONE, $is_htmlspecialchars = true, $is_mysql_real_escape_string = true) { return Request::data($_SESSION, $name, $filter, $is_htmlspecialchars, $is_mysql_real_escape_string); }
function data($key = null, $method = 'post') { return Request::data($key, $method); }
function getModules($position, $container = false) { $modules = $this->fetchModules(); $output = ''; //ob_start(); if (!empty($modules)) { foreach ($modules as $module) { if (!empty($module['Module']['position']) and $module['Module']['position'] == $position) { //check if the module is enabled in the current page if ($this->site != 'admin' and !in_array('0', $module['Module']['pages'], true) and !in_array(Request::data('_Route.index'), $module['Module']['pages'], true)) { continue; } //check permissions if (!empty($module['Module']['rules']['display']) and !Authorize::check_rules($module['Module']['rules']['display'])) { continue; } $output .= \GCore\Helpers\Module::render($module['Module'], $container); } } } //$output = ob_get_clean(); return $output; }
public static function set_params($extension, $path_chunks = array(), $type = 'extension') { $route_vars = array(); if ($type == 'extension') { $ext_router = '\\GCore\\Extensions\\' . Str::camilize($extension) . '\\' . Str::camilize($extension) . 'Router'; } else { $ext_router = '\\GCore\\Controllers\\' . Str::camilize($extension) . 'Router'; } if (class_exists($ext_router)) { //some url params should be processed if (method_exists($ext_router, 'translate')) { $route_vars = (array) $ext_router::translate($path_chunks); } else { if (!empty($ext_router::$params) and !empty($path_chunks)) { foreach ($ext_router::$params as $k => $param) { //check if param index exists in the current path if (array_key_exists($k, $path_chunks)) { if (strlen(Request::data($param)) != 0) { //param has been already set through a page param for example continue; } //Request::set($param, $path_chunks[$k]); if ($param == 'cont') { $route_vars['controller'] = $path_chunks[$k]; continue; } if ($param == 'act') { $route_vars['action'] = $path_chunks[$k]; continue; } $route_vars[$param] = $path_chunks[$k]; //Request::set('_Route.'.$param, $path_chunks[$k]); } else { //break on the first non existent param break; } } } } } return $route_vars; }
function render() { //Event::trigger('on_before_render'); $this->template = 'joomla'; $params = new Parameter(array()); //get template view from the request $this->tvout = strlen(Request::data('tvout', null)) > 0 ? Request::data('tvout') : $this->tvout; //render the active template $doc = Document::getInstance($this->site, $this->thread); $template = Template::getInstance($doc, $this->template, $this->tvout, $params); $this->buffer = $template->render(); //Event::trigger('on_after_render'); }
function _tags_search() { $app = \GCore\Libs\App::getInstance(); $app->tvout = 'ajax'; $tag_term = Request::data('term'); $tags_model = new \GCore\Admin\Models\Tag(); $list = $tags_model->find('list', array('fields' => array('Tag.title'), 'conditions' => array('Tag.title LIKE' => '%' . $tag_term . '%'))); return json_encode(array_values($list)); }
/** * Obtém dados que estão sendo enviados pra este moledo através de POST ou GET. * * @return <array> */ static function data($key = null, $method = 'post') { if (empty(static::$data)) { static::$data = \Request::data(static::name_full(), $method); } return $key ? @static::$data[$key] : static::$data; }
function render() { Event::trigger('on_before_render'); $template_model = new \GCore\Admin\Models\Template(); $params = null; if (empty($this->template)) { $template_data = $template_model->find('first', array('conditions' => array('Template.site' => $this->site, 'Template.default' => 1), 'recursive' => -1, 'cache' => true)); } else { $template_data = $template_model->find('first', array('conditions' => array('Template.name' => $this->template), 'recursive' => -1, 'cache' => true)); } if (!empty($template_data)) { $this->template = $template_data['Template']['source']; $params = new Parameter($template_data['Template']['params']); } //get template view from the request $this->tvout = strlen(Request::data('tvout', null)) > 0 ? Request::data('tvout') : $this->tvout; //render the active template $doc = Document::getInstance($this->site, $this->thread); $template = Template::getInstance($doc, $this->template, $this->tvout, $params); $this->buffer = $template->render(); Event::trigger('on_after_render'); }