svn: /web/php/trunk/include/ header.inc layout.inc site.inc

[email protected] (Hannes Magnusson)
Newsgroups php.webmaster
Message-ID <[email protected]>
bjori                                    Sat, 01 Jan 2011 21:37:30 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=306964

Log:
Add back shorturl to betaweb, and update the canonical version of pages

Changed paths:
    U   web/php/trunk/include/header.inc
    U   web/php/trunk/include/layout.inc
    U   web/php/trunk/include/site.inc

Modified: web/php/trunk/include/header.inc
===================================================================
--- web/php/trunk/include/header.inc	2011-01-01 21:22:47 UTC (rev 306963)
+++ web/php/trunk/include/header.inc	2011-01-01 21:37:30 UTC (rev 306964)
@@ -4,6 +4,12 @@
 header("Expires: Thu, 19 Nov 1981 08:52:00 GMT");
 header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
 header("Pragma: no-cache");
+
+// shorturl; http://wiki.snaplog.com/short_url
+if ($shortname = get_shortname($_SERVER["BASE_PAGE"])) {
+    $shorturl = "http://php.net/" . $shortname;
+    header("Link: <$shorturl>; rel=shorturl");
+}
 ?>
 <!DOCTYPE html>
 <html xmlns="http://www.w3.org/1999/xhtml" lang="<?php echo $lang?>">
@@ -17,7 +23,10 @@
  <link rel="search" type="application/opensearchdescription+xml" href="http://www.php.net/phpnetimprovedsearch.src" title="Add PHP.net search" />
  <link rel="alternate" type="application/atom+xml" href="http://www.php.net/releases.atom" title="PHP Release feed" />
  <link rel="alternate" type="application/atom+xml" title="PHP: Hypertext Preprocessor" href="http://www.php.net/feed.atom" />
- <link rel="canonical" href="http://php.net/index.php" />
+ <link rel="canonical" href="http://php.net/<?php echo $_SERVER['BASE_PAGE']?>" />
+<?php if ($shortname): ?>
+ <link rel="shorturl" href="<?php echo $shorturl ?>" />
+<?php endif ?>

  <link rel="stylesheet" type="text/css" href="/styles/reset.css<?php echo $v?>" media="all" />
  <link rel="stylesheet" type="text/css" href="/styles/structure.css<?php echo $v?>" media="screen" />

Modified: web/php/trunk/include/layout.inc
===================================================================
--- web/php/trunk/include/layout.inc	2011-01-01 21:22:47 UTC (rev 306963)
+++ web/php/trunk/include/layout.inc	2011-01-01 21:37:30 UTC (rev 306964)
@@ -789,6 +789,8 @@
 {
     global $SIDEBAR_DATA;
     global $setup;
+    global $MYSITE;
+
     if ($setup) {
         $lang = language_convert($setup['head'][1]);
     }

Modified: web/php/trunk/include/site.inc
===================================================================
--- web/php/trunk/include/site.inc	2011-01-01 21:22:47 UTC (rev 306963)
+++ web/php/trunk/include/site.inc	2011-01-01 21:37:30 UTC (rev 306964)
@@ -354,7 +354,45 @@
     );
 }

+function get_shortname($page) {
+    // We can at the very least kill the .php
+    $shorturl = substr($page, 0, -4);

+    // If its a "root page", we can't shorten it more
+    if (strpos($shorturl, "/") === false) {
+        return $shorturl;
+    }
+
+    // Manual pages get be quite short
+    if (strpos($page, "manual/") !== false) {
+        $sections = get_manual_search_sections();
+        // Kill the first entry (empty)
+        array_shift($sections);
+
+        // We can atleast remove manual/xx/
+        $shorturl = substr($page, strrpos($page, "/")+1);
+
+        foreach($sections as $section) {
+            // If we know this section
+            if (strpos($shorturl, $section) === 0) {
+                // We can make it even shorter
+                return substr($shorturl, strlen($section), -4);
+                break;
+            }
+        }
+
+        // Didn't recognize the section, we better not shorten it at all
+        return $page;
+    }
+
+    // /conferences/index.php can be shortened to /conferences
+    if (strpos($page, "conferences/") !== false) {
+        return "conferences";
+    }
+
+    return $shorturl;
+}
+
 // Guess the current site from what Apache tells us.
 // This should be the main name of the mirror (in case
 // it works under more then one name). SERVER_NAME is
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.