diff options
author | friendica <info@friendica.com> | 2012-07-24 22:06:21 -0700 |
---|---|---|
committer | friendica <info@friendica.com> | 2012-07-24 22:06:21 -0700 |
commit | 6911beca2f1d88a9e26c1dc110b2547a1b075951 (patch) | |
tree | 094aa281b0d896c8d2f0a039b16cbbb80d3c0b68 | |
parent | f535554cfa3a2de345f4028b109f4e941fc3a91b (diff) | |
download | volse-hubzilla-6911beca2f1d88a9e26c1dc110b2547a1b075951.tar.gz volse-hubzilla-6911beca2f1d88a9e26c1dc110b2547a1b075951.tar.bz2 volse-hubzilla-6911beca2f1d88a9e26c1dc110b2547a1b075951.zip |
ajax page loads
-rw-r--r-- | include/conversation.php | 32 | ||||
-rw-r--r-- | js/main.js | 7 | ||||
-rw-r--r-- | mod/network.php | 22 | ||||
-rw-r--r-- | mod/update_network.php | 4 |
4 files changed, 42 insertions, 23 deletions
diff --git a/include/conversation.php b/include/conversation.php index 958400db3..50ce51558 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -346,6 +346,10 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { $page_writeable = false; } + + $page_dropping = ((local_user() && local_user() == $profile_owner) ? true : false); + + if($update) $return_url = $_SESSION['return_url']; else @@ -869,14 +873,26 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { } } - $page_template = get_markup_template("conversation.tpl"); - $o = replace_macros($page_template, array( - '$baseurl' => $a->get_baseurl($ssl_state), - '$mode' => $mode, - '$user' => $a->user, - '$threads' => $threads, - '$dropping' => ($dropping?t('Delete Selected Items'):False), - )); + logger('threads: ' . count($threads) . ' update: ' . $update); + + if($update) { + $page_template = get_markup_template("conv.tpl"); + $o = replace_macros($page_template, array( + '$baseurl' => $a->get_baseurl($ssl_state), + '$mode' => $mode, + '$user' => $a->user, + '$threads' => $threads, + )); + } + else { + $page_template = get_markup_template("conv_frame.tpl"); + $o = replace_macros($page_template, array( + '$baseurl' => $a->get_baseurl($ssl_state), + '$mode' => $mode, + '$user' => $a->user, + '$dropping' => ($page_dropping?t('Delete Selected Items'):False), + )); + } return $o; }} diff --git a/js/main.js b/js/main.js index 29af7eb59..d86107c5b 100644 --- a/js/main.js +++ b/js/main.js @@ -33,6 +33,8 @@ var last_popup_menu = null; var last_popup_button = null; + var page_load = true; + $(function() { $.ajaxSetup({cache: false}); @@ -314,7 +316,10 @@ function updateConvItems(mode,data) { prev = 'live-' + src; in_progress = true; - var udargs = ((netargs.length) ? '/' + netargs : ''); + + var udargs = ((page_load) ? '/load' : ''); + page_load = false; + var update_url = 'update_' + src + udargs + '&p=' + profile_uid + '&page=' + profile_page + '&msie=' + ((msie) ? 1 : 0); $.get(update_url,function(data) { diff --git a/mod/network.php b/mod/network.php index 85f76b0b0..b740ed2a4 100644 --- a/mod/network.php +++ b/mod/network.php @@ -235,7 +235,7 @@ function network_query_get_sel_tab($a) { } -function network_content(&$a, $update = 0) { +function network_content(&$a, $update = 0, $load = false) { require_once('include/conversation.php'); @@ -451,10 +451,6 @@ function network_content(&$a, $update = 0) { if(count($r)) { $sql_extra = " AND `item`.`parent` IN ( SELECT DISTINCT(`parent`) FROM `item` WHERE 1 $sql_options AND `contact-id` = " . intval($cid) . " and deleted = 0 ) "; $o = '<h2>' . t('Contact: ') . $r[0]['name'] . '</h2>' . $o; - if($r[0]['network'] === NETWORK_OSTATUS && $r[0]['writable'] && (! get_pconfig(local_user(),'system','nowarn_insecure'))) { - notice( t('Private messages to this person are at risk of public disclosure.') . EOL); - } - } else { notice( t('Invalid contact.') . EOL); @@ -581,7 +577,7 @@ function network_content(&$a, $update = 0) { ); } - if($update) { + if($update && ! $load) { // only setup pagination on initial page view $pager_sql = ''; @@ -601,8 +597,10 @@ function network_content(&$a, $update = 0) { } $simple_update = (($update) ? " and `item`.`unseen` = 1 " : ''); + if($load) + $simple_update = ''; - if($nouveau) { + if($nouveau && $load) { // "New Item View" - show all items unthreaded in reverse created date order $items = q("SELECT `item`.*, `item`.`id` AS `item_id`, @@ -624,8 +622,8 @@ function network_content(&$a, $update = 0) { $items = fetch_post_tags($items); } - else { - + elseif($load) { +logger('loading:'); // Normal conversation view @@ -636,7 +634,7 @@ function network_content(&$a, $update = 0) { // Fetch a page full of parent items for this page - if($update) { + if($update && (! $load)) { $r = q("SELECT `parent` AS `item_id`, `contact`.`uid` AS `contact_uid` FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND @@ -649,7 +647,6 @@ function network_content(&$a, $update = 0) { } else { -dbg(1); $r = q("SELECT `item`.`id` AS `item_id`, `contact`.`uid` AS `contact_uid` FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 @@ -659,7 +656,7 @@ dbg(1); ORDER BY `item`.$ordering DESC $pager_sql ", intval(local_user()) ); -dbg(0); + } // Then fetch all the children of the parents that are on this page @@ -697,6 +694,7 @@ dbg(0); } } +logger('items: ' . count($items)); // We aren't going to try and figure out at the item, group, and page // level which items you've seen and which you haven't. If you're looking diff --git a/mod/update_network.php b/mod/update_network.php index 36de0722a..e13eef0e6 100644 --- a/mod/update_network.php +++ b/mod/update_network.php @@ -8,13 +8,13 @@ require_once('include/group.php'); function update_network_content(&$a) { $profile_uid = intval($_GET['p']); - + $load = (((argc() > 1) && (argv(1) == 'load')) ? 1 : 0); header("Content-type: text/html"); echo "<!DOCTYPE html><html><body>\r\n"; echo (($_GET['msie'] == 1) ? '<div>' : '<section>'); - $text = network_content($a,$profile_uid); + $text = network_content($a,$profile_uid, $load); $pattern = "/<img([^>]*) src=\"([^\"]*)\"/"; $replace = "<img\${1} dst=\"\${2}\""; $text = preg_replace($pattern, $replace, $text); |