\NimrodParser

NimrodParser class.

Minimal working code example:

require 'class.nimrod.parser.php';
$doc = new NimrodParser;
echo $doc->loadFile("page.html")->parse();

Summary

Methods
Properties
Constants
__construct()
__toString()
configure()
loadFile()
loadString()
parse()
$config
$resources
TOK_RE
TOK_OP
TOK_CL
TOK_MID
saveDOM()
putScripts()
putWatermark()
isBalanced()
processNimrodCode()
flagNode()
saveResource()
tokparser()
tokparserDeep()
parseAttributes()
treeWalker()
$pageDom
N/A
debugDOM()
No private properties found
N/A

Constants

TOK_RE

TOK_RE

Full regex token.

TOK_OP

TOK_OP

Opening token.

TOK_CL

TOK_CL

Closing token.

TOK_MID

TOK_MID

Middle token.

Properties

$config

$config : 

Main configuration.

Type

$resources

$resources : 

Gettext resources.

Type

$pageDom

$pageDom : 

The page DOM.

Type

Methods

__construct()

__construct() 

Constructor.

__toString()

__toString() 

String class representation.

configure()

configure(array  $conf = array()) 

Configuration setup.

Parameters

array $conf

The config properties.

loadFile()

loadFile(string  $file) : \NimrodParser

Load file to the DOM.

Parameters

string $file

Input file.

Returns

\NimrodParser

loadString()

loadString(string  $html) : \NimrodParser

Load string to the DOM.

Parameters

string $html

Input HTML.

Returns

\NimrodParser

parse()

parse() : string

Parse the DOM.

Returns

string

saveDOM()

saveDOM() : string

Save parsed DOM structure.

Returns

string

putScripts()

putScripts(array  $modules, \DOMElement  $node) 

Create SCRIPT elements and append them to the DOM.

Parameters

array $modules

File dependencies, inside jslibs dir.

\DOMElement $node

DOM node which SCRIPT will be appended to.

putWatermark()

putWatermark(\DOMElement  $node) 

Create an image watermark.

Parameters

\DOMElement $node

DOM node which SCRIPT will be appended to.

isBalanced()

isBalanced(string  $str) 

Check whether node or attribute content is well balanced.

Parameters

string $str

The content.

processNimrodCode()

processNimrodCode(\DOMElement  $node) 

Parse DOM node.

Parameters

\DOMElement $node

The DOM node.

flagNode()

flagNode(\DOMElement  $node, string  $data, string  $type) 

Mark DOM node, saving the resulting structure.

Parameters

\DOMElement $node

The DOM node.

string $data

Node data.

string $type

Node type.

saveResource()

saveResource(string  $key, string  $value, string  $type) 

Save DOM node.

Parameters

string $key

Node name.

string $value

Node value.

string $type

Node type.

tokparser()

tokparser(string  $str) : string

Parse tokenized string.

Parameters

string $str

The string.

Returns

string

tokparserDeep()

tokparserDeep(string  $str, integer  $offset, array  $dict = array()) : array

Deep parse of tokenized string.

Parameters

string $str

Input string.

integer $offset

The string.

array $dict

Cache structure.

Returns

array

parseAttributes()

parseAttributes(\HTMLElement  $el) 

Parse element attributes.

Parameters

\HTMLElement $el

Input element.

treeWalker()

treeWalker(\HTMLElement  $node) 

Recursive DOM iteration.

Parameters

\HTMLElement $node

DOM node.

debugDOM()

debugDOM() : string

Debug parsed DOM nodes.

Returns

string