\

Namespaces

Orpheus

Constants

DATE_FORMAT_GNU

DATE_FORMAT_GNU

DATE_FORMAT_LOCALE

DATE_FORMAT_LOCALE

ESCAPE_ALLQUOTES

ESCAPE_ALLQUOTES

ESCAPE_ALLQUOTES_TOHTML

ESCAPE_ALLQUOTES_TOHTML

ESCAPE_DOUBLEQUOTES

ESCAPE_DOUBLEQUOTES

ESCAPE_DOUBLEQUOTES_TOHTML

ESCAPE_DOUBLEQUOTES_TOHTML

ESCAPE_SIMPLEQUOTES

ESCAPE_SIMPLEQUOTES

ESCAPE_TOHTML

ESCAPE_TOHTML

HOOK_ACCESSDENIED

HOOK_ACCESSDENIED

HOOK_APPREADY

HOOK_APPREADY

HOOK_CHECKMODULE

HOOK_CHECKMODULE

HOOK_LIBSLOADED

HOOK_LIBSLOADED

HOOK_MENUITEMACCESS

HOOK_MENUITEMACCESS

HOOK_RUNMODULE

HOOK_RUNMODULE

HOOK_SESSIONSTARTED

HOOK_SESSIONSTARTED

HOOK_SHOWRENDERING

HOOK_SHOWRENDERING

HOOK_STARTSESSION

HOOK_STARTSESSION

HOOK_STARTSESSION_AUTO

HOOK_STARTSESSION_AUTO

LANGBASE

LANGBASE

OPT_KEY

OPT_KEY

OPT_LABEL2VALUE

OPT_LABEL2VALUE

OPT_LABEL_IS_KEY

OPT_LABEL_IS_KEY

OPT_LABEL_IS_VALUE

OPT_LABEL_IS_VALUE

OPT_PERMANENTOBJECT

OPT_PERMANENTOBJECT

OPT_VALUE

OPT_VALUE

OPT_VALUE2LABEL

OPT_VALUE2LABEL

OPT_VALUE_IS_KEY

OPT_VALUE_IS_KEY

OPT_VALUE_IS_VALUE

OPT_VALUE_IS_VALUE

PDOERROR_FATAL

PDOERROR_FATAL

PDOERROR_MINOR

PDOERROR_MINOR

PDOEXEC

PDOEXEC

PDOFETCH

PDOFETCH

PDOFETCHALL

PDOFETCHALL

PDOFETCHALLCOL

PDOFETCHALLCOL

PDOFETCHFIRSTCOL

PDOFETCHFIRSTCOL

PDONOSTMT

PDONOSTMT

PDOQUERY

PDOQUERY

PDOSTMT

PDOSTMT

SESSION_WITH_HTTPTOKEN

SESSION_WITH_HTTPTOKEN

Functions

_formInput()

_formInput(string  $fieldPath, string  $default = null) 

Display formInput()

Parameters

string $fieldPath
string $default

_htmlOptions()

_htmlOptions(string  $fieldPath, array  $values, string  $default = null, integer  $matches = null, string  $prefix = '', string  $domain = 'global') 

Display htmlOptions()

Parameters

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'.

_htmlText()

_htmlText(string  $fieldPath, string  $default = '', string  $addAttr = '', callback  $formatter = null) 

Display htmlText()

Parameters

string $fieldPath
string $default
string $addAttr
callback $formatter

_inputValue()

_inputValue(string  $fieldPath, string  $default = null) 

Display inputValue()

Parameters

string $fieldPath
string $default

_t()

_t(string  $k, string  $domain = 'global', array|string  $values = array()) 

Display t()

Parameters

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.

_u()

_u(string  $route, array  $values = array()) 

Display URL to a route

Parameters

string $route
array $values

Throws

\Exception

addAutoload()

addAutoload(string  $className, string  $classPath) 

Add a class to the autoload.

Parameters

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()

