merging new-urls branch

This commit is contained in:
real_nowhereman 2008-03-24 20:25:33 +00:00
parent a05652c00b
commit b5758344d1
7 changed files with 100 additions and 78 deletions

View File

@ -5,7 +5,7 @@
include INCLUDES_DIR . 'includes.php'; include INCLUDES_DIR . 'includes.php';
/* backward compatibility */ /* backward compatibility */
if (!@$_GET['entry']) { if (!@$_GET['entry']) {
@utils_redirect(); @utils_redirect();
} else { } else {
@ -20,7 +20,7 @@
function comment_main($module) { function comment_main($module) {
global $fpdb; global $fpdb, $fp_params;
// hackish solution to get title before fullparse starts dunno, I don't like it // hackish solution to get title before fullparse starts dunno, I don't like it
@ -32,9 +32,9 @@
return $module; return $module;
if (!empty($_GET['feed'])){ if (!empty($fp_params['feed'])){
switch($_GET['feed']) { switch($fp_params['feed']) {
case 'atom': case 'atom':
header('Content-type: application/atom+xml'); header('Content-type: application/atom+xml');
@ -58,10 +58,10 @@
function comment_feed() { function comment_feed() {
echo "\n<link rel=\"alternate\" type=\"application/rss+xml\" title=\"Get Comments RSS 2.0 Feed\" href=\"". echo "\n<link rel=\"alternate\" type=\"application/rss+xml\" title=\"Get Comments RSS 2.0 Feed\" href=\"".
theme_comments_feed_link('rss2', $_GET['entry']) theme_comments_feed_link('rss2', $fp_params['entry'])
."\" />"; ."\" />";
echo "\n<link rel=\"alternate\" type=\"application/atom+xml\" title=\"Get Comments Atom 1.0 Feed\" href=\"". echo "\n<link rel=\"alternate\" type=\"application/atom+xml\" title=\"Get Comments Atom 1.0 Feed\" href=\"".
theme_comments_feed_link('atom', $_GET['entry']) theme_comments_feed_link('atom', $fp_params['entry'])
."\" />\n"; ."\" />\n";
} }
add_action('wp_head', 'comment_feed'); add_action('wp_head', 'comment_feed');
@ -185,7 +185,7 @@
function commentform() { function commentform() {
global $smarty, $lang, $fpdb; global $smarty, $lang, $fpdb, $fp_params;
$comment_formid = 'fp-comments'; $comment_formid = 'fp-comments';
$smarty->assign('comment_formid', $comment_formid); $smarty->assign('comment_formid', $comment_formid);
@ -205,11 +205,11 @@
global $fp_config; global $fp_config;
$id = comment_save($_GET['entry'], $arr); $id = comment_save($fp_params['entry'], $arr);
do_action('comment_post', $_GET['entry'], array($id, $arr)); do_action('comment_post', $fp_params['entry'], array($id, $arr));
$q =& new FPDB_Query(array('id'=>$_GET['entry'],'fullparse'=>false), null); $q =& new FPDB_Query(array('id'=>$fp_params['entry'],'fullparse'=>false), null);
list($entryid, $e) = $q->getEntry(); list($entryid, $e) = $q->getEntry();

View File

@ -122,6 +122,21 @@
utils_redirect(); utils_redirect();
} }
} }
function system_init_action_params() {
global $fp_params;
$fp_params = array();
if ($x = @$_GET['x'])
$fp_params = utils_kexplode($x, ':;', false);
$fp_params = array_merge($_GET, $fp_params);
}
function system_init() { function system_init() {

View File

@ -239,9 +239,7 @@
function theme_init(&$smarty) { /* &$mode */ function theme_init(&$smarty) { /* &$mode */
global $fp_config; global $fp_config, $lang, $theme, $fp_params;
global $lang;
global $theme;
// avoid compiled tpl collision (i.e. change theme without this and cry) // avoid compiled tpl collision (i.e. change theme without this and cry)
$smarty->compile_id = md5($fp_config['general']['theme']); $smarty->compile_id = md5($fp_config['general']['theme']);
@ -294,7 +292,7 @@
$smarty->register_modifier('filed', 'theme_entry_categories'); $smarty->register_modifier('filed', 'theme_entry_categories');
if (!isset($_GET['feed']) || empty($_GET['feed'])) { if (!isset($fp_params['feed']) || empty($fp_params['feed'])) {
$smarty->register_modifier('date_format_daily', 'theme_smarty_modifier_date_format_daily'); $smarty->register_modifier('date_format_daily', 'theme_smarty_modifier_date_format_daily');
$smarty->register_modifier('date_format', 'theme_date_format'); $smarty->register_modifier('date_format', 'theme_date_format');
} }
@ -419,7 +417,7 @@
add_filter('feed_link', 'theme_def_feed_link', 0, 2); add_filter('feed_link', 'theme_def_feed_link', 0, 2);
function theme_def_feed_link($str, $type) { function theme_def_feed_link($str, $type) {
return BLOG_BASEURL . "?feed={$type}"; return BLOG_BASEURL . "?x=feed:{$type}";
} }
function theme_feed_link ($feed='rss2') { function theme_feed_link ($feed='rss2') {
return apply_filters('feed_link', '', $feed); return apply_filters('feed_link', '', $feed);
@ -427,7 +425,7 @@
add_filter('post_comments_feed_link', 'theme_def_feed_comments_link', 0, 3); add_filter('post_comments_feed_link', 'theme_def_feed_comments_link', 0, 3);
function theme_def_feed_comments_link($str, $feed, $id) { function theme_def_feed_comments_link($str, $feed, $id) {
return BLOG_BASEURL . "?entry=$id&amp;comments&amp;feed={$feed}"; return BLOG_BASEURL . "?x=entry:$id;comments:1;feed:{$feed}";
} }
function theme_comments_feed_link ($feed='rss2', $id) { function theme_comments_feed_link ($feed='rss2', $id) {
return apply_filters('post_comments_feed_link', '', $feed, $id); return apply_filters('post_comments_feed_link', '', $feed, $id);
@ -436,7 +434,7 @@
add_filter('post_link', 'theme_def_permalink', 0, 2); add_filter('post_link', 'theme_def_permalink', 0, 2);
function theme_def_permalink($str, $id) { function theme_def_permalink($str, $id) {
return BLOG_BASEURL . "?entry=$id"; return BLOG_BASEURL . "?x=entry:$id";
} }
function get_permalink ($id) { function get_permalink ($id) {
return apply_filters('post_link', '', $id); return apply_filters('post_link', '', $id);
@ -444,7 +442,7 @@
add_filter('comments_link', 'theme_def_commentlink', 0, 2); add_filter('comments_link', 'theme_def_commentlink', 0, 2);
function theme_def_commentlink($str, $id) { function theme_def_commentlink($str, $id) {
return BLOG_BASEURL . "?entry=$id&amp;comments"; return BLOG_BASEURL . "?x=entry:$id;comments:1";
} }
function get_comments_link ($id) { function get_comments_link ($id) {
return apply_filters('comments_link', '', $id); return apply_filters('comments_link', '', $id);
@ -461,7 +459,7 @@
add_filter('category_link', 'theme_def_catlink', 0, 2); add_filter('category_link', 'theme_def_catlink', 0, 2);
function theme_def_catlink($str, $catid) { function theme_def_catlink($str, $catid) {
return BLOG_BASEURL . "?cat=$catid"; return BLOG_BASEURL . "?x=cat:$catid";
} }
function get_category_link($catid) { function get_category_link($catid) {
return apply_filters('category_link', '', $catid); return apply_filters('category_link', '', $catid);
@ -472,7 +470,7 @@
return wp_specialchars( return wp_specialchars(
apply_filters( apply_filters(
'year_link', 'year_link',
BLOG_BASEURL . '?y='. str_pad($year, 2, '0', STR_PAD_LEFT), BLOG_BASEURL . '?x=y:'. str_pad($year, 2, '0', STR_PAD_LEFT),
$year) $year)
); );
} }
@ -481,8 +479,8 @@
return wp_specialchars( return wp_specialchars(
apply_filters( apply_filters(
'month_link', 'month_link',
BLOG_BASEURL . '?y='. str_pad($year, 2, '0', STR_PAD_LEFT) . BLOG_BASEURL . '?x=y:'. str_pad($year, 2, '0', STR_PAD_LEFT) .
'&m=' . str_pad($month, 2, '0', STR_PAD_LEFT), ';m:' . str_pad($month, 2, '0', STR_PAD_LEFT),
$year, $year,
$month) $month)
); );
@ -492,9 +490,9 @@
return wp_specialchars( return wp_specialchars(
apply_filters( apply_filters(
'month_link', 'month_link',
BLOG_BASEURL . '?y='. str_pad($year, 2, '0', STR_PAD_LEFT) BLOG_BASEURL . '?y:'. str_pad($year, 2, '0', STR_PAD_LEFT)
. '&m=' . str_pad($month, 2, '0', STR_PAD_LEFT) . ';m:' . str_pad($month, 2, '0', STR_PAD_LEFT)
. '&d=' . str_pad($day, 2, '0', STR_PAD_LEFT), . ';d:' . str_pad($day, 2, '0', STR_PAD_LEFT),
$year, $year,
$month) $month)
); );

View File

@ -1,6 +1,7 @@
<?php <?php
// Some default filters // Some default filters
add_filter('init', 'system_init_action_params');
add_filter('bloginfo','wp_specialchars'); add_filter('bloginfo','wp_specialchars');
add_filter('category_description', 'wptexturize'); add_filter('category_description', 'wptexturize');
add_filter('list_cats', 'wptexturize'); add_filter('list_cats', 'wptexturize');

View File

@ -40,6 +40,7 @@ class Plugin_PrettyURLs {
var $status = 0; var $status = 0;
var $date_handled = false; var $date_handled = false;
var $categories = null; var $categories = null;
var $fp_params;
function categories($force=true) { function categories($force=true) {
@ -156,9 +157,9 @@ class Plugin_PrettyURLs {
if (PRETTYURLS_TITLES) { if (PRETTYURLS_TITLES) {
if ($c = array_search($matches[1], $this->categories)) if ($c = array_search($matches[1], $this->categories))
$_GET['category'] = $c; $this->fp_params['cat'] = $c;
} else { } else {
$_GET['category'] = $matches[1]; $this->fp_params['cat'] = $matches[1];
} }
} }
@ -169,9 +170,9 @@ class Plugin_PrettyURLs {
function handle_date($matches) { function handle_date($matches) {
$_GET['y'] = $matches[1]; $this->fp_params['y'] = $matches[1];
if (isset($matches[3])) $_GET['m'] = $matches[3] ; if (isset($matches[3])) $this->fp_params['m'] = $matches[3] ;
if (isset($matches[5])) $_GET['d'] = $matches[5]; if (isset($matches[5])) $this->fp_params['d'] = $matches[5];
$this->date_handled = true; $this->date_handled = true;
@ -179,40 +180,40 @@ class Plugin_PrettyURLs {
function handle_static($matches) { function handle_static($matches) {
$_GET['page'] = $matches[1]; $this->fp_params['page'] = $matches[1];
$this->status = 2; $this->status = 2;
} }
function handle_entry($matches) { function handle_entry($matches) {
if (PRETTYURLS_TITLES) { if (PRETTYURLS_TITLES) {
if (isset($this->index[$_GET['y']][$_GET['m']][$_GET['d']][md5($matches[1])])) { if (isset($this->index[$this->fp_params['y']][$this->fp_params['m']][$this->fp_params['d']][md5($matches[1])])) {
$_GET['entry'] = $this->index[$_GET['y']][$_GET['m']][$_GET['d']][md5($matches[1])]; $this->fp_params['entry'] = $this->index[$this->fp_params['y']][$this->fp_params['m']][$this->fp_params['d']][md5($matches[1])];
} else { } else {
// a bit hackish: we make up a fake url when there is no match, // a bit hackish: we make up a fake url when there is no match,
// so that at the higher level the system will 404... // so that at the higher level the system will 404...
$_GET['entry'] = 'entry000000-000000'; $this->fp_params['entry'] = 'entry000000-000000';
} }
} else { } else {
$_GET['entry'] = $matches[1]; $this->fp_params['entry'] = $matches[1];
} }
} }
function handle_page($matches) { function handle_page($matches) {
$_GET['paged'] = $matches[1]; $this->fp_params['paged'] = $matches[1];
$this->status = 2; $this->status = 2;
} }
function handle_comment($matches) { function handle_comment($matches) {
$_GET['comments'] = true; $this->fp_params['comments'] = true;
} }
function handle_feed($matches) { function handle_feed($matches) {
$_GET['feed'] = isset($matches[2])? $matches[2]:'rss2'; $this->fp_params['feed'] = isset($matches[2])? $matches[2]:'rss2';
} }
@ -233,6 +234,10 @@ class Plugin_PrettyURLs {
function cache_init() { function cache_init() {
global $fp_params;
$this->fp_params =& $fp_params;
if (PRETTYURLS_TITLES) { if (PRETTYURLS_TITLES) {
if ($f = io_load_file(PRETTYURLS_CACHE)) if ($f = io_load_file(PRETTYURLS_CACHE))
$this->index = unserialize($f); $this->index = unserialize($f);
@ -415,18 +420,18 @@ class Plugin_PrettyURLs {
$l = BLOG_BASEURL; $l = BLOG_BASEURL;
if ( ( is_numeric($cid = @$_GET['category']) ) || if ( ( is_numeric($cid = @$this->fp_params['category']) ) ||
is_numeric($cid = @$_GET['cat']) ) is_numeric($cid = @$this->fp_params['cat']) )
$l = $this->categorylink($l, $cid); $l = $this->categorylink($l, $cid);
if (isset($_GET['y']) && $_GET['y']) { if (isset($this->fp_params['y']) && $this->fp_params['y']) {
$l .= '20'. $_GET['y'] . '/'; $l .= '20'. $this->fp_params['y'] . '/';
if (isset($_GET['m']) && $_GET['m']) { if (isset($this->fp_params['m']) && $this->fp_params['m']) {
$l .= $_GET['m'] . '/'; $l .= $this->fp_params['m'] . '/';
if (isset($_GET['d']) && $_GET['d']) if (isset($this->fp_params['d']) && $this->fp_params['d'])
$l .= $_GET['d'] . '/'; $l .= $this->fp_params['d'] . '/';
} }
@ -434,7 +439,7 @@ class Plugin_PrettyURLs {
$page = 1; $page = 1;
if (isset($_GET['paged']) && $_GET['paged']>1) $page = $_GET['paged']; if (isset($this->fp_params['paged']) && $this->fp_params['paged']>1) $page = $this->fp_params['paged'];
$page += $v; $page += $v;

View File

@ -33,6 +33,7 @@ Author URI: http://www.nowhereland.it/
function plugin_readmore_main($string) { function plugin_readmore_main($string) {
global $fp_params;
$MODE = 'manual'; $MODE = 'manual';
@ -77,8 +78,8 @@ function plugin_readmore_main($string) {
} }
if ($q->single || isset($_GET['entry'])) { if ($q->single || isset($fp_params['entry'])) {
$string = str_replace('[more]', "<a id=\"readmore-{$_GET['entry']}\"></a>", $string); $string = str_replace('[more]', "<a id=\"readmore-{$fp_params['entry']}\"></a>", $string);
} }
return $string; return $string;

View File

@ -45,9 +45,9 @@
function index_singlepost(&$params, &$module) { function index_singlepost(&$params, &$module) {
global $fpdb, $theme; global $fpdb, $theme, $fp_params;
$params['id'] = $_GET['entry']; $params['id'] = $fp_params['entry'];
$params['fullparse']=true; $params['fullparse']=true;
$fpdb->query($params); $fpdb->query($params);
@ -56,7 +56,7 @@
add_filter('wp_title', 'index_permatitle', 10, 2); add_filter('wp_title', 'index_permatitle', 10, 2);
if (isset($_GET['comments'])) { if (isset($fp_params['comments'])) {
$module = 'comments.tpl'; $module = 'comments.tpl';
$params['comments'] = true; $params['comments'] = true;
@ -95,35 +95,37 @@
function index_showposts(&$params, &$module) { function index_showposts(&$params, &$module) {
if (isset($_GET['d']) && $_GET['d']) global $fp_params;
$params['d'] = $_GET['d'];
if (isset($_GET['m']) && $_GET['m']) if (isset($fp_params['d']) && $fp_params['d'])
$params['m'] = $_GET['m']; $params['d'] = $fp_params['d'];
if (isset($_GET['y']) && $_GET['y']) if (isset($fp_params['m']) && $fp_params['m'])
$params['y'] = $_GET['y']; $params['m'] = $fp_params['m'];
if (isset($_GET['start']) && $_GET['start']) if (isset($fp_params['y']) && $fp_params['y'])
$params['start'] = intval($_GET['start']); $params['y'] = $fp_params['y'];
if (isset($_GET['count']) && $_GET['count']) if (isset($fp_params['start']) && $fp_params['start'])
$params['count'] = intval($_GET['count']); $params['start'] = intval($fp_params['start']);
if (isset($_GET['category']) && is_numeric($_GET['category']))
$params['category'] = intval($_GET['category']); if (isset($fp_params['count']) && $fp_params['count'])
$params['count'] = intval($fp_params['count']);
if (isset($fp_params['category']) && is_numeric($fp_params['category']))
$params['category'] = intval($fp_params['category']);
if (isset($_GET['cat']) && is_numeric($_GET['cat'])) if (isset($fp_params['cat']) && is_numeric($fp_params['cat']))
$params['category'] = intval($_GET['cat']); $params['category'] = intval($fp_params['cat']);
if (isset($_GET['random'])) { if (isset($fp_params['random'])) {
if (empty($_GET['random'])) if (empty($fp_params['random']))
$params['random'] = 1; $params['random'] = 1;
elseif (is_numeric($_GET['random'])) elseif (is_numeric($fp_params['random']))
$params['random'] = intval($_GET['random']); $params['random'] = intval($fp_params['random']);
} }
if ((isset($_GET['paged'])) && is_numeric($_GET['paged']) && $_GET['paged']>0) if ((isset($fp_params['paged'])) && is_numeric($fp_params['paged']) && $fp_params['paged']>0)
$params['page']=$_GET['paged']; $params['page']=$fp_params['paged'];
else else
$params['page'] = 1; $params['page'] = 1;
@ -131,20 +133,20 @@
function index_main() { function index_main() {
global $fpdb, $smarty, $fp_config; global $fpdb, $smarty, $fp_config, $fp_params;
$params = array(); $params = array();
$module = 'index.tpl' ; $module = 'index.tpl' ;
$can404 = true; $can404 = true;
if (!empty($_GET['entry'])) { if (!empty($fp_params['entry'])) {
index_singlepost($params, $module); index_singlepost($params, $module);
} elseif ( } elseif (
($explicit_req = $page = @$_GET['page']) || ($explicit_req = $page = @$fp_params['page']) ||
(empty($_GET) && $page = @$fp_config['general']['startpage']) (empty($fp_params) && $page = @$fp_config['general']['startpage'])
) { ) {
@ -155,11 +157,11 @@
$module = search_main(); $module = search_main();
} else { } else {
if (!empty($_GET['feed'])){ if (!empty($fp_params['feed'])){
$can404=false; $can404=false;
switch($_GET['feed']) { switch($fp_params['feed']) {
case 'atom': case 'atom':
header('Content-type: application/atom+xml'); header('Content-type: application/atom+xml');
$module = SHARED_TPLS . 'atom.tpl'; $module = SHARED_TPLS . 'atom.tpl';