[phpwebapp-commits] CVS: web_app/parser package.ParseRender.php,1.4,1.5 class.WebPage.php,1.12,1.13
Brought to you by:
dashohoxha
From: Dashamir H. <das...@us...> - 2004-07-22 16:25:50
|
Update of /cvsroot/phpwebapp/web_app/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9224/parser Modified Files: package.ParseRender.php class.WebPage.php class.WebObjectTpl.php class.WebObject.php class.WebClassTpl.php class.VarStack.php class.Template.php class.RepeatTpl.php class.Render.php class.RSNavigTpl.php class.Parser.php class.MainTpl.php class.IfTpl.php class.FileTpl.php Log Message: reformated and modified the copyleft notice Index: package.ParseRender.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/parser/package.ParseRender.php,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** package.ParseRender.php 13 Jul 2004 16:14:48 -0000 1.4 --- package.ParseRender.php 22 Jul 2004 16:25:37 -0000 1.5 *************** *** 1,21 **** <?php /* ! Copyright 2001,2002,2003 Dashamir Hoxha, das...@us... ! This file is part of phpWebApp. ! phpWebApp is free software; you can redistribute it and/or modify ! it under the terms of the GNU General Public License as published by ! the Free Software Foundation; either version 2 of the License, or ! (at your option) any later version. ! phpWebApp is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with phpWebApp; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ --- 1,22 ---- <?php /* ! This file is part of phpWebApp, which is a framework for building web ! application based on relational databases. ! Copyright 2001,2002,2003,2004 Dashamir Hoxha, das...@us... ! phpWebApp is free software; you can redistribute it and/or modify it ! under the terms of the GNU General Public License as published by the ! Free Software Foundation; either version 2 of the License, or (at your ! option) any later version. ! phpWebApp is distributed in the hope that it will be useful, but ! WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with phpWebApp; if not, write to the Free Software Foundation, ! Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Index: class.WebPage.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/parser/class.WebPage.php,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** class.WebPage.php 15 Jul 2004 14:46:04 -0000 1.12 --- class.WebPage.php 22 Jul 2004 16:25:37 -0000 1.13 *************** *** 1,21 **** <?php /* ! Copyright 2001,2002,2003 Dashamir Hoxha, das...@us... ! This file is part of phpWebApp. ! phpWebApp is free software; you can redistribute it and/or modify ! it under the terms of the GNU General Public License as published by ! the Free Software Foundation; either version 2 of the License, or ! (at your option) any later version. ! phpWebApp is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with phpWebApp; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ --- 1,22 ---- <?php /* ! This file is part of phpWebApp, which is a framework for building web ! application based on relational databases. ! Copyright 2001,2002,2003,2004 Dashamir Hoxha, das...@us... ! phpWebApp is free software; you can redistribute it and/or modify it ! under the terms of the GNU General Public License as published by the ! Free Software Foundation; either version 2 of the License, or (at your ! option) any later version. ! phpWebApp is distributed in the hope that it will be useful, but ! WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with phpWebApp; if not, write to the Free Software Foundation, ! Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ *************** *** 55,84 **** function WebPage() ! { ! $this->collect = false; ! $this->html_page = ""; ! $this->tpl_collection = array(); ! $this->rs_collection = array(); ! $this->messages = array(); ! $this->dbg_messages = array(); ! $this->timer = new Timer; ! } /** Append the given string to the content of the <head> element. */ function append_to_head($str) ! { ! $contents = $this->tpl_collection["HeadTpl"]->contents; ! $contents = ereg_replace('</head>', $str.'</head>', $contents); ! $this->tpl_collection["HeadTpl"]->contents = $contents; ! } /** Append the given string to the content of the <body> element. */ function append_to_body($str) ! { ! $this->tpl_collection["BodyTpl"]->contents .= $str; ! } /** --- 56,85 ---- function WebPage() ! { ! $this->collect = false; ! $this->html_page = ""; ! $this->tpl_collection = array(); ! $this->rs_collection = array(); ! $this->messages = array(); ! $this->dbg_messages = array(); ! $this->timer = new Timer; ! } /** Append the given string to the content of the <head> element. */ function append_to_head($str) ! { ! $contents = $this->tpl_collection["HeadTpl"]->contents; ! $contents = ereg_replace('</head>', $str.'</head>', $contents); ! $this->tpl_collection["HeadTpl"]->contents = $contents; ! } /** Append the given string to the content of the <body> element. */ function append_to_body($str) ! { ! $this->tpl_collection["BodyTpl"]->contents .= $str; ! } /** *************** *** 87,105 **** */ function link_to_body(&$tpl) ! { ! $this->tpl_collection["BodyTpl"]->contents .= '&&'.$tpl->id.';;'; ! } /** Adds a template in the template collection. */ function addTemplate($tpl) ! { ! if (!isset($tpl->id)) ! { ! print "Error:WebPage:addTemplate: unidentified template.\n"; ! $tpl->toText(); ! return; ! } ! $this->tpl_collection[$tpl->id] = $tpl; ! } /** --- 88,106 ---- */ function link_to_body(&$tpl) ! { ! $this->tpl_collection["BodyTpl"]->contents .= '&&'.$tpl->id.';;'; ! } /** Adds a template in the template collection. */ function addTemplate($tpl) ! { ! if (!isset($tpl->id)) ! { ! print "Error:WebPage:addTemplate: unidentified template.\n"; ! $tpl->toText(); ! return; ! } ! $this->tpl_collection[$tpl->id] = $tpl; ! } /** *************** *** 108,122 **** */ function getTemplate($tpl_id) ! { ! if ( !isset($this->tpl_collection[$tpl_id]) ) ! { ! return UNDEFINED; ! } ! else ! { ! $tpl = &$this->tpl_collection[$tpl_id]; ! return $tpl; ! } ! } /** --- 109,123 ---- */ function getTemplate($tpl_id) ! { ! if ( !isset($this->tpl_collection[$tpl_id]) ) ! { ! return UNDEFINED; ! } ! else ! { ! $tpl = &$this->tpl_collection[$tpl_id]; ! return $tpl; ! } ! } /** *************** *** 125,161 **** */ function getObject($obj_id) ! { ! $tpl = $this->getTemplate($obj_id); ! if ($tpl==UNDEFINED) ! { ! return UNDEFINED; ! } ! else if ($tpl->type=="WebObjectTpl") ! { ! return $tpl; ! } ! else ! { ! return UNDEFINED; ! } ! } /** Adds a recordset in the recordset collection. */ function addRecordset(&$rs) ! { ! static $rsId = "recordset_00"; ! if (!isset($rs->ID)) ! { ! print WebApp::error_msg("Error:WebPage::addRecordset(): unidentified recordset.\n"); ! print $rs->toHtmlTable(); ! return; ! } ! else if ($rs->ID==UNDEFINED) ! { ! $rsId++; ! $rs->ID = $rsId; ! } ! $this->rs_collection[$rs->ID] = $rs; ! } /** --- 126,162 ---- */ function getObject($obj_id) ! { ! $tpl = $this->getTemplate($obj_id); ! if ($tpl==UNDEFINED) ! { ! return UNDEFINED; ! } ! else if ($tpl->type=="WebObjectTpl") ! { ! return $tpl; ! } ! else ! { ! return UNDEFINED; ! } ! } /** Adds a recordset in the recordset collection. */ function addRecordset(&$rs) ! { ! static $rsId = "recordset_00"; ! if (!isset($rs->ID)) ! { ! print WebApp::error_msg("Error:WebPage::addRecordset(): unidentified recordset.\n"); ! print $rs->toHtmlTable(); ! return; ! } ! else if ($rs->ID==UNDEFINED) ! { ! $rsId++; ! $rs->ID = $rsId; ! } ! $this->rs_collection[$rs->ID] = $rs; ! } /** *************** *** 164,186 **** */ function getRecordset($rs_id) ! { ! if ( !isset($this->rs_collection[$rs_id]) ) ! { ! return UNDEFINED; ! } ! else ! { ! $rs = &$this->rs_collection[$rs_id]; ! return $rs; ! } ! } /** Add a debug message to the list of debug messages. */ function addDbgMsg($dbg_msg, $comment ="") ! { ! $len = sizeof($this->dbg_messages); ! $this->dbg_messages[$len]["dbg_msg"] = $dbg_msg; ! $this->dbg_messages[$len]["comment"] = $comment; ! } /** --- 165,187 ---- */ function getRecordset($rs_id) ! { ! if ( !isset($this->rs_collection[$rs_id]) ) ! { ! return UNDEFINED; ! } ! else ! { ! $rs = &$this->rs_collection[$rs_id]; ! return $rs; ! } ! } /** Add a debug message to the list of debug messages. */ function addDbgMsg($dbg_msg, $comment ="") ! { ! $len = sizeof($this->dbg_messages); ! $this->dbg_messages[$len]["dbg_msg"] = $dbg_msg; ! $this->dbg_messages[$len]["comment"] = $comment; ! } /** *************** *** 189,226 **** */ function messages_to_js() ! { ! 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++) ! { ! $msg = $this->messages[$i]; ! $msg = str_replace("\n", '\n', $msg); //replace new lines with '\n' ! $msg = str_replace("'", "\\'", $msg); //escape single quotes ! $js .= "\talert('$msg');\n"; ! } ! $js .= "//]]>\n"; ! $js .= "</script>\n"; ! return $js; ! } function print_dbg_messages() ! { ! $nr = sizeof($this->dbg_messages); ! if ($nr==0) return; ! print "\n<hr/>\n"; ! print "<strong>Debug Messages:</strong><br/>\n"; ! for ($i=0; $i < $nr; $i++) ! { ! $dbg_msg = $this->dbg_messages[$i]["dbg_msg"]; ! $comment = $this->dbg_messages[$i]["comment"]; ! if ($comment<>"") print $comment." : "; ! print $dbg_msg."<br/>\n"; ! } ! print "\n<hr/>\n"; ! } /*------------------ debug functions --------------------------*/ --- 190,227 ---- */ function messages_to_js() ! { ! 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++) ! { ! $msg = $this->messages[$i]; ! $msg = str_replace("\n", '\n', $msg); //replace new lines with '\n' ! $msg = str_replace("'", "\\'", $msg); //escape single quotes ! $js .= "\talert('$msg');\n"; ! } ! $js .= "//]]>\n"; ! $js .= "</script>\n"; ! return $js; ! } function print_dbg_messages() ! { ! $nr = sizeof($this->dbg_messages); ! if ($nr==0) return; ! print "\n<hr/>\n"; ! print "<strong>Debug Messages:</strong><br/>\n"; ! for ($i=0; $i < $nr; $i++) ! { ! $dbg_msg = $this->dbg_messages[$i]["dbg_msg"]; ! $comment = $this->dbg_messages[$i]["comment"]; ! if ($comment<>"") print $comment." : "; ! print $dbg_msg."<br/>\n"; ! } ! print "\n<hr/>\n"; ! } /*------------------ debug functions --------------------------*/ *************** *** 228,272 **** /** (debug) Outputs the data of each template in $this->tpl_collection. */ function template_list() ! { ! $html = "<a name='top' id='top'> </a>\n"; ! $html .= "<div class='webapp'>\n"; ! $html .= "<strong>List of Templates of the Page:</strong>\n"; ! $html .= "<ul>\n"; ! reset($this->tpl_collection); ! while ( list($tpl_id, $tpl) = each($this->tpl_collection) ) ! { ! //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"; ! } ! $html .= "</ul>\n"; ! $html .= "</div>\n"; ! //print each template ! reset($this->tpl_collection); ! while ( list($tplID, $tpl) = each($this->tpl_collection) ) ! { ! //don't output the appended templates ! if (ereg('web_app/append/append.html$', $tpl->id)) break; ! $html .= $tpl->toHtmlTable(); ! } ! $html .= "<hr />\n"; ! return $html; ! } /** (debug) Returns the structure of the loaded templates as a tree. */ function tpl_to_tree() //for debugging parse() ! { ! $tree = "<hr />\n"; ! $tree .= "<a name='top' id='top'> </a>\n"; ! $tree .= "<pre class='webapp'>\n"; ! $tree .= "<strong>The tree structure of the templates:</strong>\n\n"; ! $tree .= $this->rootTpl->to_tree(""); ! $tree .= "</pre>\n"; ! return $tree; ! } /** --- 229,273 ---- /** (debug) Outputs the data of each template in $this->tpl_collection. */ function template_list() ! { ! $html = "<a name='top' id='top'> </a>\n"; ! $html .= "<div class='webapp'>\n"; ! $html .= "<strong>List of Templates of the Page:</strong>\n"; ! $html .= "<ul>\n"; ! reset($this->tpl_collection); ! while ( list($tpl_id, $tpl) = each($this->tpl_collection) ) ! { ! //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"; ! } ! $html .= "</ul>\n"; ! $html .= "</div>\n"; ! //print each template ! reset($this->tpl_collection); ! while ( list($tplID, $tpl) = each($this->tpl_collection) ) ! { ! //don't output the appended templates ! if (ereg('web_app/append/append.html$', $tpl->id)) break; ! $html .= $tpl->toHtmlTable(); ! } ! $html .= "<hr />\n"; ! return $html; ! } /** (debug) Returns the structure of the loaded templates as a tree. */ function tpl_to_tree() //for debugging parse() ! { ! $tree = "<hr />\n"; ! $tree .= "<a name='top' id='top'> </a>\n"; ! $tree .= "<pre class='webapp'>\n"; ! $tree .= "<strong>The tree structure of the templates:</strong>\n\n"; ! $tree .= $this->rootTpl->to_tree(""); ! $tree .= "</pre>\n"; ! return $tree; ! } /** *************** *** 276,290 **** */ 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) ) ! { ! $html_recs .= $rs->toHtmlTable(); ! } ! $html_recs .= "<hr />\n"; ! return $html_recs; ! } } ?> \ No newline at end of file --- 277,291 ---- */ 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) ) ! { ! $html_recs .= $rs->toHtmlTable(); ! } ! $html_recs .= "<hr />\n"; ! return $html_recs; ! } } ?> \ No newline at end of file Index: class.WebObjectTpl.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/parser/class.WebObjectTpl.php,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** class.WebObjectTpl.php 13 Jul 2004 13:18:08 -0000 1.8 --- class.WebObjectTpl.php 22 Jul 2004 16:25:37 -0000 1.9 *************** *** 1,21 **** <?php /* ! Copyright 2001,2002,2003 Dashamir Hoxha, das...@us... ! This file is part of phpWebApp. ! phpWebApp is free software; you can redistribute it and/or modify ! it under the terms of the GNU General Public License as published by ! the Free Software Foundation; either version 2 of the License, or ! (at your option) any later version. ! phpWebApp is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with phpWebApp; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ --- 1,22 ---- <?php /* ! This file is part of phpWebApp, which is a framework for building web ! application based on relational databases. ! Copyright 2001,2002,2003,2004 Dashamir Hoxha, das...@us... ! phpWebApp is free software; you can redistribute it and/or modify it ! under the terms of the GNU General Public License as published by the ! Free Software Foundation; either version 2 of the License, or (at your ! option) any later version. ! phpWebApp is distributed in the hope that it will be useful, but ! WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with phpWebApp; if not, write to the Free Software Foundation, ! Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ *************** *** 46,82 **** /** Constructor */ function WebObjectTpl($webObjId) ! { ! //call constructor of the superclass ! $this->Template($webObjId, "WebObjectTpl"); ! //increment the object counter of the class and set the count ! $this->class->obj_count++; ! $this->obj_count = $this->class->obj_count; ! } /** This is called before the template of the WebObject is parsed. */ function before_parse() ! { ! //add the state vars of this webobj to the current scope ! global $tplVars; ! $tplVars->addVars($this->getSVars()); ! //save the current scope of the var stack ! $this->scope = $tplVars->getCurrentScope(); ! //call the event handler ! $this->handle_event(); ! //call the function onParse ! $this->onParse(); ! } /** This is called after the template of the WebObject is parsed. */ function after_parse() ! { ! $this->scope = 0; ! //call the function afterParse ! $this->afterParse(); ! } /** --- 47,83 ---- /** Constructor */ function WebObjectTpl($webObjId) ! { ! //call constructor of the superclass ! $this->Template($webObjId, "WebObjectTpl"); ! //increment the object counter of the class and set the count ! $this->class->obj_count++; ! $this->obj_count = $this->class->obj_count; ! } /** This is called before the template of the WebObject is parsed. */ function before_parse() ! { ! //add the state vars of this webobj to the current scope ! global $tplVars; ! $tplVars->addVars($this->getSVars()); ! //save the current scope of the var stack ! $this->scope = $tplVars->getCurrentScope(); ! //call the event handler ! $this->handle_event(); ! //call the function onParse ! $this->onParse(); ! } /** This is called after the template of the WebObject is parsed. */ function after_parse() ! { ! $this->scope = 0; ! //call the function afterParse ! $this->afterParse(); ! } /** *************** *** 89,147 **** */ function handle_event() ! { ! global $event; ! if ( $event->target==$this->id ! or $event->target=="any" ) ! { ! $method_name = "on_".$event->name; ! if (method_exists($this, $method_name)) ! { ! //the webclass has declared a specific ! //event handler for this event, call it ! $this->$method_name($event->args); ! } ! else ! { ! //call the general event handler of the webox ! $this->eventHandler($event); ! } ! } ! } /** Returns an array with all the evaluated parameters. */ function getParams() ! { ! $params = $this->params; ! reset($params); ! while ( list($p_name,$expr) = each($params) ) ! { ! $expr = WebApp::replaceVars($expr); ! //$params[$p_name] = WebApp::evaluate($expr); ! $params[$p_name] = $expr; ! } ! return $params; ! } function is_webbox() ! { ! $pos = strpos($this->id, "::"); ! if ($pos===false) return true; ! else return false; ! } function get_obj_name() ! { ! $pos = strpos($this->id, "::"); ! if ($pos===false) return $this->id; //this is a webbox ! else return substr($this->id, $pos+2); ! } function get_class_name() ! { ! $pos = strpos($this->id, "::"); ! if ($pos===false) return $this->id; //this is a webbox ! else return substr($this->id, 0, $pos); ! } /** --- 90,148 ---- */ function handle_event() ! { ! global $event; ! if ( $event->target==$this->id ! or $event->target=="any" ) ! { ! $method_name = "on_".$event->name; ! if (method_exists($this, $method_name)) ! { ! //the webclass has declared a specific ! //event handler for this event, call it ! $this->$method_name($event->args); ! } ! else ! { ! //call the general event handler of the webox ! $this->eventHandler($event); ! } ! } ! } /** Returns an array with all the evaluated parameters. */ function getParams() ! { ! $params = $this->params; ! reset($params); ! while ( list($p_name,$expr) = each($params) ) ! { ! $expr = WebApp::replaceVars($expr); ! //$params[$p_name] = WebApp::evaluate($expr); ! $params[$p_name] = $expr; ! } ! return $params; ! } function is_webbox() ! { ! $pos = strpos($this->id, "::"); ! if ($pos===false) return true; ! else return false; ! } function get_obj_name() ! { ! $pos = strpos($this->id, "::"); ! if ($pos===false) return $this->id; //this is a webbox ! else return substr($this->id, $pos+2); ! } function get_class_name() ! { ! $pos = strpos($this->id, "::"); ! if ($pos===false) return $this->id; //this is a webbox ! else return substr($this->id, 0, $pos); ! } /** *************** *** 151,172 **** */ function getObjVars() ! { ! $vars = array( ! "obj_count" => $this->obj_count, ! "obj_id" => $this->id, ! "obj_name" => $this->get_obj_name(), ! "class_name"=> $this->get_class_name() ! ); ! return $vars; ! } /** debug */ function attribs2html() { ! reset($this->params); ! while ( list($p_name,$expr) = each($this->params) ) ! { ! $params .= " $p_name=($expr); "; ! } ! $html = Template::attribs2html() . " <tr> <td bgcolor='#eeeeee' valign='top' align='right'>Params:</td> --- 152,173 ---- */ function getObjVars() ! { ! $vars = array( ! "obj_count" => $this->obj_count, ! "obj_id" => $this->id, ! "obj_name" => $this->get_obj_name(), ! "class_name"=> $this->get_class_name() ! ); ! return $vars; ! } /** debug */ function attribs2html() { ! reset($this->params); ! while ( list($p_name,$expr) = each($this->params) ) ! { ! $params .= " $p_name=($expr); "; ! } ! $html = Template::attribs2html() . " <tr> <td bgcolor='#eeeeee' valign='top' align='right'>Params:</td> *************** *** 178,183 **** </tr> "; ! return $html; ! } } ?> \ No newline at end of file --- 179,184 ---- </tr> "; ! return $html; ! } } ?> \ No newline at end of file Index: class.WebObject.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/parser/class.WebObject.php,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** class.WebObject.php 15 Jul 2004 14:46:04 -0000 1.9 --- class.WebObject.php 22 Jul 2004 16:25:37 -0000 1.10 *************** *** 1,21 **** <?php /* ! Copyright 2001,2002,2003 Dashamir Hoxha, das...@us... ! This file is part of phpWebApp. ! phpWebApp is free software; you can redistribute it and/or modify ! it under the terms of the GNU General Public License as published by ! the Free Software Foundation; either version 2 of the License, or ! (at your option) any later version. ! phpWebApp is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with phpWebApp; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ --- 1,22 ---- <?php /* ! This file is part of phpWebApp, which is a framework for building web ! application based on relational databases. ! Copyright 2001,2002,2003,2004 Dashamir Hoxha, das...@us... ! phpWebApp is free software; you can redistribute it and/or modify it ! under the terms of the GNU General Public License as published by the ! Free Software Foundation; either version 2 of the License, or (at your ! option) any later version. ! phpWebApp is distributed in the hope that it will be useful, but ! WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with phpWebApp; if not, write to the Free Software Foundation, ! Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ *************** *** 73,147 **** /** empty constructor */ function WebObject() ! { ! //if the class that extends WebObject defines a constructor, ! //this one will not be called during the creation of the object, ! //and if it does not define a constructor this one will be called; ! //that is why the construction of this object is not done here ! //but is done in another function that is called explicitly from ! //the parser ! } function construct_WebObject($id) ! { ! //call the constructor of the superclass ! $this->WebObjectTpl($id); ! //save the current scope ! global $tplVars; ! $this->scope = $tplVars->getCurrentScope(); ! } function getStateVars() ! { ! $sVars = $this->getSVars(); ! if (sizeof($sVars)==0) ! { ! //this is the first time that this webobj is ! //created (during the session), call init() ! $this->init(); ! //this variable is set so that the next time ! //init is not called again ! $this->addSVar("initialized", "true"); ! } ! } /** Add state var (session var). */ function addSVar($var_name, $var_value, $db =false) ! { ! global $session; ! $v_name = $this->id."->".$var_name; ! $session->addVar($v_name, $var_value, $db); ! } /** $arr_vars is a list of vars (an associative array). */ function addSVars($arr_vars, $db =false) ! { ! while (list($var_name,$var_value) = each($arr_vars)) ! { ! $this->addSVar($var_name, $var_value, $db); ! } ! } /** get a state var of the webobj */ function getSVar($var_name) ! { ! $v_name = $this->id."->".$var_name; ! global $session; ! $var_value = $session->getVar($v_name); ! return $var_value; ! } /** set a state var of the webobj */ function setSVar($var_name, $var_value) ! { ! //set it in the session ! $v_name = $this->id."->".$var_name; ! WebApp::setSVar($v_name, $var_value); ! //change it to the var stack as well ! global $tplVars; ! $tplVars->addVar($var_name, $var_value, $this->scope); ! } /** --- 74,148 ---- /** empty constructor */ function WebObject() ! { ! //if the class that extends WebObject defines a constructor, ! //this one will not be called during the creation of the object, ! //and if it does not define a constructor this one will be called; ! //that is why the construction of this object is not done here ! //but is done in another function that is called explicitly from ! //the parser ! } function construct_WebObject($id) ! { ! //call the constructor of the superclass ! $this->WebObjectTpl($id); ! //save the current scope ! global $tplVars; ! $this->scope = $tplVars->getCurrentScope(); ! } function getStateVars() ! { ! $sVars = $this->getSVars(); ! if (sizeof($sVars)==0) ! { ! //this is the first time that this webobj is ! //created (during the session), call init() ! $this->init(); ! //this variable is set so that the next time ! //init is not called again ! $this->addSVar("initialized", "true"); ! } ! } /** Add state var (session var). */ function addSVar($var_name, $var_value, $db =false) ! { ! global $session; ! $v_name = $this->id."->".$var_name; ! $session->addVar($v_name, $var_value, $db); ! } /** $arr_vars is a list of vars (an associative array). */ function addSVars($arr_vars, $db =false) ! { ! while (list($var_name,$var_value) = each($arr_vars)) ! { ! $this->addSVar($var_name, $var_value, $db); ! } ! } /** get a state var of the webobj */ function getSVar($var_name) ! { ! $v_name = $this->id."->".$var_name; ! global $session; ! $var_value = $session->getVar($v_name); ! return $var_value; ! } /** set a state var of the webobj */ function setSVar($var_name, $var_value) ! { ! //set it in the session ! $v_name = $this->id."->".$var_name; ! WebApp::setSVar($v_name, $var_value); ! //change it to the var stack as well ! global $tplVars; ! $tplVars->addVar($var_name, $var_value, $this->scope); ! } /** *************** *** 153,196 **** */ function getSVars($type =UNDEFINED) ! { ! global $session; ! switch ($type) ! { ! case "DB": ! $arr_vars = $session->dbVars; ! break; ! case "JS": ! $arr_vars = $session->Vars; ! break; ! default: ! print WebApp::warning_msg("WebObject::getSVars(): unreckognized \$type '$type'."); ! case UNDEFINED: ! $arr_vars = array_merge($session->Vars, $session->dbVars); ! break; ! } ! $stateVars = array(); ! $pattern = "^".$this->id."->(.*)"; ! while (list($var_name,$var_value) = each($arr_vars)) ! { ! if (ereg($pattern, $var_name, $regs)) ! { ! $v_name = $regs[1]; ! $stateVars[$v_name] = $var_value; ! } ! } ! return $stateVars; ! } /** $arr_vars is an associative array */ function setSVars($arr_vars) ! { ! while (list($var_name,$var_value) = each($arr_vars)) ! { ! $this->setSVar($var_name, $var_value); ! } ! } /** --- 154,197 ---- */ function getSVars($type =UNDEFINED) ! { ! global $session; ! switch ($type) ! { ! case "DB": ! $arr_vars = $session->dbVars; ! break; ! case "JS": ! $arr_vars = $session->Vars; ! break; ! default: ! print WebApp::warning_msg("WebObject::getSVars(): unreckognized \$type '$type'."); ! case UNDEFINED: ! $arr_vars = array_merge($session->Vars, $session->dbVars); ! break; ! } ! $stateVars = array(); ! $pattern = "^".$this->id."->(.*)"; ! while (list($var_name,$var_value) = each($arr_vars)) ! { ! if (ereg($pattern, $var_name, $regs)) ! { ! $v_name = $regs[1]; ! $stateVars[$v_name] = $var_value; ! } ! } ! return $stateVars; ! } /** $arr_vars is an associative array */ function setSVars($arr_vars) ! { ! while (list($var_name,$var_value) = each($arr_vars)) ! { ! $this->setSVar($var_name, $var_value); ! } ! } /** *************** *** 199,204 **** */ function state2html() ! { ! $html = " <br /> <a name='$this->id' id='$this->id'> </a>[<a href='tree'>Top</a>] --- 200,205 ---- */ function state2html() ! { ! $html = " <br /> <a name='$this->id' id='$this->id'> </a>[<a href='tree'>Top</a>] *************** *** 213,220 **** </tr>"; ! $sVars = $this->getSVars("JS"); ! while (list($var_name,$var_value) = each($sVars)) ! { ! $html .= " <tr> <td bgcolor='#f9f9f9'> </td> --- 214,221 ---- </tr>"; ! $sVars = $this->getSVars("JS"); ! while (list($var_name,$var_value) = each($sVars)) ! { ! $html .= " <tr> <td bgcolor='#f9f9f9'> </td> *************** *** 222,230 **** <td bgcolor='#f9f9ff'>$var_value</td> </tr>"; ! } ! $sVars = $this->getSVars("DB"); ! while (list($var_name,$var_value) = each($sVars)) ! { ! $html .= " <tr> <td bgcolor='#f9f9f9'>DB</td> --- 223,231 ---- <td bgcolor='#f9f9ff'>$var_value</td> </tr>"; ! } ! $sVars = $this->getSVars("DB"); ! while (list($var_name,$var_value) = each($sVars)) ! { ! $html .= " <tr> <td bgcolor='#f9f9f9'>DB</td> *************** *** 232,240 **** <td bgcolor='#f9f9ff'>$var_value</td> </tr>"; ! } ! $html .= "</table>"; ! return $html; ! } } ?> \ No newline at end of file --- 233,241 ---- <td bgcolor='#f9f9ff'>$var_value</td> </tr>"; ! } ! $html .= "</table>"; ! return $html; ! } } ?> \ No newline at end of file Index: class.WebClassTpl.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/parser/class.WebClassTpl.php,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** class.WebClassTpl.php 15 Jul 2004 13:36:13 -0000 1.10 --- class.WebClassTpl.php 22 Jul 2004 16:25:37 -0000 1.11 *************** *** 1,21 **** <?php /* ! Copyright 2001,2002,2003 Dashamir Hoxha, das...@us... ! This file is part of phpWebApp. ! phpWebApp is free software; you can redistribute it and/or modify ! it under the terms of the GNU General Public License as published by ! the Free Software Foundation; either version 2 of the License, or ! (at your option) any later version. ! phpWebApp is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with phpWebApp; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ --- 1,22 ---- <?php /* ! This file is part of phpWebApp, which is a framework for building web ! application based on relational databases. ! Copyright 2001,2002,2003,2004 Dashamir Hoxha, das...@us... ! phpWebApp is free software; you can redistribute it and/or modify it ! under the terms of the GNU General Public License as published by the ! Free Software Foundation; either version 2 of the License, or (at your ! option) any later version. ! phpWebApp is distributed in the hope that it will be useful, but ! WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with phpWebApp; if not, write to the Free Software Foundation, ! Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ *************** *** 39,75 **** function WebClassTpl($id, $path =UNDEFINED) ! { ! $this->Template($id, "WebClassTpl"); ! $this->path = $path; ! $this->params = array(); ! $this->obj_count = 0; ! } function before_parse() ! { ! //load the .db file of the webclass ! $this->parse_db_file(); ! //include the PHP class of the webClass ! $this->include_php_class(); ! //include the JS code of the webClass ! $this->include_js_code(); ! //include the CSS code of the webClass ! $this->include_css_code(); ! } /** Parse the .db file of the webclass, if it exists. */ function parse_db_file() ! { ! $fname = $this->path.$this->id.".db"; ! if (file_exists($fname)) ! { ! //parse the file ! global $parser; ! $parser->parse_file($fname); ! } ! } /** --- 40,76 ---- function WebClassTpl($id, $path =UNDEFINED) ! { ! $this->Template($id, "WebClassTpl"); ! $this->path = $path; ! $this->params = array(); ! $this->obj_count = 0; ! } function before_parse() ! { ! //load the .db file of the webclass ! $this->parse_db_file(); ! //include the PHP class of the webClass ! $this->include_php_class(); ! //include the JS code of the webClass ! $this->include_js_code(); ! //include the CSS code of the webClass ! $this->include_css_code(); ! } /** Parse the .db file of the webclass, if it exists. */ function parse_db_file() ! { ! $fname = $this->path.$this->id.".db"; ! if (file_exists($fname)) ! { ! //parse the file ! global $parser; ! $parser->parse_file($fname); ! } ! } /** *************** *** 79,97 **** */ function include_php_class() ! { ! $fname = $this->path."/".$this->id.".php"; ! if (file_exists($fname)) ! { ! include_once $fname; ! } ! else ! { ! //create a dummy class for this WebClass ! $class_name = $this->id; ! $arr_methods = get_class_methods($class_name); ! if (sizeof($arr_methods)==0) ! { ! $dummy_class_definition = ! "class $class_name extends WebObject { /** --- 80,98 ---- */ function include_php_class() ! { ! $fname = $this->path."/".$this->id.".php"; ! if (file_exists($fname)) ! { ! include_once $fname; ! } ! else ! { ! //create a dummy class for this WebClass ! $class_name = $this->id; ! $arr_methods = get_class_methods($class_name); ! if (sizeof($arr_methods)==0) ! { ! $dummy_class_definition = ! "class $class_name extends WebObject { /** *************** *** 105,112 **** } }"; ! eval($dummy_class_definition); ! } ! } ! } /** --- 106,113 ---- } }"; ! eval($dummy_class_definition); ! } ! } ! } /** *************** *** 116,129 **** */ function include_js_code() ! { ! $fname = $this->path.$this->id.".js"; ! if (file_exists($fname)) ! { ! 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); ! } ! } /** --- 117,130 ---- */ function include_js_code() ! { ! $fname = $this->path.$this->id.".js"; ! if (file_exists($fname)) ! { ! 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); ! } ! } /** *************** *** 133,156 **** */ function include_css_code() ! { ! $fname = $this->path.$this->id.".css"; ! if (file_exists($fname)) ! { ! global $webPage; ! $fname = WebApp::to_url($fname); ! $include_css = " <link type=\"text/css\" rel=\"stylesheet\" href=\"$fname\" />\n"; ! $webPage->append_to_head($include_css); ! } ! } /** for debug */ function attribs2html() ! { ! reset($this->params); ! while ( list($p_name,$expr) = each($this->params) ) ! { ! $params .= " $p_name=($expr); "; ! } ! $html = Template::attribs2html() . " <tr> <td bgcolor='#eeeeee' valign='top' align='right'>Path:</td> --- 134,157 ---- */ function include_css_code() ! { ! $fname = $this->path.$this->id.".css"; ! if (file_exists($fname)) ! { ! global $webPage; ! $fname = WebApp::to_url($fname); ! $include_css = " <link type=\"text/css\" rel=\"stylesheet\" href=\"$fname\" />\n"; ! $webPage->append_to_head($include_css); ! } ! } /** for debug */ function attribs2html() ! { ! reset($this->params); ! while ( list($p_name,$expr) = each($this->params) ) ! { ! $params .= " $p_name=($expr); "; ! } ! $html = Template::attribs2html() . " <tr> <td bgcolor='#eeeeee' valign='top' align='right'>Path:</td> *************** *** 162,167 **** </tr> "; ! return $html; ! } } ?> \ No newline at end of file --- 163,168 ---- </tr> "; ! return $html; ! } } ?> \ No newline at end of file Index: class.VarStack.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/parser/class.VarStack.php,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** class.VarStack.php 22 Jul 2004 09:41:24 -0000 1.7 --- class.VarStack.php 22 Jul 2004 16:25:37 -0000 1.8 *************** *** 1,21 **** <?php /* ! Copyright 2001,2002,2003 Dashamir Hoxha, das...@us... ! This file is part of phpWebApp. ! phpWebApp is free software; you can redistribute it and/or modify ! it under the terms of the GNU General Public License as published by ! the Free Software Foundation; either version 2 of the License, or ! (at your option) any later version. ! phpWebApp is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with phpWebApp; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ --- 1,22 ---- <?php /* ! This file is part of phpWebApp, which is a framework for building web ! application based on relational databases. ! Copyright 2001,2002,2003,2004 Dashamir Hoxha, das...@us... ! phpWebApp is free software; you can redistribute it and/or modify it ! under the terms of the GNU General Public License as published by the ! Free Software Foundation; either version 2 of the License, or (at your ! option) any later version. ! phpWebApp is distributed in the hope that it will be useful, but ! WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with phpWebApp; if not, write to the Free Software Foundation, ! Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ *************** *** 31,56 **** function VarStack() ! { ! $this->vars = array(); ! $this->pushScope(); ! } function pushScope() ! { ! array_push($this->vars, array()); ! } function popScope() ! { ! array_pop($this->vars); ! } /** Returns a number, which is the index of the current scope. */ function getCurrentScope() ! { ! $len = count($this->vars); ! $curr_scope = $len - 1; ! return $curr_scope; ! } /** --- 32,57 ---- function VarStack() ! { ! $this->vars = array(); ! $this->pushScope(); ! } function pushScope() ! { ! array_push($this->vars, array()); ! } function popScope() ! { ! array_pop($this->vars); ! } /** Returns a number, which is the index of the current scope. */ function getCurrentScope() ! { ! $len = count($this->vars); ! $curr_scope = $len - 1; ! return $curr_scope; ! } /** *************** *** 59,99 **** */ function addVar($var_name, $var_value, $scope_nr=UNDEFINED) ! { ! if ($scope_nr==UNDEFINED) //no scope is given ! { ! $scope_nr = $this->getCurrentScope(); ! $current_scope = &$this->vars[$scope_nr]; ! $current_scope[$var_name] = $var_value; ! } ! else ! { ! $len = count($this->vars); ! if ($scope_nr >= $len) return; ! $scope = &$this->vars[$scope_nr]; ! $scope[$var_name] = $var_value; ! } ! } /** Add a variable to the first scope. */ function addGlobalVar($var_name, $var_value) ! { ! $first_scope = &$this->vars[0]; ! $first_scope[$var_name] = $var_value; ! } /** Add a list of vars to the current scope. */ function addVars($arrVars) ! { ! $len = count($this->vars); ! $current_scope = &$this->vars[$len-1]; ! $current_scope = array_merge($current_scope, $arrVars); ! } /** Add a list of vars to the first scope. */ function addGlobalVars($arrVars) ! { ! $first_scope = &$this->vars[0]; ! $first_scope = array_merge($first_scope, $arrVars); ! } /** --- 60,100 ---- */ function addVar($var_name, $var_value, $scope_nr=UNDEFINED) ! { ! if ($scope_nr==UNDEFINED) //no scope is given ! { ! $scope_nr = $this->getCurrentScope(); ! $current_scope = &$this->vars[$scope_nr]; ! $current_scope[$var_name] = $var_value; ! } ! else ! { ! $len = count($this->vars); ! if ($scope_nr >= $len) return; ! $scope = &$this->vars[$scope_nr]; ! $scope[$var_name] = $var_value; ! } ! } /** Add a variable to the first scope. */ function addGlobalVar($var_name, $var_value) ! { ! $first_scope = &$this->vars[0]; ! $first_scope[$var_name] = $var_value; ! } /** Add a list of vars to the current scope. */ function addVars($arrVars) ! { ! $len = count($this->vars); ! $current_scope = &$this->vars[$len-1]; ! $current_scope = array_merge($current_scope, $arrVars); ! } /** Add a list of vars to the first scope. */ function addGlobalVars($arrVars) ! { ! $first_scope = &$this->vars[0]; ! $first_scope = array_merge($first_scope, $arrVars); ! } /** *************** *** 103,122 **** */ function getVar($var_name) ! { ! $found = false; ! $len = count($this->vars); ! for ($i = $len-1; $i>=0; $i--) ! { ! $scope = &$this->vars[$i]; ! if (isset($scope[$var_name])) ! { ! $found = true; ! $var_value = &$scope[$var_name]; ! break; ! } ! } ! if ($found) return $var_value; ! else return UNDEFINED; ! } ///////////////////////////////////////////////////////////////// --- 104,123 ---- */ function getVar($var_name) ! { ! $found = false; ! $len = count($this->vars); ! for ($i = $len-1; $i>=0; $i--) ! { ! $scope = &$this->vars[$i]; ! if (isset($scope[$var_name])) ! { ! $found = true; ! $var_value = &$scope[$var_name]; ! break; ! } ! } ! if ($found) return $var_value; ! else return UNDEFINED; ! } ///////////////////////////////////////////////////////////////// *************** *** 124,141 **** /** For debug; returns the var stack as an HTML table. */ function toHtmlTable() ! { ! $html = "<strong>VarStack</strong>\n"; ! $html .= "<table bgcolor='#aaaaaa' border='0' cellspacing='1' cellpadding='2'>"; ! $len = count($this->vars); ! for ($i = $len-1; $i>=0; $i--) ! { ! $html .= " <tr> <td bgcolor='#eeeeff' colspan='2' align='center'>Scope $i</td> </tr>"; ! $scope = &$this->vars[$i]; ! while (list($var_name,$var_value) = each($scope)) ! { ! $html .= " <tr> <td bgcolor='#eeeeee' align='right'>$var_name</td> --- 125,142 ---- /** For debug; returns the var stack as an HTML table. */ function toHtmlTable() ! { ! $html = "<strong>VarStack</strong>\n"; ! $html .= "<table bgcolor='#aaaaaa' border='0' cellspacing='1' cellpadding='2'>"; ! $len = count($this->vars); ! for ($i = $len-1; $i>=0; $i--) ! { ! $html .= " <tr> <td bgcolor='#eeeeff' colspan='2' align='center'>Scope $i</td> </tr>"; ! $scope = &$this->vars[$i]; ! while (list($var_name,$var_value) = each($scope)) ! { ! $html .= " <tr> <td bgcolor='#eeeeee' align='right'>$var_name</td> *************** *** 143,170 **** </tr> "; ! } ! reset($scope); ! } ! $html .= "</table>\n"; ! return $html; ! } /** For test and debug */ function test() ! { ! $vars = new VarStack; ! //$vars->pushScope(); ! $vars->addVars(array("a"=>"XXX", "b"=>"BBB", "c"=>"")); ! $vars->pushScope(); ! $vars->addVar("a", "XXX"); ! $vars->pushScope(); ! $vars->addVars(array("a"=>"AAA", "b"=>"YYY")); ! $vars->pushScope(); ! $vars->addGlobalVar("g1", "GGG"); ! /* print " var a='".$vars->getVar("a")."' \n"; print " var c='".$vars->getVar("c")."' \n"; --- 144,171 ---- </tr> "; ! } ! reset($scope); ! } ! $html .= "</table>\n"; ! return $html; ! } /** For test and debug */ function test() ! { ! $vars = new VarStack; ! //$vars->pushScope(); ! $vars->addVars(array("a"=>"XXX", "b"=>"BBB", "c"=>"")); ! $vars->pushScope(); ! $vars->addVar("a", "XXX"); ! $vars->pushScope(); ! $vars->addVars(array("a"=>"AAA", "b"=>"YYY")); ! $vars->pushScope(); ! $vars->addGlobalVar("g1", "GGG"); ! /* print " var a='".$vars->getVar("a")."' \n"; print " var c='".$vars->getVar("c")."' \n"; *************** *** 172,181 **** $vars->printOut(); return; ! */ ! $vars->popScope(); ! $vars->popScope(); ! /* print " var a='".$vars->getVar("a")."' \n"; print " var c='".$vars->getVar("c")."' \n"; --- 173,182 ---- $vars->printOut(); return; ! */ ! $vars->popScope(); ! $vars->popScope(); ! /* print " var a='".$vars->getVar("a")."' \n"; print " var c='".$vars->getVar("c")."' \n"; *************** *** 183,204 **** $vars->printOut(); return; ! */ ! $vars->pushScope(); ! $vars->addVars(array("a"=>"AAA", "b"=>"BBB")); ! $vars->pushScope(); ! $vars->addGlobalVar("g2", "GGG2"); ! $vars->addGlobalVar("g1", "GGG1"); ! $vars->addVar("a", "XXX"); ! $vars->pushScope(); ! $vars->addVars(array("a"=>"AAA", "b"=>"YYY")); ! print " var g1='".$vars->getVar("g1")."' \n"; ! print " var a='".$vars->getVar("a")."' \n"; ! print " var c='".$vars->getVar("c")."' \n"; ! print " var x='".$vars->getVar("x")."' \n"; ! $vars->printOut(); ! return; ! } } --- 184,205 ---- $vars->printOut(); return; ! */ ! $vars->pushScope(); ! $vars->addVars(array("a"=>"AAA", "b"=>"BBB")); ! $vars->pushScope(); ! $vars->addGlobalVar("g2", "GGG2"); ! $vars->addGlobalVar("g1", "GGG1"); ! $vars->addVar("a", "XXX"); ! $vars->pushScope(); ! $vars->addVars(array("a"=>"AAA", "b"=>"YYY")); ! print " var g1='".$vars->getVar("g1")."' \n"; ! print " var a='".$vars->getVar("a")."' \n"; ! print " var c='".$vars->getVar("c")."' \n"; ! print " var x='".$vars->getVar("x")."' \n"; ! $vars->printOut(); ! return; ! } } Index: class.Template.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/parser/class.Template.php,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** class.Template.php 15 Jul 2004 14:46:04 -0000 1.12 --- class.Template.php 22 Jul 2004 16:25:37 -0000 1.13 *************** *** 1,21 **** <?php /* ! Copyright 2001,2002,2003 Dashamir Hoxha, das...@us... ! This file is part of phpWebApp. ! phpWebApp is free software; you can redistribute it and/or modify ! it under the terms of the GNU General Public License as published by ! the Free Software Foundation; either version 2 of the License, or ! (at your option) any later version. ! phpWebApp is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with phpWebApp; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ --- 1,22 ---- <?php /* ! This file is part of phpWebApp, which is a framework for building web ! application based on relational databases. ! Copyright 2001,2002,2003,2004 Dashamir Hoxha, das...@us... ! phpWebApp is free software; you can redistribute it and/or modify it ! under the terms of the GNU General Public License as published by the ! Free Software Foundation; either version 2 of the License, or (at your ! option) any later version. ! phpWebApp is distributed in the hope that it will be useful, but ! WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with phpWebApp; if not, write to the Free Software Foundation, ! Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ *************** *** 49,79 **** /** Constructor */ function Template($tplId =UNDEFINED, $type ="Template") ! { ! static $default_id = "Template_01"; ! $this->id = ($tplId<>UNDEFINED ? $tplId : $default_id++); ! $this->type = $type; ! $this->vars = array(); ! } /** Adds a new variable in the array of variables. */ function addVar($var_name, $expression) ! { ! $var_name = $var_name; ! $this->vars[$var_name] = $expression; ! } /** Returns an array with all the evaluated variables. */ function getVars() ! { ! reset($this->vars); ! $tplVars = $this->vars; ! while ( list($var_name,$expr) = each($tplVars) ) ! { ! $expr = WebApp::replaceVars($expr); ! $tplVars[$var_name] = WebApp::evaluate($expr); ! } ! return $tplVars; ! } /** --- 50,80 ---- /** Constructor */ function Template($tplId =UNDEFINED, $type ="Template") ! { ! static $default_id = "Template_01"; ! $this->id = ($tplId<>UNDEFINED ? $tplId : $default_id++); ! $this->type = $type; ! $this->vars = array(); ! } /** Adds a new variable in the array of variables. */ function addVar($var_name, $expression) ! { ! $var_name = $var_name; ! $this->vars[$var_name] = $expression; ! } /** Returns an array with all the evaluated variables. */ function getVars() ! { ! reset($this->vars); ! $tplVars = $this->vars; ! while ( list($var_name,$expr) = each($tplVars) ) ! { ! $expr = WebApp::replaceVars($expr); ! $tplVars[$var_name] = WebApp::evaluate($expr); ! } ! return $tplVars; ! } /** *************** *** 103,160 **** */ function normalize_space() ! { ! $str = $this->contents; ! //if there are 2 or more empty lines, replace them by a single one ! $str = preg_replace('/\n([ \t]*\n){2,}/', "\n\n", $str); ! //remove any empty lines in the begining ! $str = preg_replace('/^\s*\n/', '', $str); ! //remove any empty lines in the end ! $str = preg_replace('/\n\s*$/', '', $str); ! //Trim the indentation from the beginning of each line. ! //get the indentation o... [truncated message content] |