PHP Class Falcon_Converter, Falcon

Afficher le fichier Open project: rmccue/Falcon Class Usage Examples

Protected Properties

Свойство Type Description
$document DOMDocument This may be needed to export an element as HTML
$html string HTML fragment
$links array List of URLs in the document
$list_stack array -1 represents an unordered list, while all other integers represent the current index of the ordered list
$text string Textual representation of the HTML

Méthodes publiques

Méthode Description
__construct ( string $html ) Constructor
convert ( ) : string Convert HTML into a textual representation
silence_errors ( integer $num, string $str ) No-op error handler for libxml

Méthodes protégées

Méthode Description
blockquote ( DOMElement $element ) : string Parse blockquote elements into a string
generate_links ( )
get_text ( DOMNode $node ) : string Convert a node to text
heading ( DOMElement $element ) : string Parse heading elements into a string
indent ( string $text ) : string Indent a section of text
parse_children ( DOMNode $list ) : string Parse a node's children
parse_element ( DOMElement $element ) : string Parse an element into text
preprocess ( string $html ) : string Preprocess HTML
table ( DOMElement $element ) : string Parse table elements into a string
table_row ( DOMElement $element ) : array Parse a table row element
table_section ( DOMElement $element ) : array Parse a table section element
wrap ( string $str ) : string Wrap a string to a certain number of characters

Method Details

__construct() public méthode

Constructor
public __construct ( string $html )
$html string HTML fragment to convert

blockquote() protected méthode

Parse blockquote elements into a string
protected blockquote ( DOMElement $element ) : string
$element DOMElement Blockquote element
Résultat string Text representation

convert() public méthode

Convert HTML into a textual representation
public convert ( ) : string
Résultat string Text representation

get_text() protected méthode

Handles the various types of DOM nodes
protected get_text ( DOMNode $node ) : string
$node DOMNode Node to convert
Résultat string Text representation

heading() protected méthode

Handles H1-H6, with special handling for H1 and H2
protected heading ( DOMElement $element ) : string
$element DOMElement Heading element
Résultat string Text representation

indent() protected méthode

Indent a section of text
protected indent ( string $text ) : string
$text string Text to indent
Résultat string Indented text

parse_children() protected méthode

Parse a node's children
protected parse_children ( DOMNode $list ) : string
$list DOMNode Node to parse
Résultat string Text representation of the node's children

parse_element() protected méthode

This is a huge glorified switch statement, which is the easiest way to handle giant numbers of elements like this. Some elements have their handlers split off into separate methods.
protected parse_element ( DOMElement $element ) : string
$element DOMElement Element to parse
Résultat string Text representation of the element

preprocess() protected méthode

Sanitizes the HTML for use with DOMDocument, including giving it a DOCTYPE, which forces standards mode
protected preprocess ( string $html ) : string
$html string HTML fragment
Résultat string Processed HTML document

silence_errors() public static méthode

No-op error handler for libxml
public static silence_errors ( integer $num, string $str )
$num integer Error type
$str string Error message

table() protected méthode

Parse table elements into a string
protected table ( DOMElement $element ) : string
$element DOMElement Table element
Résultat string Text representation

table_row() protected méthode

Parse a table row element
protected table_row ( DOMElement $element ) : array
$element DOMElement TR element
Résultat array Cells in the row

table_section() protected méthode

Parse a table section element
protected table_section ( DOMElement $element ) : array
$element DOMElement THEAD or TBODY element
Résultat array Rows in the section

wrap() protected méthode

Has special handling for some text elements (blockquotes and tables)
protected wrap ( string $str ) : string
$str string Text to wrap
Résultat string Word-wrapped text

Property Details

$document protected_oe property

This may be needed to export an element as HTML
protected DOMDocument $document
Résultat DOMDocument

$html protected_oe property

HTML fragment
protected string $html
Résultat string

$list_stack protected_oe property

-1 represents an unordered list, while all other integers represent the current index of the ordered list
protected array $list_stack
Résultat array

$text protected_oe property

Textual representation of the HTML
protected string $text
Résultat string