addReport(  $report,   $type,   $domain = 'global', string  $code = null, integer  $severity) : boolean

Adds a report

Parameters

$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.

Returns

boolean —

False if rejected.

apath_get()

apath_get(array  $array, string  $apath, mixed  $default = null, boolean  $pathRequired = false) : mixed

Get value from an Array Path

Parameters

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.

Returns

mixed —

The value from $apath in $array.

apath_html()

apath_html(string  $apath) : string

Convert a apath to a HTML name attribute

Parameters

string $apath

Returns

string —

e.g user/password => user[password]

apath_setp()

apath_setp(array  $array, string  $apath, mixed  $value, boolean  $overwrite = true) 

Set value into an Array Path

Parameters

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_add()

array_add(array  $array, array  $other) 

Add values from an array to another

Parameters

array $array
array $other

array_apply()

array_apply(array  $array, callable  $callback, string  $userdata = null, string  $success = null) : array

Apply a user supplied function to every member of an array

Parameters

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.

Returns

array —

The resulting array

array_filterbykeys()

array_filterbykeys(array  $array, array  $keys) : array

Filter $array entries by $keys

Parameters

array $array
array $keys

Returns

array

array_get()

array_get(array  $array, integer  $index, boolean  $default = false) : mixed

Get value of $array at $index or $default if not found

Parameters

array $array
integer $index
boolean $default

Returns

mixed

array_index()

array_index(array  $array, scalar  $key) : integer

Get the index in $array of $key

Parameters

array $array
scalar $key

Returns

integer

array_insert()

array_insert(array  $array, integer  $position, mixed  $value) 

Insert $value in $array at $position

Parameters

array $array
integer $position
mixed $value

array_last()

array_last(array  $array) : mixed

Get the last value of $array

Parameters

array $array

Returns

mixed

array_peer()

array_peer(array<mixed,string>  $array, string  $peerGlue = ': ') : array

Concat key and value in an array with a glue

Parameters

array<mixed,string> $array
string $peerGlue

Returns

array

b()

b(boolean  $b) : string

Get the string of a boolean

Parameters

boolean $b

The boolean

Returns

string —

The boolean's string

between()

between(integer  $value, integer  $min, integer  $max) : boolean

Check value in between min and max

Parameters

integer $value
integer $min
integer $max

Returns

boolean

bintest()

bintest(integer  $value, integer  $reference) : True

Do a binary test

Parameters

integer $value

The value to compare.

integer $reference

The reference for the comparison.

Returns

True —

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.

build_apath()

build_apath(  $array,   $prefix = '') : \An

Build all path to browse array

Parameters

$array

The array to get the value from.

$prefix

The prefix to get the value, this is for an internal use only.

Returns

\An —

array of apath to get all values.

calculateAge()

calculateAge(integer  $birthday, string  $relativeTo = 'today') : integer

Calculate age from $birthday $relativeTo a date

Parameters

integer $birthday
string $relativeTo

Returns

integer

checkDir()

checkDir(string  $filePath) : boolean

Ensure path avaibility as folder

Parameters

string $filePath

Returns

boolean

cleanscandir()

cleanscandir(string  $dir, boolean  $sorting_order = false) : array<mixed,string>

Scans a directory cleanly.

Parameters

string $dir

The path to the directory to scan.

boolean $sorting_order

True to reverse results order. Default value is False.

Returns

array<mixed,string> —

An array of the files in this directory.

Scans a directory and returns a clean result.

clientIP()

clientIP() : string

Get the client public IP

Returns

string —

The ip of the client

convertSpecialChars()

convertSpecialChars(string  $string) : string

Convert special characters to non-special ones

Parameters

string $string

The string to convert.

Returns

string —

The string wih no special characters.

Replace all special characters in $string by the non-special version of theses.

count_intersect_keys()

count_intersect_keys(array  $array1, array  $array2) : integer

Count intersect key in given arrays

Parameters

array $array1
array $array2

