I think it' better add an option(HAS_MOD_REWRITE default true) than
write a plugin(a little difficult).
Follow is what i try to do, it's ok but not full tested.
<1> modify index.php add code like:
if( ! defined( 'HAS_MOD_REWRITE' ) ) {
define( 'HAS_MOD_REWRITE', true );
}
>> if you have no mod_rewrite you can define:
define( 'HAS_MOD_REWRITE', false );
<2> modify Controller::parse_request()
>> modify code::
/* Trim off any leading or trailing slashes */
$start_url = trim($start_url, '/');
/* 3 line code ADD BY ME */
if ( HAS_MOD_REWRITE === FALSE ) {
$start_url = str_replace('index.php/', '', $start_url);
}
/* Allow plugins to rewrite the stub before it's passed through
the rules */
$start_url = Plugins::filter('rewrite_request', $start_url);
$controller->stub = $start_url;
/* Grab the URL filtering rules from DB */
$matched_rule = URL::parse($controller->stub);
>> My purpose is to hide "index.php" so it's same when you has
mod_rewrite and not affect current plugin which hooks
'rewrite_request',
because I remove 'index.php' in variable $start_url, but
$controller->stub
has no 'index.php' and that's why I should modify Utils::redirect
and
URL::get(URL::out call it).
<3> URL::get
if ( $selectedrule instanceOf RewriteRule ) {
$return_url = $selectedrule->build( $args, $useall, $noamp );
/* 3 line code ADD BY ME */
if ( HAS_MOD_REWRITE === FALSE ) {
$return_url = 'index.php/' . $return_url;
}
if ( $prepend_site ) {
return Site::get_url( 'habari', true ) . $return_url;
}
else {
return $return_url;
}
}
<4> Utils::redirect
public static function redirect( $url = '', $continue = false )
{
if ( $url == '' ) {
$url = Controller::get_full_url() . (isset($_SERVER
['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : '');
/* 3 line code ADD BY ME, very ugly */
if ( HAS_MOD_REWRITE === FALSE ) {
$url = Controller::get_base_url() . 'index.php/' .
Controller::get_stub() . (isset($_SERVER['QUERY_STRING']) ? '?' .
$_SERVER['QUERY_STRING'] : ''); //FIXME:yugi
}
}
header('Location: ' . $url, true, 302);
if (!$continue) exit;
}
Now it may work, but in Site::get_url(Site::out_url call it) failed.
But in theme file like loginform.php has code like
<a href="<?php Site::out_url( 'habari' ); ?>/user/logout">
I think write code like follow is better
<a href="<?php URL::out( 'user', array( 'page' => 'logout' ) ); ?
>">
Site::out_url( 'habari' ) should use for static file.
Site::out_url( 'admin' ) also has same problem, so I modify
Site::get_url
>> code::
case 'admin':
//$url = Site::get_url( 'habari' ) . '/admin';
$url = Site::get_url( 'habari' ) . '/index.php/admin'; //ADD
BY ME
If write a plugin I think it should add some more hooks.
Currently it works but not full tested, sorry for my bad English.
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at http://groups.google.com/group/habari-dev
-~----------~----~----~----~------~----~------~--~---