本文整理汇总了PHP中Controller::get_handler方法的典型用法代码示例。如果您正苦于以下问题:PHP Controller::get_handler方法的具体用法?PHP Controller::get_handler怎么用?PHP Controller::get_handler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Controller
的用法示例。
在下文中一共展示了Controller::get_handler方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_plugin_act_plaintext
/**
* Respond to the URL that was created
* Determine the post that was supposed to be displayed, and show it in raw
* @params array $handlervars An array of values passed in from the URL requested
*/
function action_plugin_act_plaintext($handlervars)
{
$activetheme = Themes::create();
$user_filters = array('fetch_fn' => 'get_row', 'limit' => 1);
$page_key = array_search('page', $activetheme->valid_filters);
unset($activetheme->valid_filters[$page_key]);
$user_filters = Plugins::filter('template_user_filters', $user_filters);
$user_filters = array_intersect_key($user_filters, array_flip($activetheme->valid_filters));
$where_filters = Controller::get_handler()->handler_vars->filter_keys($activetheme->valid_filters);
$where_filters = $where_filters->merge($user_filters);
$where_filters = Plugins::filter('template_where_filters', $where_filters);
$post = Posts::get($where_filters);
$current_url = URL::get();
$created_at = $post->pubdate->get();
header('Content-type: text/plain; charset=utf-8');
echo <<<HERE
# {$post->title}
By {$post->author->displayname}
<{$current_url}>
{$created_at}
\t
{$post->content}
HERE;
exit;
}
示例2: get
/**
* Return a single requested tag.
*
* <code>
* $tag= Tag::get( array( 'tag_slug' => 'wooga' ) );
* </code>
*
* @param array $paramarray An associated array of parameters, or a querystring
* @return Tag The first tag that matched the given criteria
**/
static function get($paramarray = array())
{
// Defaults
$defaults = array('where' => array(), 'fetch_fn' => 'get_row');
foreach ($defaults['where'] as $index => $where) {
$defaults['where'][$index] = array_merge(Controller::get_handler()->handler_vars, $where, Utils::get_params($paramarray));
}
// make sure we get at most one result
$defaults['limit'] = 1;
return Tags::get($defaults);
}
示例3: filter_post_content_out
public function filter_post_content_out($content, $post)
{
// If we're on the publish page, replacement will be destructive.
// We don't want that, so return here.
$controller = Controller::get_handler();
if (isset($controller->action) && $controller->action == 'admin' && isset($controller->handler_vars['page']) && $controller->handler_vars['page'] == 'publish') {
return $content;
}
// If there are no footnotes, save the trouble and just return it as is.
if (strpos($content, '<footnote') === false && strpos($content, ' ((') === false) {
return $content;
}
$this->footnotes = array();
$this->current_id = $post->id;
$this->post = $post;
$return = preg_replace_callback('/(?:<footnote(\\s+url=[\'"].*[\'"])?>|\\s\\(\\()(.*)(?:\\)\\)|<\\/footnote>)/Us', array($this, 'add_footnote'), $content);
$post->footnotes = $this->footnotes;
if (count($this->footnotes) == 0) {
return $content;
}
$post->footnotes = $this->footnotes;
$append = '';
if (!Options::get('footnotes__suppress_list')) {
$append .= '<ol class="footnotes">' . "\n";
foreach ($this->footnotes as $i => $footnote) {
// if there was a url
if (is_array($footnote)) {
switch ($footnote['type']) {
case "flickr":
$append .= '<li id="footnote-' . $this->current_id . '-' . $i . '" class="cite ' . $footnote['type'] . '">';
$append .= '<a href="' . $footnote['photo']['url'] . '" title="' . $footnote['photo']['title'] . '">Photo</a>';
$append .= ' by <a href="' . $footnote['owner']['url'] . '" title="' . $footnote['owner']['name'] . '">' . $footnote['owner']['username'] . '</a>';
$append .= ' on <a href="http://flickr.com">Flickr</a>';
$append .= ' <a href="#footnote-link-' . $this->current_id . '-' . $i . '">↩</a>';
$append .= "</li>\n";
break;
case "vanilla":
$append .= '<li id="footnote-' . $this->current_id . '-' . $i . '">';
$append .= '<a href="' . $footnote['url'] . '" title="' . $footnote['text'] . '">' . $footnote['text'] . '</a>';
$append .= ' <a href="#footnote-link-' . $this->current_id . '-' . $i . '">↩</a>';
$append .= "</li>\n";
break;
}
} else {
$append .= '<li id="footnote-' . $this->current_id . '-' . $i . '">';
$append .= $footnote;
$append .= ' <a href="' . $this->post->permalink . '#footnote-link-' . $this->current_id . '-' . $i . '">↩</a>';
$append .= "</li>\n";
}
}
$append .= "</ol>\n";
}
return $return . $append;
}
示例4: theme_multiple_heading
public function theme_multiple_heading($theme, $criteria)
{
$heading = '';
$hv = count($this->handler_vars) != 0 ? $this->handler_vars : Controller::get_handler()->handler_vars;
if ($this->request->display_entries_by_date && count($hv) > 0) {
$date = '';
$date .= isset($hv['year']) ? $hv['year'] : '';
$date .= isset($hv['month']) ? '-' . $hv['month'] : '';
$date .= isset($hv['day']) ? '-' . $hv['day'] : '';
$heading = _t('Dated ', 'sp') . $date;
}
return $heading;
}
示例5: action_block_content_grayposts
public function action_block_content_grayposts($block, $theme)
{
$criteria = new SuperGlobal(array());
if (User::identify()->loggedin) {
$criteria['status'] = isset($_GET['preview']) ? Post::status('any') : Post::status('published');
} else {
$criteria['status'] = Post::status('published');
}
if ($block->content_type != '') {
$criteria['content_type'] = $block->content_type;
if ($block->content_type == 0) {
unset($criteria['content_type']);
}
}
if ($block->limit != '') {
$criteria['limit'] = $block->limit;
}
if ($block->offset != '') {
$criteria['offset'] = $block->offset;
}
if ($block->tag != '') {
$criteria['tag'] = $block->tag;
}
if ($block->main) {
$where_filters = Controller::get_handler()->handler_vars->filter_keys($this->valid_filters);
if (array_key_exists('tag', $where_filters)) {
$where_filters['tag_slug'] = Utils::slugify($where_filters['tag']);
unset($where_filters['tag']);
}
$where_filters = Plugins::filter('template_where_filters', $where_filters);
$criteria = $criteria->merge($where_filters);
}
$block->posts = Posts::get($criteria);
//$block->posts = Posts::get('limit=5&status=2&content_type=0');
$block->criteria = $criteria;
}
示例6: act_display_date
/**
* Helper function: Display the posts for a specific date
* @param array $user_filters Additional arguments used to get the page content
*/
public function act_display_date($user_filters = array())
{
$handler_vars = Controller::get_handler()->handler_vars;
$y = isset($handler_vars['year']);
$m = isset($handler_vars['month']);
$d = isset($handler_vars['day']);
if ($y && $m && $d) {
$paramarray['fallback'][] = 'year.{$year}.month.{$month}.day.{$day}';
}
if ($y && $m && $d) {
$paramarray['fallback'][] = 'year.month.day';
}
if ($m && $d) {
$paramarray['fallback'][] = 'month.{$month}.day.{$day}';
}
if ($y && $m) {
$paramarray['fallback'][] = 'year.{$year}.month.{$month}';
}
if ($y && $d) {
$paramarray['fallback'][] = 'year.{$year}.day.{$day}';
}
if ($m && $d) {
$paramarray['fallback'][] = 'month.day';
}
if ($y && $d) {
$paramarray['fallback'][] = 'year.day';
}
if ($y && $m) {
$paramarray['fallback'][] = 'year.month';
}
if ($m) {
$paramarray['fallback'][] = 'month.{$month}';
}
if ($d) {
$paramarray['fallback'][] = 'day.{$day}';
}
if ($y) {
$paramarray['fallback'][] = 'year.{$year}';
}
if ($y) {
$paramarray['fallback'][] = 'year';
}
if ($m) {
$paramarray['fallback'][] = 'month';
}
if ($d) {
$paramarray['fallback'][] = 'day';
}
$paramarray['fallback'][] = 'date';
$paramarray['fallback'][] = 'multiple';
$paramarray['fallback'][] = 'home';
// Use the according preset defined in the Posts class
$default_filters = array('preset' => 'date');
$paramarray['user_filters'] = array_merge($default_filters, $user_filters);
$this->assign('year', $y ? (int) Controller::get_var('year') : null);
$this->assign('month', $m ? (int) Controller::get_var('month') : null);
$this->assign('day', $d ? (int) Controller::get_var('day') : null);
return $this->act_display($paramarray);
}
示例7: add_spoiler
private function add_spoiler($matches)
{
$this->has_spoilers = true;
list(, , , $message, $spoiler) = $matches;
if ('' == $message) {
$message = Options::get('spoiler__message');
}
$theme = Controller::get_handler()->theme;
// If it's a feed, drop the spoiler and link back.
// This is horribly hacky. Is there a nicer way to check if it's a feed (Atom or RSS)?
if (null == $theme) {
$link = $this->post->permalink;
return "<a href='{$link}'>{$message}</a>";
}
$theme->spoiler = $spoiler;
$theme->message = $message;
return $theme->fetch('spoiler');
}
示例8: action_comment_insert_before
public function action_comment_insert_before(Comment $comment)
{
if ($comment->info->mollom_session_id) {
return;
}
$user = User::identify();
$author_name = $comment->name;
$author_url = $comment->url ? $comment->url : null;
$author_email = $comment->email ? $comment->email : null;
$author_id = $user->loggedin ? $user->id : null;
$author_open_id = $user instanceof User && $user->info->openid_url ? $user->info->openid_url : null;
$post_body = $comment->content;
try {
$result = Mollom::checkContent(null, null, $post_body, $author_name, $author_url, $author_email, $author_open_id, $author_id);
$comment->info->mollom_session_id = $result['session_id'];
$comment->info->mollom_quality = $result['quality'];
switch ($result['spam']) {
case 'spam':
$comment->status = 'spam';
if ($comment->info->spamcheck) {
$comment->info->spamcheck[] = _t('Flagged as Spam by Mollom', 'mollom');
} else {
$comment->info->spamcheck = array(_t('Flagged as Spam by Mollom', 'mollom'));
}
break;
case 'ham':
// Mollom is 100% it is ham, so approve it
$comment->status = 'ham';
return;
break;
case 'unsure':
case 'unknown':
// make it spam until we are sure
$comment->status = 'spam';
Plugins::act('mollom_fallback', Controller::get_handler()->handler_vars, $comment);
return;
break;
}
} catch (Exception $e) {
EventLog::log($e->getMessage(), 'notice', 'comment', 'Mollom');
}
}
示例9: act_display_date
/**
* Helper function: Display the posts for a specific date
* @param array $user_filters Additional arguments used to get the page content
*/
public function act_display_date( $user_filters = array() )
{
$handler_vars = Controller::get_handler()->handler_vars;
$y = isset( $handler_vars['year'] );
$m = isset( $handler_vars['month'] );
$d = isset( $handler_vars['day'] );
if ( $y && $m && $d ) {
$paramarray['fallback'][] = 'year.{$year}.month.{$month}.day.{$day}';
}
if ( $y && $m && $d ) {
$paramarray['fallback'][] = 'year.month.day';
}
if ( $m && $d ) {
$paramarray['fallback'][] = 'month.{$month}.day.{$day}';
}
if ( $y && $m ) {
$paramarray['fallback'][] = 'year.{$year}.month.{$month}';
}
if ( $y && $d ) {
$paramarray['fallback'][] = 'year.{$year}.day.{$day}';
}
if ( $m && $d ) {
$paramarray['fallback'][] = 'month.day';
}
if ( $y && $d ) {
$paramarray['fallback'][] = 'year.day';
}
if ( $y && $m ) {
$paramarray['fallback'][] = 'year.month';
}
if ( $m ) {
$paramarray['fallback'][] = 'month.{$month}';
}
if ( $d ) {
$paramarray['fallback'][] = 'day.{$day}';
}
if ( $y ) {
$paramarray['fallback'][] = 'year.{$year}';
}
if ( $y ) {
$paramarray['fallback'][] = 'year';
}
if ( $m ) {
$paramarray['fallback'][] = 'month';
}
if ( $d ) {
$paramarray['fallback'][] = 'day';
}
$paramarray['fallback'][] = 'date';
$paramarray['fallback'][] = 'multiple';
$paramarray['fallback'][] = 'home';
$paramarray['user_filters'] = $user_filters;
if ( !isset( $paramarray['user_filters']['content_type'] ) ) {
$paramarray['user_filters']['content_type'] = Post::type( 'entry' );
}
$this->assign( 'year', $y ? (int)Controller::get_var( 'year' ) : null );
$this->assign( 'month', $m ? (int)Controller::get_var( 'month' ) : null );
$this->assign( 'day', $d ? (int)Controller::get_var( 'day' ) : null );
return $this->act_display( $paramarray );
}
示例10: theme_mutiple_h1
public function theme_mutiple_h1($theme)
{
$h1 = '';
if (count($this->handler_vars) === 0) {
$this->handler_vars = Controller::get_handler()->handler_vars;
}
if ($this->request->display_entries_by_date && count($this->handler_vars) > 0) {
$date_string = '';
$date_string .= isset($this->handler_vars['year']) ? $this->handler_vars['year'] : '';
$date_string .= isset($this->handler_vars['month']) ? '‒' . $this->handler_vars['month'] : '';
$date_string .= isset($this->handler_vars['day']) ? '‒' . $this->handler_vars['day'] : '';
$h1 = '<h1>' . sprintf(_t('Posts written in %s', 'demorgan'), $date_string) . '</h1>';
} else {
if ($this->request->display_entries_by_tag && isset($this->handler_vars['tag'])) {
$tag = count($this->posts) > 0 ? $this->posts[0]->tags[$this->handler_vars['tag']] : $this->handler_vars['tag'];
$h1 = '<h1>' . sprintf(_t('Posts tagged with %s', 'demorgan'), htmlspecialchars($tag)) . '</h1>';
} else {
if ($this->request->display_search && isset($this->handler_vars['criteria'])) {
$h1 = '<h1>' . sprintf(_t('Search results for “%s”', 'demorgan'), htmlspecialchars($this->handler_vars['criteria'])) . '</h1>';
}
}
}
return $h1;
}
示例11: more
/**
* Returns a truncated version of post content when the post isn't being displayed on its own.
* Posts are split either at the comment <!--more--> or at the specified maximums.
* Use only after applying autop or other paragrpah styling methods.
* Apply to posts using:
* <code>Format::apply_with_hook_params( 'more', 'post_content_out' );</code>
* @param string $content The post content
* @param Post $post The Post object of the post
* @param string $more_text The text to use in the "read more" link.
* @param integer $max_words null or the maximum number of words to use before showing the more link
* @param integer $max_paragraphs null or the maximum number of paragraphs to use before showing the more link
* @return string The post content, suitable for display
**/
public static function more($content, $post, $more_text = 'Read More »', $max_words = null, $max_paragraphs = null)
{
// There should be a more readable way than this to detect if this post is being displayed by itself:
if (isset(Controller::get_handler()->handler_vars['slug'])) {
return $content;
} else {
$matches = preg_split('/<!--\\s*more\\s*-->/is', $content, 2, PREG_SPLIT_NO_EMPTY);
if (count($matches) > 1) {
return reset($matches) . ' <a href="' . $post->permalink . '">' . $more_text . '</a>';
} elseif (isset($max_words) || isset($max_paragraphs)) {
$max_words = empty($max_words) ? 9999999 : intval($max_words);
$max_paragraphs = empty($max_paragraphs) ? 9999999 : intval($max_paragraphs);
$summary = Format::summarize($content, $max_words, $max_paragraphs);
if (strlen($summary) >= strlen($content)) {
return $content;
} else {
return $summary . ' <a href="' . $post->permalink . '">' . $more_text . '</a>';
}
}
}
return $content;
}