]> git.mxchange.org Git - friendica.git/commitdiff
more live update
authorMike Macgirvin <mike@macgirvin.com>
Sat, 24 Jul 2010 22:21:33 +0000 (15:21 -0700)
committerMike Macgirvin <mike@macgirvin.com>
Sat, 24 Jul 2010 22:21:33 +0000 (15:21 -0700)
mod/network.php
mod/profile.php
mod/update_network.php [new file with mode: 0644]
mod/update_profile.php [new file with mode: 0644]
view/jot-header.tpl
view/wall_item.tpl

index 38d2bbb0cb60c2c3cf35eb2b73c7809b40ee8d4b..cbd1f445454b004858bb46705cab0290e5288da8 100644 (file)
@@ -6,7 +6,7 @@ function network_init(&$a) {
 }
 
 
-function network_content(&$a) {
+function network_content(&$a, $update = false) {
 
        if(! local_user())
                return;
@@ -15,31 +15,36 @@ function network_content(&$a) {
 
        $contact_id = $a->cid;
 
-       $r = q("UPDATE `item` SET `unseen` = 0 
-               WHERE `unseen` = 1 AND `uid` = %d",
-               intval($_SESSION['uid'])
-       );
 
+       if(! $update) {
 
-       $tpl = file_get_contents('view/jot-header.tpl');
+
+               $tpl = file_get_contents('view/jot-header.tpl');
        
-       $a->page['htmlhead'] .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl()));
+               $a->page['htmlhead'] .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl()));
+
+               require_once('view/acl_selectors.php');
+
+               $tpl = file_get_contents("view/jot.tpl");
 
-       require_once('view/acl_selectors.php');
+               $o .= replace_macros($tpl,array(
+                       '$return_path' => $a->cmd,
+                       '$baseurl' => $a->get_baseurl(),
+                       '$visitor' => 'block',
+                       '$lockstate' => 'unlock',
+                       '$acl' => populate_acl(),
+                       '$profile_uid' => $_SESSION['uid']
+               ));
 
-       $tpl = file_get_contents("view/jot.tpl");
 
-       $o .= replace_macros($tpl,array(
-               '$return_path' => $a->cmd,
-               '$baseurl' => $a->get_baseurl(),
-               '$visitor' => 'block',
-               '$lockstate' => 'unlock',
-               '$acl' => populate_acl(),
-               '$profile_uid' => $_SESSION['uid']
-       ));
+               $o .= '<div id="live-network"></div>' . "\r\n";
+       }
 
+       $r = q("UPDATE `item` SET `unseen` = 0 
+               WHERE `unseen` = 1 AND `uid` = %d",
+               intval($_SESSION['uid'])
+       );
 
-       $o .= '<div id="live-network"></div>' . "\r\n";
 
 
        $sql_extra = ''; 
@@ -164,6 +169,9 @@ function network_content(&$a) {
                        ));
                }
        }
-       $o .= paginate($a);
+
+       if(! $update)
+               $o .= paginate($a);
+
        return $o;
 }
\ No newline at end of file
index a317568c135b306e334ebcd936ff7f073b792d5d..aa13f0a78db462cac908a7a1d48a9374eec17bd8 100644 (file)
@@ -67,7 +67,7 @@ function profile_init(&$a) {
 }
 
 
