Revision [15951]

This is an old revision of DanWest made by DanWest on 2007-01-19 04:07:53.

 

Dan West

FormattingRules

This has some extensions I did. I'm new at hacking this code so you may find someone has already done it better or it's not done the cleanest way. I did try to keep them simple (i.e.: The least amount of core code changes).
I put them on my page since I am sure they currenly dont follow the coding guidelines for submitting an official extension.

Some of these extensions are designed for my "Closed" wiki sites (Internal Users Only). So, they can be dangerous for public wiki sites.

Enjoy.

Pages I did that use wikka
antelopesoccer.com home page Uses wikka
www.posr.com Some hacking on the CSS as well as header and footer to "hide" the Wikka as the real engine


My Extensions


I know this has been done, the it's another twist. You define a page 'NavigationLinks'. In that page you list each target page tag on a line delimited by : (colons) followed by the custom links.

Example NavigationLinks page
:SomePage: [[HomePage Home]] [[PersonalPage My Page]] [[UserSettings User Settings]]
:AnotherPage: [[HomePage Home]] [[PersonalPage My Page]] [[SomePage Some Other Page]] [[UserSettings User Settings]]


This requires a small change to the header.php action. Note, I also add a fixed AdminPage to all my sites.
File header.php
  1. $nav_page = $this->LoadPage('NavigationLinks');
  2. if(ereg(':' . $this->page['tag'] . ': ([^\n]*)\n', $nav_page['body'], $match)) {
  3.     echo $this->Format($match[1] . (($this->GetUser())? ' [[AdminPage Admin]]' : ''));
  4. } else if ($this->GetUser()) {
  5.     echo $this->config['logged_in_navigation_links'] ? $this->Format($this->config['logged_in_navigation_links']).'' : '';
  6. } else {
  7.     echo $this->config['navigation_links'] ? $this->Format($this->config['navigation_links']) : '';
  8. }



Include File action

A basic include that will load a text file into the page.
Syntax: {{include name='file.txt'}}

includefile.php
<?php
$file_name = $vars['name'];
if(isset($file_name)) {
    if(is_readable($file_name)) {
        if(isset($pre)) echo '<pre>';
        @include($file_name);
        if(isset($pre)) echo '</pre>';
    } else {
        echo "{{includefile}} File $fname not found";
    }
} else {
    echo 'usage: {{includefile <b><u>name</u></b>="<i>filename</i>"}} (Missing name)';
}
?>




CRT display formatter

For some documentation pages, I wanted to display a classic "Green Screen" format. So I used the %% code formatter and a custom CRT formatter.

File: formatters/crt.php
<?php
    echo '<div class="code_crt">';
    print('<pre>'.htmlspecialchars($text, ENT_QUOTES).'</pre>');
    echo '</div>';
?>


It also requires a small addition to the CSS file (Taken from .code selector)
.code_crt {
    color: lime;
    background: black;
    border: 1px solid #CCC;
    font-size: 11px;
    font-family: "Lucida Console", Monaco, monospace;
    width: 95%;
    margin: auto;
    padding: 6px 3px 13px 3px; 
    text-align: left;      
    overflow: auto;    
    white-space: nowrap;   
}



Custom Page Header

I found that I did not always care for the 'automated' page header done by parsing out the first matched text from a list of elements. Instead, I wanted to control the page title on the page manually. I did this by first creating a "fake" action called {{pagetitle}}. The "pagetitle.php" is an empty file in the actions folder. Then, I put the following code into the wakka.class.php file.

Once this is done, you can modify the header.php action to use $this->PageHeader() to populate the page title HTML tags.

Added to wakka.class.php
    // DW - Added (Process {{pagetitle name}} fake action)
    function PageHeader() {
        $title = "";
        $pagecontent = $this->page["body"];
        if (ereg( "({){2}pagetitle ([^}\n]+)(}){2}", $pagecontent, $title)) {
            $title = $title[2];
        }
        if ($title) return strip_tags($this->Format($title));               # fix for forced links in heading
        else return $this->GetPageTag();
    }


header.php
$PgTitle = $this->PageHeader();
    .
    .
    .
<title><?php echo $PgTitle; ?></title>
There are 2 comments on this page. [Show comments]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki