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