1 | <?php |
---|
2 | # -- BEGIN LICENSE BLOCK ---------------------------------- |
---|
3 | # This file is part of splitPost, a plugin for Dotclear. |
---|
4 | # |
---|
5 | # Copyright (c) 2009 Tomtom |
---|
6 | # http://blog.zenstyle.fr/ |
---|
7 | # |
---|
8 | # Licensed under the GPL version 2.0 license. |
---|
9 | # A copy of this license is available in LICENSE file or at |
---|
10 | # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
11 | # -- END LICENSE BLOCK ------------------------------------ |
---|
12 | |
---|
13 | class splitPostPager extends pager |
---|
14 | { |
---|
15 | public function __construct($current,$nb_page_tot,$nb_page_max = 20) |
---|
16 | { |
---|
17 | parent::__construct($current,$nb_page_tot,1,$nb_page_max); |
---|
18 | } |
---|
19 | |
---|
20 | public function init($params = null) |
---|
21 | { |
---|
22 | $this->base_url = $GLOBALS['_ctx']->posts->getURL().'/page/%s'; |
---|
23 | $this->html_cur_page = isset($params['current']) ? $params['current'] : $this->html_cur_page; |
---|
24 | $this->html_prev = isset($params['prev']) ? $params['prev'] : $this->html_prev; |
---|
25 | $this->html_next = isset($params['next']) ? $params['next'] : $this->html_next; |
---|
26 | } |
---|
27 | } |
---|
28 | |
---|
29 | class splitPostBehaviors |
---|
30 | { |
---|
31 | public static function coreBlogGetPosts($rs) |
---|
32 | { |
---|
33 | $rs->extend('rsExtPostSplitPost'); |
---|
34 | } |
---|
35 | |
---|
36 | public static function postHeaders() |
---|
37 | { |
---|
38 | global $core; |
---|
39 | |
---|
40 | return |
---|
41 | '<script type="text/javascript" src="index.php?pf=splitPost/js/post.min.js"></script>'. |
---|
42 | '<script type="text/javascript">'."\n". |
---|
43 | "//<![CDATA[\n". |
---|
44 | dcPage::jsVar('jsToolBar.prototype.elements.splitPost.title',__('Post pager')). |
---|
45 | "\n//]]>\n". |
---|
46 | "</script>\n"; |
---|
47 | } |
---|
48 | } |
---|
49 | |
---|
50 | class rsExtPostSplitPost |
---|
51 | { |
---|
52 | public static function getContent($rs,$absolute_urls=false) |
---|
53 | { |
---|
54 | $_ctx = $GLOBALS['_ctx']; |
---|
55 | $core = $GLOBALS['core']; |
---|
56 | |
---|
57 | $res = rsExtPost::getContent($rs,$absolute_urls); |
---|
58 | |
---|
59 | $part = preg_split($core->post_page_pattern,$res); |
---|
60 | |
---|
61 | $page = $_ctx->post_page_current !== null ? $_ctx->post_page_current - 1 : 0; |
---|
62 | |
---|
63 | return isset($part[$page]) ? $part[$page] : ''; |
---|
64 | } |
---|
65 | } |
---|
66 | |
---|
67 | ?> |
---|