-function profile_content(&$a) {
+function profile_content(&$a, $update = false) {
 
        require_once("include/bbcode.php");
        require_once('include/security.php');
@@ -76,14 +76,7 @@ function profile_content(&$a) {
 
        $tab = 'posts';
 
-       if(x($_GET,'tab'))
-               $tab = notags(trim($_GET['tab']));
 
-       $tpl = file_get_contents('view/profile_tabs.tpl');
-
-       $o .= replace_macros($tpl,array(
-               '$url' => $a->get_baseurl() . '/' . $a->cmd
-       ));
 
 
        if(remote_user()) {
@@ -94,32 +87,49 @@ function profile_content(&$a) {
                $contact_id = $_SESSION['cid'];
        }
 
-       if($tab == 'profile') {
-               require_once('view/profile_advanced.php');
-               return $o;
+       if($update) {
+               if(! local_user())
+                       return '';
+               $a->profile['uid'] = $_SESSION['uid'];
        }
 
-       if(can_write_wall($a,$a->profile['profile_uid'])) {
-               $tpl = file_get_contents('view/jot-header.tpl');
-       
-               $a->page['htmlhead'] .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl()));
-               require_once('view/acl_selectors.php');
+       else {
+               if(x($_GET,'tab'))
+                       $tab = notags(trim($_GET['tab']));
 
-               $tpl = file_get_contents("view/jot.tpl");
+               $tpl = file_get_contents('view/profile_tabs.tpl');
 
                $o .= replace_macros($tpl,array(
-                       '$baseurl' => $a->get_baseurl(),
-                       '$return_path' => $a->cmd,
-                       '$visitor' => (($_SESSION['uid'] == $a->profile['profile_uid']) ? 'block' : 'none'),
-                       '$lockstate' => 'unlock',
-                       '$acl' => (($_SESSION['uid'] == $a->profile['profile_uid']) ? populate_acl() : ''),
-                       '$profile_uid' => $a->profile['profile_uid']
+                       '$url' => $a->get_baseurl() . '/' . $a->cmd
                ));
-       }
 
-       if($tab == 'posts' && (! $a->pager['start']))
-               $o .= '<div id="live-profile"></div>' . "\r\n";
 
+               if($tab == 'profile') {
+                       require_once('view/profile_advanced.php');
+                       return $o;
+               }
+
+               if(can_write_wall($a,$a->profile['profile_uid'])) {
+                       $tpl = file_get_contents('view/jot-header.tpl');
+       
+                       $a->page['htmlhead'] .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl()));
+                       require_once('view/acl_selectors.php');
+
+                       $tpl = file_get_contents("view/jot.tpl");
+
+                       $o .= replace_macros($tpl,array(
+                               '$baseurl' => $a->get_baseurl(),
+                               '$return_path' => $a->cmd,
+                               '$visitor' => (($_SESSION['uid'] == $a->profile['profile_uid']) ? 'block' : 'none'),
+                               '$lockstate' => 'unlock',
+                               '$acl' => (($_SESSION['uid'] == $a->profile['profile_uid']) ? populate_acl() : ''),
+                               '$profile_uid' => $a->profile['profile_uid']
+                       ));
+               }
+
+               if($tab == 'posts' && (! $a->pager['start']))
+                       $o .= '<div id="live-profile"></div>' . "\r\n";
+       }
 
        // TODO alter registration and settings and profile to update contact table when names and  photos change.  
 
@@ -129,7 +139,7 @@ function profile_content(&$a) {
 
        // Profile owner - everything is visible
 
-       if(local_user() && ($_SESSION['uid'] == $a->profile['profile_uid'])) {
+       if(local_user() && ($_SESSION['uid'] == $a->profile['uid'])) {
                $sql_extra = ''; 
                
                // Oh - while we're here... reset the Unseen messages
@@ -250,6 +260,10 @@ function profile_content(&$a) {
                }
        }
 
+       if($update) {
+               return $o;
+       }
+               
        $o .= paginate($a);
 
        return $o;
diff --git a/mod/update_network.php b/mod/update_network.php
new file mode 100644 (file)
index 0000000..655bebb
--- /dev/null
@@ -0,0 +1,14 @@
+<?php
+
+
+require_once('mod/network.php');
+
+
+function update_network_content(&$a) {
+
+       echo "<html>\r\n";
+       echo network_content($a,true);
+       echo "</html>\r\n";
+       killme();
+
+}
\ No newline at end of file
diff --git a/mod/update_profile.php b/mod/update_profile.php
new file mode 100644 (file)
index 0000000..a0cb10f
--- /dev/null
@@ -0,0 +1,14 @@
+<?php
+
+
+require_once('mod/profile.php');
+
+
+function update_profile_content(&$a) {
+
+       echo "<html>\r\n";
+       echo profile_content($a,true);
+       echo "</html>\r\n";
+       killme();
+
+}
\ No newline at end of file
index 8505b53bc247a56a0fb03f35f362f868e572075b..78e0151d80696c68294b14e93198966fc204e973 100644 (file)
@@ -53,8 +53,8 @@ tinyMCE.init({
        var src = null;
 
        $(document).ready(function() {
-               if($('#live-network').length) { src = 'net';  setTimeout(liveUpdate, 30000); }
-               if($('#live-profile').length) { src = 'wall'; setTimeout(liveUpdate, 30000); }
+               if($('#live-network').length) { src = 'network';  setTimeout(liveUpdate, 30000); }
+               if($('#live-profile').length) { src = 'profile';  setTimeout(liveUpdate, 30000); }
        });
 
        function liveUpdate() {
@@ -64,9 +64,9 @@ tinyMCE.init({
                        return;
                }
 
-//             $.get("live_update",function(data)
+//             $.get('update_' + src,function(data)
 //                     {
-//                     $(data).find('result').each(function() {
+//                     $(data).find('#wall-item-outside-wrapper').each(function() {
 //                             var net = $(this).find('net').text();
 //                             if(net == 0) { net = ''; }
 //                             $('#net-update').html(net);
index 726d1b32060f8f9639970bdb4074f8a4a6ce1b7c..72ee216d5862698b16109b4c7fa0d2ce5483110e 100644 (file)
@@ -13,5 +13,5 @@
 $comment
 </div>
 
-<div class="wall-item-$indentoutside-wrapper-end" ></div>
+<div class="wall-item-outside-wrapper-end$indent" ></div>