[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/inc/ -> template.php (summary)

DokuWiki template functions

Author: Andreas Gohr
License: GPL 2 (http://www.gnu.org/licenses/gpl.html)
File Size: 1912 lines (53 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 1 file
 lib/exe/mediamanager.php

Defines 49 functions

  template()
  tpl_incdir()
  tpl_basedir()
  tpl_content()
  tpl_content_core()
  tpl_toc()
  tpl_admin()
  tpl_metaheaders()
  _tpl_metaheaders_action()
  tpl_link()
  tpl_pagelink()
  tpl_getparent()
  tpl_button()
  tpl_actionlink()
  tpl_get_action()
  tpl_action()
  tpl_searchform()
  tpl_breadcrumbs()
  tpl_youarehere()
  tpl_userinfo()
  tpl_pageinfo()
  tpl_pagetitle()
  tpl_img_getTag()
  tpl_img_close()
  tpl_img_meta()
  tpl_get_img_meta()
  tpl_img()
  _tpl_img_action()
  tpl_indexerWebBug()
  tpl_getConf()
  tpl_loadConfig()
  tpl_getLang()
  tpl_locale_xhtml()
  tpl_localeFN()
  tpl_mediaContent()
  tpl_mediaFileList()
  tpl_mediaFileDetails()
  tpl_mediaTree()
  tpl_actiondropdown()
  tpl_license()
  tpl_include_page()
  tpl_subscribe()
  tpl_flush()
  tpl_getMediaFile()
  tpl_includeFile()
  tpl_favicon()
  tpl_media()
  tpl_classes()
  tpl_toolsevent()

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.

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

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

This replaces the deprecated DOKU_TPLINC constant

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

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

This replaces the deprecated DOKU_TPL constant

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

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
triggers: TPL_CONTENT_DISPLAY
author: Andreas Gohr <andi@splitbrain.org>
param: bool $prependTOC should the TOC be displayed here?
return: bool true if any output

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

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

tpl_admin()   X-Ref
Handle the admin page contents

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

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

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

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

_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.

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

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

Just builds a link.

author: Andreas Gohr <andi@splitbrain.org>
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

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

Wrapper around html_wikilink

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

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

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

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

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

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

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

see: tpl_get_action
author: Adrian Lang <mail@adrianlang.de>
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

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

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

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

author: Anika Henke <anika@selfthinker.org>
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

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)

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

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

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

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.

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

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?

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

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

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

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.

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

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

author: Andreas Gohr <andi@splitbrain.org>
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

tpl_img_close()   X-Ref
Garbage collects up the open JpegMeta object.


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


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

triggers: TPL_IMG_DISPLAY
param: int $maxwidth - maximal width of the image
param: int $maxheight - maximal height of the image
param: bool $link - link to the orginal size?
param: array $params - 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 template

return: bool

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

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
tpl_loadConfig()

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

return: false|array

tpl_getLang($id)   X-Ref
tpl_getLang($id)

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

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

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

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

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

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

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

author: Andreas Gohr <andi@splitbrain.org>
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

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
template

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

author: Andreas  Gohr <andi@splitbrain.org>
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

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,
default.

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

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

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

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

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

author: Kate Arzamastseva <pshns@ukr.net>

tpl_classes()   X-Ref
Return useful layout classes

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

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

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