protected static function build($filename, HTML_Builder $builder) { $pconf = new Project_Config(); if (isset($pconf->templates['remote_parser']) && $pconf->templates['remote_parser']) { $parser = new Remote_HTML_Parser($pconf->templates['remote_parser'], $builder); } else { $parser = new HTML_Parser($builder); } $parser->parse($filename); return $parser->build(); }
function _process_tag(&$content, $tag_html) { // Parse tag $parser = new HTML_Parser(); $output = $parser->parse($tag_html); // XML Error? if ($parser->xml_error == true) { $error = 'XML Error: ' . $parser->xml_error_string . ' on line ' . $parser->xml_error_line_number; $content = str_replace($html, $error, $content); return false; } // Get tag structure and innerHTML $tag = $output['0']; $innerHTML = $tag['innerhtml']; // Check array attribute if (empty($tag['attr']['ARRAY'])) { // No array, return error $error = 'Array attribute not set - unable to use Repeater Control'; $content = str_replace($tag_html, $error, $content); return false; } $array = $tag['attr']['ARRAY']; // Check if array exists if (!isset($this->_arrays[$array]) or !is_array($this->_arrays[$array])) { // No array, return error $error = 'Invalid array, not binded - unable to use Repeater Control'; $content = str_replace($tag_html, $error, $content); return false; } // Loop through array $new_html = ''; foreach ($this->_arrays[$array] as $key => $value) { // Copy innerHTML $html = $innerHTML; // Parse children $html = $this->_parse_subtags($html, $tag, $key, $value); $new_html .= $html; } // Replace custom tag with new HTML $content = str_replace($tag_html, $new_html, $content); }