Returns

integer

d()

d(mixed  $time = TIME, boolean  $utc = false) : string

Format the date as string

Parameters

mixed $time

The UNIX timestamp

boolean $utc

Is the time UTC

Returns

string —

The date using 'dateFormat' translation key

Date format is storing a date, not a specific moment, we don't care about timezone

dateToTime()

dateToTime(integer|string  $date) : integer

Convert date to time

Parameters

integer|string $date

The date or UNIX timestamp

Returns

integer —

The UNIX timestamp

Allow any strtotime format to be converted to time, if time passed, it just returns it.

dayTime()

dayTime(integer  $time = null, boolean  $gmt = true) : integer

Calculate the day timestamp using the given integer

Parameters

integer $time

The time to get the day time. Default value is current timestamp.

boolean $gmt

Is the time GMT

Returns

integer —

Return the timestamp of the current day of $time according to the midnight hour.

deleteCookie()

deleteCookie(string  $name) : boolean

Delete a HTTP cookie

Parameters

string $name

The name of the cookie to delete

Returns

boolean —

True if cookie was deleted, false if not found

df()

df(  $format, mixed  $time = TIME, mixed  $tz = null) : string

Format the date time as string

Parameters

$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

Returns

string —

The date formatted using $format

Datetime format is storing a specific moment, we care about timezone

displayReportsHTML()

displayReportsHTML(string  $stream = 'global', array<mixed,string>  $rejected = array(), boolean  $delete = 1) 

Display reports as HTML

Parameters

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.

displayText()

displayText(  $text) 

Display text as HTML

Parameters

$text

The string to display

dt()

dt(mixed  $time = TIME, boolean  $utc = false) : string

Format the date time as string

Parameters

mixed $time

The UNIX timestamp

boolean $utc

Is the time UTC

Returns

string —

The date using 'datetimeFormat' translation key

Datetime format is storing a specific moment, we care about timezone

endReportStream()

endReportStream() 

Ends the current stream

ensure_pdoinstance()

ensure_pdoinstance(string  $instance = null) : string

Ensure $instance is connected to DBMS

Parameters

string $instance

If supplied, this is the ID of the instance to use to execute the query. Optional, PDODEFINSTNAME constant by default.

Returns

string —

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.

escapeQuotes()

escapeQuotes(string  $str, integer  $flags = ESCAPE_ALLQUOTES) : string

Escape quotes from a string

Parameters

string $str

The string to escape

integer $flags

The flags option

Returns

string —

The escaped string

Escape the text $str from quotes using smart flags.

exists_route()

exists_route(string  $routeName) : boolean

Test if a route exists

Parameters

string $routeName

Returns

boolean

explodeList()

explodeList(string  $delimiter, string  $string, integer  $limit, string  $default = null) : array

Split a string by string in limited values

Parameters

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

Returns

array —

The exploded array with a defined limit of values.

extractFrom()

extractFrom(  $apath,   $array) : \Data

Extract data from array using apath

Parameters

$apath

The apath to retrieve. null retrieves all data.

$array

The array of data to browse.

Returns

\Data —

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.

fillFormData()

fillFormData(  $data) : \The

Fill the given data from input form

Parameters

$data

The data to fill, as pointer.

Returns

\The —

resulting $data.

fillInputValue()

fillInputValue(  $value,   $fieldPath,   $default = null,   $pathRequired = false) : boolean

Fill the given value from input form

Parameters

$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).

Returns

boolean —

True if got value is not null (found).

formatDouble()

formatDouble(\number  $value) : string

Format a double using locale

Parameters

\number $value

Returns

string

formatDuration_Shortest()

formatDuration_Shortest(integer  $duration) : string

Format duration to closest unit

Parameters

integer $duration

Duration in seconds

Returns

string

formatException()

formatException(\Exception  $e) : string

Format the input Exception to a human-readable string

Parameters

\Exception $e

Returns

string

formatInt()

