| 1 | <?php | 
|---|
| 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- | 
|---|
| 3 | # | 
|---|
| 4 | # This file is part of Dotclear 2. | 
|---|
| 5 | # | 
|---|
| 6 | # Copyright (c) 2003-2011 Olivier Meunier & Association Dotclear | 
|---|
| 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; | 
|---|
| 18 | $qtype = !empty($_GET['qtype']) ? $_GET['qtype'] : 'p'; | 
|---|
| 19 | if ($qtype != 'c' && $qtype != 'p') { | 
|---|
| 20 |      $qtype = 'p'; | 
|---|
| 21 | } | 
|---|
| 22 |  | 
|---|
| 23 | $starting_scripts = ''; | 
|---|
| 24 |  | 
|---|
| 25 | $page = !empty($_GET['page']) ? (integer) $_GET['page'] : 1; | 
|---|
| 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 |  | 
|---|
| 71 |  | 
|---|
| 72 | dcPage::open(__('Search'),$starting_scripts); | 
|---|
| 73 |  | 
|---|
| 74 | echo | 
|---|
| 75 | '<h2>'.html::escapeHTML($core->blog->name).' › <span class="page-title">'.__('Search').'</span></h2>'. | 
|---|
| 76 | '<form action="search.php" method="get">'. | 
|---|
| 77 | '<div class="fieldset"><h3>'.__('Search options').'</h3>'. | 
|---|
| 78 | '<p><label for="q">'.__('Query:').' </label>'.form::field('q',30,255,html::escapeHTML($q)).'</p>'. | 
|---|
| 79 | '<p><label for="qtype1" class="classic">'.form::radio(array('qtype','qtype1'),'p',$qtype == 'p').' '.__('Search entries').'</label> '. | 
|---|
| 80 | '<label for="qtype2" class="classic">'.form::radio(array('qtype','qtype2'),'c',$qtype == 'c').' '.__('Search comments').'</label></p>'. | 
|---|
| 81 | '</p><input type="submit" value="'.__('Search').'" /></p>'. | 
|---|
| 82 | '</div>'. | 
|---|
| 83 | '</form>'; | 
|---|
| 84 |  | 
|---|
| 85 | if ($q && !$core->error->flag()) | 
|---|
| 86 | { | 
|---|
| 87 |      $redir = html::escapeHTML($_SERVER['REQUEST_URI']); | 
|---|
| 88 |       | 
|---|
| 89 |      # Show posts | 
|---|
| 90 |      if ($qtype == 'p') | 
|---|
| 91 |      { | 
|---|
| 92 |           # Actions combo box | 
|---|
| 93 |           $combo_action = array(); | 
|---|
| 94 |           if ($core->auth->check('publish,contentadmin',$core->blog->id)) | 
|---|
| 95 |           { | 
|---|
| 96 |                $combo_action[__('publish')] = 'publish'; | 
|---|
| 97 |                $combo_action[__('unpublish')] = 'unpublish'; | 
|---|
| 98 |                $combo_action[__('schedule')] = 'schedule'; | 
|---|
| 99 |                $combo_action[__('mark as pending')] = 'pending'; | 
|---|
| 100 |           } | 
|---|
| 101 |           $combo_action[__('change category')] = 'category'; | 
|---|
| 102 |           if ($core->auth->check('admin',$core->blog->id)) { | 
|---|
| 103 |                $combo_action[__('change author')] = 'author'; | 
|---|
| 104 |           } | 
|---|
| 105 |           if ($core->auth->check('delete,contentadmin',$core->blog->id)) | 
|---|
| 106 |           { | 
|---|
| 107 |                $combo_action[__('Delete')] = 'delete'; | 
|---|
| 108 |           } | 
|---|
| 109 |            | 
|---|
| 110 |           # --BEHAVIOR-- adminPostsActionsCombo | 
|---|
| 111 |           $core->callBehavior('adminPostsActionsCombo',array(&$combo_action)); | 
|---|
| 112 |            | 
|---|
| 113 |           if ($counter->f(0) > 0) { | 
|---|
| 114 |                printf('<h3>'. | 
|---|
| 115 |                ($counter->f(0) == 1 ? __('%d entry found') : __('%d entries found')). | 
|---|
| 116 |                '</h3>',$counter->f(0)); | 
|---|
| 117 |           } | 
|---|
| 118 |            | 
|---|
| 119 |           $post_list->display($page,$nb_per_page, | 
|---|
| 120 |           '<form action="posts_actions.php" method="post" id="form-entries">'. | 
|---|
| 121 |            | 
|---|
| 122 |           '%s'. | 
|---|
| 123 |            | 
|---|
| 124 |           '<div class="two-cols">'. | 
|---|
| 125 |           '<p class="col checkboxes-helpers"></p>'. | 
|---|
| 126 |            | 
|---|
| 127 |           '<p class="col right"><label for="action1" class="classic">'.__('Selected entries action:').'</label> '. | 
|---|
| 128 |           form::combo(array('action','action1'),$combo_action). | 
|---|
| 129 |           '<input type="submit" value="'.__('ok').'" /></p>'. | 
|---|
| 130 |           form::hidden('redir',preg_replace('/%/','%%',$redir)). | 
|---|
| 131 |           $core->formNonce(). | 
|---|
| 132 |           '</div>'. | 
|---|
| 133 |           '</form>' | 
|---|
| 134 |           ); | 
|---|
| 135 |      } | 
|---|
| 136 |      # Show posts | 
|---|
| 137 |      elseif ($qtype == 'c') | 
|---|
| 138 |      { | 
|---|
| 139 |           # Actions combo box | 
|---|
| 140 |           $combo_action = array(); | 
|---|
| 141 |           if ($core->auth->check('publish,contentadmin',$core->blog->id)) | 
|---|
| 142 |           { | 
|---|
| 143 |                $combo_action[__('publish')] = 'publish'; | 
|---|
| 144 |                $combo_action[__('unpublish')] = 'unpublish'; | 
|---|
| 145 |                $combo_action[__('mark as pending')] = 'pending'; | 
|---|
| 146 |                $combo_action[__('mark as junk')] = 'junk'; | 
|---|
| 147 |           } | 
|---|
| 148 |           if ($core->auth->check('delete,contentadmin',$core->blog->id)) | 
|---|
| 149 |           { | 
|---|
| 150 |                $combo_action[__('Delete')] = 'delete'; | 
|---|
| 151 |           } | 
|---|
| 152 |            | 
|---|
| 153 |           if ($counter->f(0) > 0) { | 
|---|
| 154 |                printf('<h3>'. | 
|---|
| 155 |                ($counter->f(0) == 1 ? __('%d comment found') : __('%d comments found')). | 
|---|
| 156 |                '</h3>',$counter->f(0)); | 
|---|
| 157 |           } | 
|---|
| 158 |            | 
|---|
| 159 |           $comment_list->display($page,$nb_per_page, | 
|---|
| 160 |           '<form action="comments_actions.php" method="post" id="form-comments">'. | 
|---|
| 161 |            | 
|---|
| 162 |           '%s'. | 
|---|
| 163 |            | 
|---|
| 164 |           '<div class="two-cols">'. | 
|---|
| 165 |           '<p class="col checkboxes-helpers"></p>'. | 
|---|
| 166 |            | 
|---|
| 167 |           '<p class="col right"><label for="action2" class="classic">'.__('Selected comments action:').'</label> '. | 
|---|
| 168 |           form::combo(array('action','action2'),$combo_action). | 
|---|
| 169 |           '<input type="submit" value="'.__('ok').'" /></p>'. | 
|---|
| 170 |           form::hidden('redir',preg_replace('/%/','%%',$redir)). | 
|---|
| 171 |           $core->formNonce(). | 
|---|
| 172 |           '</div>'. | 
|---|
| 173 |           '</form>' | 
|---|
| 174 |           ); | 
|---|
| 175 |      } | 
|---|
| 176 | } | 
|---|
| 177 |  | 
|---|
| 178 |  | 
|---|
| 179 | dcPage::close(); | 
|---|
| 180 | ?> | 
|---|