[0] | 1 | <?php |
---|
| 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
| 3 | # |
---|
| 4 | # This file is part of Dotclear 2. |
---|
| 5 | # |
---|
[1179] | 6 | # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear |
---|
[0] | 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 | |
---|
[995] | 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 | |
---|
[0] | 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 | |
---|
[995] | 44 | if ($type) { |
---|
| 45 | $params['post_type'] = $type; |
---|
| 46 | } |
---|
| 47 | |
---|
[0] | 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 | |
---|
[500] | 52 | echo '<h2 class="page-title">'.__('Add a link to an entry').'</h2>'; |
---|
[0] | 53 | |
---|
[995] | 54 | echo '<form action="popup_posts.php" method="post">'. |
---|
[1399] | 55 | '<p><label for"type" class="classic">'.__('Entry type:').'</label> '.form::combo('type',$type_combo,$type).''. |
---|
| 56 | $core->formNonce().'</p>'. |
---|
[995] | 57 | '<noscript><div><input type="submit" value="'.__('Ok').'" /></div></noscript>'. |
---|
| 58 | '</form>'; |
---|
| 59 | |
---|
[0] | 60 | echo '<form action="popup_posts.php" method="get">'. |
---|
[1399] | 61 | '<p><label for="q" class="classic">'.__('Search entry:').'</label> '.form::field('q',30,255,html::escapeHTML($q)). |
---|
| 62 | ' <input type="submit" value="'.__('Search').'" />'. |
---|
[995] | 63 | form::hidden('type',html::escapeHTML($type)). |
---|
[1399] | 64 | '</p></form>'; |
---|
[0] | 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 | ?> |
---|