formatInt(\number  $value) : string

Format a int using locale

Parameters

\number $value

Returns

string

formatMoney()

formatMoney(\number  $value, string  $double = true, string  $currency = '€') : string

Format a money by currency and using a number formatter

Parameters

\number $value
string $double
string $currency

Returns

string

formInput()

formInput(string  $fieldPath, string  $default = null) : string

Generate HTML form intput name & value

Parameters

string $fieldPath
string $default

Returns

string

ft()

ft(  $time = null) : string

Get the date time as string

Parameters

$time

The time with %H:%M format.

Returns

string —

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()

generatePassword(integer  $length = 10, string  $chars = 'abcdefghijklmnopqrstuvwxyz0123456789') : string

Generate a new password

Parameters

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'

Returns

string —

The generated password.

Letters are randomly uppercased

GET()

GET(  $path = null) : \Data

Get GET data

Parameters

$path

The path to retrieve. The default value is null (retrieves all data).

Returns

\Data —

using the path or all data from GET array.

get_current_route()

get_current_route() : string

Get the route name of the current request

Returns

string

getDebugTrace()

getDebugTrace(string  $filterStartWith = null) : array

Get the debug trace filtered by $filterStartWith

Parameters

string $filterStartWith

Exclude functions starting with this value

Returns

array —

The filtered backtrace

getField()

getField(string  $fieldPath, string  $class = null) : \FieldDescriptor

Get the field descriptor from a field path

Parameters

string $fieldPath
string $class

Returns

\FieldDescriptor

getFlatReports()

getFlatReports(string  $stream = 'global', string  $type = null, boolean  $delete = 1) : \array[].

Get some/all reports as flatten array

Parameters

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.

Returns

\array[].

getFormData()

getFormData() : \POST()

Get input form data

Returns

\POST()

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()

getHTMLReport(string  $stream, string  $report, string  $domain, string  $type) 

Get one report as HTML

Parameters

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.

getLangDomainFile()

getLangDomainFile(string  $lang, string  $domain) : array

Get a language ini file

Parameters

string $lang

The lang to get the domain file

string $domain

The domain of the file to load

Returns

array —

The translations

getMimeType()

getMimeType(string  $filePath) : string

Get the mime type of the given file path

Parameters

string $filePath

Returns

string

getReports()

getReports(string  $stream = 'global', string  $type = null, boolean  $delete = 1) 

Get some/all reports

Parameters

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()

getReportsHTML(  $stream = 'global',   $rejected = array(),   $delete = true) : \The

Get some/all reports as HTML

Parameters

$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.

Returns

\The —

renderer HTML.

hasErrorReports()

hasErrorReports() : boolean

Check if there is error reports

Returns

boolean —

True if there is any error report.

hashString()

hashString(string  $str) : string

Hash string with salt

Parameters

string $str

Returns

string —

Hash input string with salt (constant USER_SALT) using SHA512

hasPOSTKey()

hasPOSTKey(  $path = null,   $value = null) : True

Check an existing post key

Parameters

$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.

Returns

True —

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()

hasTranslation(string  $k, string  $domain = 'global') : boolean

Check if this key exists.

Parameters

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'.

Returns

boolean —

True if the translation exists in this domain.

This function checks if the key is known in the translation list.

htmlCheckBox()

htmlCheckBox(string  $fieldPath, string  $value = null, string  $default = false, string  $addAttr = '') : string

Generate HTML checkbox input

Parameters

string $fieldPath
string $value
string $default
string $addAttr

Returns

string

htmlDisabledAttr()

htmlDisabledAttr() : string

Generate disabled HTML attribute

Returns

string —

Is this function useful ?

htmlFileUpload()

htmlFileUpload(string  $fieldPath, string  $addAttr = '') : string

Generate HTML upload input

Parameters

string $fieldPath
string $addAttr

Returns

string

htmlFormATtr()

htmlFormATtr(mixed  $var) : \The

