IUtils

Interface for the Artaengine utilities class. This interface is to insures the class will always be backward compatible.
Source
IUtils.php
Implementations
Utils

Static Methods

array2string

string IUtils::array2string(array array, array configs=null, bool first=true)

Flatten an array into a string for display purposes.

Arguments

    array (array)
    Array to render
    configs=null (array)
    Settings
    {
        bool   php      : true
            true=return string to be a valid PHP source code
            false=return to be psudo list and dictionary string,
        number id       : 1
            indent multiplier,
        bool   model    : false
            true=consider the "array" as a IModel data property definition,
        array  consts   : []
            a list of string values as [val]
            if a value anywhere inside the array matches with an item of
            this list, it will not be treated as a string,
        array  constk   : []
            a list of string values as [key] -
            if a key anywhere inside the array matches with an item of
            this list, it will not be treated as a string,
        bool   nokey    : false
            true=if array keys are numeric dont put them in place of keys
            e.g. {0:a, 1:b, c:} ===> [a, b, c],
    }
    
    first=true (bool)
    For internal use

Returns

string
The flattened array

getBrowserDictionary

array IUtils::getBrowserDictionary()

Get browser dictionary (front-end resource dictionary).

Since
Artaengine 1.2.2

Returns

array
[{js dic}, {css dic}, {template dic}]

getCallStaticMethod

mixed IUtils::getCallStaticMethod(string source)

Get class static method or static property value by string.

Since
Artaengine 1.2.2

Arguments

    source (string)
    "Class::method" or "Class::property"

Returns

mixed
The returned value of "Class::method()" or "Class::property"

getModelPath

IModel IUtils::getModelPath(IModel model, string path)

Traverse/crawl a path of objects in the model and returns the last node.

Since
Artaengine 1.2.2

Arguments

    model (IModel)
    Model object to start the traverse from
    path (string)
    Path showing model objects, last node may be a method

Returns

IModel
Last model object found

getModelPathData

mixed IUtils::getModelPathData(IModel model, string path, bool render=true, array &def=array)

Traverse/crawl a path of objects in the model and return the data found on the last node.

Arguments

    model (IModel)
    Model object to start the traverse from
    path (string)
    Path showing model objects, last node may be a method last node may be a method
    render=true (bool)
    true=apply "Render::list2Html()" on result
    &def=array (array)
    Will be set to last Model object definition

Returns

mixed
Whatever is found on the last node

isList

bool IUtils::isList(array array)

Is an array a list or a dictionary, list means keys start from 0 and are numeric and sequential.

Since
Artaengine 1.1.0

Arguments

    array (array)
    Array to be checked

Returns

bool
true=is list

mapModelPropertyOptions

void IUtils::mapModelPropertyOptions(array | string &data, array def)

If a model data property has options, this function will replace the option key which is set to the property with the option's value. This is to make all property values of a model human readable (but not actionable).

Arguments

    &data (array | string)
    Reference to model property data to render
    def (array)
    Model property definition

Returns

void

pluralize

string IUtils::pluralize(string word)

Pluralize an English word.

Arguments

    word (string)
    Word to be pluralized

Returns

string
Pluralized word

str2typ

const IUtils::str2typ(string type=null)

Convert "T::TYPE_CONST" (Artaengine data type) string to const. This ambiguous is used for editing PHP model files.

Arguments

    type=null (string)
    "T::TYPE_CONST" (Artaengine data type) string

Returns

const
"T::TYPE_CONST" (Artaengine data type)

translateArray

array IUtils::translateArray(&aReference to)

gettext an array.

Arguments

    to (&aReference)
    the array

Returns

array
Translated

typ2str

string IUtils::typ2str(string type=null)

Convert "T::TYPE_CONST" (Artaengine data type) const to string. This ambiguous is used for editing PHP model files.

Arguments

    type=null (string)
    "T::TYPE_CONST" (Artaengine data type) string

Returns

string
"T::TYPE_CONST" (Artaengine data type) as string