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