====== Environment ====== This page should give you a brief overview about available variables and constants you can use in [[plugins|plugin]] or [[templates|template]] development. ===== Global Variables ===== ==== $ACT ==== Holds the current action, see [[Action Modes]]. ([[xref>$ACT|reference]]) :!: ''$ACT'' can also be an array instead of a string depending on when it is used. So if you compare it using a string comparison function (e.g. ''strcmp()'', ''strncmp()'') then you better make sure that it is not an array using ''!is_array($ACT)''. Otherwise the result may be undefined. :!: :!: If you are handling an [[devel:event:ACTION_ACT_PREPROCESS]] event, use ''%%$event->data%%'' instead of ''$ACT''. ==== $auth ==== The globally available ''$auth'' object represents an instance of the used [[:auth|authentication plugin]], which inherites from [[xref>AuthPlugin]]. ([[xref>$auth|reference]]) ==== $conf ==== The globally available ''$conf'' array holds all of DokuWiki's configuration settings. In general it follows the following structure: * ''$conf[]'' --- DokuWiki settings (refer [[:config]]) * ''$conf[][]'' --- Some DokuWiki settings use this format, e.g. ftp, proxy and target settings. * ''$conf['tpl'][][]'' --- Template configuration settings, refer to the template documentation. Note only one template at a time is enabled. * ''$conf['plugin'][][]'' --- Plugin configuration settings, refer to the plugin documentation. * ''$conf['plugin'][][]'' --- Auth plugin settings, refer to the auth plugin documentation. Normally you don't need to access this array directly. Both, Plugins and Templates have their own methods to accessing their respective configuration settings. ([[xref>$conf|reference]]) ==== $ID ==== Holds the [[:pagename]] of the currently rendered page. This page is usually the currently viewed page, but not necessarily - see the ''$INFO['id']'' below. ([[xref>$ID|reference]]) ==== $INFO ==== This is an associative array, populated with information provided by ''inc/common.php'' function [[xref>pageinfo()]]. Current elements are: * ''id'' --- pagename of main page currently viewed. Usually the same as ''$ID'' but might sometimes be different. See [[bug>1320]] for some detail. * ''rev'' --- revision of the main page currently viewed, usually the same as $REV. * ''userinfo'' --- only set for a logged user, an associative array... * ''pass'' --- password, encrypted * ''name'' --- full name * ''mail'' --- email address * ''grps'' --- groups the user belongs to (Array :!:) * ''buid'' --- a special id constructed from details of the user's browser and IP address * ''perm'' --- the user's permissions related to the current page ($ID) * ''subscribed'' --- true if the user has subscribed to this page, false otherwise * ''namespace'' --- the namespace the current page ($ID) belongs to * ''locked'' --- true if the page is locked, false otherwise * ''filepath'' --- the file system path to the raw wiki data for the current page ($ID+$REV) * ''exists'' --- true if the raw wiki data for the current page exists ($ID+$REV), false otherwise * ''rev'' --- the revision id for the current page ($ID), an empty string if the current revision * ''writable'' --- true if for the current page ($ID+$REV) the combination of file existence, file permissions and the user's ACL permissions allow them to, write to an existing file or to create a nonexistent file. False otherwise. * ''editable'' --- true if the current page ($ID+$REV) is writable and not currently locked. * ''lastmod'' --- timestamp of the last modification to the current page ($ID+$REV) * ''meta'' --- [[metadata]] for the current page ($ID) * ''ip'' --- IP address of the last editor of the current page ($ID+$REV) * ''user'' --- username of the last editor of the current page ($ID+$REV) * ''sum'' --- edit summary annotation for the current page ($ID+$REV) * ''editor'' --- user name (or IP address if user name is unknown) of the last editor of the current page ($ID+$REV) * ''isadmin'' --- true if the currently logged in user is a [[config:superuser]] * ''ismanager'' --- true if the currently logged in user is a [[config:manager]] * ''draft'' --- contains the file name of a [[:draft]] file if it exists for the current user and page * ''ismobile'' --- true if the page is browsed from a mobile device or phone * ''client'' --- name of a user currently logged in On [[infoarray|$INFO array]] is an example array dumped. ==== $lang ==== An associative array which hold all translation strings of the interface, plugins and templates. ([[xref>$lang|reference]]) ==== $REV ==== Holds the revision timestamp of the currently rendered page. This is ''%%''%%'' (empty string) when the most current page is meant. ([[xref>$REV|reference]]) ==== $_SERVER['REMOTE_USER'] ==== This variable is explicitly set by DokuWiki's authentication mechanism when a user logs in and holds the users name. $userid = $INPUT->server->str('REMOTE_USER'); ==== $TEXT ==== On ''save'' and ''preview'' this global variable holds the text submitted via the edit form. ([[xref>$TEXT|reference]]) ==== $TOC ==== This variable will, if populated, be used by [[templates#tpl_toc()]] to build the [[:TOC]] of a page. Normally this variable is empty and [[xref>tpl_toc()]] builds the TOC from the page [[metadata]]. ([[xref>$TOC|reference]]) ==== $USERINFO ==== An globally available associative array which hold some information of an **authenticated** user. * pass - hash of the users' password * name - the users' full name * mail - the users' mail address * grps - array of groups the user is part of If logged out, or not logged in, this global is set to null. ([[xref>$USERINFO|reference]] ) The array is filled in [[xref>auth_setCookie()]] after login, or from existing session [[xref>auth_login()]]. Or if the authentication plugin uses [[xref>trustExternal()]], it is already set there. ==== $JSINFO ==== This array contained information that is passed to the JavaScript as global variable. Read more: * Javascript devel docs: [[devel:javascript#JSINFO]] * [[xref>$JSINFO|reference]] ===== Constants ===== Here follows a list of the most important constants. ==== AUTH_<*> ==== The ''AUTH_<*>'' type constants represent the permission levels, as integer value, used in DokuWiki's [[:ACL]] system. They can be used to let ACL checks for a given [[:page]]/[[:namespace]] look a little bit more verbose. if (auth_quickaclcheck($ID) >= AUTH_READ) { // do sth. } === AUTH_NONE === * **Type:** Integer * **Value:** 0 * [[xref>AUTH_NONE|reference]] === AUTH_READ === * **Type:** Integer * **Value:** 1 * [[xref>AUTH_READ|reference]] === AUTH_EDIT === * **Type:** Integer * **Value:** 2 * [[xref>AUTH_EDIT|reference]] === AUTH_CREATE === * **Type:** Integer * **Value:** 4 * [[xref>AUTH_CREATE|reference]] === AUTH_UPLOAD === * **Type:** Integer * **Value:** 8 * [[xref>AUTH_UPLOAD|reference]] === AUTH_DELETE === * **Type:** Integer * **Value:** 16 * [[xref>AUTH_DELETE|reference]] === AUTH_ADMIN === * **Type:** Integer * **Value:** 255 * [[xref>AUTH_ADMIN|reference]] ==== DOKU_<*> ==== The ''DOKU_<*>'' type constants hold information about various //system// information for DokuWiki's internal use. === DOKU_BASE === The URL base of the DokuWiki install. ([[xref>DOKU_BASE|reference]]) /dokuwiki/ Or if [[config:canonical]] is set: http://domain.org/dokuwiki/ === DOKU_REL === The URL base path to the DokuWiki install. ([[xref>DOKU_URL|reference]]) /dokuwiki/ === DOKU_URL === The absolute URL to the DokuWiki install. ([[xref>DOKU_URL|reference]]) http://domain.org/dokuwiki/ === DOKU_INC === The server side include path of the DokuWiki install. ([[xref>DOKU_INC|reference]]) /var/www/dokuwiki/ === DOKU_CONF === The server side conf path of the DokuWiki install. ([[xref>DOKU_CONF|reference]]) /var/www/dokuwiki/conf/ === DOKU_TPL === ([[deprecated]]) The URL base path to the current used template. ([[xref>DOKU_TPL|reference]]) /dokuwiki/lib/tpl/