\XilyBean

The Bean class extends the Xily\Xml class and allows advanced parsing features for XML data.

Based on the Bean class you can create your own micro parsers (Beans) which are stored in the /beans directory of your xily installation. One more speciality about Beans: Although you may define your own Beans in PHP and create your own logic and functions arround them, Beans hold very powerful data referencing methods, calls XDR - Xily Data References. An XDR helps you to use data stored in object OUTSIDE the tag you are using.

Summary

Methods
Properties
Constants
create()
createNode()
build()
dump()
run()
runChildren()
result()
xdrInsert()
xdr()
initDatasets()
setDataset()
showDatasets()
dataset()
clearDataset()
removeDataset()
hasDataset()
setLink()
clearLinks()
removeLink()
link()
hasLink()
collect()
heritage()
preHeritage()
refuseHeritage()
inherit()
noInherit()
passHeritage()
__construct()
__destruct()
__toString()
returnNode()
parse()
getNodeById()
getNodesByPath()
getNodeByPath()
buildFilter()
trace()
root()
parent()
child()
children()
cdata()
content()
index()
id()
tag()
value()
attribute()
attributes()
copy()
setIndex()
setAttribute()
setValue()
setTag()
setRoot()
setParent()
setCdata()
addCdata()
addChild()
addChildren()
addContent()
hasValue()
hasChildren()
countChildren()
hasCdata()
countCdata()
hasContent()
hasAttributes()
countAttributes()
hasAttribute()
hasParent()
isTrue()
isFalse()
isNode()
terminate()
removeChild()
removeCdata()
removeChildren()
removeContent()
removeAttribute()
reindex()
insertAfter()
insertBefore()
toString()
toTag()
toJSON()
toTree()
initValue()
initRequest()
equationBuild()
equationCheck()
strStripQuotes()
strStripBrackets()
strStripString()
strStripWhitespaces()
strStripInline()
strShorten()
strToFloat()
htmlDecode()
htmlEncode()
xmlChars()
createUID()
fileFormatDir()
fileRead()
fileReadByLine()
fileWrite()
fileRemoveDir()
fileCopyDir()
fileListDir()
fileGetExtension()
fileRename()
probe()
$bolReturnXML
$BEAN_DIRS
$basepath
$strTag
$intIndex
$strValue
$arrAttributes
$arrChildren
$arrCdata
$arrContent
$objRoot
$objParent
$xmlResult
$OPEN_TAGS
No constants found
No protected methods found
No protected properties found
N/A
includeNode()
xdrRetriveObject()
xdrRetriveData()
xdrRetriveExternal()
getPredefinedVar()
startTagCallback()
endTagCallback()
cdataCallback()
checkProperty()
getContentTarget()
getContentIndex()
addContentEntry()
terminateChildren()
removeContentEntry()
$mxtResult
$bolLoadFromURL
$arrDataset
$arrLink
$arrNoHeritage
N/A

Properties

$bolReturnXML

$bolReturnXML : bool

Type

bool — This switch commands the result() function to return the XML-string of the node or to ignore it in the result collection.

$BEAN_DIRS

$BEAN_DIRS : array

Type

array — List of additional bean directories

$basepath

$basepath : string

Type

string — The base path for external includes

$strTag

$strTag : string

Type

string — The tag type (String).

$intIndex

$intIndex : string

Type

string — The number of the node within the current list (Integer).

$strValue

$strValue : string

Type

string — The value of the node.

$arrAttributes

$arrAttributes : array

Type

array — The array containing the node's attributes.

$arrChildren

$arrChildren : array

Type

array — The array containing the node's children.

$arrCdata

$arrCdata : array

Type

array — The array containing the node's CDATA nodes.

$arrContent

$arrContent : array

Type

array — The array containing the structure of CDATA and XML nodes.

$objRoot

$objRoot : \Xily\Xml

Type

\Xily\Xml — Pointer to the root object.

$objParent

$objParent : \Xily\Xml

Type

\Xily\Xml — Pointer to the parent node.

$xmlResult

$xmlResult : \Xily\Xml

Type

\Xily\Xml — Result container for the parse function.

$OPEN_TAGS

$OPEN_TAGS : Array

Type

Array — List of tags that should be displayed as open, even if the have no value

$mxtResult

$mxtResult : string|bool|array|object

