Simple Web Presenter
An extremely basic CMS
 All Classes Files Functions Variables Pages
Functions
common-functions.inc File Reference

Functions

 repMapString ($map)
 
 basePath ()
 
 loadFile ($sFilename, $sCharset= 'UTF-8')
 
 errorPage ($errorText, $errorCode=403)
 
 genUrl ($urlParams, $keys=array(), $nonQueryParams=array())
 
 getElementByTagName ($obj, $name)
 
 startswith ($haystack, $needle)
 
 endsWith ($haystack, $needle)
 
 opttostring ($opts)
 

Detailed Description

Functionality which doesn't belong anywhere else

Function Documentation

basePath ( )

Get the location on the server where the top level script is located

Returns
directory
endsWith (   $haystack,
  $needle 
)

Checks if one string ends with another string

Parameters
$haystackthe string to search
$needlethe string to search for
Returns
bool if match
errorPage (   $errorText,
  $errorCode = 403 
)

Generate a status page and exit

Parameters
$errorTextthe text to be displayed in the body
$errorCodethe status code to be served
genUrl (   $urlParams,
  $keys = array(),
  $nonQueryParams = array() 
)

Generates an URL for the specified parameters

Parameters
$urlParamsan associative array of the values already set
$keysa set of values to override $urlParams
$nonQueryParamsa list of keys, where values should be in the URL, rather than the query part, note that the order is important
getElementByTagName (   $obj,
  $name 
)

Retrieves a single subelement

Exceptions
Exceptionif number of elements are different from 1
Todo:
Throw more specific exception
Parameters
$objthe xml element to search in
$namethe name of the element to search for
loadFile (   $sFilename,
  $sCharset = 'UTF-8' 
)

Loads a file

Parameters
$sFilenamename of the file to load
$sCharsetthe character encoding of the file
Todo:
make this function throw instead of returning codes
Returns
the contents of the file, or a status code (-3 if file does not exists, if file could not be opened -2)
opttostring (   $opts)

Generates the query part of an URI

Parameters
$optsan associative array of options
Returns
a string that can be used for the query part of an URI
repMapString (   $map)

Generates a representation for an array of key => value pairs

Note
Behaviour is undefined if value is a composite structure.
Parameters
$mapthe input array
Returns
a string representation that may be eval'ed
startswith (   $haystack,
  $needle 
)

Checks if one string start with another string

Parameters
$haystackthe string to search
$needlethe string to search for
Returns
bool if match