Thread: [phpwebapp-commits] CVS: web_app/parser class.WebPage.php,1.9,1.10 class.WebObject.php,1.7,1.8 class
Brought to you by:
dashohoxha
From: Dashamir H. <das...@us...> - 2004-07-14 14:45:51
|
Update of /cvsroot/phpwebapp/web_app/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13284/parser Modified Files: class.WebPage.php class.WebObject.php class.WebClassTpl.php class.Template.php class.Render.php class.Parser.php Log Message: Index: class.WebPage.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/parser/class.WebPage.php,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** class.WebPage.php 13 Jul 2004 13:18:08 -0000 1.9 --- class.WebPage.php 14 Jul 2004 14:45:41 -0000 1.10 *************** *** 190,194 **** if (sizeof($this->messages)==0) return ""; ! $js = "<script language='javascript'>\n"; for ($i=0; $i < sizeof($this->messages); $i++) { --- 190,195 ---- if (sizeof($this->messages)==0) return ""; ! $js = "<script type=\"text/javascript\" language=\"javascript\">\n"; ! $js .= "<![CDATA[\n"; for ($i=0; $i < sizeof($this->messages); $i++) { *************** *** 198,201 **** --- 199,203 ---- $js .= "\talert('$msg');\n"; } + $js .= "]]>\n"; $js .= "</script>\n"; return $js; *************** *** 208,213 **** if ($nr==0) return; ! print "\n<hr>\n"; ! print "<strong>Debug Messages:</strong><br>\n"; for ($i=0; $i < $nr; $i++) { --- 210,215 ---- if ($nr==0) return; ! print "\n<hr/>\n"; ! print "<strong>Debug Messages:</strong><br/>\n"; for ($i=0; $i < $nr; $i++) { *************** *** 215,221 **** $comment = $this->dbg_messages[$i]["comment"]; if ($comment<>"") print $comment." : "; ! print $dbg_msg."<br>\n"; } ! print "\n<hr>\n"; } --- 217,223 ---- $comment = $this->dbg_messages[$i]["comment"]; if ($comment<>"") print $comment." : "; ! print $dbg_msg."<br/>\n"; } ! print "\n<hr/>\n"; } *************** *** 233,237 **** { //don't output the appended templates ! if (ereg("web_app/append/append.html\$", $tpl->id)) break; $html .= "\t<li><a href='#$tpl->id'>$tpl->id</a></li>\n"; --- 235,239 ---- { //don't output the appended templates ! if (ereg('web_app/append/append.html$', $tpl->id)) break; $html .= "\t<li><a href='#$tpl->id'>$tpl->id</a></li>\n"; *************** *** 245,253 **** { //don't output the appended templates ! if (ereg("web_app/append/append.html\$", $tpl->id)) break; $html .= $tpl->toHtmlTable(); } ! $html .= "<hr>\n"; return $html; --- 247,255 ---- { //don't output the appended templates ! if (ereg('web_app/append/append.html$', $tpl->id)) break; $html .= $tpl->toHtmlTable(); } ! $html .= "<hr />\n"; return $html; *************** *** 257,261 **** function tpl_to_tree() //for debugging parse() { ! $tree = "<hr>\n"; $tree .= "<a name='top'> </a>\n"; $tree .= "<pre class='webapp'>\n"; --- 259,263 ---- function tpl_to_tree() //for debugging parse() { ! $tree = "<hr />\n"; $tree .= "<a name='top'> </a>\n"; $tree .= "<pre class='webapp'>\n"; *************** *** 273,278 **** function recordsets_to_html() { ! $html_recs = "<hr>\n"; ! $html_recs .= "<b> THE RECORDSETS OF THE PAGE: </b><br>\n"; reset($this->rs_collection); while ( list($rsId,$rs) = each($this->rs_collection) ) --- 275,280 ---- function recordsets_to_html() { ! $html_recs = "<hr />\n"; ! $html_recs .= "<b> THE RECORDSETS OF THE PAGE: </b><br />\n"; reset($this->rs_collection); while ( list($rsId,$rs) = each($this->rs_collection) ) *************** *** 280,284 **** $html_recs .= $rs->toHtmlTable(); } ! $html_recs .= "<hr>\n"; return $html_recs; } --- 282,286 ---- $html_recs .= $rs->toHtmlTable(); } ! $html_recs .= "<hr />\n"; return $html_recs; } Index: class.WebObject.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/parser/class.WebObject.php,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** class.WebObject.php 24 Sep 2003 14:20:44 -0000 1.7 --- class.WebObject.php 14 Jul 2004 14:45:41 -0000 1.8 *************** *** 201,205 **** { $html = " ! <br> <a name='$this->id'> </a>[<a href='tree'>Top</a>] <table bgcolor='#aaaaaa' border='0' cellspacing='1' cellpadding='2'> --- 201,205 ---- { $html = " ! <br /> <a name='$this->id'> </a>[<a href='tree'>Top</a>] <table bgcolor='#aaaaaa' border='0' cellspacing='1' cellpadding='2'> Index: class.WebClassTpl.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/parser/class.WebClassTpl.php,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** class.WebClassTpl.php 8 Sep 2003 13:18:24 -0000 1.8 --- class.WebClassTpl.php 14 Jul 2004 14:45:41 -0000 1.9 *************** *** 69,75 **** //parse the file global $parser; - $parser->silent = true; $parser->parse_file($fname); - $parser->silent = false; } } --- 69,73 ---- *************** *** 124,128 **** global $webPage; $fname = WebApp::to_url($fname); ! $include_js = " <script language='JavaScript' src='$fname'></script>\n"; $webPage->append_to_head($include_js); } --- 122,126 ---- global $webPage; $fname = WebApp::to_url($fname); ! $include_js = " <script type=\"text/javascript\" language=\"JavaScript\" src=\"$fname\"></script>\n"; $webPage->append_to_head($include_js); } *************** *** 141,145 **** global $webPage; $fname = WebApp::to_url($fname); ! $include_css = " <link rel='stylesheet' href='$fname' type='text/css'>\n"; $webPage->append_to_head($include_css); } --- 139,143 ---- global $webPage; $fname = WebApp::to_url($fname); ! $include_css = " <link type=\"text/css\" rel=\"stylesheet\" href=\"$fname\" />\n"; $webPage->append_to_head($include_css); } Index: class.Template.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/parser/class.Template.php,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** class.Template.php 13 Jul 2004 16:14:48 -0000 1.9 --- class.Template.php 14 Jul 2004 14:45:41 -0000 1.10 *************** *** 157,161 **** $indent = strtr($this->indent, ' ', '#'); $htmlTable = " ! <br> <a name='$this->id'> </a>[<a href='javascript: back()'>Back</a>] <table class='webapp' width='90%' bgcolor='#aaaaaa' border='0' cellspacing='1' cellpadding='2'>". $this->attribs2html() . $this->vars2html() . " --- 157,161 ---- $indent = strtr($this->indent, ' ', '#'); $htmlTable = " ! <br /> <a name='$this->id'> </a>[<a href='javascript: back()'>Back</a>] <table class='webapp' width='90%' bgcolor='#aaaaaa' border='0' cellspacing='1' cellpadding='2'>". $this->attribs2html() . $this->vars2html() . " *************** *** 239,243 **** { //don't output the appended boxes ! if (ereg("append/append.html\$", $this->id)) return; global $webPage; --- 239,243 ---- { //don't output the appended boxes ! if (ereg('append/append.html$', $this->id)) return; global $webPage; Index: class.Render.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/parser/class.Render.php,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** class.Render.php 13 Jul 2004 16:14:48 -0000 1.9 --- class.Render.php 14 Jul 2004 14:45:41 -0000 1.10 *************** *** 50,66 **** * and then print it out. */ ! function render_string($str) { //replace all {{tpl_vars}} $str = WebApp::replaceVars($str); ! //add indentation at the beginning of each line ! $str = preg_replace('/^/m', $this->indent, $str); ! //print the string ! if ($this->collect) $this->html_page .= $str; ! else print $str; } /** * Returns the tpl_id from a string like this: '&&tpl_id;;' --- 50,78 ---- * and then print it out. */ ! function render_string($str, $indent =true) { //replace all {{tpl_vars}} $str = WebApp::replaceVars($str); ! if ($indent) ! { ! //add indentation at the beginning of each line ! $str = preg_replace('/^/m', $this->indent, $str); ! //remove the indentation at the end of the string ! $str = preg_replace("/\n$this->indent\$/", "\n", $str); ! } ! ! $this->output($str); } + /** Usually prints the given string. */ + function output($str) + { + //print the string + if ($this->collect) $this->html_page .= $str; + else print $str; + } + /** * Returns the tpl_id from a string like this: '&&tpl_id;;' *************** *** 110,113 **** --- 122,157 ---- } + /** Same as render_tpl, but without applying indentation. */ + function render_tpl_unindented($tpl) + { + global $webPage, $tplVars; + + $tplVars->pushScope(); + $tplVars->addVars($tpl->getVars()); + + $arr_contents = $tpl->get_arr_contents(); + for ($i=0; $i < sizeof($arr_contents); $i++) + { + $chunk = $arr_contents[$i]; + $tpl_id = $this->get_tpl_id($chunk); + if ($tpl_id==UNDEFINED) + { + //render without indenting it + $this->render_string($chunk, false); + } + else + { + //get and render the subtemplate + $subtpl = $webPage->getTemplate($tpl_id); + $prev_indent = $this->indent; + $this->indent = ''; //start rendering without indentation + $this->render_subtpl($subtpl); + $this->indent = $prev_indent; + } + } + + $tplVars->popScope(); + } + /** * Dispatcher function: according to the type of *************** *** 119,123 **** { default: ! $this->render_Template($tpl); break; case "IfTpl": --- 163,176 ---- { default: ! $this->render_tpl($tpl); ! break; ! case "PreTpl": ! $this->render_PreTpl($tpl); ! break; ! case "XmpTpl": ! $this->render_XmpTpl($tpl); ! break; ! case "ExampleTpl": ! $this->render_ExampleTpl($tpl); break; case "IfTpl": *************** *** 142,153 **** } ! /** ! * Renders the given Template (which may have $tpl->type ! * as 'Template', 'IfEmpty', 'Header', 'Footer' and 'Separator'. ! */ ! function render_Template($tpl) ! { ! $this->render_tpl($tpl); ! } /** --- 195,218 ---- } ! function render_PreTpl($tpl) ! { ! $attr_list = $tpl->vars['attr_list']; ! $tpl->contents = "<pre$attr_list>".$tpl->contents."</pre>"; ! $this->render_tpl_unindented($tpl); ! } ! ! function render_XmpTpl($tpl) ! { ! $attr_list = $tpl->vars['attr_list']; ! $tpl->contents = "<xmp$attr_list>".$tpl->contents."</xmp>"; ! $this->render_tpl_unindented($tpl); ! } ! ! function render_ExampleTpl($tpl) ! { ! $attr_list = $tpl->vars['attr_list']; ! $contents = $tpl->contents; ! $this->output("<xmp$attr_list>".$contents."</xmp>"); ! } /** *************** *** 259,263 **** $err_msg = WebApp::error_msg("Recordset '$rs_id' is undefined."); $this->render_string($err_msg); ! $this->render_Template($tpl); return; } --- 324,328 ---- $err_msg = WebApp::error_msg("Recordset '$rs_id' is undefined."); $this->render_string($err_msg); ! $this->render_tpl($tpl); return; } *************** *** 267,271 **** $err_msg = "Recordset '$rs_id' is not of type PagedRS."; $this->render_string(WebApp::error_msg($err_msg)); ! $this->render_Template($tpl); return; } --- 332,336 ---- $err_msg = "Recordset '$rs_id' is not of type PagedRS."; $this->render_string(WebApp::error_msg($err_msg)); ! $this->render_tpl($tpl); return; } *************** *** 305,309 **** $err_msg = WebApp::error_msg("Recordset '$rs_id' is undefined."); $this->render_string($err_msg); ! $this->render_Template($tpl); return; } --- 370,374 ---- $err_msg = WebApp::error_msg("Recordset '$rs_id' is undefined."); $this->render_string($err_msg); ! $this->render_tpl($tpl); return; } *************** *** 314,318 **** { //recordset has no records, it is empty ! $this->render_Template($tpl->if_empty); return; } --- 379,383 ---- { //recordset has no records, it is empty ! $this->render_tpl($tpl->if_empty); return; } *************** *** 337,341 **** { //render the separator ! $this->render_Template($tpl->separator); } --- 402,406 ---- { //render the separator ! $this->render_tpl($tpl->separator); } Index: class.Parser.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/parser/class.Parser.php,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** class.Parser.php 13 Jul 2004 16:14:48 -0000 1.10 --- class.Parser.php 14 Jul 2004 14:45:41 -0000 1.11 *************** *** 35,42 **** var $current_tpl; - /** When $this->silent is true, $this->append() does not append - * data to the current template. */ - var $silent; - /** When $this->copy_mode is true, then the parser works in copy mode. */ var $copy_mode; --- 35,38 ---- *************** *** 56,60 **** $this->tpl_stack = array(); $this->current_tpl = UNDEFINED; - $this->silent = false; $this->copy_mode = false; $this->files = array(); --- 52,55 ---- *************** *** 183,213 **** $this->append($xml_err_msg); ! if ($this->debug) ! { ! $id = $this->current_tpl->id; ! $type = $this->current_tpl->type; ! print $this->dbg_indent; ! print "** error: $fname: $id ($type)\n"; ! //$this->print_stack(); ! } ! //When an xml parser encounters an error, its stops parsing at all. ! //Remove from the template stack all the templates that were pushed ! //by this parser, so that the previous parser can continue its work ! //normally. ! while ($this->current_tpl->type<>'FileTpl' ! and $this->current_tpl->type<>'WebObjectTpl') ! { ! $tpl = $this->pop_current_tpl(); ! $this->link_template($tpl); ! } ! //reset parsing options to default and safe values as well ! $this->copy_mode = false; ! $this->copy_level = 0; ! $this->silent = false; ! return false; } } --- 178,215 ---- $this->append($xml_err_msg); ! $this->clean_tpl_stack(); ! return false; ! } ! } ! /** ! * When an xml parser encounters an error, it stops parsing at all. ! * Remove from the template stack all the templates that were pushed ! * by this parser, but cannot be poped (since the parser has stoped ! * working and ending tags cannot be matched). This ensures that ! * the previous parser can continue its work normally. ! */ ! function clean_tpl_stack() ! { ! if ($this->debug) ! { ! $id = $this->current_tpl->id; ! $type = $this->current_tpl->type; ! print $this->dbg_indent; ! print "** error: $fname: $id ($type)\n"; ! //$this->print_stack(); ! } ! $type = $this->current_tpl->type; ! while ($type!='FileTpl' and $type!='WebObjectTpl') ! { ! $tpl = $this->pop_current_tpl(); ! $this->link_template($tpl); ! $type = $this->current_tpl->type; } + + //reset parsing options to default and safe values + $this->copy_mode = false; } *************** *** 259,278 **** switch ($name) { ! case "TEMPLATE": ! case "IF": ! case "REPEAT": ! case "IFEMPTY": ! case "SEPARATOR": ! case "RSNAVIG": ! case "INCLUDE": ! case "HEAD": ! case "BODY": ! case "WEBBOX": ! case "WEBCLASS": ! case "WEBOBJECT": case 'RECORDSET': case 'DBCOMMAND': case 'VAR': ! $start_ELEMENT = "start_".$name; $this->$start_ELEMENT($attribs); break; --- 261,283 ---- switch ($name) { ! case 'TEMPLATE': ! case 'IF': ! case 'REPEAT': ! case 'IFEMPTY': ! case 'SEPARATOR': ! case 'RSNAVIG': ! case 'INCLUDE': ! case 'HEAD': ! case 'BODY': ! case 'WEBBOX': ! case 'WEBCLASS': ! case 'WEBOBJECT': case 'RECORDSET': case 'DBCOMMAND': case 'VAR': ! case 'PRE': ! case 'XMP': ! case 'EXAMPLE': ! $start_ELEMENT = 'start_'.$name; $this->$start_ELEMENT($attribs); break; *************** *** 283,286 **** --- 288,302 ---- break; + case 'BR': + case 'HR': + case 'IMG': + case 'INPUT': + case 'META': + case 'LINK': + $name = strtolower($name); + $attr_list = $this->get_attr_list($attribs); + $this->append("<${name}${attr_list} />"); + break; + default: $name = strtolower($name); *************** *** 301,325 **** switch ($name) { ! case "TEMPLATE": ! case "IF": ! case "REPEAT": ! case "IFEMPTY": ! case "SEPARATOR": ! case "RSNAVIG": ! case "HEAD": ! case "BODY": ! case "WEBBOX": ! case "WEBCLASS": ! case "WEBOBJECT": case 'RECORDSET': case 'DBCOMMAND': case 'VAR': ! $end_ELEMENT = "end_".$name; $this->$end_ELEMENT(); break; case 'DUMMYELEM': - case 'INCLUDE': case 'REPEATBODY': //do nothing, just ignore them break; --- 317,354 ---- switch ($name) { ! case 'IFEMPTY': ! case 'SEPARATOR': ! case 'HEAD': ! case 'BODY': case 'RECORDSET': case 'DBCOMMAND': case 'VAR': ! case 'PRE': ! case 'XMP': ! $end_ELEMENT = 'end_'.$name; $this->$end_ELEMENT(); break; + case 'TEMPLATE': + case 'IF': + case 'REPEAT': + case 'RSNAVIG': + $tpl = $this->pop_current_tpl(); + $this->link_template($tpl); + break; + case 'DUMMYELEM': case 'REPEATBODY': + case 'WEBOBJECT': + //do nothing, just ignore them + break; + + case 'INCLUDE': + case 'BR': + case 'HR': + case 'IMG': + case 'INPUT': + case 'META': + case 'LINK': //do nothing, just ignore them break; *************** *** 336,343 **** switch ($name) { ! case "WEBBOX": ! case "WEBCLASS": $this->copy_level++; - default: $name = strtolower($name); $attr_list = $this->get_attr_list($attribs); --- 365,372 ---- switch ($name) { ! case 'WEBBOX': ! case 'WEBCLASS': ! case 'EXAMPLE': $this->copy_level++; $name = strtolower($name); $attr_list = $this->get_attr_list($attribs); *************** *** 347,353 **** case 'PARAMETER': //do not copy it, process it instead ! $start_ELEMENT = "start_".$name; $this->$start_ELEMENT($attribs); break; } } --- 376,388 ---- case 'PARAMETER': //do not copy it, process it instead ! $start_ELEMENT = 'start_'.$name; $this->$start_ELEMENT($attribs); break; + + default: + $name = strtolower($name); + $attr_list = $this->get_attr_list($attribs); + $this->append("<$name $attr_list>"); + break; } } *************** *** 357,370 **** switch ($name) { ! default: ! $name = strtolower($name); ! $this->append("</$name>"); ! break; ! ! case "WEBBOX": ! case "WEBCLASS": if ($this->copy_level==0) { ! $end_ELEMENT = "end_".$name; $this->$end_ELEMENT(); } --- 392,401 ---- switch ($name) { ! case 'WEBBOX': ! case 'WEBCLASS': ! case 'EXAMPLE': if ($this->copy_level==0) { ! $end_ELEMENT = 'end_'.$name; $this->$end_ELEMENT(); } *************** *** 376,388 **** } break; } } /** Append $data to the last element of the content of the current_tpl. */ function append($data) { ! if ($this->silent) return; ! ! if ($this->current_tpl===UNDEFINED) { print $data; --- 407,438 ---- } break; + + case 'PARAMETER': + //do nothing + break; + + default: + $name = strtolower($name); + $this->append("</$name>"); + break; } } + /** Return a string with the attributes in the given array. */ + function get_attr_list($attribs) + { + while (list($attr_name, $attr_value) = each($attribs)) + { + $attr_name = strtolower($attr_name); + $attr_list .= " $attr_name=\"$attr_value\""; + } + + return $attr_list; + } + /** Append $data to the last element of the content of the current_tpl. */ function append($data) { ! if ($this->current_tpl==UNDEFINED) { print $data; *************** *** 423,430 **** /** * Parsing of the current_tpl has finished; ! * store it in template collection (in $webPage) ! * and make current the top of the stack. */ ! function pop_current_tpl() { if ($this->debug) --- 473,480 ---- /** * Parsing of the current_tpl has finished; ! * pop it and store it in template collection (in $webPage). ! * Normalize the empty space of the template as well. */ ! function pop_current_tpl($normalize =true) { if ($this->debug) *************** *** 444,448 **** array_pop($this->tpl_stack); ! $tpl->normalize_space(); //add the template to the collection of templates --- 494,498 ---- array_pop($this->tpl_stack); ! if ($normalize) $tpl->normalize_space(); //add the template to the collection of templates *************** *** 486,494 **** $this->push_current_tpl($tpl); } - function end_TEMPLATE() - { - $tpl = $this->pop_current_tpl(); - $this->link_template($tpl); - } function start_IF($attribs) --- 536,539 ---- *************** *** 497,505 **** $this->push_current_tpl($tpl); } - function end_IF() - { - $tpl = $this->pop_current_tpl(); - $this->link_template($tpl); - } function start_REPEAT($attribs) --- 542,545 ---- *************** *** 509,517 **** $this->push_current_tpl($tpl); } - function end_REPEAT() - { - $tpl = $this->pop_current_tpl(); - $this->link_template($tpl); - } function start_IFEMPTY($attribs) --- 549,552 ---- *************** *** 589,597 **** $this->push_current_tpl($tpl); } - function end_RSNAVIG() - { - $tpl = $this->pop_current_tpl(); - $this->link_template($tpl); - } function start_HEAD($attribs) --- 624,627 ---- *************** *** 673,678 **** function end_WEBBOX() { - global $webPage, $tplVars; - $webClassTpl = $this->pop_current_tpl(); $this->copy_mode = false; --- 703,706 ---- *************** *** 693,696 **** --- 721,725 ---- //parse the content of the class into the object + global $tplVars; $tplVars->pushScope(); $tplVars->addVar("./", $webClassTpl->path); *************** *** 700,704 **** $tpl->after_parse(); $tplVars->popScope(); - $webPage->addTemplate($tpl); } --- 729,732 ---- *************** *** 755,760 **** function start_WEBOBJECT($attribs) { - global $webPage, $tplVars; - //get the attributes of the webobject $class_name = $attribs['CLASS']; --- 783,786 ---- *************** *** 800,803 **** --- 826,830 ---- //parse the content of the class into the object + global $tplVars; $tplVars->pushScope(); $tplVars->addVar("./", $webClassTpl->path); *************** *** 807,811 **** $tpl->after_parse(); $tplVars->popScope(); - $webPage->addTemplate($tpl); } --- 834,837 ---- *************** *** 813,817 **** { static $tpl_id = "Recordset_001"; ! $tpl = new Template($tpl_id++, 'Recordset'); $id = $attribs['ID']; $type = (isset($attribs['TYPE']) ? $attribs['TYPE'] : UNDEFINED); --- 839,843 ---- { static $tpl_id = "Recordset_001"; ! $tpl = new Template($tpl_id++, 'RecordsetTpl'); $id = $attribs['ID']; $type = (isset($attribs['TYPE']) ? $attribs['TYPE'] : UNDEFINED); *************** *** 869,873 **** { static $tpl_id = "dbCommand_001"; ! $tpl = new Template($tpl_id++, 'dbCommand'); $id = $attribs['ID']; $tpl->addVar('ID', $id); --- 895,899 ---- { static $tpl_id = "dbCommand_001"; ! $tpl = new Template($tpl_id++, 'dbCommandTpl'); $id = $attribs['ID']; $tpl->addVar('ID', $id); *************** *** 888,892 **** { static $tpl_id = "Query_001"; ! $tpl = new Template($tpl_id++, 'Query'); $this->push_current_tpl($tpl); } --- 914,918 ---- { static $tpl_id = "Query_001"; ! $tpl = new Template($tpl_id++, 'QueryTpl'); $this->push_current_tpl($tpl); } *************** *** 906,910 **** $var_name = $attribs['NAME']; ! $tpl = new Template($tpl_id++, 'Var'); $tpl->addVar('name', $var_name); $this->push_current_tpl($tpl); --- 932,936 ---- $var_name = $attribs['NAME']; ! $tpl = new Template($tpl_id++, 'VarTpl'); $tpl->addVar('name', $var_name); $this->push_current_tpl($tpl); *************** *** 918,931 **** } ! /** returns a string with the attributes in the given array */ ! function get_attr_list($attribs) { ! while (list($attr_name, $attr_value) = each($attribs)) ! { ! $attr_name = strtolower($attr_name); ! $attr_list .= " $attr_name=\"$attr_value\""; ! } ! return $attr_list; } --- 944,989 ---- } ! function start_PRE($attribs) { ! static $tpl_id = "Pre_001"; ! $tpl = new Template($tpl_id++, 'PreTpl'); ! $tpl->addVar('attr_list', $this->get_attr_list($attribs)); ! $this->push_current_tpl($tpl); ! } ! function end_PRE() ! { ! //the param 'false' in order not to normalize space ! $tpl = $this->pop_current_tpl(false); ! $this->link_template($tpl); ! } ! function start_XMP($attribs) ! { ! static $tpl_id = "Xmp_001"; ! $tpl = new Template($tpl_id++, 'XmpTpl'); ! $tpl->addVar('attr_list', $this->get_attr_list($attribs)); ! $this->push_current_tpl($tpl); ! } ! function end_XMP() ! { ! //the param 'false' in order not to normalize space ! $tpl = $this->pop_current_tpl(false); ! $this->link_template($tpl); ! } ! ! function start_EXAMPLE($attribs) ! { ! static $tpl_id = "Example_001"; ! $tpl = new Template($tpl_id++, 'ExampleTpl'); ! $tpl->addVar('attr_list', $this->get_attr_list($attribs)); ! $this->push_current_tpl($tpl); ! $this->copy_mode = true; ! } ! function end_EXAMPLE() ! { ! $this->copy_mode = false; ! //the param 'false' in order not to normalize space ! $tpl = $this->pop_current_tpl(false); ! $this->link_template($tpl); } *************** *** 935,949 **** function print_stack() { ! print "\$this->current_tpl".$this->current_tpl->toHtmlTable(); for ($i=sizeof($this->tpl_stack)-1; $i >= 0; $i--) { if (gettype($this->tpl_stack[$i])=="object") { ! print "\$this->tpl_stack[$i]"; ! print $this->tpl_stack[$i]->id."\n"; } else { ! print "\$this->tpl_stack[$i]='".$this->tpl_stack[$i]."'\n"; } } --- 993,1011 ---- function print_stack() { ! print "The state of the tpl_stack:\n"; ! print " * ->: "; ! print $this->current_tpl->type; ! print " (".$this->current_tpl->id.")\n"; for ($i=sizeof($this->tpl_stack)-1; $i >= 0; $i--) { if (gettype($this->tpl_stack[$i])=="object") { ! print " * $i: "; ! print $this->tpl_stack[$i]->type; ! print " (".$this->tpl_stack[$i]->id.")\n"; } else { ! print " * $i: ".$this->tpl_stack[$i]."\n"; } } |