Class TexyHtml
HTML helper.
usage:
$anchor = TexyHtml::el(‚a‘)->href($link)->setText(‚Texy‘);
$el->class = ‚myclass‘;
echo $el->startTag(), $el->endTag();
- TexyObject
-
TexyHtml implements ArrayAccess, IteratorAggregate, Traversable
public static
TexyHtml
|
#
el(
string
$name = NULL,
array|string
$attrs = NULL
)
Static factory. Static factory. Parameters$name string element name (or NULL)$attrs array|string element's attributes (or textual content) |
final public
TexyHtml
|
#
setName(
string
$name,
bool
$empty = NULL
)
Changes element's name. Changes element's name. Parameters$name string$empty bool Is element empty?ReturnsTexyHtml provides a fluent interface
Throws
InvalidArgumentException
|
final public
string
|
#
getName(
)
Returns element's name. Returns element's name. |
final public
bool
|
#
isEmpty(
)
Is element empty? Is element empty? |
final public
void
|
#
__set(
string
$name,
mixed
$value
)
Overloaded setter for element's attribute. Overloaded setter for element's attribute. Parameters$name string property name$value mixed property value |
final public
mixed
&
|
#
__get(
string
$name
)
Overloaded getter for element's attribute. Overloaded getter for element's attribute. Parameters$name string property nameReturnsmixed property value
|
final public
TexyHtml
|
#
href(
string
$path,
array
$query = NULL
)
Special setter for element's attribute. Special setter for element's attribute. Parameters$path string path$query array queryReturnsTexyHtml provides a fluent interface
|
final public
TexyHtml
|
#
setText(
string
$text
)
Sets element's textual content. Sets element's textual content. Parameters$text stringReturnsTexyHtml provides a fluent interface
|
final public
string
|
#
getText(
)
Gets element's textual content. Gets element's textual content. |
final public
TexyHtml
|
#
add(
TexyHtml|string
$child
)
Adds new element's child. Adds new element's child. Parameters$child TexyHtml|string child nodeReturnsTexyHtml provides a fluent interface
|
final public
TexyHtml
|
#
create(
string
$name,
array|string
$attrs = NULL
)
Creates and adds a new TexyHtml child. Creates and adds a new TexyHtml child. Parameters$name string elements's name$attrs array|string element's attributes (or textual content)ReturnsTexyHtml created element
|
public
TexyHtml
|
#
insert(
int
$index,
TexyHtml
$child,
bool
$replace = false
)
Inserts child node. Inserts child node. Parameters$index int$child TexyHtml node$replace boolReturnsTexyHtml provides a fluent interface
Throws
Exception
|
final public
void
|
#
offsetSet(
int
$index,
TexyHtml
$child
)
Inserts (replaces) child node (ArrayAccess implementation). Inserts (replaces) child node (ArrayAccess implementation). Parameters$index int$child TexyHtml nodeImplementation of |
final public
mixed
|
#
offsetGet(
int
$index
)
Returns child node (ArrayAccess implementation). Returns child node (ArrayAccess implementation). Parameters$index int indexImplementation of |
final public
bool
|
#
offsetExists(
int
$index
)
Exists child node? (ArrayAccess implementation). Exists child node? (ArrayAccess implementation). Parameters$index int indexImplementation of |
public
void
|
#
offsetUnset(
int
$index
)
Removes child node (ArrayAccess implementation). Removes child node (ArrayAccess implementation). Parameters$index int indexImplementation of |
final public
int
|
#
count(
)
Required by the Countable interface. Required by the Countable interface. |
public
void
|
#
removeChildren(
)
Removed all children. Removed all children. |
final public
ArrayIterator
|
#
getIterator(
)
Required by the IteratorAggregate interface. |
final public
|
#
getChildren(
)
Returns all of children. Returns all of children. return array |
final public
string
|
#
toString(
Texy
$texy
)
Renders element's start tag, content and end tag to internal string representation. Renders element's start tag, content and end tag to internal string representation. Parameters$texy Texy |
final public
string
|
#
toHtml(
Texy
$texy
)
Renders to final HTML. Renders to final HTML. Parameters$texy Texy |
final public
string
|
#
toText(
Texy
$texy
)
Renders to final text. Renders to final text. Parameters$texy Texy |
public
string
|
#
startTag(
)
Returns element's start tag. Returns element's start tag. |
public
string
|
#
endTag(
)
Returns element's end tag. Returns element's end tag. |
public
|
#
__clone(
)
Clones all children too. Clones all children too. |
final public
int
|
#
getContentType(
)
|
final public
void
|
#
validateAttrs(
array
$dtd
)
Parameters$dtd array |
public
|
#
validateChild(
$child,
$dtd
)
|
final public
void
|
#
parseLine(
Texy
$texy,
string
$s
)
Parses text as single line. Parses text as single line. Parameters$texy Texy$s string |
final public
void
|
#
parseBlock(
Texy
$texy,
string
$s,
bool
$indented = false
)
Parses text as block. Parses text as block. Parameters$texy Texy$s string$indented bool |
Methods Inherited From TexyObject
getClass(), getReflection(), __call(), __callStatic(), extensionMethod(), __get(), __set(), __isset(), __unset()
array
|
$attrs | array (
) |
element's attributes # |
protected
array
|
$children | array (
) |
of TexyHtml | string nodes # |
static
bool
|
$xhtml | true |
use XHTML syntax? # |
static
array
|
$emptyElements | array ( 'img' => 1, 'hr' => 1, 'br' => 1, 'input' => 1, 'meta' => 1, 'area' => 1, 'base' => 1, 'col' => 1, 'link' => 1, 'param' => 1, 'basefont' => 1, 'frame' => 1, 'isindex' => 1, 'wbr' => 1, 'embed' => 1, ) |
empty elements # |
static
array
|
$inlineElements | array ( 'ins' => 0, 'del' => 0, 'tt' => 0, 'i' => 0, 'b' => 0, 'big' => 0, 'small' => 0, 'em' => 0, 'strong' => 0, 'dfn' => 0, 'code' => 0, 'samp' => 0, 'kbd' => 0, 'var' => 0, 'cite' => 0, 'abbr' => 0, 'acronym' => 0, 'sub' => 0, 'sup' => 0, 'q' => 0, 'span' => 0, 'bdo' => 0, 'a' => 0, 'object' => 1, 'img' => 1, 'br' => 1, 'script' => 1, 'map' => 0, 'input' => 1, 'select' => 1, 'textarea' => 1, 'label' => 0, 'button' => 1, 'u' => 0, 's' => 0, 'strike' => 0, 'font' => 0, 'applet' => 1, 'basefont' => 0, 'embed' => 1, 'wbr' => 0, 'nobr' => 0, 'canvas' => 1, ) |
%inline; elements; replaced elements + br have value ‚1‘ # |
static
array
|
$optionalEnds | array ( 'body' => 1, 'head' => 1, 'html' => 1, 'colgroup' => 1, 'dd' => 1, 'dt' => 1, 'li' => 1, 'option' => 1, 'p' => 1, 'tbody' => 1, 'td' => 1, 'tfoot' => 1, 'th' => 1, 'thead' => 1, 'tr' => 1, ) |
elements with optional end tag in HTML # |
static
|
$prohibits | array ( 'a' => array ( 0 => 'a', 1 => 'button', ), 'img' => array ( 0 => 'pre', ), 'object' => array ( 0 => 'pre', ), 'big' => array ( 0 => 'pre', ), 'small' => array ( 0 => 'pre', ), 'sub' => array ( 0 => 'pre', ), 'sup' => array ( 0 => 'pre', ), 'input' => array ( 0 => 'button', ), 'select' => array ( 0 => 'button', ), 'textarea' => array ( 0 => 'button', ), 'label' => array ( 0 => 'button', 1 => 'label', ), 'button' => array ( 0 => 'button', ), 'form' => array ( 0 => 'button', 1 => 'form', ), 'fieldset' => array ( 0 => 'button', ), 'iframe' => array ( 0 => 'button', ), 'isindex' => array ( 0 => 'button', ), ) |
# |