PHP Class Texy\HtmlElement

usage: $anchor = (new HtmlElement('a'))->href($link)->setText('Texy'); $el->class = 'myclass'; echo $el->startTag(), $el->endTag();
Inheritance: implements ArrayAccess, implements IteratorAggregate, use trait Strict
显示文件 Open project: dg/texy Class Usage Examples

Public Properties

Property Type Description
$attrs element's attributes
$emptyElements empty elements
$inlineElements %inline; elements; replaced elements + br have value '1'
$optionalEnds elements with optional end tag in HTML
$prohibits
$xhtml use XHTML syntax?

Protected Properties

Property Type Description
$children of HtmlElement | string nodes

Public Methods

Method Description
__clone ( ) Clones all children too.
__construct ( $name = NULL, $attrs = NULL )
__get ( $name ) : mixed Overloaded getter for element's attribute.
__set ( $name, $value ) : void Overloaded setter for element's attribute.
add ( $child ) : self Adds new element's child.
count ( ) : integer Required by the Countable interface.
create ( $name, $attrs = NULL ) : HtmlElement Creates and adds a new HtmlElement child.
el ( $name = NULL, $attrs = NULL )
endTag ( ) : string Returns element's end tag.
getChildren ( ) Returns all of children.
getContentType ( ) : integer
getIterator ( ) : ArrayIterator Required by the IteratorAggregate interface.
getName ( ) : string Returns element's name.
getText ( ) : string Gets element's textual content.
href ( $path, $query = NULL ) : self Special setter for element's attribute.
insert ( $index, $child, $replace = FALSE ) : self Inserts child node.
isEmpty ( ) : boolean Is element empty?
offsetExists ( $index ) : boolean Exists child node? (ArrayAccess implementation).
offsetGet ( $index ) : mixed Returns child node (ArrayAccess implementation).
offsetSet ( $index, $child ) : void Inserts (replaces) child node (ArrayAccess implementation).
offsetUnset ( $index ) : void Removes child node (ArrayAccess implementation).
parseBlock ( Texy $texy, $s, $indented = FALSE ) : void Parses text as block.
parseLine ( Texy $texy, $s ) : void Parses text as single line.
removeChildren ( ) : void Removed all children.
setName ( $name, $empty = NULL ) : self Changes element's name.
setText ( $text ) : self Sets element's textual content.
startTag ( ) : string Returns element's start tag.
toHtml ( Texy $texy ) : string Renders to final HTML.
toString ( Texy $texy ) : string Renders element's start tag, content and end tag to internal string representation.
toText ( Texy $texy ) : string Renders to final text.
validateAttrs ( array $dtd ) : void
validateChild ( $child, $dtd )

Method Details

__clone() public method

Clones all children too.
public __clone ( )

__construct() public method

public __construct ( $name = NULL, $attrs = NULL )

__get() final public method

Overloaded getter for element's attribute.
final public __get ( $name ) : mixed
return mixed property value

__set() final public method

Overloaded setter for element's attribute.
final public __set ( $name, $value ) : void
return void

add() final public method

Adds new element's child.
final public add ( $child ) : self
return self

count() final public method

Required by the Countable interface.
final public count ( ) : integer
return integer

create() final public method

Creates and adds a new HtmlElement child.
final public create ( $name, $attrs = NULL ) : HtmlElement
return HtmlElement created element

el() public static method

public static el ( $name = NULL, $attrs = NULL )

endTag() public method

Returns element's end tag.
public endTag ( ) : string
return string

getChildren() final public method

return array
final public getChildren ( )

getContentType() final public method

final public getContentType ( ) : integer
return integer

getIterator() final public method

Required by the IteratorAggregate interface.
final public getIterator ( ) : ArrayIterator
return ArrayIterator

getName() final public method

Returns element's name.
final public getName ( ) : string
return string

getText() final public method

Gets element's textual content.
final public getText ( ) : string
return string

href() final public method

Special setter for element's attribute.
final public href ( $path, $query = NULL ) : self
return self

insert() public method

Inserts child node.
public insert ( $index, $child, $replace = FALSE ) : self
return self

isEmpty() final public method

Is element empty?
final public isEmpty ( ) : boolean
return boolean

offsetExists() final public method

Exists child node? (ArrayAccess implementation).
final public offsetExists ( $index ) : boolean
return boolean

offsetGet() final public method

Returns child node (ArrayAccess implementation).
final public offsetGet ( $index ) : mixed
return mixed

offsetSet() final public method

Inserts (replaces) child node (ArrayAccess implementation).
final public offsetSet ( $index, $child ) : void
return void

offsetUnset() public method

Removes child node (ArrayAccess implementation).
public offsetUnset ( $index ) : void
return void

parseBlock() final public method

Parses text as block.
final public parseBlock ( Texy $texy, $s, $indented = FALSE ) : void
$texy Texy
return void

parseLine() final public method

Parses text as single line.
final public parseLine ( Texy $texy, $s ) : void
$texy Texy
return void

removeChildren() public method

Removed all children.
public removeChildren ( ) : void
return void

setName() final public method

Changes element's name.
final public setName ( $name, $empty = NULL ) : self
return self

setText() final public method

Sets element's textual content.
final public setText ( $text ) : self
return self

startTag() public method

Returns element's start tag.
public startTag ( ) : string
return string

toHtml() final public method

Renders to final HTML.
final public toHtml ( Texy $texy ) : string
$texy Texy
return string

toString() final public method

Renders element's start tag, content and end tag to internal string representation.
final public toString ( Texy $texy ) : string
$texy Texy
return string

toText() final public method

Renders to final text.
final public toText ( Texy $texy ) : string
$texy Texy
return string

validateAttrs() final public method

final public validateAttrs ( array $dtd ) : void
$dtd array
return void

validateChild() public method

public validateChild ( $child, $dtd )

Property Details

$attrs public_oe property

element's attributes
public $attrs

$children protected_oe property

of HtmlElement | string nodes
protected $children

$emptyElements public_oe static_oe property

empty elements
public static $emptyElements

$inlineElements public_oe static_oe property

%inline; elements; replaced elements + br have value '1'
public static $inlineElements

$optionalEnds public_oe static_oe property

elements with optional end tag in HTML
public static $optionalEnds

$prohibits public_oe static_oe property

See also: http://www.w3.org/TR/xhtml1/prohibitions.html
public static $prohibits

$xhtml public_oe static_oe property

use XHTML syntax?
public static $xhtml