Keeping an offset for page switching: This helps so that you don't see old messages
This commit is contained in:
parent
d20d2f74ae
commit
7e5c8ab91c
3 changed files with 41 additions and 16 deletions
|
@ -279,6 +279,9 @@ function paginate_data(&$a, $count=null) {
|
||||||
$stripped = trim($stripped,'/');
|
$stripped = trim($stripped,'/');
|
||||||
$pagenum = $a->pager['page'];
|
$pagenum = $a->pager['page'];
|
||||||
|
|
||||||
|
if (($a->page_offset != "") AND !strstr($stripped, "&offset="))
|
||||||
|
$stripped .= "&offset=".urlencode($a->page_offset);
|
||||||
|
|
||||||
if (!strstr($stripped, "?")) {
|
if (!strstr($stripped, "?")) {
|
||||||
$pos = strpos($stripped, "&");
|
$pos = strpos($stripped, "&");
|
||||||
$stripped = substr($stripped, 0, $pos)."?".substr($stripped, $pos + 1);
|
$stripped = substr($stripped, 0, $pos)."?".substr($stripped, $pos + 1);
|
||||||
|
@ -286,7 +289,6 @@ function paginate_data(&$a, $count=null) {
|
||||||
|
|
||||||
$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="") {
|
||||||
|
|
||||||
|
@ -307,7 +309,7 @@ function paginate_data(&$a, $count=null) {
|
||||||
|
|
||||||
_l($data, "first", $url."&page=1", t('first'));
|
_l($data, "first", $url."&page=1", t('first'));
|
||||||
|
|
||||||
|
|
||||||
$numpages = $a->pager['total'] / $a->pager['itemspage'];
|
$numpages = $a->pager['total'] / $a->pager['itemspage'];
|
||||||
|
|
||||||
$numstart = 1;
|
$numstart = 1;
|
||||||
|
@ -338,11 +340,11 @@ function paginate_data(&$a, $count=null) {
|
||||||
|
|
||||||
$lastpage = (($numpages > intval($numpages)) ? intval($numpages)+1 : $numpages);
|
$lastpage = (($numpages > intval($numpages)) ? intval($numpages)+1 : $numpages);
|
||||||
_l($data, "last", $url."&page=$lastpage", t('last'));
|
_l($data, "last", $url."&page=$lastpage", t('last'));
|
||||||
|
|
||||||
if(($a->pager['total'] - ($a->pager['itemspage'] * $a->pager['page'])) > 0)
|
if(($a->pager['total'] - ($a->pager['itemspage'] * $a->pager['page'])) > 0)
|
||||||
_l($data, "next", $url."&page=".($a->pager['page'] + 1), t('next'));
|
_l($data, "next", $url."&page=".($a->pager['page'] + 1), t('next'));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $data;
|
return $data;
|
||||||
|
|
||||||
|
@ -384,14 +386,14 @@ function alt_pager(&$a, $i) {
|
||||||
$data = paginate_data($a, $i);
|
$data = paginate_data($a, $i);
|
||||||
$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));
|
||||||
|
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
|
||||||
if(! function_exists('expand_acl')) {
|
if(! function_exists('expand_acl')) {
|
||||||
/**
|
/**
|
||||||
* Turn user/group ACLs stored as angle bracketed text into arrays
|
* Turn user/group ACLs stored as angle bracketed text into arrays
|
||||||
*
|
*
|
||||||
* @param string $s
|
* @param string $s
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -473,6 +473,10 @@ if ($_GET["mode"] == "raw") {
|
||||||
if (($param != "page") AND ($param != "q"))
|
if (($param != "page") AND ($param != "q"))
|
||||||
$reload_uri .= "&".$param."=".urlencode($value);
|
$reload_uri .= "&".$param."=".urlencode($value);
|
||||||
|
|
||||||
|
if (($a->page_offset != "") AND !strstr($reload_uri, "&offset="))
|
||||||
|
$reload_uri .= "&offset=".urlencode($a->page_offset);
|
||||||
|
|
||||||
|
|
||||||
$a->page['htmlhead'] .= <<< EOT
|
$a->page['htmlhead'] .= <<< EOT
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
|
|
@ -194,8 +194,8 @@ function saved_searches($search) {
|
||||||
|
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
|
|
||||||
$srchurl = '/network?f='
|
$srchurl = '/network?f='
|
||||||
. ((x($_GET,'cid')) ? '&cid=' . $_GET['cid'] : '')
|
. ((x($_GET,'cid')) ? '&cid=' . $_GET['cid'] : '')
|
||||||
. ((x($_GET,'star')) ? '&star=' . $_GET['star'] : '')
|
. ((x($_GET,'star')) ? '&star=' . $_GET['star'] : '')
|
||||||
. ((x($_GET,'bmark')) ? '&bmark=' . $_GET['bmark'] : '')
|
. ((x($_GET,'bmark')) ? '&bmark=' . $_GET['bmark'] : '')
|
||||||
. ((x($_GET,'conv')) ? '&conv=' . $_GET['conv'] : '')
|
. ((x($_GET,'conv')) ? '&conv=' . $_GET['conv'] : '')
|
||||||
|
@ -204,7 +204,7 @@ function saved_searches($search) {
|
||||||
. ((x($_GET,'cmax')) ? '&cmax=' . $_GET['cmax'] : '')
|
. ((x($_GET,'cmax')) ? '&cmax=' . $_GET['cmax'] : '')
|
||||||
. ((x($_GET,'file')) ? '&file=' . $_GET['file'] : '');
|
. ((x($_GET,'file')) ? '&file=' . $_GET['file'] : '');
|
||||||
;
|
;
|
||||||
|
|
||||||
$o = '';
|
$o = '';
|
||||||
|
|
||||||
$r = q("select `id`,`term` from `search` WHERE `uid` = %d",
|
$r = q("select `id`,`term` from `search` WHERE `uid` = %d",
|
||||||
|
@ -264,7 +264,7 @@ function network_query_get_sel_tab($a) {
|
||||||
$spam_active = '';
|
$spam_active = '';
|
||||||
$postord_active = '';
|
$postord_active = '';
|
||||||
|
|
||||||
if(($a->argc > 1 && $a->argv[1] === 'new')
|
if(($a->argc > 1 && $a->argv[1] === 'new')
|
||||||
|| ($a->argc > 2 && $a->argv[2] === 'new')) {
|
|| ($a->argc > 2 && $a->argv[2] === 'new')) {
|
||||||
$new_active = 'active';
|
$new_active = 'active';
|
||||||
}
|
}
|
||||||
|
@ -291,8 +291,8 @@ function network_query_get_sel_tab($a) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (($new_active == '')
|
if (($new_active == '')
|
||||||
&& ($starred_active == '')
|
&& ($starred_active == '')
|
||||||
&& ($bookmarked_active == '')
|
&& ($bookmarked_active == '')
|
||||||
&& ($conv_active == '')
|
&& ($conv_active == '')
|
||||||
&& ($search_active == '')
|
&& ($search_active == '')
|
||||||
|
@ -645,6 +645,7 @@ function network_content(&$a, $update = 0) {
|
||||||
$sql_extra3 = (($nouveau) ? '' : $sql_extra3);
|
$sql_extra3 = (($nouveau) ? '' : $sql_extra3);
|
||||||
//$sql_order = "`item`.`received`";
|
//$sql_order = "`item`.`received`";
|
||||||
$sql_order = "";
|
$sql_order = "";
|
||||||
|
$order_mode = "received";
|
||||||
|
|
||||||
if ($sql_table == "")
|
if ($sql_table == "")
|
||||||
$sql_table = "`item`";
|
$sql_table = "`item`";
|
||||||
|
@ -673,6 +674,7 @@ function network_content(&$a, $update = 0) {
|
||||||
dbesc(protect_sprintf($search)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG), intval(local_user()));
|
dbesc(protect_sprintf($search)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG), intval(local_user()));
|
||||||
|
|
||||||
$sql_order = "`item`.`received`";
|
$sql_order = "`item`.`received`";
|
||||||
|
$order_mode = "received";
|
||||||
} else {
|
} else {
|
||||||
if (get_config('system','use_fulltext_engine'))
|
if (get_config('system','use_fulltext_engine'))
|
||||||
$sql_extra = sprintf(" AND MATCH (`item`.`body`, `item`.`title`) AGAINST ('%s' in boolean mode) ", dbesc(protect_sprintf($search)));
|
$sql_extra = sprintf(" AND MATCH (`item`.`body`, `item`.`title`) AGAINST ('%s' in boolean mode) ", dbesc(protect_sprintf($search)));
|
||||||
|
@ -680,6 +682,7 @@ function network_content(&$a, $update = 0) {
|
||||||
$sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(protect_sprintf(preg_quote($search))));
|
$sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(protect_sprintf(preg_quote($search))));
|
||||||
|
|
||||||
$sql_order = "`item`.`received`";
|
$sql_order = "`item`.`received`";
|
||||||
|
$order_mode = "received";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(strlen($file)) {
|
if(strlen($file)) {
|
||||||
|
@ -764,14 +767,22 @@ function network_content(&$a, $update = 0) {
|
||||||
// Normal conversation view
|
// Normal conversation view
|
||||||
|
|
||||||
|
|
||||||
if($order === 'post')
|
if($order === 'post') {
|
||||||
$ordering = "`created`";
|
$ordering = "`created`";
|
||||||
else
|
if ($sql_order == "")
|
||||||
$ordering = "`commented`";
|
$order_mode = "created";
|
||||||
|
} else {
|
||||||
|
$ordering = "`commented`";
|
||||||
|
if ($sql_order == "")
|
||||||
|
$order_mode = "commented";
|
||||||
|
}
|
||||||
|
|
||||||
if ($sql_order == "")
|
if ($sql_order == "")
|
||||||
$sql_order = "`item`.$ordering";
|
$sql_order = "`item`.$ordering";
|
||||||
|
|
||||||
|
if (($_GET["offset"] != ""))
|
||||||
|
$sql_extra3 .= sprintf(" AND $sql_order <= '%s'", dbesc($_GET["offset"]));
|
||||||
|
|
||||||
// Fetch a page full of parent items for this page
|
// Fetch a page full of parent items for this page
|
||||||
|
|
||||||
if($update) {
|
if($update) {
|
||||||
|
@ -801,6 +812,7 @@ function network_content(&$a, $update = 0) {
|
||||||
|
|
||||||
$parents_arr = array();
|
$parents_arr = array();
|
||||||
$parents_str = '';
|
$parents_str = '';
|
||||||
|
$date_offset = "";
|
||||||
|
|
||||||
if(count($r)) {
|
if(count($r)) {
|
||||||
foreach($r as $rr)
|
foreach($r as $rr)
|
||||||
|
@ -842,6 +854,13 @@ function network_content(&$a, $update = 0) {
|
||||||
$items = array();
|
$items = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($_GET["offset"] == "")
|
||||||
|
$date_offset = $items[0][$order_mode];
|
||||||
|
else
|
||||||
|
$date_offset = $_GET["offset"];
|
||||||
|
|
||||||
|
$a->page_offset = $date_offset;
|
||||||
|
|
||||||
if($parents_str)
|
if($parents_str)
|
||||||
$update_unseen = ' WHERE uid = ' . intval(local_user()) . ' AND unseen = 1 AND parent IN ( ' . dbesc($parents_str) . ' )';
|
$update_unseen = ' WHERE uid = ' . intval(local_user()) . ' AND unseen = 1 AND parent IN ( ' . dbesc($parents_str) . ' )';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue