app_name; if ($this->contentFor('title')) return $this->content('title') . " | " . $base_title; else return $base_title; } public function tag_header($tags = null) { if (!$tags) return; $tags = array_filter(explode(' ', $tags)); foreach($tags as $k => $tag) $tags[$k] = $this->linkTo(str_replace('_', ' ', $tag), array('/post', 'tags' => $tag)); return '/'.implode('+', $tags); } # Return true if the user can access the given level, or if creating an # account would. This is only actually used for actions that require # privileged or higher; it's assumed that starting_level is no lower # than member. public function can_access($level) { $needed_level = User::get_user_level($level); $starting_level = CONFIG()->starting_level; $user_level = current_user()->level; if ($user_level >= $needed_level || $starting_level >= $needed_level) return true; return false; } # Return true if the starting level is high enough to execute # this action. This is used by User.js. public function need_signup($level) { $needed_level = User::get_user_level($level); $starting_level = CONFIG()->starting_level; return $starting_level >= $needed_level; } public function get_help_action_for_controller($controller) { $singular = array("forum", "wiki"); $help_action = $controller; if (in_array($help_action, $singular)) return $help_action; else return $help_action . 's'; } public function navigation_links($post) { $html = array(); if ($post instanceof Post) { $html[] = $this->tag("link", array('rel' => "prev", 'title' => "Previous Post", 'href' => $this->urlFor(array('post#show', 'id' => $post->id - 1)))); $html[] = $this->tag("link", array('rel' => "next", 'title' => "Next Post", 'href' => $this->urlFor(array('post#show', 'id' => $post->id + 1)))); } elseif ($post instanceof Rails\ActiveRecord\Collection) { $posts = $post; $url_for = $this->request()->controller() . '#' . $this->request()->action(); if ($posts->previousPage()) { $html[] = $this->tag("link", array('href' => $this->urlFor(array_merge(array($url_for), $this->params()->merge(['page' => 1]))), 'rel' => "first", 'title' => "First Page")); $html[] = $this->tag("link", array('href' => $this->urlFor(array_merge(array($url_for), $this->params()->merge(['page' => $posts->previousPage()]))), 'rel' => "prev", 'title' => "Previous Page")); } if ($posts->nextPage()) { $html[] = $this->tag("link", array('href' => $this->urlFor(array_merge(array($url_for), $this->params()->merge(['page' => $posts->nextPage()]))), 'rel' => "next", 'title' => "Next Page")); $html[] = $this->tag("link", array('href' => $this->urlFor(array_merge(array($url_for), $this->params()->merge(['page' => $posts->totalPages()]))), 'rel' => "last", 'title' => "Last Page")); } } return implode("\n", $html); } public function format_text($text, array $options = []) { return DText::parse($text); } public function format_inline($inline, $num, $id, $preview_html = null) { if (!$inline->inline_images) return ""; if ($inline->inline_images->any()) { $url = $inline->inline_images[0]->preview_url(); } else { $url = ''; } if (!$preview_html) $preview_html = ''; $id_text = "inline-$id-$num"; $block = '