[ 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: 1873 lines (54 kb)
Included or required: 1 time
Referenced: 0 times
Includes or requires: 1 file
 lib/exe/mediamanager.php

Defines 48 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_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>
return: string
param: string $file

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>
return: string
param: string $tpl The template to use, default to current one

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>
return: string
param: string $tpl The template to use, default to current one

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.

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

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>
return: string
param: bool $return Should the TOC be returned instead to be printed?

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.

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

_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>
return: bool|string html of the link, or true if printed
param: string $url
param: string $name
param: string $more
param: bool $return if true return the link html, otherwise print

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>
return: true|string
param: string      $id   page id
param: string|null $name the name of the link
param: bool        $return

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>
return: false|string
param: string $id page id

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

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

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>
return: bool|string html or false if no data, true if printed
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

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

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

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>
return: bool|string
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

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>
return: bool
param: bool $ajax
param: bool $autocomplete

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

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

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

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>
return: bool|string
param: bool $ret return content instead of printing it

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>
return: bool|string
param: string $id page id
param: bool   $ret return content instead of printing

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>
return: string
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

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

return: bool Result of TPL_IMG_DISPLAY
triggers: TPL_IMG_DISPLAY
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

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

return: bool
param: array $data

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

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

tpl_loadConfig()   X-Ref
tpl_loadConfig()

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

return: array

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

use this function to access template language variables

return: string
param: string $id key of language 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()

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

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

return: string wiki text
param: string $id id of localized 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

author: Andreas Gohr <andi@splitbrain.org>
triggers: MEDIAMANAGER_CONTENT_OUTPUT
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>
return: string
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"?

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

return: bool|null|string
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?

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)   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>
return: string
param: string[] $search       locations to look at
param: bool     $abs           if to use absolute URL
param: array   &$imginfo   filled with getimagesize()

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: Anika Henke <anika@selfthinker.org>
author: Andreas Gohr <andi@splitbrain.org>
param: string $file

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

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

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