container = $c; header('Content-Type: text/html; charset=utf-8'); // require __DIR__ . '/../lib/functions.php'; // require __DIR__ . '/../classes/data.php'; // require __DIR__ . '/../classes/lang.php'; // require __DIR__ . '/../classes/assets.php'; $paths = $c->config['paths']; // // Load layout // (require $paths['layouts'] . $layout . '.php')($this); // Load route specific page configuration if (is_string($mixed)) $this->elements['content'] = $mixed; else if (is_array($mixed)) { if (isset($mixed['title'])) $this->title = $mixed['title']; if (isset($mixed['description'])) $this->description = $mixed['description']; if (isset($mixed['keywords'])) $this->keywords = array_merge($this->keywords, (is_string($mixed['keywords']) ? array($mixed['keywords']) : $mixed['keywords'])); if (isset($mixed['robots'])) $this->robots = $mixed['robots']; if (isset($mixed['canonical'])) $this->canonical = $mixed['canonical']; if (isset($mixed['styles'])) $this->styles = array_merge($this->styles, $mixed['styles']); if (isset($mixed['scripts'])) $this->scripts = array_merge($this->scripts, $mixed['scripts']); if (isset($mixed['content'])) $this->elements['content'] = $mixed['content']; else if (isset($mixed['elements'])) $this->elements = array_merge($this->elements, $mixed['elements']); } // assets::init(db::conn()); // $LM->load_file('includes/lang/common.xml', $FW['locale']); // OR $FW['page']['lang'] ... also loaded in sitemap! // $DB->real_query('SET time_zone = "' . $LM->languages[$FW['locale']]['tz'] . '", lc_time_names = "' . $LM->languages[$FW['locale']]['tl'] . '"'); $path = $paths['elements']; // // Execute Element Init // foreach ($this->elements as $element) { $filename = $path . $element . '/init.php'; $init = require $filename; if (is_callable($init)) $init($this); // else // by disabling this we make the `callable function` requirement OPTIONAL! // throw new \Exception('File `' . $filename . '` must return a callable function!'); } // assets::preload(true); // $AM->preload(true); // $LM->preload(true); // TODO: DEPRECATE THIS!!! ... WHY ? It's file based, not DB based! So loading them while the DB is open is bad! // if (user::is_bot() === false) if (isset($_SESSION)) session_write_close(); // $this->container->db->close(); } /** * The `renderer` is normally just a callback function set by the `layout` file. * Before rendering the page (ie. calling the view modules), we close the session and database connection. * This function just echoes the HTML layout/template and calls the (element) views */ function render() { call_user_func($this->renderer, $this->container); echo PHP_EOL, '', PHP_EOL, '', PHP_EOL, '', PHP_EOL, '', PHP_EOL, ''; // Available since PHP 5.4.0. } function setRenderer(callable $callback) { $this->renderer = $callback; } }