]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - index.php
After clicking save/cancel on a link, scroll to the link itself.
[github/shaarli/Shaarli.git] / index.php
index b7ed370dcad9cb11845dbca098e317d79476cfd1..1ac5187b91d54391961b27d877f85f088ed44390 100644 (file)
--- a/index.php
+++ b/index.php
@@ -427,7 +427,11 @@ function serverUrl()
 // (eg. http://sebsauvage.net/links/)
 function indexUrl()
 {
-    return serverUrl() . ($_SERVER["SCRIPT_NAME"] == '/index.php' ? '/' : $_SERVER["SCRIPT_NAME"]);
+    $scriptname = $_SERVER["SCRIPT_NAME"];
+    // If the script is named 'index.php', we remove it (for better looking URLs,
+    // eg. http://mysite.com/shaarli/?abcde instead of http://mysite.com/shaarli/index.php?abcde)
+    if (endswith($scriptname,'index.php')) $scriptname = substr($scriptname,0,strlen($scriptname)-9);
+    return serverUrl() . $scriptname;
 }
 
 // Returns the absolute URL of current script, WITH the query.
@@ -1433,6 +1437,7 @@ function renderPage()
         // If we are called from the bookmarklet, we must close the popup:
         if (isset($_GET['source']) && $_GET['source']=='bookmarklet') { echo '<script language="JavaScript">self.close();</script>'; exit; }
         $returnurl = ( isset($_POST['returnurl']) ? $_POST['returnurl'] : '?' );
+        $returnurl .= '#'.smallHash($linkdate);  // Scroll to the link which has been edited.
         header('Location: '.$returnurl); // After saving the link, redirect to the page the user was on.
         exit;
     }
@@ -1443,6 +1448,7 @@ function renderPage()
         // If we are called from the bookmarklet, we must close the popup;
         if (isset($_GET['source']) && $_GET['source']=='bookmarklet') { echo '<script language="JavaScript">self.close();</script>'; exit; }
         $returnurl = ( isset($_POST['returnurl']) ? $_POST['returnurl'] : '?' );
+        $returnurl .= '#'.smallHash($_POST['lf_linkdate']);  // Scroll to the link which has been edited.
         header('Location: '.$returnurl); // After canceling, redirect to the page the user was on.
         exit;
     }