Revision [19233]

This is an old revision of TimoK made by TimoK on 2008-01-28 00:14:44.

 

Who is Timo K?

Full Name: Timo Kissing
Born: 1978
Living near Stuttgart, Germany
Studying 'Medieninformatik' (Media Computer Science)
Author and maintainer of several websites, you can find an overview and more information about me at ranta.info

I enjoy PHP-Coding a lot, so participating on Wikka is 'the natural thing' to do.
I am thinking about a german translation of Wikka, but that won't happen to soon.

Wikka Contributions


Working already

Bingo card generating
See BingoActionInfo
discordian date action
See http://ranta.info/ddateAction

In beta-stadium

Code-Cleanup of handlers/page/edit.php
For some other stuff I work on I had to understand the edit handler, so I can modifiy it. I found the code quite hard to read, so i re-structured it, added some more comments and tweaked the logic a bit.
I only have this running on a test installation, but I found no problems yet and will soon use it on a real wikka. If anyone would be willing the take a look at the code or test it somewhere, I am always happy about comments.
<div class="page">
<?php
// PREPARATIONS
if ($result = mysql_query("describe ".$this->config['table_prefix']."pages tag")) {
    $field = mysql_fetch_assoc($result);
    if (preg_match("/varchar\((\d+)\)/", $field['Type'], $matches)) {
        $maxtaglen = $matches[1];
     }
} else {
    $maxtaglen = 75;
}

if (!$previous = $_POST['previous']) {
    $previous = $this->page['id'];
}

// strip CRLF line endings down to LF to achieve consistency
// ... plus it saves database space.
// Note: these codes must remain enclosed in double-quotes to work! -- JsnX
$body = str_replace("\r\n", "\n", $_POST['body']);
if (!$body) $body = $this->page['body'];

// replace each 4 spaces at beginning of a line with a tab
$body = preg_replace("/^[ ]{4}/","\t", $body);
// UNTESTED possible optimization of the next 2 replacements:
// preg_replace("/^(( {4})+)/me","str_repeat('\t',strlen('\\1')/4)",$body)
$body = preg_replace("/\n[ ]{4}/","\n\t", $body);
while (preg_match("/\t[ ]{4}/",$body)) {
    $body = preg_replace("/\t[ ]{4}/","\t\t", $body);
}

// we don't need to escape here, we do that just before display
// (i.e., treat note just like body!)
$note = trim($_POST['note']);

// DO SOMETHING!