Type

string|bool|array|object — The container of the object's results. A result can be of varible types.

$bolLoadFromURL

$bolLoadFromURL : bool

Type

bool — This switch commands the run() function to respect or ignore the source attribute of the tag.

$arrDataset

$arrDataset : array

Type

array — Container for all utility data sets

$arrLink

$arrLink : array

Type

array — Container for all object links

$arrNoHeritage

$arrNoHeritage : array

Type

array — Container for all heritage objects to be refused

Methods

create()

create(string $strXML, bool $bolLoadFile) : \Xily\Xml

Loads the XML data from a string or file

Parameters

string $strXML

Name of the XML file or XML string

bool $bolLoadFile

Load from file or parse locally

Returns

\Xily\Xml

createNode()

createNode(string $strTag, array $arrAttributes, \Xily\Xml $xmlParent) : \Xily\Xml

Creates a new XML node

(Wrapper function to simplify Bean creation)

Parameters

string $strTag

The tag name

array $arrAttributes

List of attributes

\Xily\Xml $xmlParent

Parent node

Returns

\Xily\Xml

build()

build()

The build() function initializes the node and its children Nothing to do here besides parsing the sub structure of the node.

Deviations of Xml, e.g. Beans, may have different build functions.

dump()

dump() : string

Returns a dump of the node's content.

Returns

string

run()

run(mixed $mxtData, int $intLevel) : string|mixed

Executes all functions included in the Bean First, all datasets will be loaded and Xily Data References (XDR) included Then the bean's result() function will be called

Parameters

mixed $mxtData

Temporary dataset [n:data]

int $intLevel

Level within the execution hierarchie

Returns

string|mixed —

Result of the run (usually a string, e.g. HTML code)

runChildren()

runChildren(mixed $mxtData, int $intLevel, bool $bolArray) : string|array|bool

Executes the run() function on all child nodes

Parameters

mixed $mxtData

Temporary dataset [n:data]

int $intLevel

Level within the execution hierarchie

bool $bolArray

If active, all results will be written to an array

Returns

string|array|bool —

Result of the run

result()

result(mixed $mxtData, int $intLevel) : string|mixed

Works like the tag() method, but also applies the xdrInsert() function first.

If $bolReturnXML = true, it will return the XML string of the object and will then execute the runChildren() function to get it's children's results.

Parameters

mixed $mxtData

Temporary dataset

int $intLevel

Level within the execution hierarchie

Returns

string|mixed —

Result of the run (usually a string, e.g. HTML code)

xdrInsert()

xdrInsert(string $strXDR, string|array|\Xily\Xily\Xml $mxtData, bool $bolStrict, bool $bolReturnEmpty) : string|array|\Xily\Xily\Xml

This function evaluates and inserts multiple XDRs into a string.

Parameters

string $strXDR

The string containing the XDRs or an XDR itself

string|array|\Xily\Xily\Xml $mxtData

Temporary dataset

bool $bolStrict

If strict mode is of, the function will try to convert unfitting object to strings (e.g. XML files)

bool $bolReturnEmpty

If true (default) the function will replace and invalid XDR with an empty string

Returns

string|array|\Xily\Xily\Xml

xdr()

xdr(string $strXDR, string|array|\Xily\Xily\Xml $mxtData, bool $bolStringOnly, bool $bolStrict) : string|array|\Xily\Xily\Xml|mixed

Evalutates a Xily Data Reference (XDR) The function covers the following XDR shapes in this order:

{_request(var):type} (Request variables: _post, _get, _request) {_request(var):type:default} {object::dataset} {external:type:datapath} {external:type} {object:dataset:datapath} {object:datapath} {.objectpath} {datapath}

Parameters

string $strXDR

The XDR string

string|array|\Xily\Xily\Xml $mxtData

Temporary dataset

bool $bolStringOnly

If true, the function will only return results of type string

bool $bolStrict

If strict mode is off, the function will try to convert unfitting object to strings (e.g. XML files)

Returns

string|array|\Xily\Xily\Xml|mixed

initDatasets()

initDatasets() : void

Initialize the bean's datasets (used in build() functions) A dataset is identified by a '_' as an attribute's first character e.g. <tag _dataset="{XDR}" attribute="STIRNG" />

setDataset()

setDataset(string|array|\Xily\Xily\Xml $mxtDataset, string $strDataset) : void

