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