You are here: start » core_functions

This is an old revision of the document!

Warning: Declaration of syntax_plugin_translation::handle($match, $state, $pos, &$handler) should be compatible with DokuWiki_Syntax_Plugin::handle($match, $state, $pos, Doku_Handler $handler) in /www/htdocs/w018be3b/xh/wiki/lib/plugins/translation/syntax.php on line 0

Warning: Declaration of syntax_plugin_translation::render($format, &$renderer, $data) should be compatible with DokuWiki_Syntax_Plugin::render($format, Doku_Renderer $renderer, $data) in /www/htdocs/w018be3b/xh/wiki/lib/plugins/translation/syntax.php on line 0


Core functions

The following list of functions will be presented in alphabetical order. This is a documentation for CMSimple_XH core developers, although several of these functions are useful for extension writers. If not otherwise noted all functions are defined in /cmsimple/cms.php.

⇑ top


string function a(int $number, string $query_string)

Returns an opening <a>-tag to the CMSimple_XH page given by $number. $query_string will be appended to the generated URI.

E.g. call it as follows:

echo a(0, '&amp;param=value').'Link</a>';

⇑ top


string function amp()

Returns '&' or '&amp;' according to the setting of $cf['xhtml']['amp'].

This function is deprecated: use &amp; directly instead.

⇑ top


string function autogallery(string $url)

Returns the code to display a photogallery. $url should point to autogallery's installation folder.

This function is deprecated: use a gallery plugin instead

autogallery() is defined in /cmsimple/functions.php.

⇑ top


bool function chkdl(string $url)

Returns wether the file $filename exists in the download folder and is available for download. Note: $url should be the download URL, e.g. ?download=name.ext

⇑ top


void function chkfile(string $filename, bool $writeable)

Checks wether the file $filename exists, is readable, and if $writeable is true, is writeable. Appends an according message to $e otherwise.

⇑ top


int function cmscript(string $script, string $text)

Returns the number of times the CMSimple script $script is found in $text. Caveat: cmscript() ignores the new notation {{{PLUGIN:...}}}.

⇑ top


void function download(string $filename)

Makes the file $filename available for download. If the file can't be downloaded, an HTTP 404 Not found response will be generated.

⇑ top


void function e(string $errortext, string $filetype, string $filename)

Appends an error message about the file $filename to $e. $errortext should be a key in $tx['error']; $filetype should be a key in $tx['filetype'].

⇑ top



returns a link to a CMS-file

ftp() was removed from CMSimple_XH

⇑ top


mixed function gc(string $cookiename)

Returns the value of the cookie $cookiename, or NULL if the cookie doesn't exist.

gc() is defined in /cmsimple/login.php.

⇑ top


string function geturl(string $url)

Returns the inner HTML of the <body> of the given $url.

geturl() is defined in /cmsimple/functions.php

⇑ top


string function geturlwp(string $url)

Returns the full content of the given $url.

geturlwp() is defined in /cmsimple/functions.php.

⇑ top


string function h(int $i)

Returns $h[$i]. This is a convenience function meant to be used inside other functions.

h() is defined in /cmsimple/functions.php.

⇑ top


bool function hide(int $i)

Returns wether the page no. $i is hidden.

⇑ top


void function initvar(string $varname)

Initializes the global $varname to the appropriate $_GET or $_POST value, or the empty string.

⇑ top


mixed im(string $name, string $param)

Returns parameter $param of an uploaded file $name.

im() is defined in /cmsimple/adm.php.

⇑ top


int function l(int $i)

Returns the menu level of page no. $i.

l() is defined in /cmsimple/functions.php.

⇑ top


bool logincheck()

Returns wether the user is currently logged in.

logincheck() is defined in /cmsimple/login.php.

⇑ top


mixed meta(string $name)

Returns the <meta> tag for name $name if defined in $cf['meta'], NULL otherwise.

⇑ top


string function ml(string $name)

Returns the menu entry for the special CMSimple_XH page $name, e.g. sitemap.

⇑ top


mixed function newsbox(string $title)