// check for valid pagename (only for new pages!)
if (!$this->page && !(preg_match($this->config["wikiname_regex"], $this->tag))) {
    $output = '<em>The page name is invalid.'.
        'Valid page names must start with a letter and contain'.
        ' only letters and numbers.</em>';

// else check tag length (only for new pages!)
} elseif (!$this->page && strlen($this->tag) > $maxtaglen) {
    // truncate tag to feed a backlinks-handler with the correct value.
    // may be omited. it only works if the link to a backlinks-handler
    // is built in the footer.
    $this->tag = substr($this->tag, 0, $maxtaglen);
    $output  = "<div class=\"error\">Tag too long! $maxtaglen characters max.</div>";
    $output .= "<br />\n FYI: Clicking on Rename will automatically truncate the tag";
    $output .= " to the correct size.<br /><br />\n";
    $output .= $this->FormOpen('edit');
    $output .= '<input name="newtag" size="75" value="';
    $output .= $this->htmlspecialchars_ent($this->tag).'" />';
    $output .= '<input name="submit" type="submit" value="Rename" />'."\n";
    $output .= $this->FormClose();

// else check if we are renaming and need to redirect
} elseif (isset($_POST['newtag']) && $newtag = $_POST['newtag']) {
    $this->Redirect($this->Href('edit', $newtag));

// enough checking, we can START DOING REAL STUFF
} elseif ($this->HasAccess("write") && $this->HasAccess("read")) {
    // only if SAVING
    if ($_POST['submit'] == 'Store') {

        // check for overwriting
        if ($this->page && ($this->page['id'] != $_POST['previous'])) {
            $error = 'OVERWRITE ALERT: This page was modified by someone'.
                'else while you were editing it.<br />'."\n".
                'Please copy your changes and re-edit this page.';

        // else store if new body differs from old body
        } elseif ($body != $this->page['body']) {
            // add page (revisions)
            $this->SavePage($this->tag, $body, $note);

            // now we render it internally so we can write the updated link table.
            $this->ClearLinkTable();
            $this->StartLinkTracking();
            $dummy = $this->Header();
            $dummy .= $this->Format($body);
            $dummy .= $this->Footer();
            $this->StopLinkTracking();
            $this->WriteLinkTable();
            $this->ClearLinkTable();
        }
        // forward if no error
        if (!$error) {
            $this->Redirect($this->Href());
        }
    }

    // if PREVIEW
    if ($_POST['submit'] == 'Preview') {
        // We need to escape ALL entity refs before display so we display
        // them _as_ entities instead of interpreting them
        // so we use htmlspecialchars on the edit note (as on the body)
        $previewButtons =
            "<hr />\n".
            '<input size="50" type="text" name="note" value="'.
            htmlspecialchars($note).'"/> Note on your edit.<br />'."\n".
            '<input name="submit" type="submit" value="Store" accesskey="s" />'."\n".
            '<input name="submit" type="submit" value="Re-Edit" accesskey="p" />'."\n".
            '<input type="button" value="Cancel" onclick="document.location=\''.
            $this->href('').'\';" />'."\n";

        $output .= '<div class="previewhead">Preview</div>'."\n";
        $output .= $this->Format($body);

        // We need to escape ALL entity refs before display so we display
        // them _as_ entities instead of interpreting them
        // hence htmlspecialchars() instead of htmlspecialchars_ent()
        // which UNescapes entities!
        $output .=
            $this->FormOpen('edit')."\n".
            '<input type="hidden" name="previous" value="'.$previous.'" />'."\n".
            '<input type="hidden" name="body" value="'.htmlspecialchars($body).
            '" />'."\n";

        $output .=
            "<br />\n".
            $previewButtons.
            $this->FormClose()."\n";

    // else EDIT
    } else {
        // display error
        if ($error) {
            $output .= '<div class="error">'.$error.'</div>'."\n";
        }

        // append a comment?
        if ($_REQUEST['appendcomment']) {
            $body = trim($body)."\n\n----\n\n--".$this->GetUserName().' ('.strftime("%c").')';
        }

        // We need to escape ALL entity refs before display so we display
        // them _as_ entities instead of interpreting them
        $output .=
            $this->FormOpen('edit').
            '<input type="hidden" name="previous" value="'.$previous.'" />'."\n".
            '<textarea id="body" name="body" style="width: 100%; height: 500px">'
            .htmlspecialchars($body).'</textarea><br />'."\n".
            '<input size="40" type="text" name="note" value="'.htmlspecialchars($note).
            '" /> Please add a note on your edit.<br />'."\n".
            '<input name="submit" type="submit" value="Store" accesskey="s" /> '.
            '<input name="submit" type="submit" value="Preview" accesskey="p" /> '.
            '<input type="button" value="Cancel" onclick="document.location=\''.
            $this->Href('').'\';" />'."\n".
            $this->FormClose();

        if ($this->GetConfigValue('gui_editor') == 1) {
            $output .=
                '<script language="JavaScript" src="3rdparty/plugins/wikiedit/protoedit.js">'.
                '</script>'."\n".
                '<script language="JavaScript" src="3rdparty/plugins/wikiedit/wikiedit2.js">'.
                '</script>'."\n".
                '<script type="text/javascript">'.
                "  wE = new WikiEdit(); wE.init('body','WikiEdit','editornamecss');".
                '</script>'."\n";
        }
    }

// if none of the above was true, the user has no right to edit
} else {
    $output = '<em>You don\'t have write access to this page.'.
        'You might need to register an account to get write access.</em><br />'.
        "\n"."<br />\n".
        '<a href="'.$this->Href('showcode').
        '" title="Click to view page formatting code">'.
        'View formatting code for this page</a>'.
        "<br />\n";
}

echo $output;

?>
</div>


In planning or pre-alpha-stadium

Due to my exams I have to stop working on everything of this until 21st of july
Wikipedia aniversary pages linking
I will release an action soon that provides easy linking to wikipedias 'anniversary'-pages (like http://en.wikipedia.org/wiki/April_3) in different languages.
A first preview can be found at my wikka.
Wikka-phpBB-Integration
I am already using the phpBB-userdatabase in one of my wikka-installations. I want a better integration tho, with one combined admin interface, simple linking between both systems (aka usage of wikkinames on the messageboard and easy, interwiki-like linking to threads on the wikka in a way so wikka recognizes those links as internal) and shared usergroups, categories and ACLs between both systems.
If anyone has done something like this already, please let me know. If you haven't, but you are interested in doing so, let me know too. I will soon set up a test-host just for this purpose, where you can view the progress.
Google Sitemap Support
Google Sitemaps are an improved way of telling google what it can find at your site, when the last update was and which pages are likely to be updated soon again. Since it uses a simple xml file and a ping-mechanism it should not be too difficult to include this into wikka. I will start working on this before the end of june.


CategoryUsers
There are 7 comments on this page. [Show comments]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki