functions

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
functions [2020/04/06 12:13]
aducomadmin [PHsPeed functions (general)]
functions [2020/11/17 12:06] (current)
aducomadmin
Line 3: Line 3:
 Once you start building applications, you will add PHP code to events. Below is a list of pre-set functions you can use Once you start building applications, you will add PHP code to events. Below is a list of pre-set functions you can use
  
-|function|description|prototype|returns|Notes|+^function^description^prototype^returns^Notes| 
 +|clean_html|Clean 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 HTML|based upon [[https://github.com/alixaxel/phunction/blob/master/phunction/HTML.php|https://github.com/alixaxel/phunction/blob/master/phunction/HTML.php]]| 
 +|closeSession|Closes the session by unsetting it, destroying it, closes the write buffer and clears the session cookie.|function closeSession()|nothing| | 
 +|download|Download a file|download($path, $file)| | | 
 +|encryptpsw|Encrypts the password with the given method (none, md5, sha, php)|encryptpsw($passwrd, $method)|password| | 
 +|extractFieldName|Extract the fieldname of a table.field pair|extractFieldName($theField)|field name| |
 |getGUID|Retrieves a unique string|function getGUID()|string|Returns 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.| |getGUID|Retrieves a unique string|function getGUID()|string|Returns 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.|
-|inPostState|Tests if the form has received form data or is in it's initials state|inPostState();|true or false|if(inPostState() ){…}| +|getHTMLColors|Retrieves an array of html colors|getHTMLColors()|html colors| | 
-|isAjax|Tests if the current module takes part in an Ajax handler|isAjax()|true or false|if(isAjax()) { … }| +|getProtocol|Returns the used protocol as HTTP:// or HTTPS:// |function getProtocol()|HTTP:// or HTTPS:// | | 
-|isLoggedOn|Testst if the current users is logged on|isLoggedOn()|true or false|if(isLoggedOn()) { … }+|inPostState|Tests if the form has received form data or is in it's initials state|function inPostState();|truefalse|if(inPostState() ){…}| 
-|phspCrypt|Encrypts and Decrypts data.|phspCrypt($string, $mode)|string|available modes are: 'efor encryption and 'd' for description. The key and salt used is setup in the project properties. This function is used by PHsPeed to store database credentialsemailing options etcOnce set in the IDE then do not change as this will make the encrypted files unreadable\\  \\ Sample: $mystr=phspCrypt($enc'e');+|isAjax()|Tests if the form is called in ajax mode|function isAjax()|true,false|if(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.
-|PHP redirect|Redirects current form to another page.|phspRedirect($url, $origin='')'' |nothing|Redirects to another module. Origin is optionas and can be used to pass the current module as a recepient.| +|isHTTPS|Verifies if the application runs under https|isHTTPS()|truefalse| 
-|rtrSubmitBtn|Retrieves the id of the button clicked|rtrSubmitBtn();|string|This function will return the button clicked. It is only to be used in the submit process and is not usable in ajax events. If you have more buttons on the form and want to take action depending on the submit button clicked then this function is useful\\ Sample: \\  \\ $key=rtrSubmitBtn(); \\ if($key=='mail_btn_1'{ …. } \\  \\ The name of the button is the name that is used in its constructor (#module _ #name). So if the PHP modules name is 'myapp' and the button is called 'mybtn' then the function would return 'myapp_mybtn'; +|isTrue|Test if a value is true|toClass($strin)|true, false|Checks for all kind of values: t, T, y, Y, true, TRUE, yes, YES
-|session_stop|Releases session variables and closes current session|session_stop()|nothing|This function will prevent data to be saved in reusable session cookie after termination of the application.|+|getExternalSessionVar|Get a session var of another module|getExternalSessionVar($theVar, $default=,$origin=| | 
 +|phspCreateLink|Create a valid link with an encrypted parameter list (including session variables)|function phspCreateLink($url, $parms, $initialformmode='')|link|This function returns a valid link that can be used as a valid hyperlink to any PHsPeed module. It encrypts the parameters to avoid security issuesand applies session info as well to avoid csrf issuesThe parameters need to be applied in a=b pairs. The initial form mode specifies the state the form must openValid options are adddelete, update.
 +|setSessionVar|Sets a session variable|function setSessionVar($theVar, $value)|nothing|This function sets a session variable that is maintained over the same session.| 
 +|showMessage|Displays a modal message|showMessage($msg)|nothing|In 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_stop|Terminates a session|session_stop()| | | 
 +|sessionVarExists| |sessionVarExists($theVar)|true,false| | 
 +|setFormMode($mode)|Set next form mode to edit, delete, update, create|setFormMode($mode)| |Use this funciton before redirecting to the required module| 
 +|setSessionVar|Sets a session variable|function setSessionVar($theVar, $value)|nothing|This function sets a session variable that is maintained over the same session.
 +|unsetSessionVar|Unsets a session variable|unsetSessionVar($theVar)| | | 
 +|toClass|Converts a table.field name into a table_field name class|toClass($strin)|. → _| | 
 +| | | | | |
  
-=====   =====+===== PHsPeed functions (Application object) =====
  
-\\ +^function^description^prototype^returns^Notes| 
- +|findComponent|search component reference on component name|findComponentByName($theCompName)|component reference or false|Traverses the component tree to find the required component| 
- +|login|wrapper around the root component to login|login($uid, $pwd)|true/false| | 
-===== PHsPeed functions (application object===== +|logoff|wrapper around the root component to logoff|logoff()|true/false| | 
- +|redirect|redirect to the given url|Redirect($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 pairsinitialformmodethe form mode to start the next application in (insert, edit, delete, noneThe parameter string will be encrypted using the project settings for security.| 
-|function|description|prototype|returns|Notes+|showMessage|Sets a session variable|showMessage($theMsg)|nothing|This function sets a session variable that is maintained over the same session.|
-|showMessage|Displays a modal message|showMessage($msg)|nothing  \\ In general this function can be used to submit and in ajax stage to display popup messagebut only on events that passes the $app object. \\   \\ Example$app→showMessage('process complete'); \\  \\ See also macro notation (@@showMessage('…');  |+
 | | | | | | | | | | | |
  
  • functions.1586168037.txt.gz
  • Last modified: 2020/04/06 12:13
  • by aducomadmin