DATE_FORMAT_GNU
DATE_FORMAT_GNU
_htmlOptions(string $fieldPath, array $values, string $default = null, integer $matches = null, string $prefix = '', string $domain = 'global')
Display htmlOptions()
string | $fieldPath | The name path to the field. |
array | $values | The values to build the dropdown menu. |
string | $default | The default selected value. Default value is null (no selection). |
integer | $matches | Define the associativity between array and option values. Default value is OPT_VALUE2LABEL (as null). |
string | $prefix | The prefix to use for the text name of values. Default value is an empty string. |
string | $domain | The domain to apply the Key. Default value is 'global'. |
_t(string $k, string $domain = 'global', array|string $values = array())
Display t()
string | $k | The Key to translate, prefer to use an internal language (English CamelCase). |
string | $domain | The domain to apply the Key. Default value is 'global'. |
array|string | $values | The values array to replace in text. Could be used as second parameter. |
addAutoload(string $className, string $classPath)
Add a class to the autoload.
string | $className | The class name |
string | $classPath | The class path Add the class to the autoload list, associated with its file. The semi relative path syntax has priority over the full relative path syntax. e.g: ("MyClass", "mylib/myClass") => libs/mylib/myClass_class.php or ("MyClass2", "mylib/myClass2.php") => libs/mylib/myClass.php |
addReport( $report, $type, $domain = 'global', string $code = null, integer $severity) : boolean
Adds a report
$report | string The report (Commonly a string or an UserException). |
|
$type | string The type of the message. |
|
$domain | string The domain to use to automatically translate the message. Default value is 'global'. |
|
string | $code | The code to use for this report. Default is $report. |
integer | $severity | The severity of report. Default value is 0. |
False if rejected.
apath_get(array $array, string $apath, mixed $default = null, boolean $pathRequired = false) : mixed
Get value from an Array Path
array | $array | The array to get the value from. |
string | $apath | The path used to browse the array. |
mixed | $default | The default value returned if array is valid but key is not found. |
boolean | $pathRequired | True if the path is required. Default value is False. |
The value from $apath in $array.
apath_setp(array $array, string $apath, mixed $value, boolean $overwrite = true)
Set value into an Array Path
array | $array | The array to get the value from. |
string | $apath | The path used to browse the array. |
mixed | $value | The value to set in array |
boolean | $overwrite | True to overwrite existing value. Default value is True. |
array_apply(array $array, callable $callback, string $userdata = null, string $success = null) : array
Apply a user supplied function to every member of an array
array | $array | The input array. |
callable | $callback | Typically, callback takes on two parameters. The array parameter's value being the first, and the key/index second. |
string | $userdata | If the optional userdata parameter is supplied, it will be passed as the third parameter to the callback. |
string | $success | TRUE on success or FALSE on failure. |
The resulting array
bintest(integer $value, integer $reference) : True
Do a binary test
integer | $value | The value to compare. |
integer | $reference | The reference for the comparison. |
if $value is binary included in $reference.
Do a binary test, compare $value with $reference. This function is very useful to do binary comparison for rights and inclusion in a value.
cleanscandir(string $dir, boolean $sorting_order = false) : array<mixed,string>
Scans a directory cleanly.
string | $dir | The path to the directory to scan. |
boolean | $sorting_order | True to reverse results order. Default value is False. |
An array of the files in this directory.
Scans a directory and returns a clean result.
dayTime(integer $time = null, boolean $gmt = true) : integer
Calculate the day timestamp using the given integer
integer | $time | The time to get the day time. Default value is current timestamp. |
boolean | $gmt | Is the time GMT |
Return the timestamp of the current day of $time according to the midnight hour.
df( $format, mixed $time = TIME, mixed $tz = null) : string
Format the date time as string
$format | The format to use |
|
mixed | $time | The UNIX timestamp |
mixed | $tz | Timezone to use. False for UTC, Null for default or a string to specify the one to use |
The date formatted using $format
Datetime format is storing a specific moment, we care about timezone
displayReportsHTML(string $stream = 'global', array<mixed,string> $rejected = array(), boolean $delete = 1)
Display reports as HTML
string | $stream | The stream to display. Default value is 'global'. |
array<mixed,string> | $rejected | An array of rejected messages. Can be the first parameter. |
boolean | $delete | True to delete entries from the list. |
ensure_pdoinstance(string $instance = null) : string
Ensure $instance is connected to DBMS
string | $instance | If supplied, this is the ID of the instance to use to execute the query. Optional, PDODEFINSTNAME constant by default. |
Instance ID used
Ensure to provide a valid and connected instance of PDO, here are the steps: If it is not loaded, this function attempts to load the database configuration file. If not supplied as a parameter, this function attempts to determine an existing instance name. If the instance is not connected, this function attempts to connect.
explodeList(string $delimiter, string $string, integer $limit, string $default = null) : array
Split a string by string in limited values
string | $delimiter | The boundary string |
string | $string | The input string |
integer | $limit | The limit of values exploded |
string | $default | The default value to use if missing |
The exploded array with a defined limit of values.
extractFrom( $apath, $array) : \Data
Extract data from array using apath
$apath | The apath to retrieve. null retrieves all data. |
|
$array | The array of data to browse. |
using the apath or all data from the given array.
Get data from an array using the $apath. If $apath is null, all data are returned.
fillInputValue( $value, $fieldPath, $default = null, $pathRequired = false) : boolean
Fill the given value from input form
$value | The value to fill, as pointer. |
|
$fieldPath | The apath to the input form value. |
|
$default | The default value if not found. Default value is null (apath_get()'s default). |
|
$pathRequired | True if the path is required. Default value is False (apath_get()'s default). |
True if got value is not null (found).
ft( $time = null) : string
Get the date time as string
$time | The time with %H:%M format. |
The formatted time using 'timeFormat' translation key
Convert the system time format to the user time format The system uses the constant SYSTEM_TIME_FORMAT to get the default format '%H:%M', you can define it by yourself.
generatePassword(integer $length = 10, string $chars = 'abcdefghijklmnopqrstuvwxyz0123456789') : string
Generate a new password
integer | $length | The length of the generated password. Default value is 10. |
string | $chars | The characters to use to generate password. Default value is 'abcdefghijklmnopqrstuvwxyz0123456789' |
The generated password.
Letters are randomly uppercased
getFlatReports(string $stream = 'global', string $type = null, boolean $delete = 1) : \array[].
Get some/all reports as flatten array
string | $stream | The stream to get the reports. Default value is "global". |
string | $type | Filter results by report type. Default value is null. |
boolean | $delete | True to delete entries from the list. Default value is true. |
getFormData() : \POST()
Get input form data
or global $formData if set.
Get input form data from POST. Developers can specify an array of data to use by filling global $formData. This function is designed to be used internally to have compliant way to get input form data.
getHTMLReport(string $stream, string $report, string $domain, string $type)
Get one report as HTML
string | $stream | The stream of the report. |
string | $report | The message to report. |
string | $domain | The domain of the report. |
string | $type | The type of the report. Return a valid HTML report. This function is only a HTML generator. |
getReports(string $stream = 'global', string $type = null, boolean $delete = 1)
Get some/all reports
string | $stream | The stream to get the reports. Default value is "global". |
string | $type | Filter results by report type. Default value is null. |
boolean | $delete | True to delete entries from the list. Default value is true. |
getReportsHTML( $stream = 'global', $rejected = array(), $delete = true) : \The
Get some/all reports as HTML
$stream | string The stream to get the reports. Default value is 'global'. |
|
$rejected | array An array of rejected messages. Default value is an empty array. |
|
$delete | boolean True to delete entries from the list. Default value is true. |
renderer HTML.
hasPOSTKey( $path = null, $value = null) : True
Check an existing post key
$path | string The path to the array. The default value is null (search in POST). |
|
$value | int The output value of the item to delete. |
if there is an item to delete
This function is used to key the key value from an array sent by post E.g You use POST to delete an item from a list, it's name is delete[ID], where ID is the ID of this item If you call hasPOSTKey("delete", $itemID), the function will return true if a delete item is defined and $itemID will contain the ID of the item to delete.
hasTranslation(string $k, string $domain = 'global') : boolean
Check if this key exists.
string | $k | The Key to translate, prefer to use an internal language (English CamelCase). |
string | $domain | The domain to apply the Key. Default value is 'global'. |
True if the translation exists in this domain.
This function checks if the key is known in the translation list.
htmlOptions(string $fieldPath, array $values, string $default = null, integer $matches = null, string $prefix = '', string $domain = 'global') : string
Generate the HTML source for options of a select tag
string | $fieldPath | The name path to the field. |
array | $values | The values to build the dropdown menu. |
string | $default | The default selected value. Default value is null (no selection). |
integer | $matches | Define the associativity between array and option values. Default value is OPT_VALUE2LABEL (as null). |
string | $prefix | The prefix to use for the text name of values. Default value is an empty string. |
string | $domain | The domain to apply the Key. Default value is 'global'. |
A HTML source for the built SELECT tag.
htmlRedirectTo( $destination, $time = 3, $die)
Redirect the client to a destination by HTML
$destination | The destination to go. |
|
$time | The time in seconds to wait before refresh. |
|
$die | True to stop the script. Redirect the client to a $destination using the HTML meta tag. Does not stop the running script, it only displays. |
htmlSelect(string $name, array $values, array $data = null, string $selected = null, string $prefix = '', string $domain = 'global', string $tagAttr = '') : string
Generate the HTML source for a select tag
string | $name | The name of the field. |
array | $values | The values to build the dropdown menu. |
array | $data | The array of data where to look for. Default value is $formData (if exist) or $_POST |
string | $selected | The selected value from the data. Default value is null (no selection). |
string | $prefix | The prefix to use for the text name of values. Default value is an empty string. |
string | $domain | The domain to apply the Key. Default value is 'global'. |
string | $tagAttr | Additional attributes for the SELECT tag. |
A HTML source for the built SELECT tag.
htmlValue( $name, $data = null, $default = '') : \A
Get the HTML value
$name | The name of the field |
|
$data | The array of data where to look for. Default value is $formData (if exist) or $_POST |
|
$default | The default value if $name is not defined in $data |
HTML source with the "value" attribute.
Get the HTML value attribut from an array of data if this $name exists.
id(integer|string|\Orpheus\Publisher\PermanentObject\PermanentObject $id) : integer
Get the id whatever we give to it
integer|string|\Orpheus\Publisher\PermanentObject\PermanentObject | $id |
is_date(string $date, boolean $withTime = false, integer $time = false, integer $format = null) : boolean
Check if the input is a date.
string | $date | The date to check. |
boolean | $withTime | True to use datetime format, optional. Default value is false. |
integer | $time | The output timestamp of the data, optional. |
integer | $format | The date format to check, see constants DATEFORMAT* |
True if $date si a valid date.
The date have to be well formatted and valid. The FR date format is DD/MM/YYYY and time format is HH:MM:SS Allow 01/01/1970, 01/01/1970 12:10:30, 01/01/1970 12:10 Fill missing informations with 0.
is_name(string $name, integer $charnb_max = 50, integer $charnb_min = 3) : boolean
Check if the input is a name.
string | $name | The name to check. |
integer | $charnb_max | The maximum length of the given name. Default value is 50. |
integer | $charnb_min | The minimum length of the given name. Default value is 3. |
True if $name si a name.
is_personalname(string $name, integer $charnb_max = 50, integer $charnb_min = 3) : boolean
Check if the input is a personal name.
string | $name | The name to check. |
integer | $charnb_max | The maximum length of the given name. Default value is 50. |
integer | $charnb_min | The minimum length of the given name. Default value is 3. |
True if $name si a name.
is_phone_number(string $number, string $country = 'FR') : boolean
Check if the input is a phone number.
string | $number | The phone number to check. |
string | $country | The country to use to validate the phone number, default is FR, this is the only possible value |
True if $number si a valid phone number.
It can only validate french phone number. The separator can be '.', ' ' or '-', it can be ommitted. e.g: +336.12.34.56.78, 01-12-34-56-78
log_error(string $report, string $action = '', boolean $fatal = true)
Log a system error
string | $report | The report to log. |
string | $action | The action associated to the report. Default value is an empty string. |
boolean | $fatal | True if the error is fatal, it stops script. Default value is true. |
log_hack( $report, $action = '', $message = null)
Log a hack attemp
$report | The report to log. |
|
$action | The action associated to the report. Default value is an empty string. |
|
$message | If False, it won't display the report, else if a not empty string, it displays it, else it takes the report's value. |
log_report(string|\Exception $report, string $file, string $action = '', string $message = '', boolean $noException = false)
Log a report in a file
string|\Exception | $report | The report to log. |
string | $file | The log file path. |
string | $action | The action associated to the report. Default value is an empty string. |
string | $message | The message to display. Default is an empty string. See description for details. |
boolean | $noException | True to not throw any exception (in DEV mode for now) |
monthTime( $day = 1, $time = null) : integer
Return the timestamp of the $day of the month using the given integer
$day | The day of the month to get the timestamp. Default value is 1, the first day of the month. |
|
$time | The time to get the month timestamp. Default value is current timestamp. |
pdo_error(string $report, string $action = '', integer $fetch, \PDOException $original = null)
Log a PDO error
string | $report | The report to save. |
string | $action | Optional information about what the script was doing. |
integer | $fetch | The fetch flags, if PDOERROR_MINOR, this function does nothing. Optional, default value is 0. |
\PDOException | $original | The original exception. Optional, default value is null. Save the error report $report in the log file and throw an exception. If the error is minor, nothing happen, else The error is reported and an exception is thrown |
pdo_lastInsertId(string $instance = null) : string
Get the last inserted ID
string | $instance | The instance to use to get the last inserted id. Optional, default is defined by ensure_pdoinstance(). |
The last inserted id
Get the last inserted ID for this instance
pdo_query(string $query, integer $fetch = PDOQUERY, string $instance = null) : \mxied
Execute $query
string | $query | The query to execute. |
integer | $fetch | See PDO constants above. Optional, default is PDOQUERY. |
string | $instance | The instance to use to execute the query. Optional, default is defined by ensure_pdoinstance(). |
The result of the query, of type defined by $fetch.
Execute $query on the instanciated database.
reportError(string $report, string $domain = null, integer $severity = 1)
Reports an error
string | $report | The report. |
string | $domain | The domain fo the message. Default value is the domain of Exception in case of UserException else 'global'. |
integer | $severity | The severity of the error, commonly 1 for standard user error and 0 for warning. Default value is 1. |
sendResponse( $code, $other = '', $domain = 'global', $desc = null)
Send a packaged response to the client.
$code | string The response code. |
|
$other | array Other data to send to the client. Default value is an empty string. |
|
$domain | string The translation domain. Default value is 'global'. |
|
$desc | string The alternative description code. Default value is $code. The response code is a status code, commonly a string. User $Other to send arrays and objects to the client. The packaged reponse is a json string that very useful for AJAX request. This function stops the running script. |
slug(string $string, integer $case = null) : string
Convert the string into a slug
string | $string | The string to convert. |
integer | $case | The case style flag to use, values: null (default), LOWERCAMELCASE or UPPERCAMELCASE. |
The slug version.
Convert string to lower case and converts all special characters.
sql_error(string|\Exception $report, string $action = '', boolean $noException = false)
Log a sql error
string|\Exception | $report | The report to log |
string | $action | The action associated to the report. Default value is an empty string |
boolean | $noException | True to not throw any exception (in DEV mode for now) |
ssh2_run( $command, $SSH2S = null) : \The
Run a SSH2 command.
$command | The command to execute. |
|
$SSH2S | Local settings for the connection. |
stream from ssh2_exec()
Runs a command on a SSH2 connection. You can pass the connection settings array in argument but you can declare a global variable named $SSH2S too.
standardizePhoneNumber_FR( $number, $delimiter = '.', $limit = 2) : string
Standardize the phone number to FR country format
$number | The input phone number. |
|
$delimiter | The delimiter for series of digits. Default value is current timestamp. Default value is '.'. |
|
$limit | The number of digit in a serie separated by delimiter. Optional, the default value is 2. |
Return a standard phone number for FR country format.
t(string $k, string $domain = 'global', array|string $values = array()) : string
Translate a key
string | $k | The Key to translate, prefer to use an internal language (English CamelCase). |
string | $domain | The domain to apply the Key. Default value is 'global'. |
array|string | $values | The values array to replace in text. Could be used as second parameter. |
The translated human text.
This function try to translate the given key, in case of failure, it just returns the Key. It tries to replace $values in text by key using #key# format using str_replace() but if $values is a list of values, it uses sprintf(). $values allows 3 formats:
array('value1', 'value2'...) This function is variadic, you can specify values with more scalar arguments.
Examples: t('untranslatedString', 'aDomain'), t('My already translated string'), t('untranslatedString', 'global', array('key1'=>'val1')), t('untranslatedString', 'global', 'val1', 60)
toSlug( $string, $case = null) : string
Convert the string into a slug
$string | The string to convert. |
|
$case | The case style to use, values: null (default), LOWERCAMELCASE or UPPERCAMELCASE. |
The slug version.
Convert string to lower case and converts all special characters.
translate(string $k, string $default, string $domain = 'global') : string
Check if this key exists.
string | $k | The Key to translate, prefer to use an internal language (English CamelCase). |
string | $default | The default translation value to use. |
string | $domain | The domain to apply the Key. Default value is 'global'. |
The translation
This function translate the key without any fail. If no translation is available, it uses the $default.