Keeping an offset for page switching: This helps so that you don't see old messages

This commit is contained in:
Michael Vogel 2013-12-10 00:13:19 +01:00
parent d20d2f74ae
commit 7e5c8ab91c
3 changed files with 41 additions and 16 deletions

View file

@ -279,6 +279,9 @@ function paginate_data(&$a, $count=null) {
$stripped = trim($stripped,'/');
$pagenum = $a->pager['page'];
if (($a->page_offset != "") AND !strstr($stripped, "&offset="))
$stripped .= "&offset=".urlencode($a->page_offset);
if (!strstr($stripped, "?")) {
$pos = strpos($stripped, "&");
$stripped = substr($stripped, 0, $pos)."?".substr($stripped, $pos + 1);
@ -286,7 +289,6 @@ function paginate_data(&$a, $count=null) {
$url = $a->get_baseurl() . '/' . $stripped;
$data = array();
function _l(&$d, $name, $url, $text, $class="") {

View file

@ -473,6 +473,10 @@ if ($_GET["mode"] == "raw") {
if (($param != "page") AND ($param != "q"))
$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
<script type="text/javascript">

View file

@ -645,6 +645,7 @@ function network_content(&$a, $update = 0) {
$sql_extra3 = (($nouveau) ? '' : $sql_extra3);
//$sql_order = "`item`.`received`";
$sql_order = "";
$order_mode = "received";
if ($sql_table == "")
$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()));
$sql_order = "`item`.`received`";
$order_mode = "received";
} else {
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)));
@ -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_order = "`item`.`received`";
$order_mode = "received";
}
}
if(strlen($file)) {
@ -764,14 +767,22 @@ function network_content(&$a, $update = 0) {
// Normal conversation view
if($order === 'post')
if($order === 'post') {
$ordering = "`created`";
else
if ($sql_order == "")
$order_mode = "created";
} else {
$ordering = "`commented`";
if ($sql_order == "")
$order_mode = "commented";
}
if ($sql_order == "")
$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
if($update) {
@ -801,6 +812,7 @@ function network_content(&$a, $update = 0) {
$parents_arr = array();
$parents_str = '';
$date_offset = "";
if(count($r)) {
foreach($r as $rr)
@ -842,6 +854,13 @@ function network_content(&$a, $update = 0) {
$items = array();
}
if ($_GET["offset"] == "")
$date_offset = $items[0][$order_mode];
else
$date_offset = $_GET["offset"];
$a->page_offset = $date_offset;
if($parents_str)
$update_unseen = ' WHERE uid = ' . intval(local_user()) . ' AND unseen = 1 AND parent IN ( ' . dbesc($parents_str) . ' )';
}