Format a string to be a html attribute value

Parameters

mixed $var

The variable to format

Returns

\The —

escaped string

Escape the text $str from special characters for HTML Attribute usage

htmlHidden()

htmlHidden(string  $fieldPath, string  $default = '', string  $addAttr = '') : string

Generate HTML hidden input

Parameters

string $fieldPath
string $default
string $addAttr

Returns

string

htmlOption()

htmlOption(string  $elValue, string  $label = null, boolean  $selected = false, string  $addAttr = '') : string

Generate HTML option tag

Parameters

string $elValue
string $label
boolean $selected
string $addAttr

Returns

string

htmlOptions()

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

Parameters

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'.

Returns

string —

A HTML source for the built SELECT tag.

htmlPassword()

htmlPassword(string  $fieldPath, string  $addAttr = '') : string

Generate HTML password input

Parameters

string $fieldPath
string $addAttr

Returns

string

htmlRadio()

htmlRadio(string  $fieldPath, string  $elValue, string  $default = false, string  $addAttr = '') : string

Generate HTML radio input

Parameters

string $fieldPath
string $elValue
string $default
string $addAttr

Returns

string

htmlRedirectTo()

htmlRedirectTo(  $destination,   $time = 3,   $die) 

Redirect the client to a destination by HTML

Parameters

$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()

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

Parameters

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.

Returns

string —

A HTML source for the built SELECT tag.

htmlText()

htmlText(string  $fieldPath, string  $default = '', string  $addAttr = '', callback  $formatter = null, string  $type = 'text') : string

Generate text input from parameters

Parameters

string $fieldPath
string $default
string $addAttr
callback $formatter
string $type

Returns

string

htmlTextArea()

htmlTextArea(string  $fieldPath, string  $default = '', string  $addAttr = '') : string

Generate textarea from parameters

Parameters

string $fieldPath
string $default
string $addAttr

Returns

string

htmlValue()

htmlValue(  $name,   $data = null,   $default = '') : \A

Get the HTML value

Parameters

$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

Returns

\A —

HTML source with the "value" attribute.

Get the HTML value attribut from an array of data if this $name exists.

inputValue()

inputValue(string  $fieldPath, string  $default = null) : string

Generate HTMl value attribute from $fieldPath

Parameters

string $fieldPath
string $default

Returns

string

is_closure()

is_closure(mixed  $v) : boolean

Find whether the given variable is a closure

Parameters

mixed $v

Returns

boolean —

True if $v is a closure

is_current_route()

is_current_route(  $route) : boolean

Test if the $route is the one of the current request

Parameters

$route

Returns

boolean

is_date()

is_date(string  $date, boolean  $withTime = false, integer  $time = false, integer  $format = null) : boolean

Check if the input is a date.

Parameters

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*

Returns

boolean —

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_email()

is_email(string  $email) : boolean

Check if the input is an email address.

Parameters

string $email

The email address to check.

Returns

boolean —

True if $email si a valid email address.

is_exception()

is_exception(mixed  $e) : boolean

Test the given variable is an exception

Parameters

mixed $e

Returns

boolean —

True if $v is an Exception

is_ID()

is_ID(mixed  $number) : boolean

Check if the input is an ID Number.

Parameters

mixed $number

The number to check.

Returns

boolean —

True if $number si a valid integer.

The ID number is an integer.

is_ip()

is_ip(string  $ip, integer  $flags = null) : boolean

Check if the input is an ip address.

Parameters

string $ip

The url to check.

integer $flags

The flags for the check.

Returns

boolean —

True if $ip si a valid ip address.

is_name()

is_name(string  $name, integer  $charnb_max = 50, integer  $charnb_min = 3) : boolean

Check if the input is a name.

Parameters

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.

Returns

boolean —

True if $name si a name.

is_personalname()

is_personalname(string  $name, integer  $charnb_max = 50, integer  $charnb_min = 3) : boolean

Check if the input is a personal name.

