Open-Source PHP Framework - Designed for rapid development of performance-oriented scalable applications

Wiki Component

API >> mvc >> components >> wiki
Any action or entire controller can be made into a wiki section. The wiki edit screen will use the WYSIWYG textarea if you have the TinyMCE package installed, otherwise it will default to a standard textarea that accepts HTML markup and has a WYSIWYG-preview window below it.

Action wiki

To convert any action into a wiki simply return from the action method:
get::component('wiki')->wiki();
So your action would look like:
public function discussion() {
    return 
get::component('wiki')->wiki();
}

If this where in a controller called "pizza" then any page at or under www.YourSite.com/pizza/discussion would be powered by the wiki, eg.:
www.YourSite.com/pizza/discussion
www.YourSite.com/pizza/discussion/anchovies
www.YourSite.com/pizza/discussion/favorite-pizza-parlors
www.YourSite.com/pizza/discussion/brickOven
Take note that:
  • Pages are NOT case-sensitive so both of these will go to the same page:
www.YourSite.com/pizza/discussion/brickOven
www.YourSite.com/pizza/discussion/brickoven
  • You do not need to create a view for actions that use the wiki() method of this component, if you do it will be ignored.

Wiki appearance

The content of the wiki can be controller by CSS ID wikibody
If you would like to be able to modify the appearance of the wiki page you can swap the wiki() method of this component with the getWiki() method:
get::component('wiki')->getWiki();
This method requires you to create a view and include somewhere in the view:
load::element('wiki');
You can also hide the search box via:
load::element('wiki', array('hideSearch' => true));
And then place it wherever you like via:
load::element('wikisearch');
The search can be styled via the CSS ID wikisearch eg.:
#wikisearch {float: right; margin-left: 10px; width: 210px;}

Wiki page modification access-control

It is up to your own code-logic to determine who can edit a wiki page, the single argument accepted by both wiki() and getWiki() is a Boolean determining if the wiki should be read-only or to enable editing as well as viewing/reverting to historical pages. The default is to enable editing. A typical usage for a page to be edited by superuser administrators only would be:
public function usageInstructions() { 
    return 
get::component('wiki')->wiki(get::$config->isSuperuser());
}

Controller wiki

Turning an entire controller into a wiki is the same as just an action, except the URL parameters are reduced by one level and you need to enable the optionalAction controller directive, your entire controller class would like:
class pizzaController {
    const 
optionalAction true;
    public function 
index() {
        return 
get::component('wiki')->wiki();
    }
}

The same URLs in the first example would now be:
www.YourSite.com/pizza
www.YourSite.com/pizza/anchovies
www.YourSite.com/pizza/favorite-pizza-parlors
www.YourSite.com/pizza/brickOven

Reverting to a previous version

Visit any page on your wiki and click the history link at the top (you must have page-editing enabled for the link to appear) and then click an older version. When the historical version loads click edit and then save the page (it will become the newest version.)