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