Parameters

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.

Returns

boolean —

True if $name si a name.

is_phone_number()

is_phone_number(string  $number, string  $country = 'FR') : boolean

Check if the input is a phone number.

Parameters

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

Returns

boolean —

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

is_time()

is_time(string  $time, array  $matches = null) : boolean

Check $time is a real time representation

Parameters

string $time
array $matches

Returns

boolean —

Could use global translation "timeFormat" to check this is a time e.g Basically validate 12:50

is_url()

is_url(string  $url, string  $protocol = null) : boolean

Check if the input is an url.

Parameters

string $url

The url to check.

string $protocol

Not used yet. Default to SCHEME constant, not used.

Returns

boolean —

True if $url si a valid url.

isGET()

isGET(  $apath = null) : True

Check the GET status

Parameters

$apath

The apath to test.

Returns

True —

if the request is a GET one. Compares also the $key if not null.

isPOST()

isPOST(  $apath = null) : True

Check the POST status

Parameters

$apath

The apath to test.

Returns

True —

if the request is a POST one. Compares also the $key if not null.

iURLDecode()

iURLDecode(  $u) : \The

Decode from an internal URL

Parameters

$u

The URL to decode.

Returns

\The —

decoded URL

Decode from URL

iURLEncode()

iURLEncode(  $u) : \The

Encode to an internal URL

Parameters

$u

The URL to encode.

Returns

\The —

encoded URL

Encode to URL and secures some more special characters

leadZero()

leadZero(integer  $number, integer  $length = 2) : string

Add zero to the input number

Parameters

integer $number

The number

integer $length

The length to add zero

Returns

string

loadLangFile()

loadLangFile(string  $domain = 'global') 

Load a language ini file

Parameters

string $domain

The domain of the file to load.

Load a language ini file from the file system. You don't have to use this function explicitly.

log_debug()

log_debug(  $report,   $action = '') 

Log a debug

Parameters

$report

The debug report to log.

$action

The action associated to the report. Default value is an empty string.

log_error()

log_error(string  $report, string  $action = '', boolean  $fatal = true) 

Log a system error

Parameters

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()

log_hack(  $report,   $action = '',   $message = null) 

Log a hack attemp

Parameters

$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()

log_report(string|\Exception  $report, string  $file, string  $action = '', string  $message = '', boolean  $noException = false) 

Log a report in a file

Parameters

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()

monthTime(  $day = 1,   $time = null) : integer

Return the timestamp of the $day of the month using the given integer

Parameters

$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.

Returns

integer

ms()

ms(  $precision = null) : \number|string

Get microsecond as UNIX format

Parameters

$precision

Returns

\number|string

parseFields()

parseFields(  $fields,   $quote = '"') : \A

Parse Fields array to string

Parameters

$fields

The fields array

$quote

The quote to escape key

Returns

\A —

string as fields list

It parses a field array to a fields list for queries

parseTime()

parseTime(string  $time, string  $format = SYSTEM_TIME_FORMAT) : array

Parse time from string to time array

Parameters

string $time

Parsed time

string $format

Format to use

Throws

\Exception

Returns

array

pdo_error()

pdo_error(string  $report, string  $action = '', integer  $fetch, \PDOException  $original = null) 

Log a PDO error

Parameters

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_getDefaultInstance()

pdo_getDefaultInstance() : string

Get the default instance's name

Returns

string

pdo_getSettings()

pdo_getSettings(string  $instance) : array

Get setting of $instance

Parameters

string $instance

Returns

array

pdo_instance()

pdo_instance(string  $instance) : \PDO

Get PDO instance by name

Parameters

string $instance

Returns

\PDO

pdo_lastInsertId()

pdo_lastInsertId(string  $instance = null) : string

Get the last inserted ID

Parameters

string $instance

The instance to use to get the last inserted id. Optional, default is defined by ensure_pdoinstance().

Returns

string —

The last inserted id

Get the last inserted ID for this instance

