Dotclear

source: admin/popup_posts.php @ 995:ffd146bbe114

Revision 995:ffd146bbe114, 2.4 KB checked in by franck <carnet.franck.paul@…>, 13 years ago (diff)

Every types of entries may be used to inserted an entry link in current edited post, fixes #1089

Line 
1<?php
2# -- BEGIN LICENSE BLOCK ---------------------------------------
3#
4# This file is part of Dotclear 2.
5#
6# Copyright (c) 2003-2011 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$query_string = '';
18$q = !empty($_GET['q']) ? $_GET['q'] : null;
19
20$page = !empty($_GET['page']) ? (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
49dcPage::openPopup(__('Add a link to an entry'),
50     dcPage::jsLoad('js/_posts_list.js').
51     dcPage::jsLoad('js/jsToolBar/popup_posts.js'));
52
53echo '<h2 class="page-title">'.__('Add a link to an entry').'</h2>';
54
55echo '<form action="popup_posts.php" method="post">'.
56     '<p><label for"type" class="classic">'.__('Entry type:').' '.form::combo('type',$type_combo,$type).'</label></p>'.
57     $core->formNonce().
58     '<noscript><div><input type="submit" value="'.__('Ok').'" /></div></noscript>'.
59     '</form>';
60
61echo '<form action="popup_posts.php" method="get">'.
62     '<p><label for="q" class="classic">'.__('Search entry:').' '.form::field('q',30,255,html::escapeHTML($q)).'</label> '.
63     ' <input type="submit" value="'.__('Search').'" /></p>'.
64     form::hidden('type',html::escapeHTML($type)).
65     '</form>';
66
67try {
68     $posts = $core->blog->getPosts($params);
69     $counter = $core->blog->getPosts($params,true);
70     $post_list = new adminPostMiniList($core,$posts,$counter->f(0));
71} catch (Exception $e) {
72     $core->error->add($e->getMessage());
73}
74
75echo '<div id="form-entries">'; # I know it's not a form but we just need the ID
76$post_list->display($page,$nb_per_page);
77echo '</div>';
78
79echo '<p><a class="button" href="#" id="link-insert-cancel">'.__('cancel').'</a></p>';
80
81dcPage::closePopup();
82?>
Note: See TracBrowser for help on using the repository browser.

Sites map