]> git.mxchange.org Git - friendica.git/commitdiff
more cleanup - start on ajax
authorMike Macgirvin <mike@macgirvin.com>
Tue, 20 Jul 2010 05:52:31 +0000 (22:52 -0700)
committerMike Macgirvin <mike@macgirvin.com>
Tue, 20 Jul 2010 05:52:31 +0000 (22:52 -0700)
boot.php
include/nav.php
mod/ping.php [new file with mode: 0644]
mod/settings.php
view/dfrn_request.tpl
view/head.tpl
view/profile.php
view/settings.tpl
view/settings_nick_set.tpl
view/settings_nick_subdir.tpl [new file with mode: 0644]
view/style.css

index 56d85f63829f7f9c92b416d132b9fd97b7c9e92b..5efa9a24f4dd625a59e782505f0a41e399717e4d 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -96,9 +96,14 @@ class App {
                $this->path = ltrim(trim($p),'/');
        } 
 
+       function get_path() {
+               return $this->path;
+       }
+
        function set_pager_total($n) {
                $this->pager['total'] = intval($n);
        }
+
        function set_pager_itemspage($n) {
                $this->pager['itemspage'] = intval($n);
                $this->pager['start'] = ($this->pager['page'] * $this->pager['itemspage']) - $this->pager['itemspage'];
index a7a2cf3f88cfc9af0d73b175c2b7d16b86ed0876..b788ed48a3a92c6b6ed65811587c75a2d3302a9b 100644 (file)
@@ -12,7 +12,8 @@
                $a->page['nav'] .= "<a id=\"nav-notify-link\" class=\"nav-commlink\" href=\"notifications\">Notifications</a>\r\n";
 
                $a->page['nav'] .= "<a id=\"nav-messages-link\" class=\"nav-commlink\" href=\"Messages\">Messages</a>\r\n";
-
+               
+               $a->page['nav'] .= "<div id=\"nav-notify\" class=\"nav-notify\"></div>\r\n";
 
                $a->page['nav'] .= "<a id=\"nav-logout-link\" class=\"nav-link\" href=\"logout\">Logout</a>\r\n";
 
@@ -22,7 +23,7 @@
 
                $a->page['nav'] .= "<a id=\"nav-contacts-link\" class=\"nav-link\" href=\"contacts\">Contacts</a>\r\n";
 
-               $a->page['nav'] .= "<a id=\"nav-home-link\" class=\"nav-link\" href=\"profile/{$_SESSION['uid']}\">Home</a>\r\n";
+               $a->page['nav'] .= "<a id=\"nav-home-link\" class=\"nav-link\" href=\"profile/{$a->user['nickname']}\">Home</a>\r\n";
 
                $a->page['nav'] .= "<a id=\"nav-network-link\" class=\"nav-link\" href=\"network\">Network</a>\r\n";
                
diff --git a/mod/ping.php b/mod/ping.php
new file mode 100644 (file)
index 0000000..bc160ad
--- /dev/null
@@ -0,0 +1,36 @@
+<?php
+
+
+
+function ping_init(&$a) {
+
+       if(! local_user())
+               xml_status(0);
+
+       $r = q("SELECT COUNT(*) AS `total` FROM `item` 
+               WHERE `unseen` = 1 AND `uid` = %d",
+               intval($_SESSION['uid'])
+       );
+       $network = $r[0]['total'];
+
+       $r = q("SELECT COUNT(*) AS `total` FROM `item` 
+               WHERE `unseen` = 1 AND `uid` = %d AND `type` != 'remote' ",
+               intval($_SESSION['uid'])
+       );
+       $home = $r[0]['total'];
+
+       $r = q("SELECT COUNT(*) AS `total` FROM `intro` 
+               WHERE `uid` = %d  AND `blocked` = 0 AND `ignore` = 0 ",
+               intval($_SESSION['uid'])
+       );
+       $intro = $r[0]['total'];
+
+       // TODO
+       $mail = 0;
+
+       header("Content-type: text/xml");
+       echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\r\n<result><intro>$intro</intro><mail>$mail</mail><net>$network</net><home>$home</home></result>\r\n";
+
+       killme();
+}
+
index 54fca992cf5ea0ddfb677b9387808eb0da30ba33..bd779ad4e50fe906baf0420a28f0a10d6442d77f 100644 (file)
@@ -3,20 +3,20 @@
 
 function settings_init(&$a) {
 
-       if((! x($_SESSION,'authenticated')) && (x($_SESSION,'uid'))) {
-               $_SESSION['sysmsg'] .= "Permission denied." . EOL;
+       if(! local_user()) {
+               notice("Permission denied." . EOL);
                $a->error = 404;
                return;
        }
        require_once("mod/profile.php");
-       profile_load($a,$_SESSION['uid']);
+       profile_load($a,$a->user['nickname']);
 }
 
 
 function settings_post(&$a) {
 
-       if((! x($_SESSION['authenticated'])) && (! (x($_SESSION,'uid')))) {
-               $_SESSION['sysmsg'] .= "Permission denied." . EOL;
+       if(! local_user()) {
+               notice( "Permission denied." . EOL);
                return;
        }
        if(count($a->user) && x($a->user,'uid') && $a->user['uid'] != $_SESSION['uid']) {
@@ -128,15 +128,26 @@ function settings_content(&$a) {
        $timezone = $a->user['timezone'];
 
 
-       if(x($nickname))
-               $nickname_block = file_get_contents("view/settings_nick_set.tpl");
-       else
-               $nickname_block = file_get_contents("view/settings_nick_unset.tpl");
+
+       $nickname_block = file_get_contents("view/settings_nick_set.tpl");
+       
+
+       $nickname_subdir = '';
+       if(strlen($a->get_path())) {
+               $subdir_tpl = file_get_contents('view/settings_nick_subdir.tpl');
+               $nickname_subdir = replace_macros($subdir_tpl, array(
+                       '$baseurl' => $a->get_baseurl(),
+                       '$nickname' => $nickname,
+                       '$hostname' => $a->get_hostname()
+               ));
+       }
+
 
        $nickname_block = replace_macros($nickname_block,array(
                '$nickname' => $nickname,
                '$uid' => $_SESSION['uid'],
-               '$basepath' => substr($a->get_baseurl(),strpos($a->get_baseurl(),'://') + 3), 
+               '$subdir' => $nickname_subdir,
+               '$basepath' => $a->get_hostname(),
                '$baseurl' => $a->get_baseurl()));      
 
        $o = file_get_contents('view/settings.tpl');
index df935ae2ad2f5e10f76f6ea2cfd7ec26a2d5ec8f..c1a7b1d9b0d9b586e1a24423695834ec2b00486d 100644 (file)
@@ -2,13 +2,14 @@
 <h1>Personal Introduction</h1>
 
 <p id="dfrn-request-intro">
-You may introduce yourself to this member if you have a valid <a href="http://dfrn.org">DFRN profile</a>.
+You may introduce yourself to this member if you have a valid profile locator<br />
+on the <a href="http://dfrn.org">Distributed Friends and Relations Network (DFRN)</a>.
 </p>
 
 <form action="dfrn_request/$uid" method="post" />
 
 <div id="dfrn-request-url-wrapper" >
-       <label id="dfrn-url-label" for="dfrn-url" >Your DFRN Profile URL:</label>
+       <label id="dfrn-url-label" for="dfrn-url" >Your profile location:</label>
        <input type="text" name="dfrn_url" id="dfrn-url" size="32" />
        <div id="dfrn-request-url-end"></div>
 </div>
index 8ffd639330ff55f2cb46d4aa366e689fd317865a..b384d6fc05082cabd7cef8e809cf8eb0dfc974ad 100644 (file)
@@ -7,3 +7,20 @@
 <![endif]-->
 <script type="text/javascript" src="$baseurl/include/jquery.js" ></script>
 <script type="text/javascript" src="$baseurl/include/main.js" ></script>
+
+<script type="text/javascript">
+//     $(document).ready(function() { setTimeout(NavUpdate,10 * 1000); });
+
+function NavUpdate()
+       {
+               $.get("ping",function(data)
+                       {
+                       $(data).find('result').each(function() {
+                               var net = $(this).find('net').text();
+                       alert(net);
+                       });
+               }) ;
+               setTimeout(NavUpdate,10 * 1000);
+       }
+</script>
+
index d95edb952e6b7b2363e3a2efadaff366d70f5768..e8de331e1fc05b87713e3a7a7f4f49140502a448 100644 (file)
@@ -20,7 +20,7 @@
 \r
        <div id="profile-extra-links">\r
 \r
-       <a id="dfrn-request-link" href="dfrn_request/<?php echo $profile['uid']; ?>">Introductions</a>\r
+       <a id="dfrn-request-link" href="dfrn_request/<?php echo $profile['nickname']; ?>">Introductions</a>\r
 \r
        </div>\r
 \r
index d73e45a413e6ca6856e70a308affd5c18ab73596..baf1178447f8c028f82d345c59a417bc4057d19e 100644 (file)
@@ -1,5 +1,8 @@
 <h1>Account Settings</h1>
 
+$nickname_block
+
+
 <form action="settings" id="settings-form" method="post" >
 
 <div id="settings-username-wrapper" >
@@ -14,7 +17,6 @@
 </div>
 <div id="settings-email-end" ></div>
 
-$nickname_block
 
 
 <div id="settings-timezone-wrapper" >
index 8b110457c003aa522a5cd770b59c72609ad283cc..3524fc1bc32479a3efecd0cf1fcd1c13d575633f 100644 (file)
@@ -1,10 +1,10 @@
 
 <div id="settings-nick-wrapper" >
 <p id="settings-nickname-desc">
-Your nickname cannot be changed. It is set to <strong>$nickname</strong>.<br />
-Your profile is located at <strong>'$baseurl/profile/$nickname'</strong>,<br />
-and you may use this as your profile URL when communicating with other<br />
-sites or simply <strong>'$nickname@$basepath'</strong>.
+Your site nickname is <strong>$nickname</strong> and cannot be changed.<br />
+Your profile locator is <strong>'$nickname@$basepath'</strong>.
 </p>
+$subdir
+
 </div>
 <div id="settings-nick-end" ></div>
diff --git a/view/settings_nick_subdir.tpl b/view/settings_nick_subdir.tpl
new file mode 100644 (file)
index 0000000..401a6fd
--- /dev/null
@@ -0,0 +1,7 @@
+<p>
+It appears that your website is located in a subdirectory of the<br />
+$hostname website and this setting may not work reliably.<br />
+</p>
+<p>If you have any issues, you may have better results using the profile<br />
+locator '<strong>$baseurl/profile/$nickname</strong>'.
+</p>
\ No newline at end of file
index 128464b1d5f0c3cbc9f8d3d8f6ca9d9612fa13e2..58579ae480fde42c73608c5b78eec5c018f92874 100644 (file)
@@ -210,6 +210,10 @@ input#dfrn-url {
        margin-left: 50px;
 }
 
+#settings-nick-wrapper {
+       margin-bottom: 30px;
+}
+
 #settings-username-end, #settings-email-end, #settings-nick-end, #settings-timezone-end, #settings-password-end, #settings-confirm-end {
        margin-bottom: 5px;
        clear: both;