function __construct($site = GCORE_SITE, $thread = 'gcore') { $app = \GCore\Bootstrap::getApp($site, $thread); $this->site = $site; $this->thread = $thread; $this->_vars = $app->_vars; $this->data =& Request::raw(); //&$_POST; //$this->data = array_merge($_GET, $this->data); $this->path = $app->path; $this->url = $app->url; $this->name = get_class($this); $this->action = $app->action; //set models properties if (!empty($this->models)) { $this->models = (array) $this->models; foreach ($this->models as $model) { $alias = Base::getClassName($model); $this->{$alias} = new $model(); } } //set libs properties if (!empty($this->libs)) { $this->libs = (array) $this->libs; foreach ($this->libs as $lib) { $alias = Base::getClassName($lib); if (in_array('getInstance', get_class_methods($lib))) { $this->{$alias} = $lib::getInstance(); } else { $this->{$alias} = new $lib(); } $this->{$alias}->controller =& $this; } } }
function renderModule($type) { foreach ($this->vars as $k => $val) { ${$k} = $val; } $viewpath = self::getViewsPath($this->controller); if (is_string($this->view)) { $type = $this->view; } if ($this->view !== false and file_exists($viewpath . $type . '.php')) { //view file exists, load it ob_start(); include $viewpath . $type . '.php'; $contents = ob_get_clean(); if (!empty($this->data)) { $contents = Str::replacer($contents, Request::raw(), array('escape' => true)); $contents = \GCore\Helpers\DataLoader::load($contents, Request::raw()); } echo $contents; } }