Revision [16031]

This is an old revision of WikiFile made by ChewBakka on 2007-02-02 17:22:14.

 

In Wikka, almost everything is a page.

For example, a category is a page to which other pages link. If you want to stat a new category, you do not need to learn something new - just create the category page and link your pages to it.

Here I would like to present a solution where files are represented by pages too. I will first give a description on how to use it, then the necessary pieces of code.

Description

On the server side, there are no file names any more - any file is "contained" in a particular page and referenced using only the page name. If the file is an image, it is visible in the page (through the { {file} } action) along with explaining text which is writen in the page as usual. The access rights for viewing and mpdifying files are just the page rights.

I order to add a screenshot (or any other file) to your wiki, you will first create a page for it. This is something youshould do anyway, because you should write some explaining text about your screenshot. The page should include a { {file} } action to your page, although this is not necessary for being a file page - it is just for file pages what the { {category} } action is for category pages.

The page footer reads Edit page :: File :: Stats :: Referrers and so on - note the addition of File. Clicking on it opens the file handler, which displays informations about the file (if there is already a file in the page) and an upload form; uploading a file into a page which already contains a file causes the old file to be replaced with the new file - there can be only one file per page.

Code

Below are five pieces of code. The files Wikka.class.php and footer.php are parts of the Wikka software; I have extended them without changing existing functions (hopefully). I have also added two files: actions/file.php and handlers/page/file.php.

Here comes the modification of actions/footer.php; lines 5,6,7 are added, anything else remains unchanged. This adds File:: to the footer.
  1. <div class="footer">
  2. <?php
  3.     echo $this->FormOpen("", "TextSearch", "get");
  4.     echo $this->HasAccess("write") ? "<a href=\"".$this->href("edit")."\" title=\"Click to edit this page\">Edit page</a> ::\n" : "";
  5.     echo ($this->HasAccess("write") || $this->HasAccess("read"))
  6.         ? '<a href="' . $this->href("file"). '" title="Click to view/edit the file in this page">File</a> ::' . "\n"
  7.         : '';
  8.     // ...

There are no comments on this page.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki