Skip to content

parser3/als.utils

Repository files navigation

Als/Utils

Набор классов из пакета Lib.

Включает в себя:

###########################################################################
# cut trailing and leading chars $sChars (whitespaces by default) for $sText
@trim[sText;sChars]


###########################################################################
# print link to $sURI with attributes $uAttr (string or hash) if $sURI specified, otherwise just print $sLabel
@href[sURI;sLabel;uAttr]


###########################################################################
# set location header for redirecting to $sURI and prevent caching
# $.bExternal option makes redirect 
@location[sURI;hParam]


###########################################################################
# check email format
@isEmail[sEmail]


###########################################################################
# print $iNum as a binary string
@dec2bin[iNum;iLength]


###########################################################################
# makes hash of tables from $tData. if $sKeyColumn is not specified 'parent_id' will be used
@createTreeHash[tData;sKeyColumn]


###########################################################################
# print number. options $.iFracLength, $.sThousandDivider and $.sDecimalDivider are available
@numberFormat[dNumber;hParam]


###########################################################################
# looks over hash elements in specified order
@foreach[hHash;sKeyName;sValueName;jCode;sSeparator;sDirection]


###########################################################################
# returns hash with parser version
@getParserVersion[]


###########################################################################
# every odd call returns $sColor1, every even - $sColor2, without parameters - reset sequence
@color[sColor1;sColor2]


###########################################################################
# creates 2-levels hash
@create2LevelHash[uData;sField1;sField2]
###########################################################################
# print $xDoc as string without DOCTYPE and XML declaration
@toString[xDoc]
############################################################
# print $xNode as string
@toString[xNode;sRootTag]


############################################################
# print $xNode VALUE as string: <aaa><bbb>ccc</bbb></aaa> => "<bbb>ccc</bbb>"
@valueToString[xNode;sRootTag]


############################################################
# go through all nodes in $hNodeList and execute $jCode
@foreach[hNodeList;hNodeName;sNode;sAttr;jCode;sSeparator]


############################################################
# go through all children for $xParent and execute $jCode
@foreachChild[xParent;hNodeName;sNode;sAttr;jCode;sSeparator]


############################################################
# get children of $xParent as hash
@getChildren[xParent;hNodeName]

Installation

$ composer require als/utils

References

  • Bugs and feature request are tracked on GitHub