CMSimple_XH
Functions
functions.php File Reference

General functions. More...

Functions

 geturl ($u)
 Returns the inner HTML of the body element of the given URL. More...
 
 geturlwp ($u)
 Returns the contents of the given URL adding all current GET parameters. More...
 
 h ($n)
 Returns a page heading. More...
 
 l ($n)
 Returns a page's menu level. More...
 
 evaluate_cmsimple_scripting ($__text, $__compat=true)
 Returns a text with CMSimple scripting evaluated. More...
 
 evaluate_plugincall ($text)
 Returns a text with all plugin calls evaluatated. More...
 
 XH_evaluateSinglePluginCall ($___expression)
 Returns the result of evaluating a single plugin call expression. More...
 
 XH_escapeCMSimpleScripting (array $matches)
 Escapes CMSimple scripting returned from a plugin call. More...
 
 XH_spliceString (&$string, $offset, $length=0, $replacement='')
 Removes a portion of a string and replaces it with something else. More...
 
 evaluate_scripting ($text, $compat=true)
 Returns a text with CMSimple scripting and plugin calls evaluated. More...
 
 newsbox ($heading)
 Returns content of the first page with the heading $heading with the heading removed and all scripting evaluated. More...
 
 init_editor (array $elementClasses=array(), $initFile=false)
 Calls init_*() of the configured editor. More...
 
 include_editor ()
 Calls include_*() of the configured editor. More...
 
 editor_replace ($elementID=false, $config='')
 Returns the result of calling *_replace() of the configured editor. More...
 
 XH_finalCleanUp ($html)
 Callback for output buffering. More...
 
 initvar ($name)
 Initializes a global variable according to a GET or POST parameter. More...
 
 sv ($s)
 Returns the value of a $_SERVER key. More...
 
 rmnl ($t)
 Returns $t with all (consecutive) line endings replaced by a single newline. More...
 
 XH_rmws ($str)
 Returns $str with all (consecutive) whitespaces replaced by a single space. More...
 
 rmanl ($t)
 Returns $t with all line endings removed. More...
 
 stsl ($t)
 Returns the un-quoted $t, i.e. More...
 
 download ($fl)
 Makes the file available for download. More...
 
 e ($et, $ft, $fn)
 Appends an error message about the file to $e. More...
 
 rfc ()
 Reads and parses the content file and sets global variables accordingly. More...
 
 XH_readContents ($language=null)
 Reads and parses a content file. More...
 
 XH_findPreviousPage ()
 Finds the index of the previous page. More...
 
 XH_findNextPage ()
 Finds the index of the next page. More...
 
 a ($i, $x)
 Returns an opening a tag as link to a page. More...
 
 meta ($n)
 Returns the meta element for name, if defined in $cf['meta']; null otherwise. More...
 
 ml ($i)
 Returns the link to a special CMSimple_XH page, e.g. More...
 
 uenc ($s)
 Returns a percent encoded URL component. More...
 
 XH_uenc ($s, array $search, array $replace)
 Returns a percent encoded URL component. More...
 
 sortdir ($dir)
 Returns the alphabetically sorted content of a directory. More...
 
 cmscript ($script, $text)
 Returns the number of times a CMSimple script is found. More...
 
 hide ($i)
 Returns whether a page is hidden. More...
 
 tag ($s)
 Returns an HTML stand alone tag. More...
 
 shead ($s)
 Sends error header and sets $title and $o accordingly. More...
 
 XH_debugmode ()
 Debug-Mode. More...
 
 XH_debug ($errno, $errstr, $errfile, $errline)
 Writes all recoverable PHP errors to $e. More...
 
 XH_checkValidUtf8 (array $arr)
 Checks $arr recursively for valid UTF-8. More...
 
 XH_createLanguageFile ($dst)
 Copies default file, if actual language file is missing. More...
 
 pluginFiles ($plugin)
 Set plugin paths. More...
 
 XH_plugins ($admin=false)
 Returns a list of all active plugins. More...
 
 gc ($s)
 Returns the value of a cookie, or null if the cookie doesn't exist. More...
 
 logincheck ()
 Returns wether the user is logged in. More...
 
 XH_logMessage ($type, $module, $category, $description)
 Appends a message to the log file, and returns whether that succeeded. More...
 
 loginforms ()
 Returns the login form. More...
 
 XH_readFile ($filename)
 Reads a file and returns its contents; false on failure. More...
 
 XH_writeFile ($filename, $contents)
 Writes $contents to the file $filename. More...
 
 XH_afterPluginLoading ($callback=null)
 Registers a callback for execution after all plugins were loaded, if $callback is given; otherwise executes these callbacks. More...
 
 XH_afterFinalCleanUp ($param)
 Registers or executes registered callbacks at the end of XH_finalCleanUp(). More...
 
 XH_pluginStylesheet ()
 Returns the path of the combined plugin stylesheet. More...
 
 XH_adjustStylesheetURLs ($plugin, $css)
 Adjusts all relative url(...) in a stylesheet to be used in the combined plugin stylesheet. More...
 
 XH_message ($type, $message)
 Returns an HTML element formatted as message. More...
 
 XH_backup ()
 Creates backups of all content files. More...
 
 XH_isLanguageFolder ($name)
 Returns whether $name is a language folder. More...
 
 XH_title ($site, $subtitle)
 Returns the text content for a TITLE element. More...
 
 XH_builtinTemplate ($bodyClass)
 A minimal built-in template for some special functions. More...
 
 XH_helpIcon ($tooltip)
 Returns a help icon which displays a tooltip on hover. More...
 
 XH_isContentBackup ($filename, $regularOnly=true)
 Returns whether a file is a content backup by checking the filename. More...
 
 XH_templates ()
 Returns an array of installed templates. More...
 
 XH_availableLocalizations ()
 Returns an array of available languages (in cmsimple/languages/). More...
 
 XH_secondLanguages ()
 Returns the installed second languages in alphabetic order. More...
 
 XH_isInternalPath ($path)
 Returns whether a path refers to a CMSimple index.php. More...
 
 XH_isInternalUrl ($urlParts)
 Returns whether a URL points to this CMSimple installation. More...
 
 XH_convertToPrintUrl (array $matches)
 Returns a single URL converted to a print URL, if appropriate. More...
 
 XH_convertPrintUrls ($pageContent)
 Convert all internal URLs in a text to print URLs. More...
 
 XH_decodeJson ($string)
 Returns the JSON string decoded as PHP value. More...
 
 XH_encodeJson ($value)
 Returns the JSON representation of a value. More...
 
 XH_lastJsonError ()
 Returns whether an error has occurred during the last XH_decodeJSON(). More...
 
 XH_hsc ($string)
 Converts special characters to HTML entities. More...
 
 XH_mailform ($subject=null)
 Handles a mailform embedded in a CMSimple_XH page. More...
 
 XH_includeVar ($_filename, $_varname)
 Includes a PHP data file and returns the value of the variable. More...
 
 XH_numberSuffix ($count)
 Returns a suffix for a language string key according to the number (singular, paucal or plural). More...
 
 XH_readConfiguration ($plugin=false, $language=false)
 Returns the configuration resp. More...
 
 XH_unionOf2DArrays (array $array1, array $array2)
 Returns the union of two "2-dimensional" arrays in the same manner as the union operator (i.e. More...
 
 XH_renameFile ($oldname, $newname)
 Attempts to rename oldname to newname, and returns whether that succeeded. More...
 
 XH_exit ($status=0)
 Exits the running script. More...
 
 XH_getRootFolder ()
 Returns the root (= installation) folder of the system. More...
 
 XH_registerPluginType ($type, $plugin=null)
 Registers the type of a plugin resp. More...
 
 XH_registeredEditorPlugins ()
 Returns the names of the registered editor plugins. More...
 
 XH_registeredFilebrowserPlugins ()
 Returns the names of the registered filebrowser plugins. More...
 
 XH_registeredPagemanagerPlugins ()
 Returns the names of the registered pagemanager plugins. More...
 
 XH_registeredEditmenuPlugins ()
 Returns the names of the registered editmenu plugins. More...
 
 XH_onShutdown ()
 Handles the shutdown of the script. More...
 
 XH_formatDate ($timestamp)
 Returns a timestamp formatted according to config and lang. More...
 
 XH_lockFile ($handle, $operation)
 Implements portable advisory file locking. More...
 
 XH_highlightSearchWords (array $words, $text)
 Highlights the search words in a text. More...
 
 XH_autoload ($className)
 Autoloads classes named after CMSimple_XH/PEAR coding standards. More...
 
 XH_startSession ()
 Starts a named session. More...
 
 XH_poweredBy ()
 Returns The content of the generated page "Site/CMS Info". More...
 
 XH_pluginURL ($plugin)
 Returns The link to a plugin download site. More...
 
 XH_getLocatorModel ()
 Returns the locator (breadcrumb navigation) model. More...
 
 XH_getPageURL ($index)
 Returns the full URL of a page. More...
 
 XH_redirectSelectedUrl ()
 Returns the URL where to redirect selected GEt requests. More...
 

Detailed Description

General functions.

Author
Peter Harteg peter.nosp@m.@har.nosp@m.teg.d.nosp@m.k
The CMSimple_XH developers devs@.nosp@m.cmsi.nosp@m.mple-.nosp@m.xh.o.nosp@m.rg
See also
http://cmsimple-xh.org/

Function Documentation

◆ a()

a (   $i,
  $x 
)

Returns an opening a tag as link to a page.

Parameters
int$iThe page index.
string$xArbitrary appendix of the URL.
Returns
string HTML

◆ cmscript()

cmscript (   $script,
  $text 
)

Returns the number of times a CMSimple script is found.

Parameters
string$scriptThe needle.
string$textThe haystack.
Returns
int

◆ download()

download (   $fl)

Makes the file available for download.

If the file can't be downloaded, an HTTP 404 Not found response will be generated.

Parameters
string$flThe file name.
Returns
void

◆ e()

e (   $et,
  $ft,
  $fn 
)

Appends an error message about the file to $e.

Parameters
string$etA key in $tx['error'].
string$ftA key in $tx['filetype'].
string$fnThe file name.
Returns
void

◆ editor_replace()

editor_replace (   $elementID = false,
  $config = '' 
)

Returns the result of calling *_replace() of the configured editor.

Returns false on failure.

Parameters
string | false$elementIDThe element with this ID will become an editor.
string$configThe configuration.
Returns
string|false
See also
http://www.cmsimple-xh.org/wiki/doku.php/plugin_interfaces
Since
1.5

◆ evaluate_cmsimple_scripting()

evaluate_cmsimple_scripting (   $__text,
  $__compat = true 
)

Returns a text with CMSimple scripting evaluated.

Scripts are evaluated as if they were in the global scope, except that no new global variables can be defined (unless via $GLOBALS).

Parameters
string$__textThe text.
bool$__compatWhether only last CMSimple script should be evaluated.
Returns
string
Since
1.5

◆ evaluate_plugincall()

evaluate_plugincall (   $text)

Returns a text with all plugin calls evaluatated.

All Plugins which are called through a function-call can use this. At the moment it is not possible to do this with class-based plugins. They need to be called through standard-CMSimple-Scripting. Alternatively one can offer a functional wrapper.

To call a plugin, place the following on a CMSimple_XH page (example): {{{pluginfunction('parameters');}}}

About the scope rules see XH_evaluateSinglePluginCall.

Parameters
string$textThe text.
Returns
string
Since
1.5

◆ evaluate_scripting()

evaluate_scripting (   $text,
  $compat = true 
)

Returns a text with CMSimple scripting and plugin calls evaluated.

Parameters
string$textThe text.
bool$compatWhether only last CMSimple script will be evaluated.
Returns
string
Since
1.5

◆ gc()

gc (   $s)

Returns the value of a cookie, or null if the cookie doesn't exist.

Parameters
string$sThe name of the cookie.
Returns
string

◆ geturl()

geturl (   $u)

Returns the inner HTML of the body element of the given URL.

Parameters
string$uA URL.
Returns
string HTML

◆ geturlwp()

geturlwp (   $u)

Returns the contents of the given URL adding all current GET parameters.

Parameters
string$uA URL.
Returns
string HTML

◆ h()

h (   $n)

Returns a page heading.

Parameters
int$nThe index of the page.
Returns
string
See also
$h
Deprecated:
since 1.7. Use $h instead.

◆ hide()

hide (   $i)

Returns whether a page is hidden.

Parameters
int$iThe page index.
Returns
bool

◆ include_editor()

include_editor ( )

Calls include_*() of the configured editor.

Returns whether that succeeded.

Returns
bool
See also
http://www.cmsimple-xh.org/wiki/doku.php/plugin_interfaces
Since
1.5

◆ init_editor()

init_editor ( array  $elementClasses = array(),
  $initFile = false 
)

Calls init_*() of the configured editor.

Returns whether that succeeded.

Parameters
array$elementClassesElements with these classes will become an editor.
mixed$initFileThe init file or configuration.
Returns
bool
See also
http://www.cmsimple-xh.org/wiki/doku.php/plugin_interfaces
Since
1.5

◆ initvar()

initvar (   $name)

Initializes a global variable according to a GET or POST parameter.

Parameters
string$nameThe name of the global variable.
Returns
void
Deprecated:
since 1.7.0

◆ l()

l (   $n)

Returns a page's menu level.

Parameters
int$nThe index of the page.
Returns
int
See also
$l
Deprecated:
since 1.7. Use $l instead.

◆ logincheck()

logincheck ( )

Returns wether the user is logged in.

Returns
bool.

◆ loginforms()

loginforms ( )

Returns the login form.

Returns
void

◆ meta()

meta (   $n)

Returns the meta element for name, if defined in $cf['meta']; null otherwise.

Parameters
string$nThe name attribute.
Returns
string HTML

◆ ml()

ml (   $i)

Returns the link to a special CMSimple_XH page, e.g.

sitemap.

Parameters
string$iA key of $tx['menu'].
Returns
string HTML

◆ newsbox()

newsbox (   $heading)

Returns content of the first page with the heading $heading with the heading removed and all scripting evaluated.

Returns false, if the page doesn't exist.

Parameters
string$headingThe page heading.
Returns
string|false

◆ pluginFiles()

pluginFiles (   $plugin)

Set plugin paths.

Parameters
string$pluginThe name of the plugin.
Returns
void

◆ rfc()

rfc ( )

Reads and parses the content file and sets global variables accordingly.

Returns
void

◆ rmanl()

rmanl (   $t)

Returns $t with all line endings removed.

Parameters
string$tA string.
Returns
string

◆ rmnl()

rmnl (   $t)

Returns $t with all (consecutive) line endings replaced by a single newline.

Parameters
string$tA string.
Returns
string

◆ shead()

shead (   $s)

Sends error header and sets $title and $o accordingly.

Parameters
int$sThe HTTP status response code (401, 403, 404).
Returns
void.

◆ sortdir()

sortdir (   $dir)

Returns the alphabetically sorted content of a directory.

Caveat: the result includes '.' and '..'.

Parameters
string$dirAn existing directory path.
Returns
array

◆ stsl()

stsl (   $t)

Returns the un-quoted $t, i.e.

reverses the effect of magic_quotes_gpc/magic_quotes_sybase.

If in doubt, use on all user input (but at most once!).

Parameters
string$tA string.
Returns
string

◆ sv()

sv (   $s)

Returns the value of a $_SERVER key.

Parameters
string$sThe key.
Returns
string

◆ tag()

tag (   $s)

Returns an HTML stand alone tag.

Used to returns an (X)HTML compliant stand alone tag according to the settings of $cf['xhtml']['endtags'].

Parameters
string$sThe contents of the tag.
Returns
string HTML
Deprecated:
since 1.7
Todo:
Add deprecation warning (XH 1.8?)

◆ uenc()

uenc (   $s)

Returns a percent encoded URL component.

Additionally all character sequences in $tx['urichar']['org'] will be replaced by their according character sequences in $tx['urichar']['new'].

Parameters
string$sThe URL component.
Returns
string
See also
XH_uenc()

◆ XH_adjustStylesheetURLs()

XH_adjustStylesheetURLs (   $plugin,
  $css 
)

Adjusts all relative url(...) in a stylesheet to be used in the combined plugin stylesheet.

Parameters
string$pluginThe name of the plugin.
string$cssThe content of the stylesheet.
Returns
string
Since
1.6

◆ XH_afterFinalCleanUp()

XH_afterFinalCleanUp (   $param)

Registers or executes registered callbacks at the end of XH_finalCleanUp().

Registers a callback for execution at the end of XH_finalCleanUp(), if $param is a callable; otherwise executes these callbacks, passing $param as parameter to the callback function. The latter variant is supposed to be called only by the core, and in this case will invoke the callback with the page HTML, and expects the callback to return the possibly modified HTML.

Parameters
mixed$paramA parameter.
Returns
void|string
Since
1.7

◆ XH_afterPluginLoading()

XH_afterPluginLoading (   $callback = null)

Registers a callback for execution after all plugins were loaded, if $callback is given; otherwise executes these callbacks.

Parameters
callable$callbackThe callback.
Returns
void
Since
1.6

◆ XH_autoload()

XH_autoload (   $className)

Autoloads classes named after CMSimple_XH/PEAR coding standards.

Parameters
string$classNameA class name.
Returns
void
Since
1.7

◆ XH_availableLocalizations()

XH_availableLocalizations ( )

Returns an array of available languages (in cmsimple/languages/).

Returns
array
Since
1.6

◆ XH_backup()

XH_backup ( )

Creates backups of all content files.

Surplus old backups will be deleted. Returns an appropriate message.

Returns
string HTML
Since
1.6

◆ XH_builtinTemplate()

XH_builtinTemplate (   $bodyClass)

A minimal built-in template for some special functions.

Currently used for the print view and the login screen.

Parameters
string$bodyClassThe CSS class of the BODY element.
Returns
string HTML
Since
1.6

◆ XH_checkValidUtf8()

XH_checkValidUtf8 ( array  $arr)

Checks $arr recursively for valid UTF-8.

Otherwise it exits the script.

Useful for checking user input.

Parameters
array$arrArray to check.
Returns
void
Since
1.5.5

◆ XH_convertPrintUrls()

XH_convertPrintUrls (   $pageContent)

Convert all internal URLs in a text to print URLs.

Parameters
string$pageContentSome HTML.
Returns
string
Since
1.6

◆ XH_convertToPrintUrl()

XH_convertToPrintUrl ( array  $matches)

Returns a single URL converted to a print URL, if appropriate.

Serves as helper for

See also
XH_convertPrintUrls().
Parameters
array$matchesThe matches of a PREG.
Returns
string
Since
1.6

◆ XH_createLanguageFile()

XH_createLanguageFile (   $dst)

Copies default file, if actual language file is missing.

Returns whether the language file exists afterwards.

Parameters
string$dstThe destination filename.
Returns
bool
Since
1.6
Todo:
Remove handling of LANGconfigs, unless they won't get reintroduced.

◆ XH_debug()

XH_debug (   $errno,
  $errstr,
  $errfile,
  $errline 
)

Writes all recoverable PHP errors to $e.

Parameters
int$errnoLevel of the error.
string$errstrAn error message.
string$errfileFilename where error was raised.
int$errlineLine number where error was raised.
Returns
bool

◆ XH_debugmode()

XH_debugmode ( )

Debug-Mode.

Check if file "_XHdebug.txt" exists to turn on debug-mode with default debug level 1. The level of the debug mode can be adjusted by placing an integer-value within the file using following values:

  • 0: Turn off all error reporting
  • 1: Runtime errors except warnings
  • 2: Runtime errors
  • 3: Runtime errors + notices
  • 4: All errors except notices and warnings
  • 5: All errors except notices
  • 6: All errors
Returns
boolean Whether error_reporting is enabled.
Author
Holger
Since
1.0rc3

◆ XH_decodeJson()

XH_decodeJson (   $string)

Returns the JSON string decoded as PHP value.

Parameters
string$stringA JSON string.
Returns
mixed
Since
1.6
Todo:
Deprecate starting with 1.8.

◆ XH_encodeJson()

XH_encodeJson (   $value)

Returns the JSON representation of a value.

Parameters
mixed$valueA PHP value.
Returns
string or bool false on JSON error
Since
1.6
Todo:
Deprecate starting with 1.8.

◆ XH_escapeCMSimpleScripting()

XH_escapeCMSimpleScripting ( array  $matches)

Escapes CMSimple scripting returned from a plugin call.

Parameters
array$matchesAn array of matches.
Returns
string
Since
1.6.6

◆ XH_evaluateSinglePluginCall()

XH_evaluateSinglePluginCall (   $___expression)

Returns the result of evaluating a single plugin call expression.

The expression is evaluated as if it where in the global namespace. To avoid clashes with local variables of this function, these are prefixed with a triple underscore. Reference parameters of the function do not modify the global scope.

Parameters
string$___expressionThe expression to evaluate.
Returns
string
Since
1.6

◆ XH_exit()

XH_exit (   $status = 0)

Exits the running script.

Simple wrapper for exit for testing purposes.

Parameters
mixed$statusA status message or code.
Returns
void
Since
1.6.2

◆ XH_finalCleanUp()

XH_finalCleanUp (   $html)

Callback for output buffering.

Returns the postprocessed HTML.

Currently debug information and admin menu are prepended, and $bjs is appended to the body element.

Parameters
string$htmlThe HTML generated so far.
Returns
string
Since
1.6

◆ XH_findNextPage()

XH_findNextPage ( )

Finds the index of the next page.

Returns
int|false
Since
1.6.3

◆ XH_findPreviousPage()

XH_findPreviousPage ( )

Finds the index of the previous page.

Returns
int|false
Since
1.6.3

◆ XH_formatDate()

XH_formatDate (   $timestamp)

Returns a timestamp formatted according to config and lang.

Parameters
int$timestampA UNIX timestamp.
Returns
string
Since
1.6.3

◆ XH_getLocatorModel()

XH_getLocatorModel ( )

Returns the locator (breadcrumb navigation) model.

The locator model is an ordered list of breadcrumb items, where each item is an array of the title and the URL. If there is no appropriate URL, the element is null.

Returns
array
Since
1.7

◆ XH_getPageURL()

XH_getPageURL (   $index)

Returns the full URL of a page.

Parameters
int$indexA valid page index.
Returns
string
Since
1.7

◆ XH_getRootFolder()

XH_getRootFolder ( )

Returns the root (= installation) folder of the system.

Returns
string
Since
1.6.2

◆ XH_helpIcon()

XH_helpIcon (   $tooltip)

Returns a help icon which displays a tooltip on hover.

Parameters
string$tooltipA tooltip in HTML.
Returns
string HTML
Since
1.6
Todo:
Change the DIVs to SPANs and require the $tooltip to be an inline fragment (requires block level elements to be removed from all help texts–even $plugin_tx).

◆ XH_highlightSearchWords()

XH_highlightSearchWords ( array  $words,
  $text 
)

Highlights the search words in a text.

Parameters
array$wordsAn array of search words.
string$textA text.
Returns
string HTML
Since
1.6.5

◆ XH_hsc()

XH_hsc (   $string)

Converts special characters to HTML entities.

Same as htmlspecialchars($string, ENT_COMPAT | ENT_SUBSTITUTE, 'UTF-8'), but works for PHP < 5.4 as well.

Parameters
string$stringA string.
Returns
string
Since
1.5.8

◆ XH_includeVar()

XH_includeVar (   $_filename,
  $_varname 
)

Includes a PHP data file and returns the value of the variable.

Returns false, if including failed. During the inclusion, the file is locked for shared access.

Parameters
string$_filenameA filename.
string$_varnameA variable name.
Returns
mixed
Since
1.6

◆ XH_isContentBackup()

XH_isContentBackup (   $filename,
  $regularOnly = true 
)

Returns whether a file is a content backup by checking the filename.

Parameters
string$filenameA filename.
bool$regularOnlyWhether to check for regalur backup names only.
Returns
bool
Since
1.6

◆ XH_isInternalPath()

XH_isInternalPath (   $path)

Returns whether a path refers to a CMSimple index.php.

Parameters
string$pathA relative path.
Returns
bool
Since
1.6

◆ XH_isInternalUrl()

XH_isInternalUrl (   $urlParts)

Returns whether a URL points to this CMSimple installation.

Parameters
string$urlPartsParts of an URL.
Returns
bool
Since
1.6

◆ XH_isLanguageFolder()

XH_isLanguageFolder (   $name)

Returns whether $name is a language folder.

Parameters
string$nameThe name to check.
Returns
bool
Since
1.6

◆ XH_lastJsonError()

XH_lastJsonError ( )

Returns whether an error has occurred during the last XH_decodeJSON().

Returns
bool
Since
1.6
Todo:
Deprecate starting with 1.8.

◆ XH_lockFile()

XH_lockFile (   $handle,
  $operation 
)

Implements portable advisory file locking.

For now it is just a simple wrapper around flock().

Parameters
resource$handleA file handle.
int$operationA lock operation (use LOCK_SH, LOCK_EX or LOCK_UN).
Returns
bool
Since
1.6.3

◆ XH_logMessage()

XH_logMessage (   $type,
  $module,
  $category,
  $description 
)

Appends a message to the log file, and returns whether that succeeded.

Parameters
string$typeA message type ("info", "warning", "error").
string$moduleA module name ("XH" or plugin name).
string$categoryA category.
string$descriptionA description.
Returns
bool
Since
1.6

◆ XH_mailform()

XH_mailform (   $subject = null)

Handles a mailform embedded in a CMSimple_XH page.

Parameters
string$subjectAn alternative subject field preset text instead of the subject default in localization.
Returns
string HTML
Since
1.6

◆ XH_message()

XH_message (   $type,
  $message 
)

Returns an HTML element formatted as message.

Parameters
string$typeThe type of message ('success', 'info', 'warning', 'fail').
string$messageA message format to print in an printf() style.
Returns
string
Since
1.6

◆ XH_numberSuffix()

XH_numberSuffix (   $count)

Returns a suffix for a language string key according to the number (singular, paucal or plural).

Parameters
int$countCount of the items.
Returns
string
Since
1.6

◆ XH_onShutdown()

XH_onShutdown ( )

Handles the shutdown of the script.

  • Unsets erroneously set password in session (backdoor mitigation).
  • Displays a message if a fatal error occurred.
Returns
void
Since
1.6.3

◆ XH_plugins()

XH_plugins (   $admin = false)

Returns a list of all active plugins.

Parameters
bool$adminWhether to return only plugins with a admin.php
Returns
array
Since
1.6
Todo:

Might be optimized to set $admPlugins only when necessary.

with PHP 5.4.0 replace array_values() by sort($plugins, SORT_NATURAL | SORT_FLAG_CASE)

◆ XH_pluginStylesheet()

XH_pluginStylesheet ( )

Returns the path of the combined plugin stylesheet.

If necessary, this stylesheet will be created/updated.

Returns
string
Since
1.6

◆ XH_pluginURL()

XH_pluginURL (   $plugin)

Returns The link to a plugin download site.

One of the 3 functions to show "Site/CMS Info".

Parameters
string$pluginThe plugin name.
Returns
string The URL
Since
1.7

◆ XH_poweredBy()

XH_poweredBy ( )

Returns The content of the generated page "Site/CMS Info".

One of the 3 functions to show "Site/CMS Info".

Returns
string
Since
1.7

◆ XH_readConfiguration()

XH_readConfiguration (   $plugin = false,
  $language = false 
)

Returns the configuration resp.

language array of the core resp. a plugin.

For plugins pluginFiles() has to be called before.

Parameters
bool$pluginWhether to return plugin information (opposed to core).
bool$languageWhether to return the language array (opposed to config).
Returns
array
Since
1.6

◆ XH_readContents()

XH_readContents (   $language = null)

Reads and parses a content file.

Returns an associative array containing the following information:

  • urls: The URLs of the pages.
  • too_long: Flags, whether URLs were too long.
  • headings: The headings of the pages.
  • levels: The menu levels of the pages.
  • pages: The contents of the pages.
  • pd_router: A page data router object.
  • removed: Flags whether pages are removed. Returns FALSE, if the file couldn't be read.
Parameters
string$languageThe language to read. null means the default language.
Returns
array|false
Since
1.6

◆ XH_readFile()

XH_readFile (   $filename)

Reads a file and returns its contents; false on failure.

During reading, the file is locked for shared access.

Parameters
string$filenameA file path.
Returns
string
Since
1.6

◆ XH_redirectSelectedUrl()

XH_redirectSelectedUrl ( )

Returns the URL where to redirect selected GEt requests.

Returns
string
Since
1.7.0

◆ XH_registeredEditmenuPlugins()

XH_registeredEditmenuPlugins ( )

Returns the names of the registered editmenu plugins.

Returns
array
Since
1.6.2

◆ XH_registeredEditorPlugins()

XH_registeredEditorPlugins ( )

Returns the names of the registered editor plugins.

Returns
array
Since
1.6.2

◆ XH_registeredFilebrowserPlugins()

XH_registeredFilebrowserPlugins ( )

Returns the names of the registered filebrowser plugins.

Returns
array
Since
1.6.2

◆ XH_registeredPagemanagerPlugins()

XH_registeredPagemanagerPlugins ( )

Returns the names of the registered pagemanager plugins.

Returns
array
Since
1.6.2

◆ XH_registerPluginType()

XH_registerPluginType (   $type,
  $plugin = null 
)

Registers the type of a plugin resp.

returns the registered plugins of a certain type.

Parameters
string$typeA plugin type ('editor', 'filebrowser', 'pagemanager', 'editmenu').
string$pluginA plugin name or null.
Returns
mixed
Since
1.6.2

◆ XH_renameFile()

XH_renameFile (   $oldname,
  $newname 
)

Attempts to rename oldname to newname, and returns whether that succeeded.

The file is moved between directories if necessary. If newname exists, it will be overwritten.

This is a wrapper around rename(), which offers a fallback for the limitation of PHP < 5.3 on Windows that the rename operation fails, if $newfile already exists. Note, that the fallback solution is not atomic.

Parameters
string$oldnameA filename.
string$newnameA filename.
Returns
bool
Since
1.6
Todo:
Deprecate for 1.8.

◆ XH_rmws()

XH_rmws (   $str)

Returns $str with all (consecutive) whitespaces replaced by a single space.

Parameters
string$strA string.
Returns
string
Since
1.5.4

◆ XH_secondLanguages()

XH_secondLanguages ( )

Returns the installed second languages in alphabetic order.

Returns
array
Since
1.6

◆ XH_spliceString()

XH_spliceString ( $string,
  $offset,
  $length = 0,
  $replacement = '' 
)

Removes a portion of a string and replaces it with something else.

This does basically the same to strings as array_splice() for arrays. Note that the behavior of negative values for $offset and $length is not defined.

Parameters
string$stringThe string to manipulate.
int$offsetOffset of the string where to start the replacement.
int$lengthThe number of characters to be replaced.
string$replacementThe string to replace the removed characters.
Returns
string The replaced characters.
Since
1.6

◆ XH_startSession()

XH_startSession ( )

Starts a named session.

If session is already started, nothing happens.

Returns
void
Since
1.7

◆ XH_templates()

XH_templates ( )

Returns an array of installed templates.

Returns
array
Since
1.6

◆ XH_title()

XH_title (   $site,
  $subtitle 
)

Returns the text content for a TITLE element.

Parameters
string$siteA site name.
string$subtitleA subtitle (e.g. the page heading).
Returns
string
Since
1.6

◆ XH_uenc()

XH_uenc (   $s,
array  $search,
array  $replace 
)

Returns a percent encoded URL component.

Additionally all character sequences in $search will be replaced by their according character sequences in $replace, spaces will be replaced by the configured word_separator and leading, trailing and multiple consecutive word_separators will be trimmed.

Parameters
string$sThe URL component.
array$searchStrings to search for.
array$replaceReplacement strings.
Returns
string
See also
uenc()
Since
1.6

◆ XH_unionOf2DArrays()

XH_unionOf2DArrays ( array  $array1,
array  $array2 
)

Returns the union of two "2-dimensional" arrays in the same manner as the union operator (i.e.

keys and subkeys in the first array have higher priority).

Parameters
array$array1A "2-dimensional" array.
array$array2A "2-dimensional" array.
Returns
array
Since
1.6

◆ XH_writeFile()

XH_writeFile (   $filename,
  $contents 
)

Writes $contents to the file $filename.

During writing the file is locked exclusively.

Parameters
string$filenameThe filename.
string$contentsThe content to write.
Returns
int The number of bytes written, or false on failure.
Since
1.6