Bugfix: Page switching had a problem with the search. And automatic reloading hadn't worked with some search terms

This commit is contained in:
Michael Vogel 2013-12-08 20:10:28 +01:00
parent bae844e367
commit d20d2f74ae
3 changed files with 16 additions and 10 deletions

View file

@ -21,7 +21,7 @@ if(! function_exists('replace_macros')) {
* @return string substituted string * @return string substituted string
*/ */
function replace_macros($s,$r) { function replace_macros($s,$r) {
$stamp1 = microtime(true); $stamp1 = microtime(true);
$a = get_app(); $a = get_app();
@ -55,7 +55,7 @@ function random_string($size = 64,$type = RANDOM_STRING_HEX) {
if(! function_exists('notags')) { if(! function_exists('notags')) {
/** /**
* This is our primary input filter. * This is our primary input filter.
* *
* The high bit hack only involved some old IE browser, forget which (IE5/Mac?) * The high bit hack only involved some old IE browser, forget which (IE5/Mac?)
* that had an XSS attack vector due to stripping the high-bit on an 8-bit character * that had an XSS attack vector due to stripping the high-bit on an 8-bit character
@ -278,12 +278,18 @@ function paginate_data(&$a, $count=null) {
$stripped = str_replace('q=','',$stripped); $stripped = str_replace('q=','',$stripped);
$stripped = trim($stripped,'/'); $stripped = trim($stripped,'/');
$pagenum = $a->pager['page']; $pagenum = $a->pager['page'];
if (!strstr($stripped, "?")) {
$pos = strpos($stripped, "&");
$stripped = substr($stripped, 0, $pos)."?".substr($stripped, $pos + 1);
}
$url = $a->get_baseurl() . '/' . $stripped; $url = $a->get_baseurl() . '/' . $stripped;
$data = array(); $data = array();
function _l(&$d, $name, $url, $text, $class="") { function _l(&$d, $name, $url, $text, $class="") {
$d[$name] = array('url'=>$url, 'text'=>$text, 'class'=>$class); $d[$name] = array('url'=>$url, 'text'=>$text, 'class'=>$class);
} }
@ -359,7 +365,7 @@ if(! function_exists('paginate')) {
* @return string html for pagination #FIXME remove html * @return string html for pagination #FIXME remove html
*/ */
function paginate(&$a) { function paginate(&$a) {
$data = paginate_data($a); $data = paginate_data($a);
$tpl = get_markup_template("paginate.tpl"); $tpl = get_markup_template("paginate.tpl");
return replace_macros($tpl, array("pager" => $data)); return replace_macros($tpl, array("pager" => $data));

View file

@ -471,7 +471,7 @@ if ($_GET["mode"] == "raw") {
foreach ($_GET AS $param => $value) foreach ($_GET AS $param => $value)
if (($param != "page") AND ($param != "q")) if (($param != "page") AND ($param != "q"))
$reload_uri .= "&".$param."=".$value; $reload_uri .= "&".$param."=".urlencode($value);
$a->page['htmlhead'] .= <<< EOT $a->page['htmlhead'] .= <<< EOT
<script type="text/javascript"> <script type="text/javascript">

View file

@ -115,21 +115,21 @@ function network_init(&$a) {
'/network?f=&bmark=1', //bookmarked '/network?f=&bmark=1', //bookmarked
'/network?f=&spam=1', //spam '/network?f=&spam=1', //spam
); );
// redirect if current selected tab is 'no_active' and // redirect if current selected tab is 'no_active' and
// last selected tab is _not_ 'all_active'. // last selected tab is _not_ 'all_active'.
// and this isn't a date query // and this isn't a date query
if ($sel_tabs[0] == 'active' && $last_sel_tabs[0]!='active' && (! $is_a_date_query)) { if ($sel_tabs[0] == 'active' && $last_sel_tabs[0]!='active' && (! $is_a_date_query)) {
$k = array_search('active', $last_sel_tabs); $k = array_search('active', $last_sel_tabs);
// merge tab querystring with request querystring // merge tab querystring with request querystring
$dest_qa = array(); $dest_qa = array();
list($dest_url,$dest_qs) = explode("?", $tab_urls[$k]); list($dest_url,$dest_qs) = explode("?", $tab_urls[$k]);
parse_str( $dest_qs, $dest_qa); parse_str( $dest_qs, $dest_qa);
$dest_qa = array_merge($query_array, $dest_qa); $dest_qa = array_merge($query_array, $dest_qa);
$dest_qs = build_querystring($dest_qa); $dest_qs = build_querystring($dest_qa);
// groups filter is in form of "network/nnn". Add it to $dest_url, if it's possible // groups filter is in form of "network/nnn". Add it to $dest_url, if it's possible
if ($a->argc==2 && is_numeric($a->argv[1]) && strpos($dest_url, "/",1)===false){ if ($a->argc==2 && is_numeric($a->argv[1]) && strpos($dest_url, "/",1)===false){
$dest_url .= "/".$a->argv[1]; $dest_url .= "/".$a->argv[1];