[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; |
---|
[2756] | 18 | $plugin_id = !empty($_GET['plugin_id']) ? html::sanitizeURL($_GET['plugin_id']) : ''; |
---|
[0] | 19 | |
---|
[1912] | 20 | $page = !empty($_GET['page']) ? max(1,(integer) $_GET['page']) : 1; |
---|
[0] | 21 | $nb_per_page = 10; |
---|
| 22 | |
---|
[2812] | 23 | $type = !empty($_GET['type']) ? $_GET['type'] : null; |
---|
| 24 | |
---|
[995] | 25 | $post_types = $core->getPostTypes(); |
---|
| 26 | foreach ($post_types as $k => $v) { |
---|
| 27 | $type_combo[__($k)] = (string) $k; |
---|
| 28 | } |
---|
| 29 | if (!in_array($type, $type_combo)) { |
---|
| 30 | $type = null; |
---|
| 31 | } |
---|
| 32 | |
---|
[0] | 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 | |
---|
| 38 | if ($q) { |
---|
| 39 | $params['search'] = $q; |
---|
| 40 | } |
---|
| 41 | |
---|
[995] | 42 | if ($type) { |
---|
| 43 | $params['post_type'] = $type; |
---|
| 44 | } |
---|
| 45 | |
---|
[0] | 46 | dcPage::openPopup(__('Add a link to an entry'), |
---|
| 47 | dcPage::jsLoad('js/_posts_list.js'). |
---|
[2756] | 48 | $core->callBehavior('adminPopupPosts', $plugin_id)); |
---|
[0] | 49 | |
---|
[500] | 50 | echo '<h2 class="page-title">'.__('Add a link to an entry').'</h2>'; |
---|
[0] | 51 | |
---|
[2811] | 52 | echo '<form action="popup_posts.php" method="get">'. |
---|
| 53 | '<p><label for="type" class="classic">'.__('Entry type:').'</label> '.form::combo('type',$type_combo,$type).''. |
---|
[995] | 54 | '<noscript><div><input type="submit" value="'.__('Ok').'" /></div></noscript>'. |
---|
[2971] | 55 | form::hidden('plugin_id',html::escapeHTML($plugin_id)).'</p>'. |
---|
[995] | 56 | '</form>'; |
---|
| 57 | |
---|
[0] | 58 | echo '<form action="popup_posts.php" method="get">'. |
---|
[1399] | 59 | '<p><label for="q" class="classic">'.__('Search entry:').'</label> '.form::field('q',30,255,html::escapeHTML($q)). |
---|
| 60 | ' <input type="submit" value="'.__('Search').'" />'. |
---|
[2844] | 61 | form::hidden('plugin_id',html::escapeHTML($plugin_id)). |
---|
[995] | 62 | form::hidden('type',html::escapeHTML($type)). |
---|
[1399] | 63 | '</p></form>'; |
---|
[0] | 64 | |
---|
| 65 | try { |
---|
| 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 | |
---|
| 73 | echo '<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); |
---|
| 75 | echo '</div>'; |
---|
| 76 | |
---|
| 77 | echo '<p><a class="button" href="#" id="link-insert-cancel">'.__('cancel').'</a></p>'; |
---|
| 78 | |
---|
| 79 | dcPage::closePopup(); |
---|