Translations of this page?:
Learn about DokuWiki
Advanced Use
Corporate Use
Our Community
Follow us on Facebook, Twitter and other social networks.
Learn about DokuWiki
Advanced Use
Corporate Use
Our Community
Follow us on Facebook, Twitter and other social networks.
This is a walk through the source code during a request for /doku.php?id=start&do=show
to explain the basics of DokuWiki. You should have the full source available when reading this to fully enjoy this journey. Use the XRef links to obtain a browsable version of the source. There is also a more detailed callgraph page available including the rendering process. A lot of detail is left out of this description to make it simpler.
Filename | Code snippet | Description |
---|---|---|
doku.php | if(!defined('DOKU_INC')) | Everything starts here by defining the base code directory |
$ACT = $_REQUEST['do'] | next we determine which action is requested a.k.a. do modes | |
require_once('init.php') | over to init.php, initialize core | |
inc/init.php | include('preload.php') | preload make it possible to override directories and configuration cascade |
if(!defined('DOKU_CONF') | create environment defines for code location | |
include(DOKU_INC. 'inc/config_cascade.php') | prepare and load the global configuration file(s) | |
global $lang; | load and prepare the language files using English for all missing entries | |
if(!defined('DOKU_REL') | create all environment defines not already defined, which might be dependent of the config settings | |
if(!headers_sent() && .. | init session and set cookie | |
require_once (DOKU_INC.'inc/load.php') | autoload all libraries | |
… | initialize plugin controller, event handling system, authentication and exit after setting up mail | |
doku.php | $ID = getID() | back from init.php, sanitize and turn request into global variables |
$INFO = pageinfo() | add page metadata into a global variable, this includes calling auth_quickaclcheck() and p_get_metadata(). The later causing a rendering of page metadata if it isn't cached. | |
if(!$INFO['exists'] … | send 404 for missing pages | |
trigger_event(DOKUWIKI_STARTED) | call action plugins subscribing the DOKUWIKI_STARTED event | |
inc/actions.php | act_dispatch($ACT) | do the work depending on action |
if ($evt->advise_before()) ... | allow plugins to override default behavior using ACTION_ACT_PREPROCESS event | |
$ACT = act_clean($ACT) | sanitize and redirect disabled actions into do=show |
|
… | call processing code for requested action(s) while checking needed ACL permissions. The $ACT might change during act_dispatch(). | |
global $INFO | make global variables accessible to template code | |
trigger_event(ACTION_HEADERS_SEND) | call action plugins subscribing the ACTION_HEADERS_SEND event | |
include(template('main.php')) | over to the selected template main script | |
lib/tpl/default/main.php | … | the template main script consist of HTML design elements calling on php methods for content like metaheaders, buttons, breadcrumb navigation elements etc. all available in the inc/template.php file |
tpl_content() | here the actual wiki page is created | |
inc/template.php | ||
trigger_event(TPL_ACT_RENDER) | call to tpl_content_core() using TPL_ACT_RENDER event | |
switch($ACT) | select content based on action, the basic do=show calls html_show() |
|
inc/html.php | $html = p_wiki_xhtml(…) | which uses a cached XHTML version of the page OR triggers the renderer to render cached instructions as XHTML OR use the parser to turn wiki text into instructions first. |
inc/template.php | trigger_event(TPL_CONTENT_DISPLAY) | back in tpl_content() action plugin's have a last chance to edit raw HTML before output by using TPL_CONTENT_DISPLAY event |
doku.php | trigger_event(DOKUWIKI_DONE) | finish by calling action plugins subscribing the DOKUWIKI_DONE event when the template main script has ended |