Sets the value for the $mxtDataset variable.

Caution: existing data will be overwritten!

Parameters

string|array|\Xily\Xily\Xml $mxtDataset

[data]

string $strDataset

Name of the dataset. [name]

showDatasets()

showDatasets(bool $bolShowAll) : string

Lists all available datasets of a function

Parameters

bool $bolShowAll

If TRUE the function will also search all child nodes [0:recursive]

Returns

string

dataset()

dataset(string $strDataset) : string|array|\Xily\Xily\Xml

Returns a specified dataset

Parameters

string $strDataset

Name of the dataset. [name]

Returns

string|array|\Xily\Xily\Xml

clearDataset()

clearDataset(string $strDataset) : void

Clears a defined dataset.

If no dataset name is supplied, all datasets will be removed by clearing the entire dataset variable.

Parameters

string $strDataset

Name of the dataset [n:name]

removeDataset()

removeDataset(string $strDataset) : void

Removes a single dataset from the $mxtDataset variable.

Parameters

string $strDataset

Name of the dataset. [name]

hasDataset()

hasDataset(string $strDataset) : bool

Checks, if the node has a specified dataset

Parameters

string $strDataset

Name of the dataset. [name]

Returns

bool

setLink()

setLink(string $strLink, \Xily\Bean $xlyObject) : void

Sets a link to another Bean

Parameters

string $strLink
\Xily\Bean $xlyObject

clearLinks()

clearLinks() : void

Clears all links from the node

removeLink()

removeLink(string $strLink) : void

Removes a specified link

Parameters

string $strLink

link()

link(string $strLink) : \Xily\Bean

Returns a pointer to the linked object

Parameters

string $strLink

Name of the link

Returns

\Xily\Bean

hasLink()

hasLink(string $strLink) : bool

Check, if a specified link exists

Parameters

string $strLink

Name of the link

Returns

bool

collect()

collect(string $strCollector, mixed $mxtContent) : void

The collect() function passes a value to the local of foreign collector

Parameters

string $strCollector

The name of the collector

mixed $mxtContent

heritage()

heritage() : \Xily\void@return

The heritage function collects all inherit() and noInherit() statements for each bean.

Therefore, each bean has its own heritage() function. The heritag() function is called in the run() function.

Returns

\Xily\void@return —

void

preHeritage()

preHeritage() : void

The preHeritage() function should be called at the beginning of a class's heritage() function, as it calls the children's refuseHeritage() functions, which is required to invoce the noHeritage() statements before the inhertited data is passed

refuseHeritage()

refuseHeritage() : void

The refuseHeritage() function collects all noInherit() statements for each bean.

Therefore, each bean has its own noheritage() function. The noheritage() function is called by the parents preheritage function.

inherit()

inherit(string $strAs, string $strName, mixed $mxtValue, bool $bolPersistent) : void

Inherits a certain set of properties to all child nodes.

Parameters

string $strAs

Type of inheritence (attribute, link, dataset or value)

string $strName

The attribute/dataset/link name

mixed $mxtValue

The inharitence value

bool $bolPersistent

noInherit()

noInherit(string $strAs, string $strName, bool $bolSkip) : void

This function adds a restriction for the passHeritage() function in order to refuse a certain heritage.

This is especially useful when working with persistent heritage functions, as some child nodes will not be supposed to inherit some parameters.

Parameters

string $strAs
string $strName
bool $bolSkip

If true, the element is only skipped during an persistent heritage operation.

passHeritage()

passHeritage(string $strAs, mixed $mxtValue, string $strName, bool $bolPersistent) : void

This function accepts the inheritance brought through the inherit() function.

Parameters

string $strAs

Type of inheritence (attribute, link, dataset or value)

mixed $mxtValue

The inharitence value

string $strName

The attribute/dataset/link name

bool $bolPersistent

If set, the inherit function will be called again, causing to pass the inheritance to all child nodes

__construct()

__construct(string $strTag, string|null $strValue, array $arrAttributes, \Xily\Xml|\Xily\Bean $objParent)

Constructor

Parameters

string $strTag

The tag name

string|null $strValue

The CDATA value

array $arrAttributes

Associative array with attributes

\Xily\Xml|\Xily\Bean $objParent

The parent element

__destruct()

__destruct()

