Summary: Enable Object Oriented Extensions for PmWiki
Version: February 13, 2009
Prerequisites: PHP 5.2
Status: Experimental
Maintainer: Henrik Bechmann
Categories: Cookbook

Questions answered by this recipe

This section is optional; use it to indicate the types of questions (if any) this recipe is intended to answer.

How to enable adding object oriented extensions to PmWiki


This recipe defines an __autoload($classname) function (in WikiObjects.php), which does a cascading search for the class declaration in a php file of the same name as the parameter in:

  • customclasses/ (from local launch directory)
  • $FarmD/customclasses/ (farm directory, if different from local launch directory)
  • $FarmD/pluginclasses/ (farmdirectory, same as local directory in a single site installation, intended for PmWiki plugins)
  • $FarmD/coreclasses/ (farmdirectory, same as local directory in a single site installation, intended for PmWiki core OOP wrappers and core extensions)

These directories are searched in the order listed.

The recipe (through WikiObjectsSetHandlers.php) also hijacks the selected action handler from the global $HandleActions array (then chains back to it).

This allows the main object environment to be initialized after configuration activity, and before action handlers proceed.


  1. Install WikiObjects.zipΔ in cookbook/ directory unzipped of course).
  2. add the line
    to config.php or farmconfig.php at the very beginning of the config file.
  3. add the line
    to config.php or farmconfig.php at the very end of the config file. If this is a farmconfig.php file, make sure that local/config.php is called from within farmconfig.php before the set handlers call. In other words all configuration should be complete by the time this cookbook script is called.
  4. prior to the above include statement, add the lines
    SDV($CurrentTime, strftime($TimeFmt, $Now));

SDV($CurrentTimeISO, strftime($TimeISOFmt, $Now));

if (IsEnabled($EnableStdConfig,1))


calling stdconfig before the ObjectWiki initialization allows the upload $ActionHandler to be set first.

  1. Create the above search directories.
  2. unzip the wrappers and extensions below to the coreclasses directory.
  3. extend classes from the core classes, and place them in the pluginclasses or customclasses directories. Place class definitions in the appropriate directory, file names same as class names with ".php" extension (eg. MyClass.php)

Additional Components

These components are generic, and are intended to be placed in the "coreclasses" directory. Custom classes would be placed in a "customclasses" directory. Plugins (analogue to "recipes") would be placed in the "pluginclasses" directory. These versions are extremely early, sketchy, and experimental.

PmWiki Wrappers

PmWiki wrappers are Classes wrapped around PmWiki native core scripts. The goal is to have a wrapper for each native script, to be referenced in the short run by core extensions classes. This mitigates against future changes to the organization and implementation of the PmWiki Core. To isolate wrapper classes from other classes, we use the "PMW_" prefix. PmWiki wrappers are all singleton classes (PMW_Wrapper::instance())

wikiobjects-pmwikiwrappers.zipΔ Version: February 8, 2009

Current wrappers:

  • PMW_PmWiki: beginnings of a wrapper around pmwiki.php, the PmWiki driver script
  • PMW_Skins: the beginnings of a wrapper around the PmWiki skins.php script.
  • PMW_Uploads: beginnings of a wrapper around uploads.php

Core Extensions

PmWiki extensions are intended to take advantage of availability of object modeling and general experience with PmWiki to extend (carefully) the core PmWiki model. Another intention is to shield custom extensions from native wrappers (left column) as much as possible. These are generic extensions. Custom extensions would be based on inheritance of these extensions.

wikiobjects-core_extensions.zipΔ Version: February 8, 2009

Current core extensions:

  • ObjectWiki: The main class (singleton object)
  • Repository: An abstraction of the generalized cascade search function often used in PmWiki.
  • PageFrameworks: A factory class to generate Page Framework objects as selected during configuration (singleton object)
  • PageFramework: An abstract class, inherited by specific implementations of page frameworks. See Definitions section of this table for meaning of "PageFramework"
  • PageAddin: An abstract class, inherited by specific implementations of page addins added to Page Frameworks. See Definitions section of this table for meaning of "PageComponent"

Key Definitions

A compound object, plus an aggregator of ancillary components (PageAddin objects, see below), being a collection of functional components included in a page layout, including layout components (such as sidebars), and dynamic components (such as menus and tabs). PageAddin objects are explicitly registered with PageFramework objects.
An enhancement to a PageFramework, with (possibly) server script (php), public script (javascript), and stylistic (css) components. This allows skins to be separated from framework functionality, and behavior (javscript and server script) to be separated from style.
Repository is an arbitrary list of directories that can be searched in order (cascade)
- Repository also collects matching urls as appropriate
- Repository also takes a list of filenames associated with the repository.
- Directories (locations) are in a list for cascading searches.
- Urls are in a list that is parallel (same keys) to the directory list, where matches are appropriate
- Searching directory lists (locations) with filenames yield lists of indexes of found directories (locations)
- Repositories can contain named Repositories
- Contained repositories, though arbitrary, are usually
-- useful partitions of the containing repositories, or
-- substructures (such as sub-directories) of the repositories
- Repositories can contain named "resources" which are diretory/url pairs

Release Notes

If the recipe has multiple releases, then release notes can be placed here. Note that it's often easier for people to work with "release dates" instead of "version numbers".

  • February 2, 2008: establish __autoload() function (WikiObjects.php cookbook script):
  • February 2, 2008: establish PMW_Skins class.
  • February 2, 2008: establish PageFrameworks, PageFramework, and PageComponent classes.
  • February 3, 2008: change class script directory organization: classes changed to customclasses; pluginclasses added
  • February 8, 2008: added WikiObjectsSetHandlers.php cookbook script
  • February 8, 2008: - PageComponent class renamed to PageAddin class - Wrappers added: PMW_PmWiki, PMW_Uploads - classes added: Repository, ObjectWiki
  • February 9, 2008: Added 'upload' to list of hijacked action handlers; removed 'parent_repository' from Repository class
  • February 11, 2009: Added diff to list of actions hijacked by WikiObjects
  • February 13, 2009: Generalized WikiObjectsSetHandlers.php to generically hijack any selected action handler

See Also


Henrik Bechmann


User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.