Revision [277]

This is an old revision of Mod032bModRewrite made by JsnX on 2004-05-13 03:10:58.

 

Wikka Mod 032

Type: Bug Fix

Credit:

JoeD -- Joe Delaney -- http://www.wakkawiki.com/RewriteMode
Jason Tourtelotte -- Minor improvements.


Note: These are not the exact coding changes used in Wikka....but the ideas and file pointers are pretty much right on.



When rewrite mode is off, the base url will contain "wakka.php?wakka=" and this will cause a series of problem for dependent files (stylesheets, graphics) and generated links (the revisions page and backlink page search).

Here is a solution that I came up with. It works for me, but use at your own risk.

Replace actions/header.php with this version:
<?php
    $message = $this->GetMessage();
    $user = $this->GetUser();
    $site_base = $this->GetConfigValue("base_url");
    if ( substr_count($site_base, 'wakka.php?wakka=') > 0 )
        $site_base = substr($site_base,0,-16);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
    <title><?php echo $this->GetWakkaName()." : ".$this->GetPageTag(); ?></title>
    <base href="<?php echo $site_base ?>" />
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <meta name="keywords" content="<?php echo $this->GetConfigValue("meta_keywords") ?>" />
    <meta name="description" content="<?php echo $this->GetConfigValue("meta_description") ?>" />
    <link rel="stylesheet" type="text/css" href="css/wakka.css" />
    <script language="JavaScript" type="text/javascript">
        function fKeyDown()
        {
            if (event.keyCode == 9)
            {
                event.returnValue = false;
                document.selection.createRange().text = String.fromCharCode(9);
            }
        }
    </script>
</head>

<body
    <?php echo (!$user || ($user["doubleclickedit"] == Y)) && ($this->GetMethod() == "show") ? "ondblclick=\"document.location='".$this->href("edit")."';\" " : "" ?>
    <?php echo $message ? "onLoad=\"alert('".$message."');\" " : "" ?>
>

<div class="header">
    <h2><?php echo $this->config["wakka_name"] ?> : <a href="<?php echo $this->config["base_url"] ?>TextSearch<?php
        if (!$this->config["rewrite_mode"])
        {
            echo "&amp;";
        }
        else
        {
            echo "?";
        } ?>phrase=<?php echo urlencode($this->GetPageTag()); ?>"><?php echo $this->GetPageTag(); ?></a></h2>
    <?php echo $this->Link($this->config["root_page"]); ?> ::
    <?php echo $this->config["navigation_links"] ? $this->Format($this->config["navigation_links"])." :: " : "" ?>
    You are <?php echo $this->Format($this->UserName()) ?>
</div>

You will have to edit actions/footer.php too, look for the img tag with the "xml/xml.gif" source and change it to
<img src=\"xml/xml.gif\" width=\"36\" height=\"14\" align=\"middle\" style=\"border : 0px;\" alt=\"XML\" />


Now in handlers/page/revisions.php
 replace
<?php

    $output .= "<td>&nbsp;<a href=\"".$this->href("show")."?time=".urlencode($page["time"])."\">".$page["time"]."</a></td>";

?>

with
<?php

    if (!$this->config["rewrite_mode"]) {
        $output .= "<td>&nbsp;<a href=\"".$this->href("show")."&amp;time=".urlencode($page["time"])."\">".$page["time"]."</a></td>";
    }
    else
    {
        $output .= "<td>&nbsp;<a href=\"".$this->href("show")."?time=".urlencode($page["time"])."\">".$page["time"]."</a></td>";
    }

?>


There may be other broken links that depend on the rewrite rules (look on WakkaBugTracker), but I haven't found any others yet. With these modifications you can turn rewrite_mode on or off at will (remember to change the base_url too) and the stylesheets, xml icon, back-linking and revisions keep working.

You may also need to delete the .htaccess file on the /xml and /css directories.



actions/recentchanges.php need the same xml/xml.gif as actions/footer.php



Similarly in handlers/page/revisions.xml.php
 replace

<?php

                            $xml .= "<link>".$this->href("show")."?time=".urlencode($page["time"])."</link>\n";
?>

with
<?php

                             if (!$this->config["rewrite_mode"]) {
                                       $xml .= "<link>".$this->href("show")."&amp;time=".urlencode($page["time"])."</link>\n";
                               }
                               else
                               {
                                        $xml .= "<link>".$this->href("show")."?time=".urlencode($page["time"])."</link>\n";
                               }
?>
There are no comments on this page.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki