You are here: start » core_functions

Functions

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

a

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

amp

string function amp()

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

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

⇑ top

autogallery

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

chkdl

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

chkfile

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

Checks wether $file exists1), is readable, and if $writeable is true, is writeable. Appends an according message to $e otherwise.

⇑ top

cmscript()

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

download

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

e

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

ftp

ftp($name)

returns a link to a CMS-file

ftp() was removed from CMSimple_XH

⇑ top

gc

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

geturl

string function geturl(string $url)

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

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

⇑ top

geturlwp

string function geturlwp(string $url)

Returns the full content of the given $url.

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

⇑ top

h

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

hide

bool function hide(int $i)

Returns wether the page no. $i is hidden.

⇑ top

initvar

void function initvar(string $varname)

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

⇑ top

im

mixed im(string $name, string $param)

Returns parameter $param of an uploaded file $name.

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

⇑ top

l

int function l(int $i)

Returns the menu level of page no. $i.

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

⇑ top

logincheck

bool logincheck()

Returns wether the user is currently logged in.

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

⇑ top

meta

mixed meta(string $name)

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

⇑ top

ml

string function ml(string $name)

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

⇑ top

newsbox

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

rf

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

rfc

void function rfc()

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

⇑ top

rmanl

string function rmanl(string $text)

Returns $text with all newlines removed from it.

⇑ top

rmnl

string function rmnl(string $text)

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

⇑ top

rp

string function rp(string $path)

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

⇑ top

selectlist

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

shead

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

sortdir

array function sortdir(string $dirname)

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

⇑ top

stsl

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

sv

string function sv(string $name)

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

⇑ top

tag

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

uenc

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

writelog

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

plugin_admin_common

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

find_all

array function $pd_router->find_all()

Returns all page data.

⇑ top

find_page

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

Returns the page data of page no. $id.

⇑ top

update

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

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

⇑ top

new_page

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

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

⇑ top

destroy

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

Deletes the page data of page no. $id.

⇑ top

model->refresh

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

1)
where $file doesn't specify the path, but instead is one of the keys of $pth['file']
 
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