pdo_loadConfig()

pdo_loadConfig() 

Load DB config from config file

pdo_query()

pdo_query(string  $query, integer  $fetch = PDOQUERY, string  $instance = null) : \mxied

Execute $query

Parameters

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().

Returns

\mxied —

The result of the query, of type defined by $fetch.

Execute $query on the instanciated database.

pdo_quote()

pdo_quote(string  $string) : string

Quote and Escape $string

Parameters

string $string

The value to escape

Returns

string —

The quoted and escaped value

permanentRedirectTo()

permanentRedirectTo(  $destination = null) 

Redirect permanently the client to a destination by HTTP

Parameters

$destination

The destination to go. Default value is SCRIPT_NAME.

POST()

POST(string  $path = null) : mixed

Get POST data

Parameters

string $path

The path to retrieve. The default value is null (retrieves all data).

Returns

mixed —

Data using the path or all data from POST array.

redirectTo()

redirectTo(  $destination = null) 

Redirect the client to a destination by HTTP

Parameters

$destination

The destination to go. Default value is SCRIPT_NAME.

rejectReport()

rejectReport(mixed  $report, string  $type = null) 

Reject reports

Parameters

mixed $report

The report message to reject, could be an array.

string $type

Filter reject by type, could be an array. Default value is null, not filtering.

reportError()

reportError(string  $report, string  $domain = null, integer  $severity = 1) 

Reports an error

Parameters

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.

reportInfo()

reportInfo(string  $report, string  $domain = null) 

Reports an information to the user

Parameters

string $report

The message to report.

string $domain

The domain fo the message. Not used for translation. Default value is global.

reportSuccess()

reportSuccess(  $report,   $domain = null) 

Reports a success

Parameters

$report

string The message to report.

$domain

string The domain fo the message. Not used for translation. Default value is global.

reportWarning()

reportWarning(string  $report, string  $domain = null) 

Reports a warning

Parameters

string $report

The message to report.

string $domain

The domain fo the message. Not used for translation. Default value is the domain of Exception in case of UserException else 'global'.

reverse_values()

reverse_values(mixed  $val1, mixed  $val2) 

Reverse values

Parameters

mixed $val1
mixed $val2

sanitizeNumber()

sanitizeNumber(string  $value) : string

Convert a localized string number into a programming one

Parameters

string $value

Returns

string

sendJSON()

sendJSON(  $data) 

Send a JSON response to the client.

Parameters

$data

The data to send

Send data and end script

sendResponse()

sendResponse(  $code,   $other = '',   $domain = 'global',   $desc = null) 

Send a packaged response to the client.

Parameters

$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.

sendRESTfulJSON()

sendRESTfulJSON(mixed  $data, integer  $code = null) 

Send a RESTful JSON response to the client.

Parameters

mixed $data

The data to send

integer $code

Send data and end script. This function takes care of exceptions and codes.

slug()

slug(string  $string, integer  $case = null) : string

Convert the string into a slug

Parameters

string $string

The string to convert.

integer $case

The case style flag to use, values: null (default), LOWERCAMELCASE or UPPERCAMELCASE.

Returns

string —

The slug version.

Convert string to lower case and converts all special characters.

sql2Time()

sql2Time(string  $datetime) : string

Get the date as string

Parameters

string $datetime

The datetime

Returns

string —

The date using 'dateFormat' translation key

Date format is storing a date, not a specific moment, we don't care about timezone

sql_error()

sql_error(string|\Exception  $report, string  $action = '', boolean  $noException = false) 

Log a sql error

Parameters

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)

sqlDate()

sqlDate(integer  $time = TIME) : string

Get the date as string in SQL format

Parameters

integer $time

The UNIX timestamp.

Returns

string —

The date using sql format

Date format is storing a date, not a specific moment, we don't care about timezone

sqlDatetime()

sqlDatetime(integer  $time = TIME) : string

Get the date time as string in SQL format

