public function Index() { $this->layout = 'homepage'; $content = Content::find_by_permalink("index"); $nextEvent = Event::next_event(); $news = array(); if ($nextEvent) { $permalink = mysql_real_escape_string($nextEvent->permalink); $newsTags = NewsTag::find_all("news.publish_at <= NOW() AND news.published AND tags.permalink = '{$permalink}'", "news.publish_at DESC", 3); foreach ($newsTags as $tag) { $tag->news->reload(); $news[] = $tag->news; } } $this->assign("news", $news); $this->assign("content", $content); $this->assign("next_event", $nextEvent); global $config; $this->assign("baseurl", $config['forums']['base_url']); $this->render("home/index.tpl"); }
public static function render($title = null, $headcontent = null) { self::init(); global $site; global $config; $smarty = new SmartySite(); $smarty->assign("title", $title); $smarty->assign("site", $site); $smarty->assign("content", "|--|CONTENT|--|"); $smarty->assign("headcontent", $headcontent); $smarty->assign("next_event", Event::next_event()); $all_events = Event::find_all("events.visible = true", "events.startdate DESC"); $events = array(); foreach ($all_events as $event) { if ($event->check_user(Site::CurrentUser())) { $events[] = $event; } } $smarty->assign("all_events", $events); $output = $smarty->fetch("application/layout.tpl"); $output = explode("|--|CONTENT|--|", $output); return array("header" => $output[0], "footer" => $output[1]); }
function RenderPage($title, $content, $layout = "layout", $nosql = false, $vars = array()) { global $site; global $config; $smarty = new SmartySite(); $smarty->assign("title", $title); $smarty->assign("content", $content); $smarty->assign("headcontent", ""); $smarty->assign("site", $site); foreach ($vars as $name => $value) { $smarty->assign($name, $value); } if (isset($_SESSION['csrf'])) { $smarty->assign("csrf", $_SESSION['csrf']); } if (!$nosql) { $revert = false; if (isset($config['dev_sql']) && $config['dev_sql']) { $config['dev_sql'] = false; $revert = true; } $smarty->assign("next_event", Event::next_event()); $events = array('future' => Event::find_all("(events.visible = true OR events.advertised = true) AND events.enddate > NOW()", "events.enddate ASC"), 'past' => Event::find_all("(events.visible = true OR events.advertised = true) AND events.enddate <= NOW()", "events.enddate DESC")); foreach ($events as $type => $collection) { ${$type} = array(); foreach ($collection as $key => $event) { if ($event->check_user(Site::CurrentUser())) { array_push(${$type}, $event); } } $smarty->assign("{$type}Events", ${$type}); } $smallEvents = array(); $largeEvents = array(); foreach ($future as $event) { if ($event->capacity < 50) { $smallEvents[] = $event; } else { $largeEvents[] = $event; } } $smallEvents = array_slice($smallEvents, 0, 3); $largeEvents = array_slice($largeEvents, 1, 1); $smarty->assign('smallEvents', $smallEvents); $smarty->assign('largeEvents', $largeEvents); if ($revert) { $config['dev_sql'] = true; } } // Determine SSL or not $protocol = "http"; if (isset($_SERVER['SERVER_PORT']) and $_SERVER['SERVER_PORT'] == 443) { $protocol = "https"; } $baseuri = "{$protocol}://{$_SERVER['HTTP_HOST']}"; $smarty->assign("protocol", $protocol); $smarty->assign("baseuri", $baseuri); $smarty->display("application/{$layout}.tpl"); if (isset($config['dev_sql']) && $config['dev_sql']) { file_put_contents("logs/sql.log", "\r\n", FILE_APPEND); } die; }