/** Last inn siden (kalles til slutten av scriptet for å hente themet */ public function load() { $this->content .= ob_get_contents(); @ob_clean(); // load through twig template? $templates = array('guest_simple' => 'templates/guest/simple', 'guest' => 'templates/guest/wide', 'node' => 'templates/guest/node', 'doc' => 'templates/doc'); if (isset($templates[$this->theme_file])) { $template = $templates[$this->theme_file]; \Kofradia\View::forgeTwig($template); $response = new \Kofradia\Response(); $response->setContents(\Kofradia\View::forgeTwig($template)); $response->output(); die; } global $_base; $_base->dt("page_load_pre"); // temafilen $theme_file = PATH_PUBLIC . "/themes/" . $this->theme . "/" . $this->theme_file . ".php"; // finnes ikke temafilen? if (!file_exists($theme_file)) { throw new HSException("Fant ikke temafilen <b>{$this->theme_file}.php</b> for temaet <b>{$this->theme}</b>."); } if (mb_strpos($this->content, '<boxes />') === false) { $this->content = '<boxes />' . $this->content; } // hent temafilen require $theme_file; // hent full html kode som ble generert $content = ob_get_contents(); @ob_clean(); echo $this->postParse($content); die; }
/** * List polls */ public function action_index($page = 1) { \ess::$b->page->add_title("Avstemninger"); // hent avstemningene $pagei = new \pagei(\pagei::PER_PAGE, 10, \pagei::ACTIVE_GET, "side"); $pagei->__construct(\pagei::ACTIVE, intval($page)); $polls = Poll::getPolls($pagei, \login::$logged_in ? \login::$user : null); $data = array(); foreach ($polls as $poll) { $vote = \login::$logged_in ? $poll->getVote() : null; // finn alternativet med flest stemmer $votes_max = 0; foreach ($poll->options as $option) { if ($option->data['po_votes'] > $votes_max) { $votes_max = $option->data['po_votes']; } } $options = array(); foreach ($poll->options as $option) { $options[] = array("item" => $option, "percent" => $option->getPercent(), "is_vote" => $option == $vote, "width" => round($option->data['po_votes'] / $votes_max * 100)); } $data[] = array("item" => $poll, "options" => $options, "in_progress" => $poll->data['p_time_end'] > time()); } return View::forgeTwig("polls/poll_list", array("polls" => $data, "pagei" => $pagei)); }
/** * Show full list */ public function action_list() { \ess::$b->page->add_title("Donasjoner"); // hent donasjonene på denne siden $pagei = new \pagei(\pagei::ACTIVE_GET, "side", \pagei::PER_PAGE, 30); $list = Donation::getDonations($pagei); return View::forgeTwig("donations/list", array("pagei" => $pagei, "donations" => $list)); }
/** * Show the form */ protected function showForm() { return View::forgeTwig('game/utpressing/form', array("match" => \ess::session_get("utpressing_opt_key") ?: null, "wait" => $this->ut->getWait(), "options" => $this->ut->getOptions(), "form" => $this->form)); }
/** * Vis side for feilmelding hvis det er noen feilmelding */ protected function show_errors() { // ingen feilmelding? if (!isset($_SESSION[$GLOBALS['__server']['session_prefix'] . 'login_error'])) { return; } // vis feilside $login_error = $_SESSION[$GLOBALS['__server']['session_prefix'] . 'login_error'][0]; $info = $_SESSION[$GLOBALS['__server']['session_prefix'] . 'login_error'][1]; unset($_SESSION[$GLOBALS['__server']['session_prefix'] . 'login_error']); \ess::$b->page->theme_file = "guest"; switch ($login_error) { case "deactivated": \ess::$b->page->add_title("Deaktivert"); return \Kofradia\View::forgeTwig('users/login/deactivated', array("email" => $info['u_email'], "date" => $info['u_deactivated_time'], "reason" => \game::bb_to_html($info['u_deactivated_reason']))); default: throw new HSException("Ukjent innloggingsfeil ({$login_error})"); } }
/** * Hent boks med livefeed */ public function action_livefeed() { $lf = \livefeed::get_latest(3); return \Kofradia\View::forgeTwig('users/login/helpers/livefeed', array("data" => $lf)); }