Changeset 2091 in ExiteCMS


Ignore:
Timestamp:
12/04/08 14:50:04 (3 years ago)
Author:
WanWizard
Message:

rewritten part of the search module logic. Now a session variable is used to store the search parameters, so they don't have to be exposed in the URL anymore

Location:
modules/common
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • modules/common/download_statistics/php-files/modules/download_statistics/search.files.php

    r2043 r2091  
    3232    } else { 
    3333 
    34         // get the required variables (could be POST or GET vars!) 
    35         if (isset($stext)) { 
    36             $stext = stripinput($stext); 
     34        // make sure the sub search ID is defined 
     35        if (!isset($sub_search_id)) $sub_search_id = 0; 
     36 
     37        // retrieve the search criteria 
     38        if (isset($_SESSION['search'])) { 
     39            // from the session store (used when paging through the results) 
     40            $stext = $_SESSION['search']['stext']; 
     41            $qtype = $_SESSION['search']['qtype']; 
     42            $datelimit = $_SESSION['search']['datelimit']; 
     43            $boolean = $_SESSION['search']['boolean']; 
     44            $sortby = $_SESSION['search']['sortby']; 
     45            $order = $_SESSION['search']['order']; 
     46            $limit = $_SESSION['search']['limit']; 
     47            $contentfilter_forums = $_SESSION['search']['contentfilter_forums']; 
     48            $contentfilter_users = $_SESSION['search']['contentfilter_users']; 
    3749        } else { 
     50            // from the search form 
    3851            $stext = isset($_POST['stext']) ? stripinput($_POST['stext']) : ""; 
     52            $stext = str_replace(',', ' ', $stext); 
     53            $boolean = isset($_POST['boolean']) ? 0 : 1; 
     54            $qtype = isset($_POST['qtype']) ? stripinput($_POST['qtype']) : "AND"; 
     55            if ($qtype != "OR" && $qtype != "AND") { 
     56                $qtype = "AND"; 
     57            } 
     58            $sortby = isset($_POST['sortby']) ? stripinput($_POST['sortby']) : "score"; 
     59            if (!in_array($sortby, $select_filters)) { 
     60                $sortby = $select_filters[0]; 
     61            } 
     62            $order = isset($_POST['order']) && isNum($_POST['order']) ? $_POST['order'] : 1; 
     63            $limit = isset($_POST['limit']) && isNum($_POST['limit']) ? $_POST['limit'] : 0; 
     64            $datelimit = isset($_POST['datelimit']) && isNum($_POST['datelimit']) ? $_POST['datelimit'] : 0; 
     65            // add a forum filter if requested 
     66            if (isset($_POST['contentfilter_forums']) && isNum($_POST['contentfilter_forums']) && $_POST['contentfilter_forums'] > 0 ) { 
     67                $contentfilter_forums =  stripinput($_POST['contentfilter_forums']); 
     68            } 
     69            // add an author if requested 
     70            if (isset($_POST['contentfilter_users']) && isNum($_POST['contentfilter_users']) && $_POST['contentfilter_users'] > 0 ) { 
     71                $contentfilter_users = stripinput($_POST['contentfilter_users']); 
     72            } 
    3973        } 
    40         $stext = str_replace(',', ' ', $stext); 
    4174        $variables['stext'] = $stext; 
    4275 
    43         if (!isset($qtype)) { 
    44             $qtype = isset($_POST['qtype']) ? $_POST['qtype'] : "AND"; 
    45         } 
    46         if ($qtype != "OR" && $qtype != "AND") { 
    47             $qtype = "AND"; 
    48         } 
    49         if (!isset($datelimit)) { 
    50             $datelimit = isset($_POST['datelimit']) ? $_POST['datelimit'] : 0; 
    51         } 
    52         if (!isNum($datelimit)) { 
    53             $datelimit = 0; 
    54         } 
    55         if (!isset($sortby)) { 
    56             $sortby = isset($_POST['sortby']) ? $_POST['sortby'] : "score"; 
    57         } 
    58         if (!in_array($sortby, $select_filters)) { 
    59             $sortby = $select_filters[0]; 
    60         } 
    61         if (!isset($order)) { 
    62             $order = isset($_POST['order']) ? $_POST['order'] : 1; 
    63         } 
    64         if (!isNum($order)) { 
    65             $order = 1; 
    66         } 
    67         if (!isset($limit)) { 
    68             $limit = isset($_POST['limit']) ? $_POST['limit'] : 0; 
    69         } 
    70         if (!isNum($limit)) { 
    71             $limit = 0; 
    72         } 
    73         if (!isset($boolean)) { 
    74             $boolean = isset($_POST['boolean']) ? 0 : 1; 
    75         } 
    76  
    77         if (!isset($sub_search_id)) $sub_search_id = 0; 
    78  
    79         // construct the page navigator URL to allow paging 
    80         $variables['pagenav_url'] = FUSION_SELF."?action=search&search_id=".$search_id."&"; 
    81         $variables['pagenav_url'] .= "stext=".urlencode($stext)."&"; 
    82         $variables['pagenav_url'] .= "boolean=".$boolean."&"; 
    83         $variables['pagenav_url'] .= "datelimit=".$datelimit."&"; 
    84         $variables['pagenav_url'] .= "sortby=".$sortby."&"; 
    85         $variables['pagenav_url'] .= "order=".$order."&"; 
    86         $variables['pagenav_url'] .= "limit=".$limit."&"; 
     76        // store the search parameters in the session record 
     77        $_SESSION['search'] = array('stext' => $stext, 
     78                                    'qtype' => $qtype, 
     79                                    'datelimit' => $datelimit, 
     80                                    'boolean' => $boolean, 
     81                                    'sortby' => $sortby, 
     82                                    'order' => $order, 
     83                                    'limit' => $limit, 
     84                                    'contentfilter_forums' => $contentfilter_forums, 
     85                                    'contentfilter_users' => $contentfilter_users 
     86                                ); 
    8787 
    8888        // basis of the query for this search 
  • modules/common/wiki/php-files/modules/wiki/search.wiki.php

    r2043 r2091  
    5050    } else { 
    5151 
    52         // get the required variables (could be POST or GET vars!) 
    53         if (isset($stext)) { 
    54             $stext = stripinput($stext); 
     52        // make sure the sub search ID is defined 
     53        if (!isset($sub_search_id)) $sub_search_id = 0; 
     54 
     55        // retrieve the search criteria 
     56        if (isset($_SESSION['search'])) { 
     57            // from the session store (used when paging through the results) 
     58            $stext = $_SESSION['search']['stext']; 
     59            $qtype = $_SESSION['search']['qtype']; 
     60            $datelimit = $_SESSION['search']['datelimit']; 
     61            $boolean = $_SESSION['search']['boolean']; 
     62            $sortby = $_SESSION['search']['sortby']; 
     63            $order = $_SESSION['search']['order']; 
     64            $limit = $_SESSION['search']['limit']; 
     65            $contentfilter_forums = $_SESSION['search']['contentfilter_forums']; 
     66            $contentfilter_users = $_SESSION['search']['contentfilter_users']; 
    5567        } else { 
     68            // from the search form 
    5669            $stext = isset($_POST['stext']) ? stripinput($_POST['stext']) : ""; 
    57         } 
    58         $stext = str_replace(',', ' ', $stext); 
     70            $stext = str_replace(',', ' ', $stext); 
     71            $boolean = isset($_POST['boolean']) ? 0 : 1; 
     72            $qtype = isset($_POST['qtype']) ? stripinput($_POST['qtype']) : "AND"; 
     73            if ($qtype != "OR" && $qtype != "AND") { 
     74                $qtype = "AND"; 
     75            } 
     76            $sortby = isset($_POST['sortby']) ? stripinput($_POST['sortby']) : "score"; 
     77            if (!in_array($sortby, $select_filters)) { 
     78                $sortby = $select_filters[0]; 
     79            } 
     80            $order = isset($_POST['order']) && isNum($_POST['order']) ? $_POST['order'] : 1; 
     81            $limit = isset($_POST['limit']) && isNum($_POST['limit']) ? $_POST['limit'] : 0; 
     82            $datelimit = isset($_POST['datelimit']) && isNum($_POST['datelimit']) ? $_POST['datelimit'] : 0; 
     83            // add a forum filter if requested 
     84            if (isset($_POST['contentfilter_forums']) && isNum($_POST['contentfilter_forums']) && $_POST['contentfilter_forums'] > 0 ) { 
     85                $contentfilter_forums =  stripinput($_POST['contentfilter_forums']); 
     86            } 
     87            // add an author if requested 
     88            if (isset($_POST['contentfilter_users']) && isNum($_POST['contentfilter_users']) && $_POST['contentfilter_users'] > 0 ) { 
     89                $contentfilter_users = stripinput($_POST['contentfilter_users']); 
     90            } 
     91        } 
    5992        $variables['stext'] = $stext; 
    6093 
    61         if (!isset($qtype)) { 
    62             $qtype = isset($_POST['qtype']) ? $_POST['qtype'] : "AND"; 
    63         } 
    64         if ($qtype != "OR" && $qtype != "AND") { 
    65             $qtype = "AND"; 
    66         } 
    67         if (!isset($datelimit)) { 
    68             $datelimit = isset($_POST['datelimit']) ? $_POST['datelimit'] : 0; 
    69         } 
    70         if (!isNum($datelimit)) { 
    71             $datelimit = 0; 
    72         } 
    73         if (!isset($sortby)) { 
    74             $sortby = isset($_POST['sortby']) ? $_POST['sortby'] : "score"; 
    75         } 
    76         if (!in_array($sortby, $select_filters)) { 
    77             $sortby = $select_filters[0]; 
    78         } 
    79         if (!isset($order)) { 
    80             $order = isset($_POST['order']) ? $_POST['order'] : 1; 
    81         } 
    82         if (!isNum($order)) { 
    83             $order = 1; 
    84         } 
    85         if (!isset($limit)) { 
    86             $limit = isset($_POST['limit']) ? $_POST['limit'] : 0; 
    87         } 
    88         if (!isNum($limit)) { 
    89             $limit = 0; 
    90         } 
    91         if (!isset($boolean)) { 
    92             $boolean = isset($_POST['boolean']) ? 0 : 1; 
    93         } 
    94  
    95         if (!isset($sub_search_id)) $sub_search_id = 0; 
    96  
    97         // construct the page navigator URL to allow paging 
    98         $variables['pagenav_url'] = FUSION_SELF."?action=search&search_id=".$search_id."&"; 
    99         $variables['pagenav_url'] .= "stext=".urlencode($stext)."&"; 
    100         $variables['pagenav_url'] .= "boolean=".$boolean."&"; 
    101         $variables['pagenav_url'] .= "datelimit=".$datelimit."&"; 
    102         $variables['pagenav_url'] .= "sortby=".$sortby."&"; 
    103         $variables['pagenav_url'] .= "order=".$order."&"; 
    104         $variables['pagenav_url'] .= "limit=".$limit."&"; 
     94        // store the search parameters in the session record 
     95        $_SESSION['search'] = array('stext' => $stext, 
     96                                    'qtype' => $qtype, 
     97                                    'datelimit' => $datelimit, 
     98                                    'boolean' => $boolean, 
     99                                    'sortby' => $sortby, 
     100                                    'order' => $order, 
     101                                    'limit' => $limit, 
     102                                    'contentfilter_forums' => $contentfilter_forums, 
     103                                    'contentfilter_users' => $contentfilter_users 
     104                                ); 
    105105 
    106106        // basis of the query for this search 
  • modules/common/wiki/php-files/modules/wiki/templates/modules.wiki.search.wiki.tpl

    r2043 r2091  
    2626            {$reportvars.output[idx].tag} 
    2727        {/if} 
    28         <br />&nbsp;<span class='small'> 
     28        <blockquote>{$reportvars.output[idx].snippet}</blockquote> 
     29        &nbsp;<span class='small'> 
    2930            <font class='smallalt'>{$locale.425}</font> {$reportvars.output[idx].time|date_format:"longdate"} -  
    3031            <font class='smallalt'>{$locale.426}</font> 
     
    3536            {/if} 
    3637        </span> 
    37         <blockquote>{$reportvars.output[idx].snippet}</blockquote> 
     38        <br /><br /> 
    3839    {/section} 
    3940{else} 
Note: See TracChangeset for help on using the changeset viewer.