PHP
This is an overview of useful PHP functions and variables.
They let you work with data easily and make your prototype feel real.
Function Reference
Function | Description and Parameters |
---|---|
__() | (Two underscores) Returns the translation for the provided key. Returns the value of the key when no translation is found.
ParameterskeyThe key to translatelanguage (optional) The language the key is to be translated to. Defaults to the current active language of the prototype |
alert() | Builds the HTML for a Bootstrap Alert.
ParameterstextThe text you want to display, can contain HTMLclass (optional) The name of one of the Boostrap alert modifier classes: info, success, warning or danger. defaults to info if not providedicon (optional) The name of the Font Awesome icon to be used for the alert. Defaults to a predefined icon for each modifier class:id (optional) The id you want to give the alert. Defaults to alertiddismiss (optional) Boolean value to make the alert dismissable. Defaults to true |
forceLogin() | When called Protostrap will force the user to log into the prototype to access the page requested. Instead of the page requested Protostrap will show a login form if the user is not logged in, The function is ideally called in the HTML before the <body> tag
ParametersNone. |
getDeeplink() | Returns the link to the current page including GET Parameters and automatic user login. This is especially useful in a rolebased prototype. Deeplinks make it possible to view a page the way it was when the Deeplink was generated. This includes anything that refers to the current role. Deeplinks are great for documentation and specification in development, not forcing developers to log in as a the user of the userstory.
ParametersNone. |
getFirstUserLogin() | Gets the email of the first user specified in the users array in the users.yml file.
ParametersNone. |
getUniqueId() | Returns a number as a unique identifier. The id is incremented on each call.
ParametersvariableName (optional)Variable name, when added the function will use the variable with the paramater's name as unique id variable. If the variable does not exist it will create one. |
hideIf() | Will output the class hide if the current user is in one of the specified usergroups
ParametersusergroupsThe names of the usergroups affected. Multiple groups can be specified as a comma-separated list: admin, superadmin |
includeIf() | Will include the specified file if the current user is in one of the specified usergroups
ParametersusergroupsThe names of the usergroups affected. Multiple groups can be specified as a comma-separated list: admin, superadminfile The path to the file to be included. |
makeDateFromString() | Returns a date from almost any English textual datetime description. Examples:
ParametersstringThe textual daytime descriptionformat (optional) The formatting pattern for the date, corresponding to the PHP format parameter strings |
reorder() | Reorders an array by the values of the specified key. Think of the Array as a table and each key as a column. Returns a reordered copy of the original array.
ParametersarrayThe array to reordercolumn The column or key by which the array is to be reordereddirection (optional) The direction in which the columns should be reordered. Defaults to ascending if none is provided. Possible values: asc and desc |
showIf() | Will not output the class hide if the current user is in one of the specified usergroups
ParametersusergroupsThe name of the usergroups affected. Multiple groups can be specified as a comma-separated list: admin, superadmin |
today() | Returns today's date in the format specified in the config.yml file in the variable defaultPHPdateFormat (default d.m.Y)
Parametersformat (optional)The formatting pattern for the date, corresponding to the PHP format parameter strings |
tomorrow() | Returns tomorrow's date in the format specified in the config.yml file in the variable defaultPHPdateFormat (default d.m.Y)
Parametersformat (optional)The formatting pattern for the date, corresponding to the PHP format parameter strings |
yesterday() | Returns yesterday's date in the format specified in the config.yml file in the variable defaultPHPdateFormat (default d.m.Y)
Parametersformat (optional)The formatting pattern for the date, corresponding to the PHP format parameter strings |
Variables
Name | Description |
---|---|
$lastUniqueId | Retruns the value assigned to it by calling the function getUniqueId(). |
$currentYear | Returns the current year as a four digit number |
$loggedIn | Tells you if a user is logged in. Returns false if not. |
$justloggedIn | Tells you if a user just logged in. This variable returns true only on the page called by the form. |
$activeUser | An array of the current active user. Will show false if no user is logged in. |
$username | The active user's username |
$usermail | The active user's email |
$userrole | The active user's role |
$userpermissions | An array of the permissions given to the user as defined in the users.yml file |