[0] | 1 | <?php |
---|
| 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
| 3 | # |
---|
| 4 | # This file is part of Dotclear 2. |
---|
| 5 | # |
---|
[270] | 6 | # Copyright (c) 2003-2011 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 | |
---|
| 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 | } |
---|
| 52 | |
---|
| 53 | |
---|
| 54 | dcPage::open(__('Search'),$starting_scripts); |
---|
| 55 | |
---|
| 56 | echo |
---|
[500] | 57 | '<h2>'.html::escapeHTML($core->blog->name).' › <span class="page-title">'.__('Search').'</span></h2>'. |
---|
[0] | 58 | '<form action="search.php" method="get">'. |
---|
[557] | 59 | '<div class="fieldset"><h3>'.__('Search options').'</h3>'. |
---|
| 60 | '<p><label for="q">'.__('Query:').' </label>'.form::field('q',30,255,html::escapeHTML($q)).'</p>'. |
---|
| 61 | '<p><label for="qtype1" class="classic">'.form::radio(array('qtype','qtype1'),'p',$qtype == 'p').' '.__('Search entries').'</label> '. |
---|
[848] | 62 | '</p>'. |
---|
[557] | 63 | '</p><input type="submit" value="'.__('Search').'" /></p>'. |
---|
| 64 | '</div>'. |
---|
[0] | 65 | '</form>'; |
---|
| 66 | |
---|
| 67 | if ($q && !$core->error->flag()) |
---|
| 68 | { |
---|
| 69 | $redir = html::escapeHTML($_SERVER['REQUEST_URI']); |
---|
| 70 | |
---|
| 71 | # Show posts |
---|
| 72 | if ($qtype == 'p') |
---|
| 73 | { |
---|
| 74 | # Actions combo box |
---|
| 75 | $combo_action = array(); |
---|
| 76 | if ($core->auth->check('publish,contentadmin',$core->blog->id)) |
---|
| 77 | { |
---|
| 78 | $combo_action[__('publish')] = 'publish'; |
---|
| 79 | $combo_action[__('unpublish')] = 'unpublish'; |
---|
| 80 | $combo_action[__('schedule')] = 'schedule'; |
---|
| 81 | $combo_action[__('mark as pending')] = 'pending'; |
---|
| 82 | } |
---|
| 83 | $combo_action[__('change category')] = 'category'; |
---|
| 84 | if ($core->auth->check('admin',$core->blog->id)) { |
---|
| 85 | $combo_action[__('change author')] = 'author'; |
---|
| 86 | } |
---|
| 87 | if ($core->auth->check('delete,contentadmin',$core->blog->id)) |
---|
| 88 | { |
---|
[747] | 89 | $combo_action[__('Delete')] = 'delete'; |
---|
[0] | 90 | } |
---|
| 91 | |
---|
| 92 | # --BEHAVIOR-- adminPostsActionsCombo |
---|
| 93 | $core->callBehavior('adminPostsActionsCombo',array(&$combo_action)); |
---|
| 94 | |
---|
| 95 | if ($counter->f(0) > 0) { |
---|
| 96 | printf('<h3>'. |
---|
| 97 | ($counter->f(0) == 1 ? __('%d entry found') : __('%d entries found')). |
---|
| 98 | '</h3>',$counter->f(0)); |
---|
| 99 | } |
---|
| 100 | |
---|
| 101 | $post_list->display($page,$nb_per_page, |
---|
| 102 | '<form action="posts_actions.php" method="post" id="form-entries">'. |
---|
| 103 | |
---|
| 104 | '%s'. |
---|
| 105 | |
---|
| 106 | '<div class="two-cols">'. |
---|
| 107 | '<p class="col checkboxes-helpers"></p>'. |
---|
| 108 | |
---|
[125] | 109 | '<p class="col right"><label for="action1" class="classic">'.__('Selected entries action:').'</label> '. |
---|
[70] | 110 | form::combo(array('action','action1'),$combo_action). |
---|
[0] | 111 | '<input type="submit" value="'.__('ok').'" /></p>'. |
---|
| 112 | form::hidden('redir',preg_replace('/%/','%%',$redir)). |
---|
| 113 | $core->formNonce(). |
---|
| 114 | '</div>'. |
---|
| 115 | '</form>' |
---|
| 116 | ); |
---|
| 117 | } |
---|
| 118 | } |
---|
| 119 | |
---|
| 120 | |
---|
| 121 | dcPage::close(); |
---|
| 122 | ?> |
---|