Returns the content of page $title, with heading and CMSimple scripting removed, if the page exists, NULL otherwise.

newsbox() is defined in /cmsimple/functions.php.

⇑ top


mixed function rf(string $filename)

Returns the content of file $filename, if it does exist, NULL otherwise.

Remarks on rf() vs. file_get_contents(): These functions have nearly identical results, but rf() also clears the stat cache, returns NULL instead of FALSE in case of failure, has no additional parameters, and uses a fallback in case file_get_contents() is not defined (PHP < 4.3.0).

BUG?: In case the fallback is used, rf() doubles the line endings.

return join("\n", file($fl));

should IMHO be changed to

return join('', file($fl));

AFAIK support for PHP < 4.3.0 isn't required for CMSimple_XH, so rf() might as well be changed to not use the fallback at all.

⇑ top


void function rfc()

This basic function reads content.htm and creates all according global variables of CMSimple_XH.

⇑ top


string function rmanl(string $text)

Returns $text with all newlines removed from it.

⇑ top


string function rmnl(string $text)

Returns $text with multiple consecutive line endings in it replaced by single line endings.

⇑ top


string function rp(string $path)

Returns the canonicalized absolute pathname of $path, if $path exists, else $path.

⇑ top


void function selectlist(string $function, string $pattern, string $replacement)

Appends a dropdown menu to $o (used in the back-end for language and template selection).

selectlist() is defined in /cmsimple/adm.php

⇑ top


void function shead(string $errorname)

Sends header 401 resp. 404, if $errorname is '401' resp. '404'. Otherwise appends $tx['error'][$errorname] as <h1> to $o.

⇑ top


array function sortdir(string $dirname)

Returns the alphabetically sorted content of directory $dirname. Caveat: the result includes '.' and '..'.

⇑ top


string function stsl(string $text)

Returns $text with all backslashes stripped according to the setting of gpc_magic_quotes. IOW it undoes the result of gpc_magic_quotes == on.

⇑ top


string function sv(string $name)

Returns the server variable $name, if it's set, the empty string otherwise.

⇑ top


string function tag(string $content)

Returns an HTML/XHTML compliant stand alone tag $content according to the settings of $cf['xhtml']['endtags']. E.g.

tag('img src="img.jpg"')

returns '<img src=“img.jpg”>' resp. '<img src=“img.jpg” />'

⇑ top


string function uenc(string $url)

Returns url encoded $url with all character sequences in $tx['urichar']['org'] replaced by their according character sequences in $tx['urichar']['new']. uenc() should be prefered over urlencode() for CMSimple_XH.

⇑ top


void function writelog(string $message)

Appends the message $message to the logfile, if the logfile does exist, otherwise appends an according message to $e.

⇑ top

Plugin loader functions


string function plugin_admin_common(string $action, string $admin, string $plugin, array $hint=array())

Returns the standard forms for common back-end tasks, eg. “Plugin Stylesheet” according to $action, $admin and $plugin. See the tutorial for plugin developers for details.

⇑ top

string function print_plugin_admin(string $main)

Returns the current plugin's menu in the back-end. If $main != 'on' the “Plugin Main Settings” will be supressed.

⇑ top

Pagedata methods


array function $pd_router->find_all()

Returns all page data.

⇑ top


array function $pd_router->find_page(int $id)

Returns the page data of page no. $id.

⇑ top


void function $pd_router->update(int $id, array $params)

Updates the page data of page no. $id with the data from $params.

⇑ top


array function $pd_router->new_page(array $params = null)

Returns a new page data page array initialitzed with $params.

⇑ top


void function $pd_router->destroy(int $id)

Deletes the page data of page no. $id.

⇑ top


bool function $pd_router->model->refresh(array $data = NULL)

Rewrites all page data with $data, if $data is not NULL. Returns wether this was the case.

⇑ top

You are here: start » core_functions
Except where otherwise noted, content on this wiki is licensed under the following license: GNU Free Documentation License 1.3
Valid XHTML 1.0 Valid CSS Driven by DokuWiki