From 35d36f61c5ff584e705d42e0459650f21e35bcff Mon Sep 17 00:00:00 2001 From: secretr Date: Tue, 2 Dec 2008 23:44:19 +0000 Subject: [PATCH] eURL news mod rewrite profile - work in progress --- e107.htaccess | 23 +++++++++++---- e107_admin/eurl.php | 7 +++-- .../core/news/apache_mod_rewrite/main.php | 28 +++++++++++++++++++ e107_files/e_url/core/news/main.php | 8 ++++-- .../shortcode/batch/news_shortcodes.php | 12 ++++---- e107_languages/English/admin/lan_eurl.php | 8 +++--- news.php | 13 +++++---- 7 files changed, 74 insertions(+), 25 deletions(-) create mode 100644 e107_files/e_url/core/news/apache_mod_rewrite/main.php diff --git a/e107.htaccess b/e107.htaccess index a08f4d689..d7b9cc3c6 100644 --- a/e107.htaccess +++ b/e107.htaccess @@ -1,5 +1,18 @@ -ErrorDocument 400 /error.php?400 -ErrorDocument 401 /error.php?401 -ErrorDocument 403 /error.php?403 -ErrorDocument 404 /error.php?404 -ErrorDocument 500 /error.php?500 \ No newline at end of file +Options +FollowSymlinks +RewriteEngine On + +### Set this to your e107 site root +RewriteBase / + +### NEWS ### +RewriteRule ^news/?$ news.php +#item, default, cat actions +RewriteRule ^news/([a-z]+)-([0-9]+)-([0-9]+)(\.html)?$ news.php?$1.$2.$3 [L] +#extend, cat, list actions +RewriteRule ^news/([a-z]+)-([0-9]+)(\.html)?$ news.php?.$1.$2 [L] + +#ErrorDocument 400 /error.php?400 +#ErrorDocument 401 /error.php?401 +#ErrorDocument 403 /error.php?403 +#ErrorDocument 404 /error.php?404 +#ErrorDocument 500 /error.php?500 \ No newline at end of file diff --git a/e107_admin/eurl.php b/e107_admin/eurl.php index c9d559f6b..3273a4c4a 100644 --- a/e107_admin/eurl.php +++ b/e107_admin/eurl.php @@ -9,8 +9,8 @@ * URL Management * * $Source: /cvs_backup/e107_0.8/e107_admin/eurl.php,v $ - * $Revision: 1.4 $ - * $Date: 2008-12-02 12:27:10 $ + * $Revision: 1.5 $ + * $Date: 2008-12-02 23:44:19 $ * $Author: secretr $ */ @@ -259,7 +259,8 @@ class admin_url_config { { $core_def = array( 'news' => array("core_name" => LAN_EURL_CORE_NEWS, 'core_path' => 'news'), - 'downloads' => array("core_name" => LAN_EURL_CORE_DOWNLOADS, 'core_path' => 'downloads') + 'download' => array("core_name" => LAN_EURL_CORE_DOWNLOADS, 'core_path' => 'download'), + 'user' => array("core_name" => LAN_EURL_CORE_USERS, 'core_path' => 'user') ); return $core_def; diff --git a/e107_files/e_url/core/news/apache_mod_rewrite/main.php b/e107_files/e_url/core/news/apache_mod_rewrite/main.php new file mode 100644 index 000000000..6f2536020 --- /dev/null +++ b/e107_files/e_url/core/news/apache_mod_rewrite/main.php @@ -0,0 +1,28 @@ + \ No newline at end of file diff --git a/e107_files/e_url/core/news/main.php b/e107_files/e_url/core/news/main.php index b6df62ca0..d07011db8 100644 --- a/e107_files/e_url/core/news/main.php +++ b/e107_files/e_url/core/news/main.php @@ -12,9 +12,13 @@ function url_news_main($parms) case 'list'://TODO - find out what are list params case 'month': //TODO - find out what are month params case 'day': //TODO - find out what are day params - return $base.'.'.$parms['value']; + return $base.'.'.varsettrue($parms['value'],'0'); case 'item': - return $base.".{$parms['id']}.{$parms['cat']}"; + case 'default': + return $base.".{$parms['value1']}.{$parms['value2']}"; + case 'nextprev': + return e_HTTP."news.php?{$parms['to_action']}.{$parms['subaction']}.[FROM]"; + default: return false; } diff --git a/e107_files/shortcode/batch/news_shortcodes.php b/e107_files/shortcode/batch/news_shortcodes.php index 60e9159f7..54f4e49e7 100644 --- a/e107_files/shortcode/batch/news_shortcodes.php +++ b/e107_files/shortcode/batch/news_shortcodes.php @@ -9,8 +9,8 @@ * News Shortcode Batch * * $Source: /cvs_backup/e107_0.8/e107_files/shortcode/batch/news_shortcodes.php,v $ - * $Revision: 1.12 $ - * $Date: 2008-12-02 16:50:15 $ + * $Revision: 1.13 $ + * $Date: 2008-12-02 23:44:19 $ * $Author: secretr $ */ if (!defined('e107_INIT')) { exit; } @@ -251,15 +251,15 @@ SC_END SC_BEGIN NEWSTHUMBNAIL global $e107; $news_item = getcachedvars('current_news_item'); -$param = getcachedvars('current_news_param'); echo -return (isset($news_item['news_thumbnail']) && $news_item['news_thumbnail']) ? "" : ""; +$param = getcachedvars('current_news_param'); +return (isset($news_item['news_thumbnail']) && $news_item['news_thumbnail']) ? "" : ""; SC_END SC_BEGIN NEWSIMAGE global $e107; $news_item = getcachedvars('current_news_item'); $param = getcachedvars('current_news_param'); -return (isset($news_item['news_thumbnail']) && $news_item['news_thumbnail']) ? "" : ""; +return (isset($news_item['news_thumbnail']) && $news_item['news_thumbnail']) ? "" : ""; SC_END SC_BEGIN STICKY_ICON @@ -272,7 +272,7 @@ SC_BEGIN NEWSTITLELINK global $e107; $news_item = getcachedvars('current_news_item'); $param = getcachedvars('current_news_param'); -return "".$news_item['news_title'].""; +return "".$news_item['news_title'].""; SC_END SC_BEGIN NEWSCATICON diff --git a/e107_languages/English/admin/lan_eurl.php b/e107_languages/English/admin/lan_eurl.php index 40ff92fd3..1c8d310ef 100644 --- a/e107_languages/English/admin/lan_eurl.php +++ b/e107_languages/English/admin/lan_eurl.php @@ -9,8 +9,8 @@ * Administration Language File * * $Source: /cvs_backup/e107_0.8/e107_languages/English/admin/lan_eurl.php,v $ - * $Revision: 1.2 $ - * $Date: 2008-12-02 12:27:10 $ + * $Revision: 1.3 $ + * $Date: 2008-12-02 23:44:19 $ * $Author: secretr $ */ if (!defined("PAGE_NAME")) { define("PAGE_NAME", "Manage Site URLs"); } @@ -28,10 +28,10 @@ define("LAN_EURL_LOCATION", "Profile Location:"); define("LAN_EURL_CORE_NEWS", "News"); -define("LAN_EURL_CORE_DOWNLOADS", "News"); +define("LAN_EURL_CORE_DOWNLOADS", "Downloads"); +define("LAN_EURL_CORE_USERS", "Users"); define("LAN_EURL_MODREWR_TITLE", "SEF URLs"); define("LAN_EURL_MODREWR_DESCR", "You'll need mod_rewrite isntalled and running on your server (Apache Web Server). After enabling this profile go to your site root folder, rename htaccess.txt to .htaccess and uncomment the corresponding line."); -define("LAN_EURL_COREPR_DOWNLOADS", "Downloads SEF URLs"); //define("LAN_EURL_", ""); //define("LAN_EURL_", ""); diff --git a/news.php b/news.php index df75962bb..67b02b393 100644 --- a/news.php +++ b/news.php @@ -11,11 +11,12 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/news.php,v $ -| $Revision: 1.13 $ -| $Date: 2008-12-02 20:51:52 $ +| $Revision: 1.14 $ +| $Date: 2008-12-02 23:44:19 $ | $Author: secretr $ +----------------------------------------------------------------------------+ */ + require_once("class2.php"); require_once(e_HANDLER."news_class.php"); require_once(e_HANDLER."comment_class.php"); @@ -172,7 +173,8 @@ if ($action == 'cat' || $action == 'all') $amount = ($action == "all") ? NEWSALL_LIMIT : NEWSLIST_LIMIT; $icon = ($row['category_icon']) ? "" : ""; - $parms = $news_total.",".$amount.",".$newsfrom.",".e_SELF.'?'.$action.".".$category.".[FROM]"; + + $parms = $news_total.",".$amount.",".$newsfrom.",".$e107->url->getUrl('core:news', 'main', "action=nextprev&to_action={$action}&subaction={$category}"); $text .= "
".$tp->parseTemplate("{NEXTPREV={$parms}}")."
"; if(!$NEWSLISTTITLE) @@ -466,7 +468,7 @@ if(isset($pref['news_unstemplate']) && $pref['news_unstemplate'] && file_exists( $text = preg_replace("/\{(.*?)\}/e", '$\1', $NEWSCLAYOUT); require_once(HEADERF); - $parms = $news_total.",".ITEMVIEW.",".$newsfrom.",".e_SELF.'?'.($action ? $action : 'default' ).($sub_action ? ".".$sub_action : ".0").".[FROM]"; + $parms = $news_total.",".ITEMVIEW.",".$newsfrom.",".$e107->url->getUrl('core:news', 'main', "action=nextprev&to_action=".($action ? $action : 'default' )."&subaction=".($sub_action ? $sub_action : "0")); $nextprev = $tp->parseTemplate("{NEXTPREV={$parms}}"); $text .= ($nextprev ? "
".$nextprev."
" : ""); // $text=''.$text.'
'.$nextprev.'
'; @@ -509,7 +511,8 @@ else $ix->render_newsitem($news); $i++; } - $parms = $news_total.",".ITEMVIEW.",".$newsfrom.",".e_SELF.'?'.($action ? $action : 'default' ).($sub_action ? ".".$sub_action : ".0").".[FROM]"; + + $parms = $news_total.",".ITEMVIEW.",".$newsfrom.",".$e107->url->getUrl('core:news', 'main', "action=nextprev&to_action=".($action ? $action : 'default' )."&subaction=".($sub_action ? $sub_action : "0")); $nextprev = $tp->parseTemplate("{NEXTPREV={$parms}}"); echo ($nextprev ? "
".$nextprev."
" : "");