Dotclear

source: admin/popup_posts.php @ 2971:df3d6bf1741d

Revision 2971:df3d6bf1741d, 2.4 KB checked in by Nicolas <nikrou77@…>, 10 years ago (diff)

Missing plugin_id when changing post type
Fixes #2075

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$type = !empty($_GET['type']) ? $_GET['type'] : null;
24
25$post_types = $core->getPostTypes();
26foreach ($post_types as $k => $v) {
27     $type_combo[__($k)] = (string) $k;
28}
29if (!in_array($type, $type_combo)) {
30     $type = null;
31}
32
33$params = array();
34$params['limit'] = array((($page-1)*$nb_per_page),$nb_per_page);
35$params['no_content'] = true;
36$params['order'] = 'post_dt DESC';
37
38if ($q) {
39     $params['search'] = $q;
40}
41
42if ($type) {
43     $params['post_type'] = $type;
44}
45
46dcPage::openPopup(__('Add a link to an entry'),
47     dcPage::jsLoad('js/_posts_list.js').
48     $core->callBehavior('adminPopupPosts', $plugin_id));
49
50echo '<h2 class="page-title">'.__('Add a link to an entry').'</h2>';
51
52echo '<form action="popup_posts.php" method="get">'.
53     '<p><label for="type" class="classic">'.__('Entry type:').'</label> '.form::combo('type',$type_combo,$type).''.
54     '<noscript><div><input type="submit" value="'.__('Ok').'" /></div></noscript>'.
55     form::hidden('plugin_id',html::escapeHTML($plugin_id)).'</p>'.
56     '</form>';
57
58echo '<form action="popup_posts.php" method="get">'.
59     '<p><label for="q" class="classic">'.__('Search entry:').'</label> '.form::field('q',30,255,html::escapeHTML($q)).
60     ' <input type="submit" value="'.__('Search').'" />'.
61     form::hidden('plugin_id',html::escapeHTML($plugin_id)).
62     form::hidden('type',html::escapeHTML($type)).
63     '</p></form>';
64
65try {
66     $posts = $core->blog->getPosts($params);
67     $counter = $core->blog->getPosts($params,true);
68     $post_list = new adminPostMiniList($core,$posts,$counter->f(0));
69} catch (Exception $e) {
70     $core->error->add($e->getMessage());
71}
72
73echo '<div id="form-entries">'; # I know it's not a form but we just need the ID
74$post_list->display($page,$nb_per_page);
75echo '</div>';
76
77echo '<p><a class="button" href="#" id="link-insert-cancel">'.__('cancel').'</a></p>';
78
79dcPage::closePopup();
Note: See TracBrowser for help on using the repository browser.

Sites map