LightPressPlugin($frontend, $args, $dummy_run); } function &run($hook, &$hook_data) { $context = $this->_frontend->context; $db =& $this->_frontend->db; $tpl =& $this->_frontend->tpl; $index = $context['index']; $posts_per_page = $this->_frontend->options['posts_per_page']; $prev_label = $prev_posts = $next_label = $next_posts = ''; $tpl->setFile('plugin_pagination', 'plugins/pagination.xml', true); $num_posts = $this->_frontend->num_posts; $show_divide = true; $page_previous = $index - $posts_per_page; // echo "num_posts: $num_posts context_index: " . $context['index'] . " ppp: $posts_per_page pp: $page_previous"; if ($index == 0) { $tpl->setBlock('plugin_pagination', $this->_block_previous); $tpl->setVar(strtoupper($this->_block_previous), ''); $show_divide = false; } else if ($page_previous < 0) { $page_previous = 0; } else if ($page_previous >= $num_posts) { $page_previous = $num_posts - $posts_per_page; } if ($index == 1) { $prev_label = $this->_frontend->messages['post']; $prev_posts = ''; } else { $prev_label = $this->_frontend->messages['posts']; $prev_posts = ($index > $num_posts ? $num_posts : $index); } $page_next = $index + $posts_per_page; if ($page_next >= $num_posts) { $tpl->setBlock('plugin_pagination', $this->_block_next); $tpl->setVar(strtoupper($this->_block_next), ''); $show_divide = false; } else { if ($num_posts - $page_next == 1) { $next_label = $this->_frontend->messages['post']; } else { $next_label = $this->_frontend->messages['posts']; $next_posts = $num_posts - ($index + $posts_per_page); } } $this->page_current = $index; $this->page_previous = $page_previous; $this->page_next = $page_next; $this->posts_previous = $prev_posts; $this->posts_next = $next_posts; if ($this->_frontend->raw_urls) { if (strpos($context['url'], '?') === false) $sep = '?'; else $sep = '&'; $this->url_previous = $prev_url = $context['url'] . "${sep}i=$page_previous"; $this->url_next = $next_url = $context['url'] . "${sep}i=$page_next"; } else { $this->url_previous = $prev_url = $context['url'] . "/record/$page_previous"; $this->url_next = $next_url = $context['url'] . "/record/$page_next"; } $tpl->setVar(array( 'context_url' => $context['url'], 'plugin_pagination_prev_url' => $prev_url, 'plugin_pagination_next_url' => $next_url, 'plugin_pagination_prev_posts' => $prev_posts, 'plugin_pagination_next_posts' => $next_posts, 'plugin_pagination_prev_index' => $page_previous, 'plugin_pagination_next_index' => $page_next, 'plugin_pagination_prev_label' => $prev_label, 'plugin_pagination_next_label' => $next_label, 'plugin_pagination_divide' => ($show_divide) ? '|' : '')); $tpl->parse('PLUGIN_PAGINATION', 'plugin_pagination'); } } ?>