Update of /cvsroot/php-blog/serendipity
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30705
Modified Files:
index.php
Log Message:
- Fix paging and simplify the paging function
- When using paging, use the rewrite rules to make sexy pages /P[n].html
TODO: Fix header title when browsing frontpage pages
Index: index.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/index.php,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -d -r1.63 -r1.64
--- index.php 10 Dec 2004 19:58:00 -0000 1.63
+++ index.php 13 Dec 2004 12:28:45 -0000 1.64
@@ -28,6 +28,16 @@
$track_referer = true;
$uri = $_SERVER['REQUEST_URI'];
+/* Explode the path into sections, to later be able to check for arguments and add our own */
+preg_match('/^'. preg_quote($serendipity['serendipityHTTPPath'], '/') .'('. preg_quote($serendipity['indexFile'], '/') .'\?\/)?([a-z0-9\-*\/]+)/i', $uri, $_res);
+if ( strlen($_res[2]) != 0 ) {
+ $serendipity['uriArguments'] = explode('/', $_res[2]);
+} else {
+ $serendipity['uriArguments'] = array();
+}
+
+
+
if (isset($_SERVER['HTTP_REFERER']) && empty($_SESSION['HTTP_REFERER'])) {
$_SESSION['HTTP_REFERER'] = $_SERVER['HTTP_REFERER'];
}
@@ -37,7 +47,7 @@
define('DATA_UNSUBSCRIBED', urldecode($res[1]));
}
- $uri = '/' . PATH_UNSUBSCRIBE . '/' . $res[2] . '_untitled.html';
+ $uri = '/' . PATH_UNSUBSCRIBE . '/' . $res[2] . '-untitled.html';
}
if (preg_match(PAT_DELETE, $uri, $res) && $serendipity['serendipityAuthedUser'] === true) {
@@ -58,28 +68,43 @@
if (preg_match(PAT_ARCHIVES, $uri, $matches) || isset($serendipity['GET']['range']) && is_numeric($serendipity['GET']['range'])) {
- preg_match_all('@/([a-z0-9]+)@i', $matches[1], $args);
+ $_args = $serendipity['uriArguments'];
/* Attempt to locate hidden variables within the URI */
- foreach ($args[1] as $k => $v){
+ foreach ($_args as $k => $v){
+ if ($v == PATH_ARCHIVES) {
+ continue;
+ }
if ($v{0} == 'C') { /* category */
$serendipity['GET']['category'] = substr($v, 1);
- unset($args[1][$k]);
+ unset($_args[$k]);
} elseif ($v{0} == 'W') { /* Week */
$week = substr($v, 1);
- unset($args[1][$k]);
+ unset($_args[$k]);
} elseif ($v == 'summary') { /* Summary */
$serendipity['short_archives'] = true;
- unset($args[1][$k]);
+ unset($_args[$k]);
+ } elseif ($v{0} == 'P') { /* Page */
+ $serendipity['GET']['page'] = substr($v, 1);
+ unset($_args[$k]);
+ unset($serendipity['uriArguments'][$k]);
}
}
/* We must always *assume* that Year, Month and Day are the first 3 arguments */
- list($year, $month, $day) = $args[1];
+ list(,$year, $month, $day) = $_args;
$_GET['serendipity']['action'] = 'read';
$_GET['serendipity']['hidefooter'] = true;
+ if ( !isset($year) ) {
+ $year = date('Y');
+ $month = date('m');
+ $day = date('j');
+ $_GET['serendipity']['action'] = null;
+ $_GET['serendipity']['hidefooter'] = null;
+ }
+
if ($week) {
$tm = strtotime('+ '. ($week-2) .' WEEKS monday', mktime(0, 0, 0, 1, 1, $year));
$ts = mktime(0, 0, 0, date('m', $tm), date('j', $tm), $year);
@@ -189,17 +214,31 @@
serendipity_plugin_api::hook_event('external_plugin', $matches[1]);
exit;
} else if (preg_match(PAT_CATEGORIES, $uri, $matches)) {
- $serendipity['GET']['category'] = $matches[1];
- $serendipity['GET']['action'] = 'read';
- $cInfo = serendipity_fetchCategoryInfo($serendipity['GET']['category']);
- $serendipity['head_title'] = $cInfo['category_name'];
- $serendipity['head_subtitle'] = $serendipity['blogTitle'];
+ $_args = $serendipity['uriArguments'];
- include_once(S9Y_INCLUDE_PATH . 'include/genpage.inc.php');
+ /* Attempt to locate hidden variables within the URI */
+ foreach ($_args as $k => $v){
+ if ($v == PATH_CATEGORIES) {
+ continue;
+ }
+ if ($v{0} == 'P') { /* Page */
+ $serendipity['GET']['page'] = substr($v, 1);
+ unset($_args[$k]);
+ unset($serendipity['uriArguments'][$k]);
+ }
+ }
+
+ $serendipity['GET']['category'] = $matches[1];
+ $serendipity['GET']['action'] = 'read';
+ $cInfo = serendipity_fetchCategoryInfo($serendipity['GET']['category']);
+ $serendipity['head_title'] = $cInfo['category_name'];
+ $serendipity['head_subtitle'] = $serendipity['blogTitle'];
+
+ include_once(S9Y_INCLUDE_PATH . 'include/genpage.inc.php');
} else if (preg_match('@/(index(\.php|\.html)?)|'. preg_quote($serendipity['indexFile']) .'@', $uri) ||
preg_match('@^/' . preg_quote(trim($serendipity['serendipityHTTPPath'], '/')) . '/?(\?.*)?$@', $uri)) {
-
- include_once(S9Y_INCLUDE_PATH . 'include/genpage.inc.php');
+ $serendipity['uriArguments'][] = PATH_ARCHIVES;
+ include_once(S9Y_INCLUDE_PATH . 'include/genpage.inc.php');
} else {
header('HTTP/1.0 404 Not found');
include_once(S9Y_INCLUDE_PATH . 'include/genpage.inc.php');
|