From 25755c40d05e457d47a730ebd0f04cb46d925976 Mon Sep 17 00:00:00 2001 From: garvinhicking Date: Fri, 19 May 2006 08:51:16 +0000 Subject: [PATCH] Insert new "view" parameter --- docs/NEWS | 5 +++++ include/genpage.inc.php | 3 ++- index.php | 17 +++++++++++++++-- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/docs/NEWS b/docs/NEWS index 9837c0d..19a6340 100644 --- 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 diff --git a/include/genpage.inc.php b/include/genpage.inc.php index b71ed68..9f9a187 100644 --- a/include/genpage.inc.php +++ b/include/genpage.inc.php @@ -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; diff --git a/index.php b/index.php index 13d24da..b48ace1 100644 --- 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('
' . DOCUMENT_NOT_FOUND . '
', $uri); @@ -484,4 +498,3 @@ if ($global_debug) { } /* vim: set sts=4 ts=4 expandtab : */ -?> -- 2.39.5