Dotclear

source: admin/popup_posts.php @ 2811:612f4c2bd456

Revision 2811:612f4c2bd456, 2.3 KB checked in by franck <carnet.franck.paul@…>, 11 years ago (diff)

cope with different entry types for pagination, fixes #1971

Line 
1<?php
2# -- BEGIN LICENSE BLOCK ---------------------------------------
3#
4# This file is part of Dotclear 2.
5#
6# Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear
7# Licensed under the GPL version 2.0 license.
8# See LICENSE file or
9# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
10#
11# -- END LICENSE BLOCK -----------------------------------------
12
13require dirname(__FILE__).'/../inc/admin/prepend.php';
14
15dcPage::check('usage,contentadmin');
16
17$q = !empty($_GET['q']) ? $_GET['q'] : null;
18$plugin_id = !empty($_GET['plugin_id']) ? html::sanitizeURL($_GET['plugin_id']) : '';
19
20$page = !empty($_GET['page']) ? max(1,(integer) $_GET['page']) : 1;
21$nb_per_page =  10;
22
23$post_types = $core->getPostTypes();
24foreach ($post_types as $k => $v) {
25     $type_combo[__($k)] = (string) $k;
26}
27if (!in_array($type, $type_combo)) {
28     $type = null;
29}
30
31$params = array();
32$params['limit'] = array((($page-1)*$nb_per_page),$nb_per_page);
33$params['no_content'] = true;
34$params['order'] = 'post_dt DESC';
35
36if ($q) {
37     $params['search'] = $q;
38}
39
40if ($type) {
41     $params['post_type'] = $type;
42}
43
44dcPage::openPopup(__('Add a link to an entry'),
45     dcPage::jsLoad('js/_posts_list.js').
46     $core->callBehavior('adminPopupPosts', $plugin_id));
47
48echo '<h2 class="page-title">'.__('Add a link to an entry').'</h2>';
49
50echo '<form action="popup_posts.php" method="get">'.
51     '<p><label for="type" class="classic">'.__('Entry type:').'</label> '.form::combo('type',$type_combo,$type).''.
52     '<noscript><div><input type="submit" value="'.__('Ok').'" /></div></noscript>'.
53     '</form>';
54
55echo '<form action="popup_posts.php" method="get">'.
56     '<p><label for="q" class="classic">'.__('Search entry:').'</label> '.form::field('q',30,255,html::escapeHTML($q)).
57     ' <input type="submit" value="'.__('Search').'" />'.
58     form::hidden('type',html::escapeHTML($type)).
59     '</p></form>';
60
61try {
62     $posts = $core->blog->getPosts($params);
63     $counter = $core->blog->getPosts($params,true);
64     $post_list = new adminPostMiniList($core,$posts,$counter->f(0));
65} catch (Exception $e) {
66     $core->error->add($e->getMessage());
67}
68
69echo '<div id="form-entries">'; # I know it's not a form but we just need the ID
70$post_list->display($page,$nb_per_page);
71echo '</div>';
72
73echo '<p><a class="button" href="#" id="link-insert-cancel">'.__('cancel').'</a></p>';
74
75dcPage::closePopup();
Note: See TracBrowser for help on using the repository browser.

Sites map