/** * Add some variables to the template output */ public function add_template_vars() { if (!$this->template_engine->assigned('pages')) { $this->assign('pages', Posts::get(array('content_type' => 'page', 'status' => Post::status('published'), 'nolimit' => 1))); } $page = Controller::get_var('page'); $page = isset($page) ? $page : 1; if (!$this->template_engine->assigned('page')) { $this->assign('page', $page); } $this->assign('show_previously', false); $this->assign('show_latest', false); $action = Controller::get_action(); if ($action == 'display_home' || $action == 'display_entries') { $offset = (int) (($page + 1 - 1) * Options::get('pagination')); $this->assign('previously', Posts::get(array('status' => 'published', 'content_type' => 'entry', 'offset' => $offset, 'limit' => self::PREVIOUSLY_ITEMS))); $this->assign('show_previously', true); } if ($action != 'display_home') { $this->assign('latest', Posts::get(array('status' => 'published', 'content_type' => 'entry', 'offset' => 0, 'limit' => self::LATEST_ITEMS))); $this->assign('show_latest', true); } $this->assign('controller_action', $action); parent::add_template_vars(); }
/** * On request modify <code> tags. * We do this here because otherwise you'd get a mess * of HTML in your database. */ public function filter_post_content($output, $post) { if (Controller::get_action() == 'admin' || $output == "") { return $output; } $output = preg_replace_callback("/<code([^>]*)>(.*)<\\/code>/siU", array($this, "syntax_highlight"), $output); return $output; }
/** * Add the Pingback header on single post/page requests * Not to the entire site. Clever. */ public function action_add_template_vars() { $action = Controller::get_action(); if ($action == 'display_post') { header('X-Pingback: ' . URL::get('xmlrpc')); } else { header('X-action: ' . $action); } }
/** * Add the Pingback header on single post/page requests * Not to the entire site. Clever. */ public function action_add_template_vars() { $action = Controller::get_action(); $add_header = $action == 'display_post'; $add_header = Plugins::filter('pingback_add_header', $add_header, $action); if ($add_header) { header('X-Pingback: ' . URL::get('xmlrpc')); } else { header('X-action: ' . $action); } }
/** * When the AtomHandler is created, check what action called it * If the action is set in our URL list, intercept and redirect to Feedburner */ public function action_init_atom() { $action = Controller::get_action(); $feed_uri = Options::get('feedburner__' . $action); $exclude_ips = Options::get('feedburner__exlude_ips'); $exclude_agents = Options::get('feedburner__exclude_agents'); if ($feed_uri != '' && (!isset(URL::get_matched_rule()->named_arg_values['index']) || URL::get_matched_rule()->named_arg_values['index'] == 1)) { if (!in_array($_SERVER['REMOTE_ADDR'], (array) $exclude_ips)) { if (isset($_SERVER['HTTP_USER_AGENT']) && !in_array($_SERVER['HTTP_USER_AGENT'], (array) $exclude_agents)) { ob_clean(); header('Location: http://feedproxy.google.com/' . $feed_uri, TRUE, 302); die; } } } }
/** * Add the link and meta data to the header * * @param object $theme Theme object with all its properties and methods available */ public function theme_header($theme) { $search_url = Site::get_url('habari') . '/opensearch.xml'; $site_title = Options::get('title'); echo '<link rel="search" type="application/opensearchdescription+xml" href="' . $search_url . '" title="' . $site_title . '">' . "\r\n"; if (Controller::get_action() == 'search') { $totalResults = $theme->posts->count_all(); $startIndex = $theme->page; $itemsPerPage = isset($this->handler_vars['count']) ? $this->handler_vars['count'] : Options::get('pagination'); echo '<meta name="totalResults" content="' . $totalResults . '">' . "\r\n"; echo '<meta name="startIndex" content="' . $startIndex . '">' . "\r\n"; echo '<meta name="itemsPerPage" content="' . $itemsPerPage . '">' . "\r\n"; } }
public function action_user_identify() { if (Controller::get_action() == 'login' && !empty($_POST['openid_url'])) { self::openid_start(); } }
/** * theme: show_calendar * * @access public * @param object $theme * @return string */ public function theme_show_calendar($theme) { $handler_vars = Controller::get_handler_vars(); if (Controller::get_action() == 'display_date' && isset($handler_vars['month'])) { $year = (int) $handler_vars['year']; $month = (int) $handler_vars['month']; } else { $year = date('Y'); $month = date('m'); } $next_year = $year; $prev_year = $year; $next_month = $month + 1; $prev_month = $month - 1; if ($next_month == 13) { $next_month = 1; $next_year++; } if ($prev_month == 0) { $prev_month = 12; $prev_year--; } $start_time = mktime(0, 0, 0, $month, 1, $year); $end_time = mktime(0, 0, 0, $next_month, 1, $next_year); $t_posts_day = DB::get_column('SELECT pubdate FROM {posts} WHERE pubdate >= ? AND pubdate < ? AND status = ?', array($start_time, $end_time, Post::status('published'))); $posts_day = array(); @reset($t_posts_day); while (list(, $pubdate) = @each($t_posts_day)) { $posts_day[] = (int) date("j", $pubdate); } $month_start_week = date("w", $start_time); $month_days = date("t", $start_time); $week_days = array(_t('Sun', 'calendar'), _t('Mon', 'calendar'), _t('Tue', 'calendar'), _t('Wed', 'calendar'), _t('Thu', 'calendar'), _t('Fri', 'calendar'), _t('Sat', 'calendar')); $week_start = Options::get('calendar__week_start'); $calendar = array(); $day = 0; while (1) { $week = array(); for ($i = 0; $i < 7; $i++) { $wday = ($i + $week_start) % 7; if (count($calendar) == 0) { $week[] = array('label' => $week_days[($i + $week_start) % 7]); continue; } elseif ($day == 0) { if ($wday == $month_start_week) { $day = 1; if (array_search($day, $posts_day) !== false) { $week[] = array('label' => $day, 'url' => URL::get('display_entries_by_date', array('year' => $year, 'month' => sprintf('%02d', $month), 'day' => sprintf('%02d', $day)))); } else { $week[] = array('label' => $day); } } else { $week[] = array('label' => null); continue; } } elseif ($day >= $month_days) { $week[] = array('label' => null); continue; } else { $day++; if (array_search($day, $posts_day) !== false) { $week[] = array('label' => $day, 'url' => URL::get('display_entries_by_date', array('year' => $year, 'month' => sprintf('%02d', $month), 'day' => sprintf('%02d', $day)))); } else { $week[] = array('label' => $day); } } } $calendar[] = $week; if ($day == $month_days) { break; } } $theme->year = $year; $theme->month = $month; $theme->prev_month_url = URL::get('display_entries_by_date', array('year' => $prev_year, 'month' => sprintf('%02d', $prev_month))); $theme->next_month_url = URL::get('display_entries_by_date', array('year' => $next_year, 'month' => sprintf('%02d', $next_month))); $theme->calendar = $calendar; return $theme->fetch('calendar'); }