Remove all children on destruction

__toString()

__toString() : string

Converts an XML node to a string

Returns

string

returnNode()

returnNode(string $strXML, \Xily\Xml|\Xily\Bean $xmlMom, bool $bolLoadFile) : \Xily\Xml|\Xily\Bean

Initialize the parser by loading a file or an XML string

Parameters

string $strXML

Name of the XML file or XML string

\Xily\Xml|\Xily\Bean $xmlMom

Parent node

bool $bolLoadFile

Load from file or parse locally

Returns

\Xily\Xml|\Xily\Bean

parse()

parse(string $strXML) : \Xily\Xml|bool

Parses an XML string

Parameters

string $strXML

Returns

\Xily\Xml|bool

getNodeById()

getNodeById(string $strNodeId) : \Xily\Xml

Returns the first node found with the specified ID

Parameters

string $strNodeId

[id]

Returns

\Xily\Xml

getNodesByPath()

getNodesByPath(string|array $mxtPath) : array

Returns an array of nodes or attributes

Parameters

string|array $mxtPath

[path]

Returns

array

getNodeByPath()

getNodeByPath(string $strNodePath) : \Xily\Xml|false

Will return the fist matching node to be found.

Parameters

string $strNodePath

[path]

Returns

\Xily\Xml|false

buildFilter()

buildFilter(array|string $mxtNode) : array|bool

This is an assisting method for getNodesByPath, in order to shape a path link to be used by the children() method Anatomy (example): node(@attribute == 'condition', id == 'myid') Returns an array containing the filter attribute as key and filter + value as value, e.g. $arrFilter = array('tag' => 'node', 'id' => 'myid', 'attributes' => array('attribute' => 'condition'));

Parameters

array|string $mxtNode

