public function __construct() { parent::__construct(); JS::add('/js/Chart.min.js', false); JS::startup('lightning.stats.init()'); // Prepare the JS. JS::set('chart.' . $this->id . '.renderer', $this->renderer); JS::set('chart.' . $this->id . '.url', '/' . Request::getLocation()); JS::set('chart.' . $this->id . '.params.start', ['source' => 'start']); JS::set('chart.' . $this->id . '.params.number_format', $this->numberFormat); JS::set('chart.' . $this->id . '.params.diff', !empty($this->diff)); if (!empty($this->data)) { JS::set('chart.' . $this->id . '.data', $this->data); } JS::set('chart.' . $this->id . '.ajax', $this->ajax); }
public function get() { $page = Request::getLocation(); $template_page = Configuration::get('splash.pages.' . $page); // No template found. if (empty($template_page) || is_array($template_page) && empty($template_page['template'])) { Output::error('Page not found.'); } else { $this->page = is_array($template_page) ? $template_page['template'] : $template_page; } // Add any CSS or JS files. if (is_array($template_page)) { if (!empty($template_page['css'])) { CSS::add($template_page['css']); } if (!empty($template_page['js'])) { JS::add($template_page['js']); } } }
/** * Redirect the page to the same current page with the current query string. * * @param array * Additional query string parameters to add to the current url. */ public function redirect($params = array()) { $output_params = array(); foreach ($this->params as $param) { if (isset($params[$param])) { $output_params[$param] = $params[$param]; } elseif (isset($this->$param)) { $output_params[$param] = $this->$param; } } Navigation::redirect('/' . Request::getLocation(), $output_params); }
public function get() { $user = ClientUser::getInstance(); $template = Template::getInstance(); $request = Request::getLocation(); $content_locator = empty($request) ? 'index' : Request::getFromURL('/(.*)\\.html$/') ?: '404'; // Determine if the user can edit this page. $template->set('editable', $user->isAdmin()); // Set the page template. $template->set('content', 'page'); // LOAD PAGE DETAILS if ($full_page = $this->loadPage($content_locator)) { header('HTTP/1.0 200 OK'); if (Configuration::get('page.modification_date') && $full_page['last_update'] > 0) { header("Last-Modified: " . gmdate("D, d M Y H:i:s", $full_page['last_update']) . " GMT"); } } elseif ($this->new) { $full_page['title'] = ''; $full_page['keywords'] = ''; $full_page['description'] = ''; $full_page['url'] = ''; $full_page['body'] = 'This is your new page.'; $full_page['layout'] = 0; $full_page['site_map'] = 1; CKEditor::init(); JS::startup('lightning.page.edit();'); } elseif ($full_page = $this->loadPage('404')) { header('HTTP/1.0 404 NOT FOUND'); $full_page['url'] = Request::get('page'); $template->set('page_blank', true); } else { header('HTTP/1.0 404 NOT FOUND'); $full_page['title'] = 'Lightning'; $full_page['keywords'] = 'Lightning'; $full_page['description'] = 'Lightning'; $full_page['url'] = ''; $full_page['body'] = 'Your site has not been set up.'; $full_page['layout'] = 0; $full_page['site_map'] = 1; $template->set('page_blank', true); } // Replace special tags. if (!$user->isAdmin()) { $matches = array(); preg_match_all('|{{.*}}|', $full_page['body'], $matches); foreach ($matches as $match) { if (!empty($match)) { $match_clean = trim($match[0], '{} '); $match_clean = explode('=', $match_clean); switch ($match_clean[0]) { case 'template': $sub_template = new Template(); $full_page['body'] = str_replace($match[0], $sub_template->render($match_clean[1], true), $full_page['body']); break; } } } } // PREPARE FORM DATA CONTENTS foreach (array('title', 'keywords', 'description') as $meta_data) { $full_page[$meta_data] = Scrub::toHTML($full_page[$meta_data]); if (!empty($full_page[$meta_data])) { Configuration::set('page_' . $meta_data, str_replace("*", Configuration::get('page_' . $meta_data), $full_page[$meta_data])); } } if ($full_page['url'] == "" && isset($_GET['page'])) { $full_page['url'] = $_GET['page']; } else { $full_page['url'] = Scrub::toHTML($full_page['url'], ENT_QUOTES); } $template->set('page_header', $full_page['title']); $template->set('full_page', $full_page); $template->set('full_width', $full_page['layout'] == 1); }
public function get() { $blog_id = Request::get('id', 'int') | Request::get('blog_id', 'int'); $path = explode('/', Request::getLocation()); $blog = BlogModel::getInstance(); if (preg_match('/.*\\.htm/', $path[0])) { $blog->loadContentByURL($path[0]); } elseif ($blog_id) { $blog->loadContentById($blog_id); } elseif (array_shift($path) == 'blog') { if (!empty($path)) { $blog->page = is_numeric($path[count($path) - 1]) ? $path[count($path) - 1] : 1; if ($path[0] == 'category') { // Load category roll $blog->loadList($blog->page, 'category', $path[1]); } elseif ($path[0] == 'author') { // Load an author roll. $blog->loadList($blog->page, 'author', $path[1]); } elseif (!empty($blog->page)) { $blog->loadList(); } else { // Try to load a specific blog. $blog->loadContentByURL($path[0]); } } } if (empty($blog->posts)) { // Fall back, load blogroll $blog->loadList(1); } $template = Template::getInstance(); if (count($blog->posts) == 1) { $template->set('page_section', 'blog'); } else { // If there is more than one, we show a list with short bodies. $blog->shorten_body = true; } if (count($blog->posts) == 1) { foreach (array('title', 'keywords', 'description', 'author') as $meta_data) { switch ($meta_data) { case 'title': $value = $blog->posts[0]['title'] . ' | ' . Configuration::get('meta_data.title') . ' | ' . Scrub::toHTML($blog->body($blog->posts[0]['author_name'], true)); break; case 'description': $value = Scrub::toHTML($blog->body($blog->posts[0]['body'], true)); break; case 'author': $value = Scrub::toHTML($blog->body($blog->posts[0]['author_name'], true)); break; default: $value = Scrub::toHTML($blog->body($blog->posts[0][$meta_data], true)); } $template->set('page_' . $meta_data, $value); } } //meta facebook image if (count($blog->posts) == 1 && !empty($blog->posts[0]['header_image'])) { $template->set('og_image', Configuration::get('web_root') . $blog->posts[0]['header_image']); } elseif ($default_image = Configuration::get('blog.default_image')) { $template->set('og_image', Configuration::get('web_root') . $default_image); } }