[phpwebapp-commits] CVS: web_app/convert class.Template.php,1.1,1.2 class.Render.php,1.2,1.3 class.P
Brought to you by:
dashohoxha
From: Dashamir H. <das...@us...> - 2004-07-22 16:25:52
|
Update of /cvsroot/phpwebapp/web_app/convert In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9224/convert Modified Files: class.Template.php class.Render.php class.Parser.php Log Message: reformated and modified the copyleft notice Index: class.Template.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/convert/class.Template.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** class.Template.php 20 Jul 2004 16:51:14 -0000 1.1 --- class.Template.php 22 Jul 2004 16:25:38 -0000 1.2 *************** *** 1,3 **** --- 1,24 ---- <?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 + */ + class Template { Index: class.Render.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/convert/class.Render.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** class.Render.php 21 Jul 2004 17:04:31 -0000 1.2 --- class.Render.php 22 Jul 2004 16:25:38 -0000 1.3 *************** *** 1,3 **** --- 1,25 ---- <?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 + */ + + class Render { Index: class.Parser.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/convert/class.Parser.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** class.Parser.php 20 Jul 2004 16:51:14 -0000 1.1 --- class.Parser.php 22 Jul 2004 16:25:38 -0000 1.2 *************** *** 1,3 **** --- 1,25 ---- <?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 + */ + + class Parser { *************** *** 12,42 **** function Parser() ! { ! $this->tpl_stack = array(); ! $this->current_tpl = UNDEFINED; ! } function parse_file($filename) ! { ! if ( !file_exists($filename) ) ! { ! print "'$filename' not found\n"; ! return UNDEFINED; ! } ! $tpl = new Template; ! $this->fp = fopen($filename, "r"); //open file ! //parse the file into $tpl ! $this->push($tpl); ! $this->parse(); ! $tpl = $this->pop(); ! //close the file ! fclose($this->fp); ! return $tpl; ! } /** --- 34,64 ---- function Parser() ! { ! $this->tpl_stack = array(); ! $this->current_tpl = UNDEFINED; ! } function parse_file($filename) ! { ! if ( !file_exists($filename) ) ! { ! print "'$filename' not found\n"; ! return UNDEFINED; ! } ! $tpl = new Template; ! $this->fp = fopen($filename, "r"); //open file ! //parse the file into $tpl ! $this->push($tpl); ! $this->parse(); ! $tpl = $this->pop(); ! //close the file ! fclose($this->fp); ! return $tpl; ! } /** *************** *** 45,57 **** */ function parse() ! { ! $closing_tag = false; ! while (!$closing_tag and !feof($this->fp)) ! { ! $line = $this->get_line(); ! if ($line=='') continue; ! $closing_tag = $this->parse_line($line); ! } ! } /** --- 67,79 ---- */ function parse() ! { ! $closing_tag = false; ! while (!$closing_tag and !feof($this->fp)) ! { ! $line = $this->get_line(); ! if ($line=='') continue; ! $closing_tag = $this->parse_line($line); ! } ! } /** *************** *** 62,93 **** */ function parse_line($line) ! { ! $tag = Parser::get_tag_name($line); ! switch ($tag) ! { ! default: ! $this->add_line($line); ! break; ! case "<Repeat": ! $this->parse_Repeat($line); ! break; ! case "</Repeat": ! $this->add_line($line); ! return true; ! break; ! case "<Header": ! case "<Footer": ! $this->parse_Repeat_subtpl($line); ! break; ! case "</Header": ! case "</Footer": ! return true; ! break; ! } ! return false; ! } /** --- 84,115 ---- */ function parse_line($line) ! { ! $tag = Parser::get_tag_name($line); ! switch ($tag) ! { ! default: ! $this->add_line($line); ! break; ! case "<Repeat": ! $this->parse_Repeat($line); ! break; ! case "</Repeat": ! $this->add_line($line); ! return true; ! break; ! case "<Header": ! case "<Footer": ! $this->parse_Repeat_subtpl($line); ! break; ! case "</Header": ! case "</Footer": ! return true; ! break; ! } ! return false; ! } /** *************** *** 96,106 **** */ function push(&$tpl) ! { ! //push the current_tpl on tpl_stack ! array_push($this->tpl_stack, $this->current_tpl); ! //make current the new template ! $this->current_tpl = &$tpl; ! } /** --- 118,128 ---- */ function push(&$tpl) ! { ! //push the current_tpl on tpl_stack ! array_push($this->tpl_stack, $this->current_tpl); ! //make current the new template ! $this->current_tpl = &$tpl; ! } /** *************** *** 109,177 **** */ function pop() ! { ! //pop the last template from tpl_stack into current_tpl ! $tpl = $this->current_tpl; ! $last = count($this->tpl_stack) - 1; ! $this->current_tpl = &$this->tpl_stack[$last]; ! array_pop($this->tpl_stack); ! //add the template in the template collection ! global $tpl_collection; ! $tpl_collection[$tpl->id] = $tpl; ! return $tpl; ! } function parse_Repeat($line) ! { ! $tpl = new Template('RepeatTpl'); ! $tpl->header = new Template; ! $tpl->footer = new Template; ! //set a pointer from this template to the new template ! $this->add_line("##\n"); ! $this->add_line($tpl->id."\n"); ! //parse the new template into $tpl ! $this->push($tpl); ! $this->add_line($line); ! $this->parse(); ! $this->pop(); ! } /** Parse <Header> and <Footer> */ function parse_Repeat_subtpl($line) ! { ! $tag = Parser::get_tag_name($line); ! $tag = substr($tag, 1); ! $tpl = new Template; ! $this->push($tpl); ! $this->parse(); ! $tpl = $this->pop(); ! switch ($tag) ! { ! case "Header": ! $this->current_tpl->header = $tpl; ! break; ! case "Footer": ! $this->current_tpl->footer = $tpl; ! break; ! } ! } /** returns a line from the file that is being parsed */ function get_line() ! { ! $line = fgets($this->fp,896); ! return $line; ! } /** add a line to the current template */ function add_line($line) ! { ! $this->current_tpl->content[] = $line; ! } /** --- 131,199 ---- */ function pop() ! { ! //pop the last template from tpl_stack into current_tpl ! $tpl = $this->current_tpl; ! $last = count($this->tpl_stack) - 1; ! $this->current_tpl = &$this->tpl_stack[$last]; ! array_pop($this->tpl_stack); ! //add the template in the template collection ! global $tpl_collection; ! $tpl_collection[$tpl->id] = $tpl; ! return $tpl; ! } function parse_Repeat($line) ! { ! $tpl = new Template('RepeatTpl'); ! $tpl->header = new Template; ! $tpl->footer = new Template; ! //set a pointer from this template to the new template ! $this->add_line("##\n"); ! $this->add_line($tpl->id."\n"); ! //parse the new template into $tpl ! $this->push($tpl); ! $this->add_line($line); ! $this->parse(); ! $this->pop(); ! } /** Parse <Header> and <Footer> */ function parse_Repeat_subtpl($line) ! { ! $tag = Parser::get_tag_name($line); ! $tag = substr($tag, 1); ! $tpl = new Template; ! $this->push($tpl); ! $this->parse(); ! $tpl = $this->pop(); ! switch ($tag) ! { ! case "Header": ! $this->current_tpl->header = $tpl; ! break; ! case "Footer": ! $this->current_tpl->footer = $tpl; ! break; ! } ! } /** returns a line from the file that is being parsed */ function get_line() ! { ! $line = fgets($this->fp,896); ! return $line; ! } /** add a line to the current template */ function add_line($line) ! { ! $this->current_tpl->content[] = $line; ! } /** *************** *** 181,195 **** */ function get_tag_name($line) ! { ! $line = trim($line); ! if ( ereg("^(</?[^[:space:] >]*)", $line, $regs) ) ! { ! return $regs[1]; ! } ! else ! { ! return UNDEFINED; ! } ! } /** --- 203,217 ---- */ function get_tag_name($line) ! { ! $line = trim($line); ! if ( ereg("^(</?[^[:space:] >]*)", $line, $regs) ) ! { ! return $regs[1]; ! } ! else ! { ! return UNDEFINED; ! } ! } /** *************** *** 199,215 **** */ function get_attr_value($line, $attrib) ! { ! $line = trim($line); ! $pattern = '[[:space:]]+'.$attrib.'[[:space:]]*=[[:space:]]*"([^"]*)"'; ! if ( ereg($pattern, $line, $regs) ) ! { ! $attr = $regs[1]; ! return $attr; ! } ! else ! { ! return UNDEFINED; ! } ! } } ?> \ No newline at end of file --- 221,237 ---- */ function get_attr_value($line, $attrib) ! { ! $line = trim($line); ! $pattern = '[[:space:]]+'.$attrib.'[[:space:]]*=[[:space:]]*"([^"]*)"'; ! if ( ereg($pattern, $line, $regs) ) ! { ! $attr = $regs[1]; ! return $attr; ! } ! else ! { ! return UNDEFINED; ! } ! } } ?> \ No newline at end of file |