Once you start building applications, you will add PHP code to events. Below is a list of pre-set functions you can use

clean_htmlClean HTML string removing all element attributes and elements which are not in the provided whitelist (but keeping their allowed children).function clean_html($html, array $whitelist)sanitized HTMLbased upon
closeSessionCloses the session by unsetting it, destroying it, closes the write buffer and clears the session cookie.function closeSession()nothing
downloadDownload a filedownload($path, $file)
encryptpswEncrypts the password with the given method (none, md5, sha, php)encryptpsw($passwrd, $method)password
extractFieldNameExtract the fieldname of a table.field pairextractFieldName($theField)field name
getGUIDRetrieves a unique stringfunction getGUID()stringReturns a string that can be used for validation situations, i.e. for confirming credentials etc. In PHsPeed this string is used to let users validate their account.
getHTMLColorsRetrieves an array of html colorsgetHTMLColors()html colors
getProtocolReturns the used protocol as HTTP: or HTTPS: function getProtocol()HTTP: or HTTPS:
inPostStateTests if the form has received form data or is in it's initials statefunction inPostState();true, falseif(inPostState() ){…}
isAjax()Tests if the form is called in ajax modefunction isAjax()true,falseif(isAjax()) {…} As the controller application is called in stages, the ajax stage is when the system needs to supply the form data. The initial stage is used to create the html template. To avoid operations being performed twice, you can use this switch to determine if your code needs to be executed in the initial or ajax state.
isHTTPSVerifies if the application runs under httpsisHTTPS()true, false
isTrueTest if a value is truetoClass($strin)true, falseChecks for all kind of values: t, T, y, Y, true, TRUE, yes, YES
getExternalSessionVarGet a session var of another modulegetExternalSessionVar($theVar, $default=,$origin=
phspCreateLinkCreate a valid link with an encrypted parameter list (including session variables)function phspCreateLink($url, $parms, $initialformmode='')linkThis function returns a valid link that can be used as a valid hyperlink to any PHsPeed module. It encrypts the parameters to avoid security issues, and applies session info as well to avoid csrf issues. The parameters need to be applied in a=b pairs. The initial form mode specifies the state the form must open. Valid options are add, delete, update.
setSessionVarSets a session variablefunction setSessionVar($theVar, $value)nothingThis function sets a session variable that is maintained over the same session.
showMessageDisplays a modal messageshowMessage($msg)nothingIn general this function can be used to submit and in ajax stage to display a popup message, but only on events that passes the $app object.

Example: $app→showMessage('process complete');

See also macro notation (@@showMessage('…');
session_stopTerminates a sessionsession_stop()
sessionVarExists sessionVarExists($theVar)true,false
setFormMode($mode)Set next form mode to edit, delete, update, createsetFormMode($mode) Use this funciton before redirecting to the required module
setSessionVarSets a session variablefunction setSessionVar($theVar, $value)nothingThis function sets a session variable that is maintained over the same session.
unsetSessionVarUnsets a session variableunsetSessionVar($theVar)
toClassConverts a table.field name into a table_field name classtoClass($strin). → _
findComponentsearch component reference on component namefindComponentByName($theCompName)component reference or falseTraverses the component tree to find the required component
loginwrapper around the root component to loginlogin($uid, $pwd)true/false
logoffwrapper around the root component to logofflogoff()true/false
redirectredirect to the given urlRedirect($theUrl, $origin, $parms=,$initialformmode) Can be used in a regular status and within an ajax event. Origin: current module as recepient, parms: a=b&c=d&… parameter pairs, initialformmode: the form mode to start the next application in (insert, edit, delete, none) The parameter string will be encrypted using the project settings for security.
showMessageSets a session variableshowMessage($theMsg)nothingThis function sets a session variable that is maintained over the same session.
@@login(…)will be translated to $app→login(…) For some commonly used functions, it is more convenient to use the @@ notation as PHsPeed will 'know' in what module the function resides. So you don't have to remember that login is part of the $app.
@@showMessagewill be translated to $app>showMessage(…)

  • functions.txt
  • Last modified: 2020/11/17 12:06
  • by aducomadmin