]> git.mjollnir.org Git - s9y.git/commitdiff
Insert new "view" parameter
authorgarvinhicking <garvinhicking>
Fri, 19 May 2006 08:51:16 +0000 (08:51 +0000)
committergarvinhicking <garvinhicking>
Fri, 19 May 2006 08:51:16 +0000 (08:51 +0000)
docs/NEWS
include/genpage.inc.php
index.php

index 9837c0d797a5af44d01019d9a455247525031c62..19a63408ca02106c0ea829663109513eeedfb224 100644 (file)
--- a/docs/NEWS
+++ b/docs/NEWS
@@ -3,6 +3,11 @@
 Version 1.0 ()
 ------------------------------------------------------------------------
 
+   * Add smarty parameter $view which can be used to detect what kind
+     of page is being displayed. One of: archives, entry, feed, admin,
+     archives, plugin, categories, authors, search, css, start, 404
+     (garvinhicking)
+
    * Change Spartacus plugin to use new SourceForge URLs (garvinhicking)
 
    * Added polish language translation by CoSTa
index b71ed688943321f3eaf83decee448d083346f02b..9f9a1872a752a346b9f185aea67f67644d90ca53 100644 (file)
@@ -8,7 +8,8 @@ include_once(S9Y_INCLUDE_PATH . 'include/plugin_internal.inc.php');
 
 $uri_addData = array(
     'startpage' => false,
-    'uriargs'   => implode('/', serendipity_getUriArguments($uri, true))
+    'uriargs'   => implode('/', serendipity_getUriArguments($uri, true)),
+    'view'      => $serendipity['view']
 );
 if ((empty($uri_addData['uriargs']) || trim($uri_addData['uriargs']) == $serendipity['indexFile']) && empty($serendipity['GET']['subpage'])) {
     $uri_addData['startpage'] = true;
index 13d24da997fc9698f44918d211d345981676d131..b48ace184cadcfe2d041f0f4112b450fad3e4e80 100644 (file)
--- a/index.php
+++ b/index.php
@@ -79,6 +79,7 @@ if (isset($serendipity['POST']['isMultiAuth']) && is_array($serendipity['POST'][
 }
 
 if (preg_match(PAT_ARCHIVES, $uri, $matches) || isset($serendipity['GET']['range']) && is_numeric($serendipity['GET']['range'])) {
+    $serendipity['view'] = 'archives';
     $_args = $serendipity['uriArguments'];
 
     /* Attempt to locate hidden variables within the URI */
@@ -218,7 +219,7 @@ if (preg_match(PAT_ARCHIVES, $uri, $matches) || isset($serendipity['GET']['range
     echo $data;
 } else if ( preg_match(PAT_COMMENTSUB, $uri, $matches) ||
             preg_match(PAT_PERMALINK, $uri, $matches) ) {
-
+    $serendipity['view'] = 'entry';
     $matches[1] = serendipity_searchPermalink($serendipity['permalinkStructure'], $uri, $matches[1], 'entry');
     serendipity_rememberComment();
 
@@ -270,6 +271,7 @@ if (preg_match(PAT_ARCHIVES, $uri, $matches) || isset($serendipity['GET']['range
     }
     print $data;
 } elseif (preg_match(PAT_PERMALINK_FEEDCATEGORIES, $uri, $matches) || preg_match(PAT_PERMALINK_FEEDAUTHORS, $uri, $matches) || preg_match(PAT_FEEDS, $uri)) {
+    $serendipity['view'] = 'feed';
     header('Content-Type: text/html; charset=utf-8');
 
     if (preg_match('@/(index|atom[0-9]*|rss|comments|opml)\.(rss[0-9]?|rdf|rss|xml|atom)@', $uri, $vmatches)) {
@@ -308,6 +310,7 @@ if (preg_match(PAT_ARCHIVES, $uri, $matches) || isset($serendipity['GET']['range
     print $data;
     exit;
 } else if (preg_match(PAT_ADMIN, $uri)) {
+    $serendipity['view'] = 'admin';
     $base = $serendipity['baseURL'];
     if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
         $base = str_replace('http://', 'https://', $base);
@@ -315,6 +318,7 @@ if (preg_match(PAT_ARCHIVES, $uri, $matches) || isset($serendipity['GET']['range
     header("Location: {$base}serendipity_admin.php");
     exit;
 } else if (preg_match(PAT_ARCHIVE, $uri)) {
+    $serendipity['view'] = 'archives';
     $serendipity['GET']['action'] = 'archives';
     $_args = $serendipity['uriArguments'];
     /* Attempt to locate hidden variables within the URI */
@@ -334,11 +338,13 @@ if (preg_match(PAT_ARCHIVES, $uri, $matches) || isset($serendipity['GET']['range
 
     include_once(S9Y_INCLUDE_PATH . 'include/genpage.inc.php');
 } else if (preg_match(PAT_PLUGIN, $uri, $matches)) {
+    $serendipity['view'] = 'plugin';
     serendipity_plugin_api::hook_event('external_plugin', $matches[2]);
     if (!defined('NO_EXIT')) {
         exit;
     }
 } else if ($is_multicat || preg_match(PAT_PERMALINK_CATEGORIES, $uri, $matches)) {
+    $serendipity['view'] = 'categories';
 
     if ($is_multicat) {
         $serendipity['GET']['category'] = implode(';', $serendipity['POST']['multiCat']);
@@ -379,6 +385,8 @@ if (preg_match(PAT_ARCHIVES, $uri, $matches) || isset($serendipity['GET']['range
 
     include_once(S9Y_INCLUDE_PATH . 'include/genpage.inc.php');
 } else if ($is_multiauth || preg_match(PAT_PERMALINK_AUTHORS, $uri, $matches)) {
+    $serendipity['view'] = 'authors';
+
     if ($is_multiauth) {
         $serendipity['GET']['viewAuthor'] = implode(';', $serendipity['POST']['multiAuth']);
         $serendipity['uriArguments'][]    = PATH_AUTHORS;
@@ -416,6 +424,7 @@ if (preg_match(PAT_ARCHIVES, $uri, $matches) || isset($serendipity['GET']['range
 
     include_once(S9Y_INCLUDE_PATH . 'include/genpage.inc.php');
 } else if (preg_match(PAT_SEARCH, $uri, $matches)) {
+    $serendipity['view'] = 'search';
     $_args = $serendipity['uriArguments'];
 
     /* Attempt to locate hidden variables within the URI */
@@ -441,12 +450,15 @@ if (preg_match(PAT_ARCHIVES, $uri, $matches) || isset($serendipity['GET']['range
     $serendipity['GET']['searchTerm'] = urldecode(htmlspecialchars(strip_tags(implode(' ', $search))));
     include_once(S9Y_INCLUDE_PATH . 'include/genpage.inc.php');
 } elseif (preg_match(PAT_CSS, $uri, $matches)) {
+    $serendipity['view'] = 'css';
     $css_mode = $matches[1];
     include_once(S9Y_INCLUDE_PATH . 'serendipity.css.php');
     exit;
 } else if (preg_match('@/(index(\.php|\.html)?)|'. preg_quote($serendipity['indexFile']) .'@', $uri) ||
            preg_match('@^/' . preg_quote(trim($serendipity['serendipityHTTPPath'], '/')) . '/?(\?.*)?$@', $uri)) {
 
+    $serendipity['view'] = 'start';
+
     if ($serendipity['GET']['action'] == 'search') {
         $serendipity['uriArguments'] = array(PATH_SEARCH, urlencode($serendipity['GET']['searchTerm']));
     } else {
@@ -455,6 +467,8 @@ if (preg_match(PAT_ARCHIVES, $uri, $matches) || isset($serendipity['GET']['range
 
     include_once(S9Y_INCLUDE_PATH . 'include/genpage.inc.php');
 } else {
+    $serendipity['view'] = '404';
+
     header('HTTP/1.0 404 Not found');
     include_once(S9Y_INCLUDE_PATH . 'include/genpage.inc.php');
     // printf('<div class="serendipity_msg_important">' . DOCUMENT_NOT_FOUND . '</div>', $uri);
@@ -484,4 +498,3 @@ if ($global_debug) {
 }
 
 /* vim: set sts=4 ts=4 expandtab : */
-?>