The current node including filter (array format: [{tag including filter}, {tag}, {filter}]

Returns

array|bool

trace()

trace(string $strPath) : string

Trace a single node attribute or property.

Works like getNodeByPath, but it will not return a whole object, but will only evaluate the node's property, e.g. node.subnode.@value

Parameters

string $strPath

[path]

Returns

string

root()

root() : \Xily\Xml

Returns the root object

Returns

\Xily\Xml

parent()

parent() : \Xily\Xml

Returns the parent of the current node If the node has no parent / is root, the function returns false

Returns

\Xily\Xml

child()

child(int|string $mxtID) : \Xily\Xml

Return the specified child of the node.

If no index specified, it will return the first node

Parameters

int|string $mxtID

The child index (int) or tag type (string) [index]

Returns

\Xily\Xml

children()

children(string|array $mxtTag, int|array $mxtIndex, string|array $mxtValue, array $arrAttributes, array $arrPath) : array

Returns the node's children

Parameters

string|array $mxtTag

The node's tag (single value or filter array [value, operator]) [n:tag]

int|array $mxtIndex

The node's index (single value or filter array [value, operator]) [n:index]

string|array $mxtValue

The node's value (single value or filter array [value, operator]) [n:value]

array $arrAttributes

The node's attribute (filter array [[attribute, value, operator], ...]) [a:attributes]

array $arrPath

Checks, if a certain sub-path applies to the node (filter array [[path, value, operator], ...]) [a:path]

Returns

array —

Array of XML nodes

cdata()

cdata(integer $intIndex) : array|string

Returns the CDATA entries of the tag

Parameters

integer $intIndex

The index of the CDATA element (Optional) [n:index]

Returns

array|string

content()

content(integer $intIndex) : array|string|\Xily\Xml

Returns the Content (Children and CDATA) of the Tag

Parameters

integer $intIndex

The index of the content element (Optional) [n:index]

Returns

array|string|\Xily\Xml

index()

index() : int

Identifies the zero-indexed position of this XML object within the context of its parent.

Returns

int

id()

id() : string

Returns the node's ID

Returns

string

tag()

tag() : string

Returns the node's tag

Returns

string

value()

value() : string

Returns the node's ID, if any

Returns

string

attribute()

attribute(string $strKey) : string

Returns the value of an attribute

Parameters

string $strKey

[key]

Returns

string —

Attibute value

attributes()

attributes() : array

Returns an associative array containing the node's attributes

Returns

array

copy()

copy() : object

Returns a copy of the given XML object.

Returns

object

setIndex()

setIndex(string $intValue)

Sets the index of the node

Parameters

string $intValue

[value]

setAttribute()

setAttribute(string $strAttribute, string $strValue)

Sets an attribute

Parameters

string $strAttribute

[key]

string $strValue

[value]

setValue()

setValue(string $strValue)

Sets the value of the node

Parameters

string $strValue

[n:value]

setTag()

setTag(string $strTag)

Changes the tag of the node

Parameters

string $strTag

[value]

setRoot()

setRoot(object $xmlRoot, bool $bolPersistent)

Sets the root object for a node or its children

Parameters

object $xmlRoot

The new root object

bool $bolPersistent

If $bolPersistent=true, the object passes the new parent object to all ancestors

setParent()

setParent(object $xmlParent)

Sets the parent object for a node or its children

Parameters

object $xmlParent

The new parent object

setCdata()

setCdata(integer $intIndex, string $strValue)

Changes the content of a CDATA element

Parameters

integer $intIndex

Index of the CDATA element [index]

string $strValue

New Value of the CDATA element [value]

addCdata()

addCdata(string $strValue, int $intIndex, int $intContentIndex)

Adds a new CDATA element

Parameters

string $strValue

New Value of the new CDATA element

int $intIndex

The desired position of the new CDATA element (overrides $intContentIndex!)

int $intContentIndex

The desired position within the content stream

addChild()

addChild(object $xmlNode, int $intIndex, int $intContentIndex) : \Xily\Xml

Adds a new child to the node

This adds a new node at the end of the XML and content array: $xml->addChild(new Xml('div', 'hello world'));

This adds a new node at a specific position within the XML structure (index 3) igonring its position within the content stream: $xml->addChild(new Xml('div', 'hello world'), 3);

This adds a new node at a specific position within the content stream, automatically positioning it within the XML array. $xml->addChild(new Xml('div', 'hello world'), null, 2);

Parameters

object $xmlNode

[node]

int $intIndex

The desired position of the new child node (overrides $intContentIndex!) [n:index]

int $intContentIndex

The desired position within the content stream [n:content_index]

Returns

\Xily\Xml

addChildren()

addChildren(array $arrChildren, int $intIndex) : bool

Adds serveral children

Parameters

array $arrChildren

Array containing the XML elements [children]

int $intIndex

Target index of the child nodes [n:index]

Returns

bool

addContent()

addContent(\Xily\Xml|string $mxtNode, int $intIndex)

Adds a content element (either CDATA or an XML node)

Parameters

\Xily\Xml|string $mxtNode

The content node

int $intIndex

The sequence index

hasValue()

hasValue() : bool

Checks, if the node has a value

Returns

bool

hasChildren()

hasChildren() : bool

Checks, if the node has children

Returns

bool

countChildren()

countChildren() : int

Counts the node's children

Returns

int

hasCdata()

hasCdata() : bool

Checks, if the node has any CDATA tags

Returns

bool

countCdata()

countCdata() : int

Counts the node's CDATA tags

Returns

int

hasContent()

hasContent() : bool

Checks, if the node has any content

Returns

bool

hasAttributes()

hasAttributes() : bool

Checks, if the node has attributes

Returns

bool

countAttributes()

countAttributes() : int

Counts the node's attributes

Returns

int

hasAttribute()

hasAttribute(string|array $mxtAttributes, string $mode) : bool

Checks, if the node has a certain attriubte You can check for one single attribute or you can apply a whole attribute list (represented by an array).

Checking modes are - "normal": Checks, if the node has the specified attributes - "strict": Checks, if the node has exactly (only) the specified attributes - "count" : Counts the number of deviations;

Parameters

string|array $mxtAttributes

[key]

string $mode

[n:mode]

Returns

bool

hasParent()

hasParent() : bool

Checks whether the node has a parent or not

Returns

bool

isTrue()

isTrue(string $strAttribute) : bool

Checks, if a a certain attribute is true

Parameters

string $strAttribute

[key]

Returns

bool

isFalse()

isFalse(string $strAttribute) : bool

Checks, if a a certain attribute is false

Parameters

string $strAttribute

[key]

Returns

bool

isNode()

isNode(string $strTag, int $intIndex, string $strValue, array $arrFilter) : bool

Identifies if a node corresponds to certain properties

Parameters

string $strTag
int $intIndex
string $strValue
array $arrFilter

Returns

bool

terminate()

terminate()

Terminates the node

removeChild()

removeChild(\Xily\Xml|string|int $mxtChild) : bool

Removes a specified child node The child node can either be defined by a path, an index or an XML object

Parameters

\Xily\Xml|string|int $mxtChild

[child]

Returns

bool

removeCdata()

removeCdata(int $intIndex) : bool

Removes a CDATA element

Parameters

int $intIndex

Index of the CDATA element. If NULL all CDATA element will be removed. [n:index]

Returns

bool

removeChildren()

removeChildren(array|string $mxtChildren) : bool

Removes multiple children from a node If no identifier is specified, the function will remove all child nodes Additionally a XML path or array of XML objects can be used as identifier

Parameters

array|string $mxtChildren

[n:children]

Returns

bool

removeContent()

removeContent(int $intIndex) : bool

Removes a content element (value, CDATA or XML)

Parameters

int $intIndex

Content index. If NULL, all content elements will be removed [index]

Returns

bool

removeAttribute()

removeAttribute(string $strAttriubte)

Removes an attribute

Parameters

string $strAttriubte

[key]

reindex()

reindex()

Re-Builds the indexes of all sub-nodes

insertAfter()

insertAfter(object $xmlNode) : bool

Inserts a new node AFTER the current node (on the same level).

The function will reindex the current branch after the inserting operation

Parameters

object $xmlNode

[node]

Returns

bool

insertBefore()

insertBefore(object $xmlNode) : bool

Inserts a new node BEFORE the current node (on the same level) The function will reindex the current branch after the inserting operation

Parameters

object $xmlNode

[node]

Returns

bool

toString()

toString(int $intStructure, bool $intEncode, int $numLevel) : string

Returns the XML code of the tree as string

Parameters

int $intStructure

0: The XML string will be forced into one single line; 1: The XML string is created without additional tabs for content; 2: Insert additional tabs to pretty up the structure

bool $intEncode

0: No enconding of the tag's content; 1: encode special XML-chars (default); 2: add CDATA tags;

int $numLevel

Number of tabs before the current tag

Returns

string

toTag()

toTag(bool $bolEncode) : string

Returns the single XML tag as string

Parameters

bool $bolEncode

If unset, the function will add CDATA-tags for all tag values rather than encoding the XML special chars.

Returns

string

toJSON()

toJSON(bool $bolEncode) : string

Converts the XML tree to a JSON string

Parameters

bool $bolEncode

Return encoded string

Returns

string

toTree()

toTree(array $arrSpaces, string $strSpacer, int $intContentIndex, int $intElemIndex, string $strCdata) : string

Displays the structure of the XML data as plain text tree

Parameters

array $arrSpaces

The collection of connector spaces

string $strSpacer

The indentation character (default: tab)

int $intContentIndex

The node index

int $intElemIndex

The element index

string $strCdata

The node's CDATA value

Returns

string

initValue()

initValue(int|float|array|bool|object|string $mxtValue, string $strType, int|float|array|bool|object|string $mxtDefault) : int|float|array|bool|object|string

Initialize a variable value

Parameters

int|float|array|bool|object|string $mxtValue

Value to initialize

string $strType

Variable type

int|float|array|bool|object|string $mxtDefault

Default value

Returns

int|float|array|bool|object|string —

Initialized value

initRequest()

initRequest(string $strKey, mixed $mxtDefault)

Initializes a request variable

Parameters

string $strKey

Name of the variable

mixed $mxtDefault

Default value

equationBuild()

equationBuild(string $strFilter, bool $bolList) : array

Creates an array containing the tree parameters attribute, operator and value to express an equation. The method also aims to simplify the operator by narrowing them down to <, >, =, and !

Parameters

string $strFilter

The filter string, e.g "x >= 10"

bool $bolList

Returns a list of all equations

Returns

array —

['attribute', 'operator', 'value']

equationCheck()

equationCheck(string $strValue1, string $strValue2, string $strOperator) : bool

Checks, if an equation is correct

Parameters

string $strValue1

First parameter

string $strValue2

Second parameter

string $strOperator

Equation operator (==, !=, <, >, <=, >=)

Returns

bool

strStripQuotes()

strStripQuotes(string $strQuote) : string

Strips the quote symbols form a string

Parameters

string $strQuote

Returns

string

strStripBrackets()

strStripBrackets(string $strQuote) : string

Strips the brackets from the beginning and end of a string

Parameters

string $strQuote

Returns

string

strStripString()

strStripString(string $strText, string $strOpen, string $strClose, bool $bolStrict) : string

Strips defined chars from the beginning and the end of a string

Parameters

string $strText
string $strOpen
string $strClose
bool $bolStrict

Only strip symmetrical strings

Returns

string

strStripWhitespaces()

strStripWhitespaces(string $strText) : string

Strips all whitespaces from the beginning and end of a string

Parameters

string $strText

Returns

string

strStripInline()

strStripInline(string $strText, bool $bolLineBreaks) : string

Reduces a paragraph to one single line, removing all linebreaks, tabs and blank spaces

Parameters

string $strText
bool $bolLineBreaks

If set, also linebreaks are removed (otherwise only tabs and blank spaces)

Returns

string

strShorten()

strShorten(string $strText, int $numLength, bool $bolDots, bool $bolWords) : string

Shortens a string to a specified number of chars.

Parameters

string $strText
int $numLength
bool $bolDots

Puts three dots [...] at the end of the shortened string.

bool $bolWords

Respect single words when shortening a text.

Returns

string

strToFloat()

strToFloat(string $strNumber, bool $bolNegative) : float

Converts a formated string into a float

Parameters

string $strNumber

The formated number, e.g. "1,293.00 €"

bool $bolNegative

Support negative numbers

Returns

float

htmlDecode()

htmlDecode(string $strHTML, bool $bolBreak) : string

Converts a HTML string into a plain text string, decoding existing HTML special chars

Parameters

string $strHTML
bool $bolBreak

Also replace
linebreaks in regular linebreaks "\n"

Returns

string

htmlEncode()

htmlEncode(string $strText, string $bolBreak) : \Xily\unknown

Converts a regular string into HTML code, encoding HTML special chars.

Parameters

string $strText
string $bolBreak

If linebreak is true, the function will add
linebreaks

Returns

\Xily\unknown

xmlChars()

xmlChars(string $strRaw) : string

Encodes special XML characters

Parameters

string $strRaw

Returns

string

createUID()

createUID() : string

Creates a unique identifier

Returns

string

fileFormatDir()

fileFormatDir(string $strDirectory, string $strSlash) : string

Makes sure the directory ends with a slash

Parameters

string $strDirectory

The directory

string $strSlash

The slash format (default is DIRECTORY_SEPARATOR)

Returns

string

fileRead()

fileRead(string $strFile) : string|bool

Reads the contents of a file to a string

Parameters

string $strFile

The filename

Returns

string|bool

fileReadByLine()

fileReadByLine(string $strFile, \Xily\stirng $strFunction) : string

Reads the contents of a file to a string line by line and optionally calls a function for each line

Parameters

string $strFile

The filename

\Xily\stirng $strFunction

Name of the function to be called for each line

Returns

string —

The file contents

fileWrite()

fileWrite(string $strFile, string $strText, bool $bolModeAdd) : bool

Writes a string to a file

Parameters

string $strFile

The filename

string $strText

String to write

bool $bolModeAdd

Appends the string at the end of the file

Returns

bool

fileRemoveDir()

fileRemoveDir(string $strDirectory, bool $bolEmpty) : bool

Recursively removes a directory and the files and subdirectories contained in it

Parameters

string $strDirectory
bool $bolEmpty

Declaration of the directory to be empty

Returns

bool

fileCopyDir()

fileCopyDir(string $strDirectory, string $strDestination, bool $bolCreate) : bool

Recursively copies a directory and the files and subdirectories contained in it

Parameters

string $strDirectory
string $strDestination
bool $bolCreate

This option defines, if the whole directory should be copied or only its contents

Returns

bool

fileListDir()

fileListDir(string $strDirName, string $strFiletype) : array

Returns an array with the contents of a directory

Parameters

string $strDirName

The directory name

string $strFiletype

Filter for certain file extensions

Returns

array

fileGetExtension()

fileGetExtension(string $strFilename) : string

Returns the file extension

Parameters

string $strFilename

Filename

Returns

string

fileRename()

fileRename(string $strOldFileName, string $strNewFileName) : bool

Renames a file

Parameters

string $strOldFileName
string $strNewFileName

Returns

bool

probe()

probe(string $strSource, string $strMessage, int $intLevel) : bool

Echos a message, if modeDebug is active. This function can be very useful to place status messages in your functions, to gain some insights of what your program is doing.

Parameters

string $strSource

The function's name where the probe is placed

string $strMessage

The debug message

int $intLevel

Priority/Level of the message

Returns

bool —

Returns, whether the probe was echoed

includeNode()

includeNode(array $addDirs, string $strParserFile, string $strParserClass)

Scan the bean directories and include the Bean

Parameters

array $addDirs
string $strParserFile
string $strParserClass

xdrRetriveObject()

xdrRetriveObject(string $strObject, bool $bolStringOnly, bool $bolStrict) : string|array|\Xily\Xily\Xml|mixed

Retrieves a local object This function evaluates an XML path, in order to receive an XML object or to trace the complete path ($bolStringOnly).

Parameters

string $strObject

The object path or ID of the node

bool $bolStringOnly

If true, the function will only return results of type string

bool $bolStrict

If strict mode is of, the function will try to convert unfitting object to strings (e.g. XML files)

Returns

string|array|\Xily\Xily\Xml|mixed

xdrRetriveData()

xdrRetriveData(string $strDataPath, \Xily\Xily\Xml $mxtDataset, bool $bolStringOnly, bool $bolStrict) : string|array|\Xily\Xily\Xml|mixed

This function evaluates a datapath relativ to the given dataset.

Parameters

string $strDataPath

The XML data path

\Xily\Xily\Xml $mxtDataset

The dataset on which the datapath should be applied

bool $bolStringOnly

If true, the function will only return results of type string

bool $bolStrict

If strict mode is of, the function will try to convert unfitting object to strings (e.g. XML files)

Returns

string|array|\Xily\Xily\Xml|mixed

xdrRetriveExternal()

xdrRetriveExternal(string $strURL, string $strType, string $strMethod) : object|string

Fetches an external dataset.

Parameters

string $strURL

The URL or directory of the file

string $strType

Declares the type of data (plain*, xml, bean, json)

string $strMethod

Loading method for the external resource: open*, get, post

Returns

object|string

getPredefinedVar()

getPredefinedVar(string $strVariable) : array

Returns a predefined PHP variable

Parameters

string $strVariable

Variable name

Returns

array

startTagCallback()

startTagCallback(resource $objParser, string $strTag, array $arrAttributes) : void

Callback for start tags

Parameters

resource $objParser

Parser resource

string $strTag

Tag name

array $arrAttributes

List of attributes

endTagCallback()

endTagCallback(resource $objParser, string $strTag) : void

Callback for end tags

Parameters

resource $objParser

Parser resource

string $strTag

Tag name

cdataCallback()

cdataCallback(resource $objParser, string $strCdata) : void

Callback for CDATA

Parameters

resource $objParser

Parser resource

string $strCdata

CDATA string

checkProperty()

checkProperty(string $strValue, array|string $mxtFilter)

Checks a single attribute (Utility function for Xml::chilren)

Parameters

string $strValue

the value to check

array|string $mxtFilter

Either the value to compare to or an array with an additional operator [value, operator]

getContentTarget()

getContentTarget(int $intIndex, int $intType) : int

Returns a valid XML/CDATA index for a desired content index

Parameters

int $intIndex
int $intType

Returns

int

getContentIndex()

getContentIndex(int $intTarget, int $intType) : int

Returns the content index of a specified XML/CDATA index

Parameters

int $intTarget
int $intType

Returns

int

addContentEntry()

addContentEntry(int $intIndex, int $intType, int $intTarget) : void

Inserts a new element in the content stream

Parameters

int $intIndex

Index of the content element

int $intType

Type of the content element

int $intTarget

Target index within the content stream

terminateChildren()

terminateChildren(object $xmlNode) : bool

Supporting function for removeChild and removeChildren Kills either all or a specified child node

Parameters

object $xmlNode

Returns

bool

removeContentEntry()

removeContentEntry(int $intIndex, int $intType) : bool

Assisting function to update the content array after removing CDATA or XML

Parameters

int $intIndex

Index of the XML or CDATA tag

int $intType

Content type (XML = 1; CDATA = 0)

Returns

bool