Dotclear

source: admin/popup_posts.php @ 2756:ff017877e7f9

Revision 2756:ff017877e7f9, 2.6 KB checked in by Nicolas <nikrou77@…>, 11 years ago (diff)

Fix issue for inserting link to entry when current editor is different from preferred editor
Closes #1996

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

Sites map