[ Index ]

PHP Cross Reference of DokuWiki




/inc/ -> template.php (summary)

DokuWiki template functions

Author: Andreas Gohr
License: GPL 2 (http://www.gnu.org/licenses/gpl.html)
File Size: 1836 lines (52 kb)
Included or required: 1 time
Referenced: 0 times
Includes or requires: 1 file

Defines 48 functions


Functions that are not part of a class:

template($file)   X-Ref
Access a template file

Returns the path to the given file inside the current template, uses
default template if the custom version doesn't exist.

param: string $file
return: string
author: Andreas Gohr <andi@splitbrain.org>

tpl_incdir($tpl='')   X-Ref
Convenience function to access template dir from local FS

This replaces the deprecated DOKU_TPLINC constant

param: string $tpl The template to use, default to current one
return: string
author: Andreas Gohr <andi@splitbrain.org>

tpl_basedir($tpl='')   X-Ref
Convenience function to access template dir from web

This replaces the deprecated DOKU_TPL constant

param: string $tpl The template to use, default to current one
return: string
author: Andreas Gohr <andi@splitbrain.org>

tpl_content($prependTOC = true)   X-Ref
Print the content

This function is used for printing all the usual content
(defined by the global $ACT var) by calling the appropriate
outputfunction(s) from html.php

Everything that doesn't use the main template file isn't
handled by this function. ACL stuff is not done here either.

triggers: TPL_ACT_RENDER
param: bool $prependTOC should the TOC be displayed here?
return: bool true if any output
author: Andreas Gohr <andi@splitbrain.org>

tpl_content_core()   X-Ref
Default Action of TPL_ACT_RENDER

return: bool

tpl_toc($return = false)   X-Ref
Places the TOC where the function is called

If you use this you most probably want to call tpl_content with
a false argument

param: bool $return Should the TOC be returned instead to be printed?
return: string
author: Andreas Gohr <andi@splitbrain.org>

tpl_admin()   X-Ref
Handle the admin page contents

return: bool
author: Andreas Gohr <andi@splitbrain.org>

tpl_metaheaders($alt = true)   X-Ref
Print the correct HTML meta headers

This has to go into the head section of your template.

param: bool $alt Should feeds and alternative format links be added?
return: bool
author: Andreas Gohr <andi@splitbrain.org>

_tpl_metaheaders_action($data)   X-Ref
prints the array build by tpl_metaheaders

$data is an array of different header tags. Each tag can have multiple
instances. Attributes are given as key value pairs. Values will be HTML
encoded automatically so they should be provided as is in the $data array.

For tags having a body attribute specify the body data in the special
attribute '_data'. This field will NOT BE ESCAPED automatically.

param: array $data
author: Andreas Gohr <andi@splitbrain.org>

tpl_link($url, $name, $more = '', $return = false)   X-Ref
Print a link

Just builds a link.

param: string $url
param: string $name
param: string $more
param: bool $return if true return the link html, otherwise print
return: bool|string html of the link, or true if printed
author: Andreas Gohr <andi@splitbrain.org>

tpl_pagelink($id, $name = null, $return = false)   X-Ref
Prints a link to a WikiPage

Wrapper around html_wikilink

param: string      $id   page id
param: string|null $name the name of the link
param: bool        $return
return: true|string
author: Andreas Gohr <andi@splitbrain.org>

tpl_getparent($id)   X-Ref
get the parent page

Tries to find out which page is parent.
returns false if none is available

param: string $id page id
return: false|string
author: Andreas Gohr <andi@splitbrain.org>

tpl_button($type, $return = false)   X-Ref
Print one of the buttons

see: tpl_get_action
param: string $type
param: bool $return
return: bool|string html, or false if no data, true if printed
author: Adrian Lang <mail@adrianlang.de>

tpl_actionlink($type, $pre = '', $suf = '', $inner = '', $return = false)   X-Ref
Like the action buttons but links

see: tpl_get_action
param: string $type    action command
param: string $pre     prefix of link
param: string $suf     suffix of link
param: string $inner   innerHML of link
param: bool   $return  if true it returns html, otherwise prints
return: bool|string html or false if no data, true if printed
author: Adrian Lang <mail@adrianlang.de>

tpl_get_action($type)   X-Ref
Check the actions and get data for buttons and links

param: string $type
return: array|bool|string
author: Andreas Gohr <andi@splitbrain.org>
author: Matthias Grimm <matthiasgrimm@users.sourceforge.net>
author: Adrian Lang <mail@adrianlang.de>

tpl_action($type, $link = false, $wrapper = false, $return = false, $pre = '', $suf = '', $inner = '')   X-Ref
Wrapper around tpl_button() and tpl_actionlink()

param: string        $type action command
param: bool          $link link or form button?
param: string|bool   $wrapper HTML element wrapper
param: bool          $return return or print
param: string        $pre prefix for links
param: string        $suf suffix for links
param: string        $inner inner HTML for links
return: bool|string
author: Anika Henke <anika@selfthinker.org>

tpl_searchform($ajax = true, $autocomplete = true)   X-Ref
Print the search form

If the first parameter is given a div with the ID 'qsearch_out' will
be added which instructs the ajax pagequicksearch to kick in and place
its output into this div. The second parameter controls the propritary
attribute autocomplete. If set to false this attribute will be set with an
value of "off" to instruct the browser to disable it's own built in
autocompletion feature (MSIE and Firefox)

param: bool $ajax
param: bool $autocomplete
return: bool
author: Andreas Gohr <andi@splitbrain.org>

tpl_breadcrumbs($sep = null, $return = false)   X-Ref
Print the breadcrumbs trace

param: string $sep Separator between entries
param: bool   $return return or print
return: bool|string
author: Andreas Gohr <andi@splitbrain.org>

tpl_youarehere($sep = null, $return = false)   X-Ref
Hierarchical breadcrumbs

This code was suggested as replacement for the usual breadcrumbs.
It only makes sense with a deep site structure.

param: string $sep Separator between entries
param: bool   $return return or print
return: bool|string
author: Andreas Gohr <andi@splitbrain.org>
author: Nigel McNie <oracle.shinoda@gmail.com>
author: Sean Coates <sean@caedmon.net>
author: <fredrik@averpil.com>

tpl_userinfo()   X-Ref
Print info if the user is logged in
and show full name in that case

Could be enhanced with a profile link in future?

return: bool
author: Andreas Gohr <andi@splitbrain.org>

tpl_pageinfo($ret = false)   X-Ref
Print some info about the current page

param: bool $ret return content instead of printing it
return: bool|string
author: Andreas Gohr <andi@splitbrain.org>

tpl_pagetitle($id = null, $ret = false)   X-Ref
Prints or returns the name of the given page (current one if none given).

If useheading is enabled this will use the first headline else
the given ID is used.

param: string $id page id
param: bool   $ret return content instead of printing
return: bool|string
author: Andreas Gohr <andi@splitbrain.org>

tpl_img_getTag($tags, $alt = '', $src = null)   X-Ref
Returns the requested EXIF/IPTC tag from the current image

If $tags is an array all given tags are tried until a
value is found. If no value is found $alt is returned.

Which texts are known is defined in the functions _exifTagNames
and _iptcTagNames() in inc/jpeg.php (You need to prepend IPTC
to the names of the latter one)

Only allowed in: detail.php

param: array|string $tags tag or array of tags to try
param: string       $alt  alternative output if no data was found
param: null|string  $src  the image src, uses global $SRC if not given
return: string
author: Andreas Gohr <andi@splitbrain.org>

tpl_img_meta()   X-Ref
Returns a description list of the metatags of the current image

return: string html of description list

tpl_get_img_meta()   X-Ref
Returns metadata as configured in mediameta config file, ready for creating html

return: array with arrays containing the entries:

tpl_img($maxwidth = 0, $maxheight = 0, $link = true, $params = null)   X-Ref
Prints the image with a link to the full sized version

Only allowed in: detail.php

param: $maxwidth  int - maximal width of the image
param: $maxheight int - maximal height of the image
param: $link bool     - link to the orginal size?
param: $params array  - additional image attributes
return: bool Result of TPL_IMG_DISPLAY

_tpl_img_action($data)   X-Ref
Default action for TPL_IMG_DISPLAY

param: array $data
return: bool

tpl_indexerWebBug()   X-Ref
This function inserts a small gif which in reality is the indexer function.

Should be called somewhere at the very end of the main.php

return: bool

tpl_getConf($id, $notset=false)   X-Ref

use this function to access template configuration variables

param: string $id      name of the value to access
param: mixed  $notset  what to return if the setting is not available
return: mixed

tpl_loadConfig()   X-Ref

reads all template configuration variables
this function is automatically called by tpl_getConf()

return: array

tpl_getLang($id)   X-Ref

use this function to access template language variables

param: string $id key of language string
return: string

tpl_locale_xhtml($id)   X-Ref
Retrieve a language dependent file and pass to xhtml renderer for display
template equivalent of p_locale_xhtml()

param: string $id id of language dependent wiki page
return: string     parsed contents of the wiki page in xhtml format

tpl_localeFN($id)   X-Ref
Prepends appropriate path for a language dependent filename

param: string $id id of localized text
return: string wiki text

tpl_mediaContent($fromajax = false, $sort='natural')   X-Ref
prints the "main content" in the mediamanager popup

Depending on the user's actions this may be a list of
files in a namespace, the meta editing dialog or
a message of referencing pages

Only allowed in mediamanager.php

param: bool $fromajax - set true when calling this function via ajax
param: string $sort
author: Andreas Gohr <andi@splitbrain.org>

tpl_mediaFileList()   X-Ref
Prints the central column in full-screen media manager
Depending on the opened tab this may be a list of
files in a namespace, upload form or search form

author: Kate Arzamastseva <pshns@ukr.net>

tpl_mediaFileDetails($image, $rev)   X-Ref
Prints the third column in full-screen media manager
Depending on the opened tab this may be details of the
selected file, the meta editing dialog or
list of file revisions

param: string $image
param: boolean $rev
author: Kate Arzamastseva <pshns@ukr.net>

tpl_mediaTree()   X-Ref
prints the namespace tree in the mediamanager popup

Only allowed in mediamanager.php

author: Andreas Gohr <andi@splitbrain.org>

tpl_actiondropdown($empty = '', $button = '&gt;')   X-Ref
Print a dropdown menu with all DokuWiki actions

Note: this will not use any pretty URLs

param: string $empty empty option label
param: string $button submit button label
author: Andreas Gohr <andi@splitbrain.org>

tpl_license($img = 'badge', $imgonly = false, $return = false, $wrap = true)   X-Ref
Print a informational line about the used license

param: string $img     print image? (|button|badge)
param: bool   $imgonly skip the textual description?
param: bool   $return  when true don't print, but return HTML
param: bool   $wrap    wrap in div with class="license"?
return: string
author: Andreas Gohr <andi@splitbrain.org>

tpl_include_page($pageid, $print = true, $propagate = false, $useacl = true)   X-Ref
Includes the rendered HTML of a given page

This function is useful to populate sidebars or similar features in a

param: string $pageid The page name you want to include
param: bool $print Should the content be printed or returned only
param: bool $propagate Search higher namespaces, too?
param: bool $useacl Include the page only if the ACLs check out?
return: bool|null|string

tpl_subscribe()   X-Ref
Display the subscribe form

author: Adrian Lang <lang@cosmocode.de>

tpl_flush()   X-Ref
Tries to send already created content right to the browser

Wraps around ob_flush() and flush()

author: Andreas Gohr <andi@splitbrain.org>

tpl_getMediaFile($search, $abs = false, &$imginfo = null, $fallback = true)   X-Ref
Tries to find a ressource file in the given locations.

If a given location starts with a colon it is assumed to be a media
file, otherwise it is assumed to be relative to the current template

param: string[] $search       locations to look at
param: bool     $abs          if to use absolute URL
param: array    &$imginfo     filled with getimagesize()
param: bool     $fallback     use fallback image if target isn't found or return 'false' if potential
return: string
author: Andreas  Gohr <andi@splitbrain.org>

tpl_includeFile($file)   X-Ref
PHP include a file

either from the conf directory if it exists, otherwise use
file in the template's root directory.

The function honours config cascade settings and looks for the given
file next to the ┬┤main┬┤ config files, in the order protected, local,

Note: no escaping or sanity checking is done here. Never pass user input
to this function!

param: string $file
author: Anika Henke <anika@selfthinker.org>
author: Andreas Gohr <andi@splitbrain.org>

tpl_favicon($types = array('favicon')   X-Ref
Returns <link> tag for various icon types (favicon|mobile|generic)

param: array $types - list of icon types to display (favicon|mobile|generic)
return: string
author: Anika Henke <anika@selfthinker.org>

tpl_media()   X-Ref
Prints full-screen media manager

author: Kate Arzamastseva <pshns@ukr.net>

tpl_classes()   X-Ref
Return useful layout classes

return: string
author: Anika Henke <anika@selfthinker.org>

tpl_toolsevent($toolsname, $items, $view = 'main')   X-Ref
Create event for tools menues

param: string $toolsname name of menu
param: array $items
param: string $view e.g. 'main', 'detail', ...
author: Anika Henke <anika@selfthinker.org>