Dotclear


Ignore:
Timestamp:
03/02/18 15:55:06 (8 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
default
Message:

Use specialized input fields (color, email, url, number, …) where is relevant

File:
1 edited

Legend:

Unmodified
Added
Removed
  • admin/search.php

    r3182 r3725  
    1111# -- END LICENSE BLOCK ----------------------------------------- 
    1212 
    13 require dirname(__FILE__).'/../inc/admin/prepend.php'; 
     13require dirname(__FILE__) . '/../inc/admin/prepend.php'; 
    1414 
    1515dcPage::check('usage,contentadmin'); 
    1616 
    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); 
    1818$qtype = !empty($_REQUEST['qtype']) ? $_REQUEST['qtype'] : 'p'; 
    1919if ($qtype != 'c' && $qtype != 'p') { 
    20      $qtype = 'p'; 
     20    $qtype = 'p'; 
    2121} 
    2222 
    2323$starting_scripts = ''; 
    2424 
    25 $page = !empty($_GET['page']) ? max(1,(integer) $_GET['page']) : 1; 
    26 $nb_per_page =  30; 
     25$page        = !empty($_GET['page']) ? max(1, (integer) $_GET['page']) : 1; 
     26$nb_per_page = 30; 
    2727 
     28if ($q) { 
     29    $q = html::escapeHTML($q); 
    2830 
    29 if ($q) 
    30 { 
    31      $q = html::escapeHTML($q); 
     31    $params = array(); 
    3232 
    33      $params = array(); 
     33    # Get posts 
     34    if ($qtype == 'p') { 
     35        $starting_scripts .= dcPage::jsLoad('js/_posts_list.js'); 
    3436 
    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'; 
    3941 
    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'); 
    4453 
    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'; 
    5758 
    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    } 
    7167} 
    7268 
    7369if ($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)); 
    7571 
    76      if ($posts_actions_page->process()) { 
    77           return; 
    78      } 
     72    if ($posts_actions_page->process()) { 
     73        return; 
     74    } 
    7975} 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)); 
    8177 
    82      if ($comments_actions_page->process()) { 
    83           return; 
    84      } 
     78    if ($comments_actions_page->process()) { 
     79        return; 
     80    } 
    8581} 
    8682 
    87 dcPage::open(__('Search'),$starting_scripts, 
    88      dcPage::breadcrumb( 
    89           array( 
    90                html::escapeHTML($core->blog->name) => '', 
    91                __('Search') => '' 
    92           )) 
     83dcPage::open(__('Search'), $starting_scripts, 
     84    dcPage::breadcrumb( 
     85        array( 
     86            html::escapeHTML($core->blog->name) => '', 
     87            __('Search')                        => '' 
     88        )) 
    9389); 
    9490 
    9591echo 
    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>'; 
    104100 
    105 if ($q && !$core->error->flag()) 
    106 { 
    107      $redir = html::escapeHTML($_SERVER['REQUEST_URI']); 
     101if ($q && !$core->error->flag()) { 
     102    $redir = html::escapeHTML($_SERVER['REQUEST_URI']); 
    108103 
    109      # Show posts 
    110      if ($qtype == 'p') 
    111      { 
     104    # Show posts 
     105    if ($qtype == 'p') { 
    112106 
    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           } 
     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        } 
    118112 
    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">' . 
    121115 
    122           '%s'. 
     116            '%s' . 
    123117 
    124           '<div class="two-cols">'. 
    125           '<p class="col checkboxes-helpers"></p>'. 
     118            '<div class="two-cols">' . 
     119            '<p class="col checkboxes-helpers"></p>' . 
    126120 
    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 
    140133 
    141           if ($counter->f(0) > 0) { 
    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        } 
    146139 
    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">' . 
    149142 
    150           '%s'. 
     143            '%s' . 
    151144 
    152           '<div class="two-cols">'. 
    153           '<p class="col checkboxes-helpers"></p>'. 
     145            '<div class="two-cols">' . 
     146            '<p class="col checkboxes-helpers"></p>' . 
    154147 
    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           '</form>' 
    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    } 
    164157} 
    165158 
Note: See TracChangeset for help on using the changeset viewer.

Sites map