[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 | |
---|
[3725] | 10 | require dirname(__FILE__) . '/../inc/admin/prepend.php'; |
---|
[0] | 11 | |
---|
| 12 | dcPage::check('usage,contentadmin'); |
---|
| 13 | |
---|
[3725] | 14 | $q = !empty($_REQUEST['q']) ? $_REQUEST['q'] : (!empty($_REQUEST['qx']) ? $_REQUEST['qx'] : null); |
---|
[2210] | 15 | $qtype = !empty($_REQUEST['qtype']) ? $_REQUEST['qtype'] : 'p'; |
---|
[0] | 16 | if ($qtype != 'c' && $qtype != 'p') { |
---|
[3725] | 17 | $qtype = 'p'; |
---|
[0] | 18 | } |
---|
| 19 | |
---|
| 20 | $starting_scripts = ''; |
---|
| 21 | |
---|
[3725] | 22 | $page = !empty($_GET['page']) ? max(1, (integer) $_GET['page']) : 1; |
---|
| 23 | $nb_per_page = 30; |
---|
[0] | 24 | |
---|
[3725] | 25 | if ($q) { |
---|
| 26 | $q = html::escapeHTML($q); |
---|
[0] | 27 | |
---|
[3874] | 28 | $params = []; |
---|
[2727] | 29 | |
---|
[3725] | 30 | # Get posts |
---|
| 31 | if ($qtype == 'p') { |
---|
| 32 | $starting_scripts .= dcPage::jsLoad('js/_posts_list.js'); |
---|
[2566] | 33 | |
---|
[3725] | 34 | $params['search'] = $q; |
---|
[3874] | 35 | $params['limit'] = [(($page - 1) * $nb_per_page), $nb_per_page]; |
---|
[3725] | 36 | $params['no_content'] = true; |
---|
| 37 | $params['order'] = 'post_dt DESC'; |
---|
[2566] | 38 | |
---|
[3725] | 39 | try { |
---|
| 40 | $posts = $core->blog->getPosts($params); |
---|
| 41 | $counter = $core->blog->getPosts($params, true); |
---|
| 42 | $post_list = new adminPostList($core, $posts, $counter->f(0)); |
---|
| 43 | } catch (Exception $e) { |
---|
| 44 | $core->error->add($e->getMessage()); |
---|
| 45 | } |
---|
| 46 | } |
---|
| 47 | # Get comments |
---|
| 48 | elseif ($qtype == 'c') { |
---|
| 49 | $starting_scripts .= dcPage::jsLoad('js/_comments.js'); |
---|
[2566] | 50 | |
---|
[3725] | 51 | $params['search'] = $q; |
---|
[3874] | 52 | $params['limit'] = [(($page - 1) * $nb_per_page), $nb_per_page]; |
---|
[3725] | 53 | $params['no_content'] = true; |
---|
| 54 | $params['order'] = 'comment_dt DESC'; |
---|
[2566] | 55 | |
---|
[3725] | 56 | try { |
---|
| 57 | $comments = $core->blog->getComments($params); |
---|
| 58 | $counter = $core->blog->getComments($params, true); |
---|
| 59 | $comment_list = new adminCommentList($core, $comments, $counter->f(0)); |
---|
| 60 | } catch (Exception $e) { |
---|
| 61 | $core->error->add($e->getMessage()); |
---|
| 62 | } |
---|
| 63 | } |
---|
[0] | 64 | } |
---|
| 65 | |
---|
[2210] | 66 | if ($qtype == 'p') { |
---|
[3874] | 67 | $posts_actions_page = new dcPostsActionsPage($core, $core->adminurl->get("admin.search"), ['q' => $q, 'qtype' => $qtype]); |
---|
[2210] | 68 | |
---|
[3725] | 69 | if ($posts_actions_page->process()) { |
---|
| 70 | return; |
---|
| 71 | } |
---|
[2210] | 72 | } else { |
---|
[3874] | 73 | $comments_actions_page = new dcCommentsActionsPage($core, $core->adminurl->get("admin.search"), ['q' => $q, 'qtype' => $qtype]); |
---|
[2210] | 74 | |
---|
[3725] | 75 | if ($comments_actions_page->process()) { |
---|
| 76 | return; |
---|
| 77 | } |
---|
[2210] | 78 | } |
---|
[0] | 79 | |
---|
[3725] | 80 | dcPage::open(__('Search'), $starting_scripts, |
---|
| 81 | dcPage::breadcrumb( |
---|
[3874] | 82 | [ |
---|
[3725] | 83 | html::escapeHTML($core->blog->name) => '', |
---|
| 84 | __('Search') => '' |
---|
[3874] | 85 | ]) |
---|
[1358] | 86 | ); |
---|
[1332] | 87 | |
---|
[0] | 88 | echo |
---|
[3725] | 89 | '<form action="' . $core->adminurl->get("admin.search") . '" method="get" role="search">' . |
---|
| 90 | '<div class="fieldset"><h3>' . __('Search options') . '</h3>' . |
---|
| 91 | '<p><label for="q">' . __('Query:') . ' </label>' . form::field('q', 30, 255, $q) . '</p>' . |
---|
[3874] | 92 | '<p><label for="qtype1" class="classic">' . form::radio(['qtype', 'qtype1'], 'p', $qtype == 'p') . ' ' . __('Search in entries') . '</label> ' . |
---|
| 93 | '<label for="qtype2" class="classic">' . form::radio(['qtype', 'qtype2'], 'c', $qtype == 'c') . ' ' . __('Search in comments') . '</label></p>' . |
---|
[3725] | 94 | '<p><input type="submit" value="' . __('Search') . '" /></p>' . |
---|
| 95 | '</div>' . |
---|
| 96 | '</form>'; |
---|
[0] | 97 | |
---|
[3725] | 98 | if ($q && !$core->error->flag()) { |
---|
| 99 | $redir = html::escapeHTML($_SERVER['REQUEST_URI']); |
---|
[2566] | 100 | |
---|
[3725] | 101 | # Show posts |
---|
| 102 | if ($qtype == 'p') { |
---|
[2566] | 103 | |
---|
[3725] | 104 | if ($counter->f(0) > 0) { |
---|
| 105 | printf('<h3>' . |
---|
| 106 | ($counter->f(0) == 1 ? __('%d entry found') : __('%d entries found')) . |
---|
| 107 | '</h3>', $counter->f(0)); |
---|
| 108 | } |
---|
[2566] | 109 | |
---|
[3725] | 110 | $post_list->display($page, $nb_per_page, |
---|
| 111 | '<form action="' . $core->adminurl->get("admin.search") . '" method="post" id="form-entries">' . |
---|
[2566] | 112 | |
---|
[3725] | 113 | '%s' . |
---|
[2566] | 114 | |
---|
[3725] | 115 | '<div class="two-cols">' . |
---|
| 116 | '<p class="col checkboxes-helpers"></p>' . |
---|
[2566] | 117 | |
---|
[3725] | 118 | '<p class="col right"><label for="action1" class="classic">' . __('Selected entries action:') . '</label> ' . |
---|
[3874] | 119 | form::combo(['action', 'action1'], $posts_actions_page->getCombo()) . |
---|
[3725] | 120 | '<input id="do-action" type="submit" value="' . __('ok') . '" /></p>' . |
---|
| 121 | $core->formNonce() . |
---|
| 122 | $posts_actions_page->getHiddenFields() . |
---|
| 123 | '</div>' . |
---|
| 124 | '</form>' |
---|
| 125 | ); |
---|
| 126 | } |
---|
| 127 | # Show posts |
---|
| 128 | elseif ($qtype == 'c') { |
---|
| 129 | # Actions combo box |
---|
[2566] | 130 | |
---|
[3725] | 131 | if ($counter->f(0) > 0) { |
---|
| 132 | printf('<h3>' . |
---|
| 133 | ($counter->f(0) == 1 ? __('%d comment found') : __('%d comments found')) . |
---|
| 134 | '</h3>', $counter->f(0)); |
---|
| 135 | } |
---|
[2566] | 136 | |
---|
[3725] | 137 | $comment_list->display($page, $nb_per_page, |
---|
| 138 | '<form action="' . $core->adminurl->get("admin.search") . '" method="post" id="form-comments">' . |
---|
[2566] | 139 | |
---|
[3725] | 140 | '%s' . |
---|
[2566] | 141 | |
---|
[3725] | 142 | '<div class="two-cols">' . |
---|
| 143 | '<p class="col checkboxes-helpers"></p>' . |
---|
[2566] | 144 | |
---|
[3725] | 145 | '<p class="col right"><label for="action2" class="classic">' . __('Selected comments action:') . '</label> ' . |
---|
[3874] | 146 | form::combo(['action', 'action2'], $comments_actions_page->getCombo()) . |
---|
[3725] | 147 | '<input id="do-action" type="submit" value="' . __('ok') . '" /></p>' . |
---|
| 148 | $core->formNonce() . |
---|
| 149 | $comments_actions_page->getHiddenFields() . |
---|
| 150 | '</div>' . |
---|
| 151 | '</form>' |
---|
| 152 | ); |
---|
| 153 | } |
---|
[0] | 154 | } |
---|
| 155 | |
---|
[2314] | 156 | dcPage::helpBlock('core_search'); |
---|
[0] | 157 | dcPage::close(); |
---|