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