Parameters

integer $time

The UNIX timestamp.

Returns

string —

The date using sql format

Datetime format is storing a specific moment, we care about timezone

ssh2_run()

ssh2_run(  $command,   $SSH2S = null) : \The

Run a SSH2 command.

Parameters

$command

The command to execute.

$SSH2S

Local settings for the connection.

Returns

\The —

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()

standardizePhoneNumber_FR(  $number,   $delimiter = '.',   $limit = 2) : string

Standardize the phone number to FR country format

Parameters

$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.

Returns

string —

Return a standard phone number for FR country format.

startReportStream()

startReportStream(string  $stream) 

Starts a new report stream

Parameters

string $stream

The new report stream name

startSession()

startSession(mixed  $type = SESSION_WITH_COOKIE) 

Start a PHP Session

Parameters

mixed $type

The type flag of the session

Throws

\Orpheus\Exception\UserException

Start a secured PHP Session and initialize Orpheus

str_first()

str_first(string  $str) : string

Get the first char of a string

Parameters

string $str

Returns

string

str_last()

str_last(string  $str) : string

Get the last char of a string

Parameters

string $str

Returns

string

str_ucfirst()

str_ucfirst(string  $str) : string

Make a string's first-only character uppercase

Parameters

string $str

Returns

string

str_ucwords()

str_ucwords(string  $str) : string

Uppercase the first-only character of each word in a string

Parameters

string $str

Returns

string

stringify()

stringify(mixed  $s) : string

Stringify any variable

Parameters

mixed $s

the input data to stringify

Returns

string

t()

t(string  $k, string  $domain = 'global', array|string  $values = array()) : string

Translate a key

Parameters

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.

Returns

string —

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('key1'=>'value1', 'key2'=>'value2'...)
  • array(array('key1', 'key2'...), array('value1', 'value2'...))
  • 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)

tc()

tc(string  $k) : string

Translate currency using t() or server config with localeconv()

Parameters

string $k

Returns

string

text2HTML()

text2HTML(  $text) 

Convert Text to HTML

Parameters

$text

The string to convert

timeFormatToRegex()

timeFormatToRegex(string  $format) : string

Create time format regex from strftime format

Parameters

string $format

Returns

string

toHtml()

toHtml(mixed  $s) : string

Convert a variable a HTML-readable string

Parameters

mixed $s

the input data to stringify

Returns

string

toSlug()

toSlug(  $string,   $case = null) : string

Convert the string into a slug

Parameters

$string

The string to convert.

$case

The case style to use, values: null (default), LOWERCAMELCASE or UPPERCAMELCASE.

Returns

string —

The slug version.

Convert string to lower case and converts all special characters.

toString()

toString(mixed  $s) : string

Convert a variable a Text-readable string

Parameters

mixed $s

the input data to stringify

Returns

string

transferReportStream()

transferReportStream(  $from = null,   $to = 'global') 

Transfers the stream reports to another

Parameters

$from

Transfers $from this stream. Default value is null (current stream).

$to

Transfers $to this stream. Default value is global.

Transfers the stream reports to another

translate()

translate(string  $k, string  $default, string  $domain = 'global') : string

Check if this key exists.

Parameters

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'.

Returns

string —

The translation

This function translate the key without any fail. If no translation is available, it uses the $default.

u()

u(string  $routeName, array  $values = array()) : string

Generate URL to a route

Parameters

string $routeName
array $values

Throws

\Exception

Returns

string

userID()

userID() : integer|string

Get the id of the current user

Returns

integer|string —

The user's id

using()

using(  $pkgPath) 

Imports the required class(es).

Parameters

$pkgPath

The package path.

valueField()

valueField(string  $v) : string

Generate HTML value attribute

Parameters

string $v

The value

Returns

string

valueOf()

valueOf(string  $fieldPath, string  $default = null) : string

Get value of $fieldPath

Parameters

string $fieldPath
string $default

Returns

string