phpwebapp-commits Mailing List for phpWebApp (Page 17)
Brought to you by:
dashohoxha
You can subscribe to this list here.
2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(15) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2002 |
Jan
(2) |
Feb
|
Mar
|
Apr
(5) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2003 |
Jan
|
Feb
(43) |
Mar
|
Apr
|
May
|
Jun
(2) |
Jul
|
Aug
(194) |
Sep
(60) |
Oct
(6) |
Nov
|
Dec
(16) |
2004 |
Jan
(73) |
Feb
(13) |
Mar
(5) |
Apr
|
May
(5) |
Jun
|
Jul
(183) |
Aug
|
Sep
(5) |
Oct
(30) |
Nov
|
Dec
|
2005 |
Jan
|
Feb
|
Mar
|
Apr
(9) |
May
(1) |
Jun
(35) |
Jul
(17) |
Aug
(2) |
Sep
(6) |
Oct
(19) |
Nov
(108) |
Dec
|
2006 |
Jan
(10) |
Feb
(1) |
Mar
(5) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Dashamir H. <das...@us...> - 2004-07-15 13:36:30
|
Update of /cvsroot/phpwebapp/web_app/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2760/parser Modified Files: class.WebPage.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.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** class.WebPage.php 14 Jul 2004 14:45:41 -0000 1.10 --- class.WebPage.php 15 Jul 2004 13:36:13 -0000 1.11 *************** *** 71,75 **** function append_to_head($str) { ! $this->tpl_collection["HeadTpl"]->contents .= $str; } --- 71,77 ---- function append_to_head($str) { ! $contents = $this->tpl_collection["HeadTpl"]->contents; ! $contents = ereg_replace('</head>', $str.'</head>', $contents); ! $this->tpl_collection["HeadTpl"]->contents = $contents; } *************** *** 191,195 **** $js = "<script type=\"text/javascript\" language=\"javascript\">\n"; ! $js .= "<![CDATA[\n"; for ($i=0; $i < sizeof($this->messages); $i++) { --- 193,197 ---- $js = "<script type=\"text/javascript\" language=\"javascript\">\n"; ! $js .= "//<![CDATA[\n"; for ($i=0; $i < sizeof($this->messages); $i++) { *************** *** 199,203 **** $js .= "\talert('$msg');\n"; } ! $js .= "]]>\n"; $js .= "</script>\n"; return $js; --- 201,205 ---- $js .= "\talert('$msg');\n"; } ! $js .= "//]]>\n"; $js .= "</script>\n"; return $js; Index: class.WebClassTpl.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/parser/class.WebClassTpl.php,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** class.WebClassTpl.php 14 Jul 2004 14:45:41 -0000 1.9 --- class.WebClassTpl.php 15 Jul 2004 13:36:13 -0000 1.10 *************** *** 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); } --- 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); } Index: class.Template.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/parser/class.Template.php,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** class.Template.php 14 Jul 2004 14:45:41 -0000 1.10 --- class.Template.php 15 Jul 2004 13:36:13 -0000 1.11 *************** *** 184,188 **** <td bgcolor='#eeeeee' align='right'>Indent:</td> <td bgcolor='#f9f9f9'> ! <pre><span style='background-color: #888888;'>$indent</span></pre> </td> </tr> --- 184,188 ---- <td bgcolor='#eeeeee' align='right'>Indent:</td> <td bgcolor='#f9f9f9'> ! <span style='background-color: #888888;'>$indent</span> </td> </tr> Index: class.Render.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/parser/class.Render.php,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** class.Render.php 14 Jul 2004 14:45:41 -0000 1.10 --- class.Render.php 15 Jul 2004 13:36:13 -0000 1.11 *************** *** 253,258 **** function render_MainTpl($main_tpl) { ! $main_tpl->head->contents = '<head>'.$main_tpl->head->contents; ! $main_tpl->head->contents .= '</head>'; $main_tpl->body->contents .= '</body>'; /* --- 253,257 ---- function render_MainTpl($main_tpl) { ! //the body element was not closed in order to append easily other things $main_tpl->body->contents .= '</body>'; /* Index: class.Parser.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/parser/class.Parser.php,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** class.Parser.php 14 Jul 2004 14:45:41 -0000 1.11 --- class.Parser.php 15 Jul 2004 13:36:13 -0000 1.12 *************** *** 20,1014 **** */ ! /** ! * Parses the templates and constructs $webPage, which ! * keeps the structure of the page. ! * ! * @package parser ! * @see WebPage, Render ! */ [...2010 lines suppressed...] ! 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"; ! } ! } ! } ! } ?> \ No newline at end of file |
From: Dashamir H. <das...@us...> - 2004-07-15 13:36:30
|
Update of /cvsroot/phpwebapp/web_app/boxes/editMenus/sample_menu In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2760/boxes/editMenus/sample_menu Modified Files: include_menus.js Log Message: Index: include_menus.js =================================================================== RCS file: /cvsroot/phpwebapp/web_app/boxes/editMenus/sample_menu/include_menus.js,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** include_menus.js 14 Jul 2004 14:45:41 -0000 1.4 --- include_menus.js 15 Jul 2004 13:36:13 -0000 1.5 *************** *** 61,65 **** //load the arrays of menu data ! document.write("<script type='text/javascript' language='JavaScript1.2' src='{{menu_data_path}}/menu_arrays.js'><\/script>"); //load the JS code for the menus --- 61,65 ---- //load the arrays of menu data ! document.write("<script type='text/javascript' language='javascript' src='{{menu_data_path}}/menu_arrays.js'><\/script>"); //load the JS code for the menus |
From: Dashamir H. <das...@us...> - 2004-07-15 13:36:29
|
Update of /cvsroot/phpwebapp/web_app/webobjects/form In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2760/webobjects/form Modified Files: formWebObj.php Log Message: Index: formWebObj.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/webobjects/form/formWebObj.php,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** formWebObj.php 14 Jul 2004 14:45:35 -0000 1.7 --- formWebObj.php 15 Jul 2004 13:36:13 -0000 1.8 *************** *** 44,52 **** $js_code = " <script type=\"text/javascript\" language=\"javascript\"> ! <![CDATA[ var form = document.$form_name; var formData = '$formData'; setFormData(form, formData); ! ]]> </script> "; --- 44,52 ---- $js_code = " <script type=\"text/javascript\" language=\"javascript\"> ! //<![CDATA[ var form = document.$form_name; var formData = '$formData'; setFormData(form, formData); ! //]]> </script> "; |
From: Dashamir H. <das...@us...> - 2004-07-14 14:46:18
|
Update of /cvsroot/phpwebapp/web_app/tools/fileBrowser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13284/tools/fileBrowser Modified Files: panel.html fileBrowser.html Log Message: Index: panel.html =================================================================== RCS file: /cvsroot/phpwebapp/web_app/tools/fileBrowser/panel.html,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** panel.html 22 Aug 2003 06:47:20 -0000 1.2 --- panel.html 14 Jul 2004 14:45:35 -0000 1.3 *************** *** 6,28 **** <form name="changeViewForm" onsubmit="return false;"> <td width="17%" nowrap="true" valign="top"> ! <input type="checkbox" name="hide" class="checkbox"><span class="font">Hide Folder Box</span><br> <input type="button" name="refresh" value="Refresh" class="button" onclick="on_refresh()"> </td> <td width="17%" nowrap="true" valign="top"> ! <input type="radio" name="viewMode" value="codeView" class="radio" {{codeView_checked}}><span class="font">Code View</span> <br> <input type="radio" name="viewMode" value="preview" class="radio" {{preview_checked}}><span class="font">Preview</span> </td> <td bgcolor="#006633"></td> <td width="10%" nowrap="true" valign="top" align="right"> ! <span class="font">Change Session:</span> <br> <input type="button" name="changeSess" value="Change" class="button" onclick="on_changeSess()"> </td> <td width="20%" nowrap="true" valign="top"> ! <input type="text" name="var_name" class="text" size="15"> <br> <input type="text" name="var_value" class="text" size="15"> </td> <td bgcolor="#006633"></td> <td width="40%" nowrap="true"> ! <span class="font">Root Folder:</span> <br> <input type="text" name="root_folder" class="text" value="{{folderListing->root}}" size="30"> <input type="button" name="changePath" value="GO" class="button" onclick="on_changePath()"> --- 6,28 ---- <form name="changeViewForm" onsubmit="return false;"> <td width="17%" nowrap="true" valign="top"> ! <input type="checkbox" name="hide" class="checkbox"><span class="font">Hide Folder Box</span><br /> <input type="button" name="refresh" value="Refresh" class="button" onclick="on_refresh()"> </td> <td width="17%" nowrap="true" valign="top"> ! <input type="radio" name="viewMode" value="codeView" class="radio" {{codeView_checked}}><span class="font">Code View</span> <br /> <input type="radio" name="viewMode" value="preview" class="radio" {{preview_checked}}><span class="font">Preview</span> </td> <td bgcolor="#006633"></td> <td width="10%" nowrap="true" valign="top" align="right"> ! <span class="font">Change Session:</span> <br /> <input type="button" name="changeSess" value="Change" class="button" onclick="on_changeSess()"> </td> <td width="20%" nowrap="true" valign="top"> ! <input type="text" name="var_name" class="text" size="15"> <br /> <input type="text" name="var_value" class="text" size="15"> </td> <td bgcolor="#006633"></td> <td width="40%" nowrap="true"> ! <span class="font">Root Folder:</span> <br /> <input type="text" name="root_folder" class="text" value="{{folderListing->root}}" size="30"> <input type="button" name="changePath" value="GO" class="button" onclick="on_changePath()"> Index: fileBrowser.html =================================================================== RCS file: /cvsroot/phpwebapp/web_app/tools/fileBrowser/fileBrowser.html,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** fileBrowser.html 20 Aug 2003 07:00:48 -0000 1.3 --- fileBrowser.html 14 Jul 2004 14:45:35 -0000 1.4 *************** *** 2,6 **** <head> <title>File Browser</title> ! <link rel="stylesheet" type="text/css" href="{{APP_STYLE}}"> </head> <body> --- 2,6 ---- <head> <title>File Browser</title> ! <link type="text/css" rel="stylesheet" href="{{APP_STYLE}}" /> </head> <body> |
From: Dashamir H. <das...@us...> - 2004-07-14 14:46:18
|
Update of /cvsroot/phpwebapp/web_app/timer In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13284/timer Modified Files: class.Timer.php Log Message: Index: class.Timer.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/timer/class.Timer.php,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** class.Timer.php 25 Aug 2003 13:18:29 -0000 1.5 --- class.Timer.php 14 Jul 2004 14:45:35 -0000 1.6 *************** *** 104,113 **** $timer_path = WebApp::to_url(TIMER_PATH); $js_code = " ! <script language='JavaScript' src='".$timer_path."class.Timer.js'></script> ! <script language='JavaScript'> ! var timer = new Timer(); ! var comment = 'Time that spends the web-page to be transfered and loaded in browser'; ! timer.Start('web-page', comment); ! </script> "; return $js_code; --- 104,115 ---- $timer_path = WebApp::to_url(TIMER_PATH); $js_code = " ! <script type=\"text/javascript\" language=\"javascript\" src=\"".$timer_path."class.Timer.js\"></script> ! <script type=\"text/javascript\" language=\"javascript\"> ! <![CDATA[ ! var timer = new Timer(); ! var comment = 'Time that spends the web-page to be transfered and loaded in browser'; ! timer.Start('web-page', comment); ! ]]> ! </script> "; return $js_code; *************** *** 117,126 **** { $js_code = " ! <script language='JavaScript'> ! var timerHtmlTable; ! timer.Stop('web-page'); ! timerHtmlTable = timer.toHtmlTable(); ! document.write(timerHtmlTable); ! </script> "; return $js_code; --- 119,130 ---- { $js_code = " ! <script type=\"text/javascript\" language=\"javascript\"> ! <![CDATA[ ! var timerHtmlTable; ! timer.Stop('web-page'); ! timerHtmlTable = timer.toHtmlTable(); ! document.write(timerHtmlTable); ! ]]> ! </script> "; return $js_code; |
From: Dashamir H. <das...@us...> - 2004-07-14 14:46:18
|
Update of /cvsroot/phpwebapp/web_app/webobjects/dbTable In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13284/webobjects/dbTable Modified Files: dbTable.html Log Message: Index: dbTable.html =================================================================== RCS file: /cvsroot/phpwebapp/web_app/webobjects/dbTable/dbTable.html,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** dbTable.html 11 May 2004 06:45:29 -0000 1.5 --- dbTable.html 14 Jul 2004 14:45:35 -0000 1.6 *************** *** 21,25 **** <th bgcolor="#eeeeee"> <a href="javascript: dbTable_select('{{obj_id}}', '{{UNDEFINED}}')"> ! <img border="0" src="{{./}}select.png"> </a> </th> --- 21,25 ---- <th bgcolor="#eeeeee"> <a href="javascript: dbTable_select('{{obj_id}}', '{{UNDEFINED}}')"> ! <img border="0" src="{{./}}select.png" /> </a> </th> *************** *** 44,48 **** <td bgcolor="{{bgcolor}}"> <a href="javascript: dbTable_select('{{obj_id}}', '{{rec_id}}')"> ! <img border="0" src="{{./}}select.png"> </a> </td> --- 44,48 ---- <td bgcolor="{{bgcolor}}"> <a href="javascript: dbTable_select('{{obj_id}}', '{{rec_id}}')"> ! <img border="0" src="{{./}}select.png" /> </a> </td> *************** *** 55,59 **** </table> ! <br> <WebObject Class="editRecord" Name="{{obj_name}}" /> --- 55,59 ---- </table> ! <br /> <WebObject Class="editRecord" Name="{{obj_name}}" /> |
From: Dashamir H. <das...@us...> - 2004-07-14 14:46:18
|
Update of /cvsroot/phpwebapp/web_app/webobjects/xlistbox In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13284/webobjects/xlistbox Modified Files: xlistbox.txt xlistbox.html Log Message: Index: xlistbox.txt =================================================================== RCS file: /cvsroot/phpwebapp/web_app/webobjects/xlistbox/xlistbox.txt,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** xlistbox.txt 16 Jul 2003 09:27:59 -0000 1.3 --- xlistbox.txt 14 Jul 2004 14:45:35 -0000 1.4 *************** *** 70,78 **** If you want to init the lists with some values, you can add this JS code after the </form> is closed: ! <script language="javascript"> var form = document.userdata; xlistbox_select(form.office, '{{office}}'); fill_sublist(form.department, '{{office}}', '{{department}}'); fill_sublist(form.user, '{{department}}', '{{user}}'); </script> The mainlist usually doesn't need to be initialized, because it is --- 70,80 ---- If you want to init the lists with some values, you can add this JS code after the </form> is closed: ! <script type="text/javascript" language="javascript"> ! <![CDATA[ var form = document.userdata; xlistbox_select(form.office, '{{office}}'); fill_sublist(form.department, '{{office}}', '{{department}}'); fill_sublist(form.user, '{{department}}', '{{user}}'); + ]]> </script> The mainlist usually doesn't need to be initialized, because it is Index: xlistbox.html =================================================================== RCS file: /cvsroot/phpwebapp/web_app/webobjects/xlistbox/xlistbox.html,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** xlistbox.html 22 Aug 2003 06:47:19 -0000 1.3 --- xlistbox.html 14 Jul 2004 14:45:35 -0000 1.4 *************** *** 28,32 **** </Repeat> </select> ! <script language="javascript"> var arr_{{obj_name}} = new Array(); var item; --- 28,32 ---- </Repeat> </select> ! <script type="text/javascript" language="javascript"> var arr_{{obj_name}} = new Array(); var item; |
From: Dashamir H. <das...@us...> - 2004-07-14 14:46:18
|
Update of /cvsroot/phpwebapp/web_app/webobjects/table In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13284/webobjects/table Modified Files: table.html Log Message: Index: table.html =================================================================== RCS file: /cvsroot/phpwebapp/web_app/webobjects/table/table.html,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** table.html 22 Aug 2003 06:47:19 -0000 1.3 --- table.html 14 Jul 2004 14:45:35 -0000 1.4 *************** *** 3,7 **** <Parameter name="fields" default="*" /> <Parameter name="where" default="" /> ! <br> <table bgcolor="#aaaaaa" border="0" cellspacing="1" cellpadding="2"> <tr> --- 3,7 ---- <Parameter name="fields" default="*" /> <Parameter name="where" default="" /> ! <br /> <table bgcolor="#aaaaaa" border="0" cellspacing="1" cellpadding="2"> <tr> |
From: Dashamir H. <das...@us...> - 2004-07-14 14:46:17
|
Update of /cvsroot/phpwebapp/web_app/webobjects/form In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13284/webobjects/form Modified Files: formWebObj.php Log Message: Index: formWebObj.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/webobjects/form/formWebObj.php,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** formWebObj.php 13 Jul 2004 13:18:08 -0000 1.6 --- formWebObj.php 14 Jul 2004 14:45:35 -0000 1.7 *************** *** 33,38 **** //prepend js code to the content of this template $form_url = WebApp::to_url(FORM_PATH); ! $js_code = "<script language='JavaScript' " ! . "src='".$form_url."formWebObj.js'></script>\n"; $webPage->append_to_head($js_code); --- 33,38 ---- //prepend js code to the content of this template $form_url = WebApp::to_url(FORM_PATH); ! $js_code = "<script type=\"text/javascript\" language=\"javascript\" " ! . "src=\"".$form_url."formWebObj.js\"></script>\n"; $webPage->append_to_head($js_code); *************** *** 43,50 **** $form_name = $this->get_form_name(); $js_code = " ! <script language='JavaScript'> var form = document.$form_name; var formData = '$formData'; setFormData(form, formData); </script> "; --- 43,52 ---- $form_name = $this->get_form_name(); $js_code = " ! <script type=\"text/javascript\" language=\"javascript\"> ! <![CDATA[ var form = document.$form_name; var formData = '$formData'; setFormData(form, formData); + ]]> </script> "; |
From: Dashamir H. <das...@us...> - 2004-07-14 14:45:52
|
Update of /cvsroot/phpwebapp/web_app In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13284 Modified Files: class.WebApp.php Log Message: Index: class.WebApp.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/class.WebApp.php,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** class.WebApp.php 13 Jul 2004 13:18:08 -0000 1.17 --- class.WebApp.php 14 Jul 2004 14:45:41 -0000 1.18 *************** *** 92,97 **** //add also the stylesheet of the framework ! $webapp_styles = ' <link rel="stylesheet" type="text/css" ' ! . 'href="'.WEBAPP_URL.'styles.css">'."\n"; $webPage->append_to_head($webapp_styles); --- 92,97 ---- //add also the stylesheet of the framework ! $webapp_styles = ' <link type="text/css" rel="stylesheet" ' ! . 'href="'.WEBAPP_URL.'styles.css" />'."\n"; $webPage->append_to_head($webapp_styles); *************** *** 249,253 **** //if it is the state var of a webobject //set it in the webobject's scope as well ! if (ereg("(.*)->(.*)", $var_name, $regs)) { $obj_id = $regs[1]; --- 249,253 ---- //if it is the state var of a webobject //set it in the webobject's scope as well ! if (ereg('(.*)->(.*)', $var_name, $regs)) { $obj_id = $regs[1]; *************** *** 285,295 **** /*------ end variable functions ----------------*/ - /*------ begin evaluate ------------------------*/ - /** Returns the value of the given expression. */ function evaluate($expr) { //declare as global any variables that are used in $expr ! $var_names = implode(",", WebApp::get_var_names($expr)); if ($var_names <> '') { --- 285,294 ---- /*------ end variable functions ----------------*/ /** Returns the value of the given expression. */ function evaluate($expr) { //declare as global any variables that are used in $expr ! preg_match_all('/\$[[:alnum:]_]+/', $expr, $matches); ! $var_names = implode(',', $matches[0]); if ($var_names <> '') { *************** *** 307,327 **** return $webApp_value; } - /** - * Returns an array with all the variable names that are used - * in the given $expr. Called by evaluate() (which will be declared - * these variables as global). - * @see evaluate() - */ - function get_var_names($expr) - { - $var_names = array(); - while ( ereg('\$[[:alnum:]_]+', $expr, $regs) ) - { - $var_names[] = $regs[0]; - $expr = str_replace($regs[0], '', $expr); - } - return $var_names; - } - /*------ end evaluate --------------------------*/ /** --- 306,309 ---- *************** *** 378,381 **** --- 360,373 ---- * the variable is inside a string, and if it contains quotes inside * the value, then it may break the string. + * + * A variable can be commented by adding a diesis before or after its + * name. In this case, the variable will not be expanded. + * + * Variables can be nested with each-other, like this: + * {{item_{{id}}_checked}}. The most inner variables are expanded first + * (in this case {{id}}). + * + * Variables are expanded recursively, so, if the value of a variable + * contains another variable, it will be expanded as well. */ function replaceVars($str) *************** *** 438,442 **** break; default: ! print "warning: escape_quotes: the quote '$quote' is unknown.<br>\n"; break; } --- 430,434 ---- break; default: ! print "warning: escape_quotes: the quote '$quote' is unknown.<br />\n"; break; } *************** *** 530,534 **** function to_url($path) { ! $DocumentRoot = ereg_replace(APP_URL."\$", '', APP_PATH); $url = str_replace($DocumentRoot, '', $path); return $url; --- 522,526 ---- function to_url($path) { ! $DocumentRoot = ereg_replace(APP_URL.'$', '', APP_PATH); $url = str_replace($DocumentRoot, '', $path); return $url; *************** *** 601,605 **** <div class='xml_error'> <strong>XML Error:</strong> $error_string. At <strong>$fname</strong>, ! line <strong>$line_nr</strong>, column <strong>$col_nr</strong>: <br> <span class='xml_err_str'>...$xml_string</span>. </div> --- 593,597 ---- <div class='xml_error'> <strong>XML Error:</strong> $error_string. At <strong>$fname</strong>, ! line <strong>$line_nr</strong>, column <strong>$col_nr</strong>: <br /> <span class='xml_err_str'>...$xml_string</span>. </div> |
From: Dashamir H. <das...@us...> - 2004-07-14 14:45:52
|
Update of /cvsroot/phpwebapp/web_app/boxes/editMenus In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13284/boxes/editMenus Modified Files: editMenus.html class.Menus.php Log Message: Index: editMenus.html =================================================================== RCS file: /cvsroot/phpwebapp/web_app/boxes/editMenus/editMenus.html,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** editMenus.html 22 Aug 2003 06:47:20 -0000 1.3 --- editMenus.html 14 Jul 2004 14:45:41 -0000 1.4 *************** *** 22,30 **** <tr> <td> ! description: <br> <input type="text" name="description" size="30"> </td> <td> ! action: <br> <input type="text" name="action" size="30"> </td> --- 22,30 ---- <tr> <td> ! description: <br /> <input type="text" name="description" size="30"> </td> <td> ! action: <br /> <input type="text" name="action" size="30"> </td> *************** *** 54,58 **** <tr> <td> ! description: <br> <textarea name="description_list" cols="25" rows="5"></textarea> <!--# --- 54,58 ---- <tr> <td> ! description: <br /> <textarea name="description_list" cols="25" rows="5"></textarea> <!--# *************** *** 65,69 **** </td> <td> ! action: <br> <textarea name="action_list" cols="25" rows="5"></textarea> <!--# --- 65,69 ---- </td> <td> ! action: <br /> <textarea name="action_list" cols="25" rows="5"></textarea> <!--# Index: class.Menus.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/boxes/editMenus/class.Menus.php,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** class.Menus.php 25 Aug 2003 13:18:34 -0000 1.5 --- class.Menus.php 14 Jul 2004 14:45:41 -0000 1.6 *************** *** 149,153 **** function to_HTML_table() { ! $menu_bar = "<link rel='stylesheet' type='text/css' href='{{./}}menubar.css'>\n" ."<table class='menubar_table'>\n" ."\t<tr class='menubar_tr'>\n"; --- 149,153 ---- function to_HTML_table() { ! $menu_bar = "<link type='text/css' rel='stylesheet' href='{{./}}menubar.css' />\n" ."<table class='menubar_table'>\n" ."\t<tr class='menubar_tr'>\n"; |
From: Dashamir H. <das...@us...> - 2004-07-14 14:45:52
|
Update of /cvsroot/phpwebapp/web_app/database In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13284/database Modified Files: package.DB.php class.Recordset.php class.MySQLCnn.php Log Message: Index: package.DB.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/database/package.DB.php,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** package.DB.php 3 May 2004 10:57:19 -0000 1.8 --- package.DB.php 14 Jul 2004 14:45:41 -0000 1.9 *************** *** 37,41 **** case "SQLServer": default: ! print "Sorry, DB_TYPE='".DB_TYPE."' is not implemented yet.<br>\n"; break; } --- 37,41 ---- case "SQLServer": default: ! print "Sorry, DB_TYPE='".DB_TYPE."' is not implemented yet.<br />\n"; break; } Index: class.Recordset.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/database/class.Recordset.php,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** class.Recordset.php 13 Jul 2004 13:18:08 -0000 1.10 --- class.Recordset.php 14 Jul 2004 14:45:41 -0000 1.11 *************** *** 353,357 **** } $htmlTable = " ! <br> <table border='0' cellspacing='1' cellpadding='0'> <tr><td> --- 353,357 ---- } $htmlTable = " ! <br /> <table border='0' cellspacing='1' cellpadding='0'> <tr><td> Index: class.MySQLCnn.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/database/class.MySQLCnn.php,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** class.MySQLCnn.php 25 Aug 2003 13:18:32 -0000 1.7 --- class.MySQLCnn.php 14 Jul 2004 14:45:41 -0000 1.8 *************** *** 93,98 **** if (mysql_errno()==1062) return; //ignore this error if (mysql_errno()==1136) return; //ignore this error ! print "Query: '$query' <br> \n"; ! print mysql_errno().": ".mysql_error()." <br> \n"; } } --- 93,98 ---- if (mysql_errno()==1062) return; //ignore this error if (mysql_errno()==1136) return; //ignore this error ! print "Query: '$query' <br /> \n"; ! print mysql_errno().": ".mysql_error()." <br /> \n"; } } |
From: Dashamir H. <das...@us...> - 2004-07-14 14:45:52
|
Update of /cvsroot/phpwebapp/web_app/boxes/fileView In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13284/boxes/fileView Modified Files: viewImage.html Log Message: Index: viewImage.html =================================================================== RCS file: /cvsroot/phpwebapp/web_app/boxes/fileView/viewImage.html,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** viewImage.html 21 Feb 2003 08:15:50 -0000 1.1.1.1 --- viewImage.html 14 Jul 2004 14:45:41 -0000 1.2 *************** *** 1,3 **** <WebBox ID="viewImage"> ! <img src="{{image_src}}" border="0"> </WebBox> --- 1,3 ---- <WebBox ID="viewImage"> ! <img src="{{image_src}}" border="0" /> </WebBox> |
From: Dashamir H. <das...@us...> - 2004-07-14 14:45:51
|
Update of /cvsroot/phpwebapp/web_app/append In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13284/append Modified Files: wbDebug.php wbDebug.html wbDbgStatevars.php append.html Log Message: Index: wbDebug.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/append/wbDebug.php,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** wbDebug.php 25 Aug 2003 13:18:38 -0000 1.4 --- wbDebug.php 14 Jul 2004 14:45:41 -0000 1.5 *************** *** 11,15 **** global $webPage; ! $debug_goto = "<script language='javascript'> debug_GoTo = true; </script>"; WebApp::addVar("debug_goto", $debug_goto); --- 11,15 ---- global $webPage; ! $debug_goto = '<script type="text/javascript" language="javascript"> debug_GoTo = true; </script>'; WebApp::addVar("debug_goto", $debug_goto); Index: wbDebug.html =================================================================== RCS file: /cvsroot/phpwebapp/web_app/append/wbDebug.html,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** wbDebug.html 13 Jul 2004 13:18:08 -0000 1.4 --- wbDebug.html 14 Jul 2004 14:45:41 -0000 1.5 *************** *** 15,24 **** --- 15,27 ---- <br/> </If> + <WebBox ID="wbDbgStatevars"> <!--# debug state vars #--> </WebBox> + <WebBox ID="wbDbgTemplates"> <!--# debug template structure #--> </WebBox> + <WebBox ID="wbDebug"> <!--# debug GoTo() transitions #--> *************** *** 26,33 **** --- 29,38 ---- {{debug_goto}} </If> + <!--# debug recordsets #--> <If condition="'{{DEBUG_RECORDSETS}}'!=''"> {{debug_recordsets}} </If> + <!--# show timer results #--> <If condition="'{{EXECUTION_TIME_INFO}}'!=''"> Index: wbDbgStatevars.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/append/wbDbgStatevars.php,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** wbDbgStatevars.php 13 Jul 2004 13:18:08 -0000 1.6 --- wbDbgStatevars.php 14 Jul 2004 14:45:41 -0000 1.7 *************** *** 36,40 **** function webobjects_to_tree() { ! $tree = "<hr>\n"; $tree .= "<a name='tree'> </a>"; $tree .= "<strong>WebObjects and their state variables:</strong>\n"; --- 36,40 ---- function webobjects_to_tree() { ! $tree = "<hr />\n"; $tree .= "<a name='tree'> </a>"; $tree .= "<strong>WebObjects and their state variables:</strong>\n"; *************** *** 105,112 **** { //don't display the webobjects of append ! if (ereg("append\.html", $tplId)) { return $html; ! $html .= "<hr>\n"; } --- 105,112 ---- { //don't display the webobjects of append ! if (ereg('web_app/append/append.html$', $tplId)) { return $html; ! $html .= "<hr />\n"; } *************** *** 116,120 **** } } ! $html .= "<hr>\n"; return $html; } --- 116,120 ---- } } ! $html .= "<hr />\n"; return $html; } Index: append.html =================================================================== RCS file: /cvsroot/phpwebapp/web_app/append/append.html,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** append.html 15 Aug 2003 07:05:07 -0000 1.3 --- append.html 14 Jul 2004 14:45:41 -0000 1.4 *************** *** 1,22 **** ! <!--# ! This file is appended automatically by the framework ! after each template in order to include session variables, ! debug info, etc. ! #--> ! <!--# insert phpWebApp logo #--> ! <div class="webapp_logo"> ! <a href="http://phpwebapp.sourceforge.net/" target="_blank"> ! Powered by phpWebApp ! </a> ! </div> ! <!--# include session variables #--> ! <Include SRC="{{SESSION_PATH}}wbSession.html" /> ! <!--# display any messages from server-side code #--> ! <WebBox ID="wbMessages"> ! {{MESSAGES}} ! </WebBox> ! <!--# include debug info #--> ! <Include SRC="{{./}}wbDebug.html" /> --- 1,23 ---- ! <!--# ! This file is appended automatically by the framework ! after each template in order to include session variables, ! debug info, etc. ! #--> ! <!--# insert phpWebApp logo #--> ! <div class="webapp_logo"> ! <a href="http://phpwebapp.sourceforge.net/" target="_blank"> ! Powered by phpWebApp ! </a> ! </div> ! <!--# include session variables #--> ! <Include SRC="{{SESSION_PATH}}wbSession.html" /> ! <!--# display any messages from server-side code #--> ! <WebBox ID="wbMessages"> ! {{MESSAGES}} ! </WebBox> ! ! <!--# include debug info #--> ! <Include SRC="{{./}}wbDebug.html" /> |
From: Dashamir H. <das...@us...> - 2004-07-14 14:45:51
|
Update of /cvsroot/phpwebapp/web_app/boxes/editMenus/sample_menu/menu_data In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13284/boxes/editMenus/sample_menu/menu_data Modified Files: menubar.html Log Message: Index: menubar.html =================================================================== RCS file: /cvsroot/phpwebapp/web_app/boxes/editMenus/sample_menu/menu_data/menubar.html,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** menubar.html 22 Aug 2003 06:47:20 -0000 1.3 --- menubar.html 14 Jul 2004 14:45:41 -0000 1.4 *************** *** 1,3 **** ! <link rel='stylesheet' type='text/css' href='{{./}}menubar.css'> <table class='menubar_table'> <tr class='menubar_tr'> --- 1,3 ---- ! <link type='text/css' rel='stylesheet' href='{{./}}menubar.css' /> <table class='menubar_table'> <tr class='menubar_tr'> |
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"; } } |
From: Dashamir H. <das...@us...> - 2004-07-14 14:45:51
|
Update of /cvsroot/phpwebapp/web_app/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13284/doc Modified Files: to_do.txt changes_3.txt changes_1.txt changes.txt WebApp.txt ToDo.XML.txt Log Message: Index: to_do.txt =================================================================== RCS file: /cvsroot/phpwebapp/web_app/doc/to_do.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** to_do.txt 13 Jul 2004 16:15:20 -0000 1.2 --- to_do.txt 14 Jul 2004 14:45:41 -0000 1.3 *************** *** 1,21 **** * Parse the templates using an XML parser. ! - Handle XML errors (in templates) as gracefully as possible. ! + In case of error, when popping the templates from the stack, ! call also the corresponding function (e.g. end_IF()), ! according to the type of the template. ! ! - The xml parser has problems with entities (e.g. < & etc.) ! Why? - Fix the problems with <Repeat>. + Why the navigation vars work even without a <RSNavig> template? ! - class.WebPage.php::print_dbg_messages() ! Output debug messages using EditableRS and templates. ! ! - Use css styles to the other debug messages as well. ! ! - Substitute ereg_replace() with preg_replace(). - Use 'tidy' or any shell scripts for converting from HTML to XHTML. --- 1,10 ---- * Parse the templates using an XML parser. ! - The xml parser has problems with entities (e.g. < & etc.). Why? - Fix the problems with <Repeat>. + Why the navigation vars work even without a <RSNavig> template? ! - Fix some errors with JS. - Use 'tidy' or any shell scripts for converting from HTML to XHTML. *************** *** 27,36 **** <img>, etc. - - Improve the output, so that the XHTML page that is generated - is well-formed, well-indented, etc. - + fix some problems with the indentation - + don't output <br></br>, but <br/> (similar for other empty tags) - + don't apply indentation for tags <pre>, <xmp>, etc. - - Use the new framework with the other web applications (app1, app2, app3, documentation, top10, smewapp, ilar, kushtetuta, --- 16,19 ---- *************** *** 38,41 **** --- 21,26 ---- conversion tool(s)). + - Replace the old edit_menu with the new one. + - Reformat all the files (automatically with emacs). Index: changes_3.txt =================================================================== RCS file: /cvsroot/phpwebapp/web_app/doc/changes_3.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** changes_3.txt 13 Jul 2004 16:15:20 -0000 1.1 --- changes_3.txt 14 Jul 2004 14:45:41 -0000 1.2 *************** *** 191,198 **** in the same folder with the <WebBox>. If it exists there, then the framework includes a line like this in the <head> of the page: ! <script language='javascript' src='path/to/box_id.js'></script> Similarly, for the CSS code, the framework includes a line like ! this: <link type='stylesheet' src='path/to/box_id.css' ....> in the <head> of the page. --- 191,198 ---- in the same folder with the <WebBox>. If it exists there, then the framework includes a line like this in the <head> of the page: ! <script type='text/javascript' language='javascript' src='path/to/box_id.js'></script> Similarly, for the CSS code, the framework includes a line like ! this: <link type='stylesheet' src='path/to/box_id.css' .... /> in the <head> of the page. Index: changes_1.txt =================================================================== RCS file: /cvsroot/phpwebapp/web_app/doc/changes_1.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** changes_1.txt 16 Jul 2003 09:27:59 -0000 1.2 --- changes_1.txt 14 Jul 2004 14:45:41 -0000 1.3 *************** *** 524,528 **** the given message after the page is rendered. The comment is optional. You can also print a debug message like this: ! print "$comment: $msg<br>\n"; but the output of this statement may be mixed with the HTML code and sometimes it may break the page, so the first --- 524,528 ---- the given message after the page is rendered. The comment is optional. You can also print a debug message like this: ! print "$comment: $msg<br />\n"; but the output of this statement may be mixed with the HTML code and sometimes it may break the page, so the first Index: changes.txt =================================================================== RCS file: /cvsroot/phpwebapp/web_app/doc/changes.txt,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** changes.txt 13 Jul 2004 16:15:20 -0000 1.3 --- changes.txt 14 Jul 2004 14:45:41 -0000 1.4 *************** *** 10,13 **** --- 10,38 ---- ------------------------------------------------------------------- ------------------------------------------------------------------- + * Added the tag <example>. It can be used like this: + + <example style="border: 1px solid #eeeeee;"> test + <b>test</b> + {{test}} + <Include SRC="{{content_html}}" /> + </example> + + It is converted by the framework to an <xmp> element, like this: + + <xmp style="border: 1px solid #eeeeee;"> test + <b>test</b> + {{test}} + <Include SRC="{{content_html}}" /> + </xmp> + + The content of the element is copied verbatim, no variable replacement + or other processing is done. Even the white-space is preserved and + the overall indentation of the generated page does not touch the + original indentation of this element. + + Also, the framework preserves the original white-space and indentation + for the xhtml tags <pre> and <xmp>, however their contents are processed + for template variables and framework tags. + ------------------------------------------------------------------- Index: WebApp.txt =================================================================== RCS file: /cvsroot/phpwebapp/web_app/doc/WebApp.txt,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** WebApp.txt 11 Aug 2003 16:17:52 -0000 1.3 --- WebApp.txt 14 Jul 2004 14:45:41 -0000 1.4 *************** *** 124,129 **** developer. Maybe it could be enforced if the template processor didn't allow absolute paths inside the templates, like this: ! <img src="/images/image1.png">, and required the usage of variables ! like this: <img src="{{IMG_URL}}image1.png">, which would force the developer to declare the constant IMG_URL in 'const.Paths.php'. ?) --- 124,129 ---- developer. Maybe it could be enforced if the template processor didn't allow absolute paths inside the templates, like this: ! <img src="/images/image1.png" />, and required the usage of variables ! like this: <img src="{{IMG_URL}}image1.png" />, which would force the developer to declare the constant IMG_URL in 'const.Paths.php'. ?) Index: ToDo.XML.txt =================================================================== RCS file: /cvsroot/phpwebapp/web_app/doc/ToDo.XML.txt,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ToDo.XML.txt 4 Aug 2003 12:06:13 -0000 1.3 --- ToDo.XML.txt 14 Jul 2004 14:45:41 -0000 1.4 *************** *** 9,14 **** <Attrib name="attr2" default="val1"/> <!--# the template of the tag #--> ! attr1='{{attr1}}'<br> ! attr2='{{attr2}}'<br> Tag Body: <xmp> {{ElementContent}} </xmp> --- 9,14 ---- <Attrib name="attr2" default="val1"/> <!--# the template of the tag #--> ! attr1='{{attr1}}'<br /> ! attr2='{{attr2}}'<br /> Tag Body: <xmp> {{ElementContent}} </xmp> *************** *** 98,100 **** (to convert a query result into HTML), the <TagDefinition> can be used to display XML content (to transform an XML content to HTML). ! </xmp> \ No newline at end of file --- 98,100 ---- (to convert a query result into HTML), the <TagDefinition> can be used to display XML content (to transform an XML content to HTML). ! </xmp> |
From: Dashamir H. <das...@us...> - 2004-07-14 14:45:50
|
Update of /cvsroot/phpwebapp/web_app/boxes/editMenus/sample_menu In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13284/boxes/editMenus/sample_menu Modified Files: include_menus.js Log Message: Index: include_menus.js =================================================================== RCS file: /cvsroot/phpwebapp/web_app/boxes/editMenus/sample_menu/include_menus.js,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** include_menus.js 11 Aug 2003 16:17:52 -0000 1.3 --- include_menus.js 14 Jul 2004 14:45:41 -0000 1.4 *************** *** 61,67 **** //load the arrays of menu data ! document.write("<script language='JavaScript1.2' src='{{menu_data_path}}/menu_arrays.js'><\/script>"); //load the JS code for the menus ! document.write("<script language='JavaScript1.2' src='{{./}}hierMenus.js'><\/script>"); } --- 61,67 ---- //load the arrays of menu data ! document.write("<script type='text/javascript' language='JavaScript1.2' src='{{menu_data_path}}/menu_arrays.js'><\/script>"); //load the JS code for the menus ! document.write("<script type='text/javascript' language='JavaScript1.2' src='{{./}}hierMenus.js'><\/script>"); } |
From: Dashamir H. <das...@us...> - 2004-07-14 14:45:50
|
Update of /cvsroot/phpwebapp/web_app/boxes/folderListing In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13284/boxes/folderListing Modified Files: folderListing.html Log Message: Index: folderListing.html =================================================================== RCS file: /cvsroot/phpwebapp/web_app/boxes/folderListing/folderListing.html,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** folderListing.html 21 Feb 2003 08:15:50 -0000 1.1.1.1 --- folderListing.html 14 Jul 2004 14:45:41 -0000 1.2 *************** *** 6,10 **** / </Repeat> ! <br> <a href="javascript: on_folderUp()"> <span class="folderListing_up">Up</span> --- 6,10 ---- / </Repeat> ! <br /> <a href="javascript: on_folderUp()"> <span class="folderListing_up">Up</span> *************** *** 13,26 **** <span class="folderListing_up">Root</span> </a> ! <br> <a href="javascript: on_folderUp()"> <span class="folderListing_folder">[+] ..</span> </a> ! <br> <Repeat rs="folders"> <a href="javascript: on_folder('{{folder}}')"> <span class="folderListing_folder">[+] {{folder}}</span> </a> ! <br> </Repeat> <Repeat rs="files"> --- 13,26 ---- <span class="folderListing_up">Root</span> </a> ! <br /> <a href="javascript: on_folderUp()"> <span class="folderListing_folder">[+] ..</span> </a> ! <br /> <Repeat rs="folders"> <a href="javascript: on_folder('{{folder}}')"> <span class="folderListing_folder">[+] {{folder}}</span> </a> ! <br /> </Repeat> <Repeat rs="files"> *************** *** 28,32 **** <span class="folderListing_file">[-] {{file}}</span> </a> ! <br> </Repeat> </WebBox> --- 28,32 ---- <span class="folderListing_file">[-] {{file}}</span> </a> ! <br /> </Repeat> </WebBox> |
From: Dashamir H. <das...@us...> - 2004-07-14 14:45:49
|
Update of /cvsroot/phpwebapp/web_app/session In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13284/session Modified Files: wbSession.php wbSession.html doc.Session.txt class.Session.php Log Message: Index: wbSession.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/session/wbSession.php,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** wbSession.php 25 Aug 2003 13:18:30 -0000 1.5 --- wbSession.php 14 Jul 2004 14:45:41 -0000 1.6 *************** *** 31,36 **** global $webPage; $session_url = WebApp::to_url(SESSION_PATH); ! $func_goto = " <script language='JavaScript' " ! . "src='${session_url}func.GoTo.js'></script>\n"; $webPage->append_to_head($func_goto); } --- 31,36 ---- global $webPage; $session_url = WebApp::to_url(SESSION_PATH); ! $func_goto = ' <script type="text/javascript" language="javascript" ' ! . "src=\"${session_url}func.GoTo.js\"></script>\n"; $webPage->append_to_head($func_goto); } Index: wbSession.html =================================================================== RCS file: /cvsroot/phpwebapp/web_app/session/wbSession.html,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** wbSession.html 13 Jul 2004 13:18:08 -0000 1.4 --- wbSession.html 14 Jul 2004 14:45:41 -0000 1.5 *************** *** 13,17 **** <!--# insert the session vars #--> ! <script language="JavaScript" src="{{./}}class.Session.js"></script> {{SESSION_VARS}} </WebBox> --- 13,17 ---- <!--# insert the session vars #--> ! <script type="text/javascript" language="javascript" src="{{./}}class.Session.js"></script> {{SESSION_VARS}} </WebBox> Index: doc.Session.txt =================================================================== RCS file: /cvsroot/phpwebapp/web_app/session/doc.Session.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** doc.Session.txt 16 Jul 2003 09:27:59 -0000 1.2 --- doc.Session.txt 14 Jul 2004 14:45:41 -0000 1.3 *************** *** 66,75 **** automatically by the framework: ! <script language="JavaScript" src="class.Session.js"></script> ! <script language='JavaScript'> ! session = new Session(); ! session.addVar('ID_S','IP: 192.168.1.2; DATE: 2001/11/01/ 00:24:33'); ! session.addVar('var1','val1'); ! session.addVar('var2','val2'); </script> --- 66,77 ---- automatically by the framework: ! <script type="text/javascript" language="JavaScript" src="class.Session.js"></script> ! <script type="text/javascript" language="JavaScript"> ! <![CDATA[ ! session = new Session(); ! session.addVar('ID_S','IP: 192.168.1.2; DATE: 2001/11/01/ 00:24:33'); ! session.addVar('var1','val1'); ! session.addVar('var2','val2'); ! ]]> </script> Index: class.Session.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/session/class.Session.php,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** class.Session.php 8 Sep 2003 13:18:23 -0000 1.7 --- class.Session.php 14 Jul 2004 14:45:41 -0000 1.8 *************** *** 288,293 **** function to_JS() { ! $session_vars = "<script language='JavaScript'>\n"; ! $session_vars .= "\tsession = new Session();\n"; reset($this->Vars); //add each variable of the session --- 288,294 ---- function to_JS() { ! $session_vars = '<script type="text/javascript" language="javascript">'."\n"; ! $session_vars .= "<![CDATA[\n"; ! $session_vars .= " session = new Session();\n"; reset($this->Vars); //add each variable of the session *************** *** 295,300 **** { $var_value = $this->js_encode($var_value); ! $session_vars .= "\tsession.addVar('$var_name','$var_value');\n"; } $session_vars .= "</script>"; --- 296,302 ---- { $var_value = $this->js_encode($var_value); ! $session_vars .= " session.addVar('$var_name','$var_value');\n"; } + $session_vars .= "]]>\n"; $session_vars .= "</script>"; *************** *** 336,340 **** //build the table of vars $html = " ! <br> <a name='session'> </a>[<a href='tree'>Top</a>] <table bgcolor='#aaaaaa' border='0' cellspacing='1' cellpadding='2'> --- 338,342 ---- //build the table of vars $html = " ! <br /> <a name='session'> </a>[<a href='tree'>Top</a>] <table bgcolor='#aaaaaa' border='0' cellspacing='1' cellpadding='2'> |
From: Dashamir H. <das...@us...> - 2004-07-14 14:45:49
|
Update of /cvsroot/phpwebapp/web_app/session/sample In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13284/session/sample Modified Files: test.Session.php Log Message: Index: test.Session.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/session/sample/test.Session.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** test.Session.php 11 Aug 2003 16:17:51 -0000 1.3 --- test.Session.php 14 Jul 2004 14:45:35 -0000 1.4 *************** *** 12,16 **** <html> <head> ! <script language="javascript" src="functions.js"></script> </head> --- 12,16 ---- <html> <head> ! <script type="text/javascript" language="javascript" src="functions.js"></script> </head> *************** *** 25,40 **** <form name="addVarForm"> ! Add a new variable to the session:<br> ! var_name : <input type="text" name="var_name" value=""><br> ! var_value: <input type="text" name="var_value" value=""><br> <a href="JavaScript:on_Add()"> ! <img src="add.png" border="0"> </a> </form> <p> <a href="JavaScript:on_Back()"> ! <img src="back.png" border="0"> </a> <p> --- 25,40 ---- <form name="addVarForm"> ! Add a new variable to the session:<br /> ! var_name : <input type="text" name="var_name" value=""><br /> ! var_value: <input type="text" name="var_value" value=""><br /> <a href="JavaScript:on_Add()"> ! <img src="add.png" border="0" /> </a> </form> <p> <a href="JavaScript:on_Back()"> ! <img src="back.png" border="0" /> </a> <p> *************** *** 44,55 **** <p> ! <b>DEBUG:</b><br> ! <b><?print "\$sessionVars = '$sessionVars'";?></b><br> ! <b><?print "\$phpVars = '$phpVars'";?></b><br> ! <b><?print "\$event = '$event'";?></b><br> ! <b><?print "\$test1='".$test1."'";?></b><br> ! <b><?print "\$test2='".$test2."'";?></b><br> ! <b><?print "\$arr[0]='".$arr[0]."'";?></b><br> ! <b><?print "\$arr[1]='".$arr[1]."'";?></b><br> <p> <!-- display session vars for debug --> --- 44,55 ---- <p> ! <b>DEBUG:</b><br /> ! <b><?print "\$sessionVars = '$sessionVars'";?></b><br /> ! <b><?print "\$phpVars = '$phpVars'";?></b><br /> ! <b><?print "\$event = '$event'";?></b><br /> ! <b><?print "\$test1='".$test1."'";?></b><br /> ! <b><?print "\$test2='".$test2."'";?></b><br /> ! <b><?print "\$arr[0]='".$arr[0]."'";?></b><br /> ! <b><?print "\$arr[1]='".$arr[1]."'";?></b><br /> <p> <!-- display session vars for debug --> |
From: Dashamir H. <das...@us...> - 2004-07-13 16:15:45
|
Update of /cvsroot/phpwebapp/web_app/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8906/doc Modified Files: xhtml_template_specification.txt to_do.txt changes.txt Added Files: changes_3.txt Log Message: --- NEW FILE: changes_3.txt --- Changes made to the application framework that the application developer should know: =========================================== -------- afterParse() ---------------------------- * - WebObject::afterParse() is like WebObject::onParse(), only that it is called after the WebObject is parsed. -------- webobject vars -------------------------- * - The framework declares for each webobject these variables: {{obj_id}} -- the object id ({{class_name}}::{{obj_name}}) {{class_name}} -- the name of the class {{obj_name}} -- the name of the object {{obj_count}} -- counts the objects of the same class, starting from 1 These vars can be used inside the template of the webclass, if the webclass designer needs them, e.g.: <input type="text" name="staff_{{obj_count}}"> -------- transmitVars() -------------------------- * - function transmitVar(var_name, var_value) This function sends the var_name (which has the given var_value) to the server side as a PHP global variable. It can also be used in the template as a tpl variable: {{var_name}}, since all PHP global variables can be used as tpl variables. It should be used carefully, because any tpl variable with the same name will override its value. It must be called before GoTo(). - function transmitVars(var_list) Similar to transmitVar() but can transmit more than one variable. The format of var_list is: var1=val1&var=val2&var3=val3. Must be called before GoTo(). -------- formWebObj ---------------------------------- * - formWebObj is a webobject that makes easy the handling of big forms (which have many inputs) and their data connection to the databaze. It is used like this: when you have a webbox that has a big form, in the PHP code of the webbox you include the class 'formWebObj', and then inherit this class, instead of inheriting 'WebObject' ('formWebObj' itself extends 'WebObject', so this is OK). E.g.: <WebBox ID="editProject"> <form name="bigForm"> . . . . . . . . <!--# many <input>s, <select>s, etc. here #--> . . . . . . . . </form> </WebBox> ---------------------------------------------- <? include_once FORM_PATH."formWebObj.php"; class editProject extends formWebObj { . . . . . . . . . . } ?> ---------------------------------------------- <? class formWebObj extends WebObject { . . . . . . . . . . . } ?> Then, in the JS code of the webbox you can use these JS functions which have been declared and included by the 'formWebObj': getEventArgs(form); /** * Returns all the data in the inputs of the given form * so that they can be sent as event args, e.g. * GoTo("thisPage?event=editProject.save(" + getEventArgs(form) + ")"); */ saveFormData(form); /** * Transmit the data of the form, so that * the changed values are not lost. * Must be called before GoTo(). */ This is useful when the page is refreshed for some reason, but you don't want to lose the values that are inputed in it. There are also these two functions that are used internally by 'formWebObj', but you can use them as well, if you need them: function getFormData(form) //returns all the data filled in the given form function setFormData(form, formData) //fills the form with the given data ------------- date WebObject ------------------------------- * - The webobject date can be used to select the date from a calendar. It can be used like this: First include the webclass that defines it: <Include SRC="{{DATE_PATH}}date.html" /> (DATE_PATH is defined by the framework) Then declare as many date objects as needed: <WebObject Class="date" Name="information_date" /> <WebObject Class="date" Name="contact_date" /> etc. When an object of class date is declared, the framework replaces it with this html code: <input type="text" class="datebox" onFocus="blur()" name="information_date" value="{{information_date}}"> <input type="image" ...(the calendar that selects the date)> So, it requires a default value {{information_date}}, which can be declared in the PHP code of the webox that uses the date object. If you want to modify it, you can copy it to a path local to the application, modify it and use the modified copy, e.g. <Include SRC="{{./}}date/date.html" /> -------------------------------------------------------------- * - <Repeat rs="{{tpl_var}}"> The attribute rs of the <Repeat> tag can contain variables (so that the same repeat can use different recordsets, according to the logic of the program). These variables are evaluated now in render time (before they were evaluated in parse time) because this is more convenient. ------------- listbox WebObject ------------------------------- * - The WebClass "listbox" is used to display a list of values with the <select> tag of HTML. These values are taken from a recordset (which can be retrieved from DB or can be supplied by PHP code. The recodset associated with the listbox must have two fields: 'id' and 'label'. 'label' is the field displayed, and 'id' is the value that is selected, saved in DB and retrieved from DB. Recordset example: <Recordset ID="listbox::country"> <Query> SELECT country_id AS id, country_name AS label FROM countries </Query> </Recordset> Usage example: <WebObject Class="listbox" Name="country" rs="rs_id" width="---------------" /> The attribute "rs" is optional. Its default value (if not specified) is {{obj_id}} (in the example above, it would be 'listbox::country'). The attribute "width" is also optional; it is used as the last line of the list, in order to keep the width of the <select> to a certain size (which can also be used as a nothing selected (none of the above) value). This WebClass uses a <select> tag like this: <select name="country"> (name="{{obj_name}}") . . . . . </select> So, this should be kept in mind when accessing the selected value and when giving an initial value. If the 'listbox' is used inside a 'formWebObj' webbox, then it takes care of it automatically. -------------------------------------------------------------------- * - The tag <WebObject> can be written in several lines (for making it more readable, in case that it has many attributes) and the parser can handle it. E.g. <WebObject Class = "listbox" Name = "country" rs = "rs_id" width = "---------------" /> -------------------------------------------------------------------- * - define("VAR_NOT_FOUND", "{var_name}"); is added to 'config/const.Settings.php' This constant sets the format of the error message that is displayed when a {{variable}} is not found. 'var_name' is replaced by the actual variable name. Examples: "'var_name' is not defined", "", "undefined", etc. It cannot contain "{{var_name}}" inside. -------------------------------------------------------------------- * - The recordsets declared by the <Recordset> tag were by default of type "StaticRS". Now the default type is "EditableRS", because this is more useful (and anyway EditableRS extends StaticRS). It can be declared explicitly as "StaticRS" only when the programer has strong reasons to disallow the modification of this recordset from the PHP code. -------------------------------------------------------------------- * - The JS code of a <WebBox> is included automatically by the framework at the <head> of the page. The framework looks for the file 'box_id.js' (or 'class_id.js', in case of a <WebClass>) in the same folder with the <WebBox>. If it exists there, then the framework includes a line like this in the <head> of the page: <script language='javascript' src='path/to/box_id.js'></script> Similarly, for the CSS code, the framework includes a line like this: <link type='stylesheet' src='path/to/box_id.css' ....> in the <head> of the page. ---------------- SendEvent() ---------------------------------------- * - js function: SendEvent(obj_id, event_name, event_args) Sends an event to the server-side (PHP) code. obj_id -- the object to which the event is sent event_name -- the name of the event event_args -- the arguments of the event, optional It is defined in 'func.GoTo.js' which is included automatically by the framework in each page. This function uses GoTo() to send an event to a webobject (or webbox). Its target is always 'thisPage' (so, it cannot switch to another page of the application, like GoTo()) and it cannot send global PHP variables (like GoTo()). So, GoTo() is more general, but SendEvent() should be more common and more frequently used. ---------------- WebObject table ------------------------------------- * - WebObject 'table' is used to display the content of a table inside a page. It is used like this: <Include SRC="{{TABLE_PATH}}table.html" /> <WebObject Class="table" Name="offices" table="offices" fields="off_id,name" where="off_id < 10" /> If attribute 'table' is the name of the table that will be displayed. If it is not specified, its default value is {{obj_name}} (the value of attribute 'Name'). The attribute 'fields' is the list of fields that will be displayed. It is optional and its default value is "*" (all fields). The attribute 'where' is the select condition for selecting the records. It is optional and its default value is "" (all the records). ---------------- WebObject editableTable --------------------------- * - WebObject 'editableTable' is used to display and edit the content of a database table inside a page. It is used like this: <Include SRC="{{EDITABLE_PATH}}editableTable.html" /> <WebObject Class="editableTable" Name="offices" table="offices" fields="off_id,name" where="off_id < 10" /> WebObject 'editableTable' is like 'table', but it also allows to add new records to the table, to edit the existing records, to delete a record from the table, or to remove all the records of the table that are displayed. ---------------- NULL values ----------------------------------------- * - For a DB value that was NULL, the framework used to return UNDEFINED and, as a result, in the page was displayed {var_name}. Now, the constant NULL_VALUE is returned, which can be specified in the file 'config/const.Settings.php'. It can be "", "NULL", NULL, etc. ---------------- leftMenu webobject ---------------------------------- * - WebObject 'leftMenu' displays a menu, usually on the left side of the page. It is used like this: <Include SRC="{{LEFTMENU_PATH}}leftMenu.html" /> <WebObject Class="leftMenu" Name="su" items="{{./}}su_menu_items.php" /> The attribute 'items' is a PHP file that contains the items of the menu, like this: <? /** * The $menu_items array contains the items of the leftMenu. */ $menu_items = array( "item1" => " Menu Item 1 ", "item2" => " Menu Item 2 ", "item3" => " Menu Item 3 ", "etc1" => " . . . ", "etc2" => " . . . " ); ?> The item of the menu that is selected can be retrieved like this: $selected = WebApp::getSVar("leftMenu::su->selected_item"); If you need to change the look of the leftMenu, then make a local copy and modify 'leftMenu.css'. -------------------------------------------------------------------- * - config/const.Settings.php is divided into const.Options.php (some constants that can have optional values, depending on the application), and const.Debug.php (constants that enable or disable several debugging features of the framework). -------------------------------------------------------------------- * - The GoTo() function accepts only a string of the form GoTo("target.html?event=obj_id.event_name(event_args)"); Before it was possible to send some global PHP vars, by appending them after the event like this: &var1=val1&var2=val2 etc. This was deprecated and actually it is almost never used. In the rare cases when it is needed to send a global variable to PHP, the functions transmitVar() and transmitVars() can be used. The values of the event arguments could not contain '&' before, but now they can. They cannot contain ';', because it is used to separate event args from each-other, however, the JS function encode_arg_value(str), which is defined by the framework, can be used to replace them with '#semicolumn#', in cases that they need to contain ';'. The decoding (replacing '#semicolumn#' by ';') is done by the framework itself. -------------------------------------------------------------------- * - The expression of the <Var> tag can now be declared in several lines, like this: <Var name="class"> ( "{{item}}"=="{{{{obj_id}}->selected_item}}" ? "leftMenu-item-selected" :"leftMenu-item" ) </Var> -------------------------------------------------------------------- * - WebObject 'dbTable' is used to display and edit the content of a database table inside a page. It is used like this: <Include SRC="{{DBTABLE_PATH}}dbTable.html" /> <WebObject Class="dbTable" Name="offices" table = "offices" fields = "off_id,name" where = "off_id < 10" editable = "true" selectable = "true" /> It is like 'editableTable' but has two more attributes. The attributes 'editable' and 'selectable' have default values of "false". In this case the 'dbTable' behaves just like 'table'. When 'editable' has a value "true", then the table is editable, i.e. its records can be added, deleted or modified. When 'selectable' has a value "true", then it is possible to select a record from the displayed ones. The fields of the selected record are declared as global template variables and can be used where they are needed. It makes obsolete WebObjects 'table' and 'editableTable', however 'table' is still left in the framework because it is simpler than 'dbTable' and it can be easier to modify and customize to fit the needs of a certain application. -------------------------------------------------------------------- * - config/const.Debug.php: define("SHOW_ERROR_MESSAGES", true); If this constant is 'false' than the framework suppresses all the error and warning messages (that are generated by the framework). Usually it should be 'true' during the development and should be switched to 'false' when the application is deployed, in order not to confuse the users of the application with error messages that have no meaning for them. -------------------------------------------------------------------- * - The function: session.isset(var_name) can be used to check whether a certain variable egzists in the session or not. -------------- datebox WebObject ----------------------------------- * - The webbox 'date' is renamed to 'datebox' and the attributes (parameters) 'value', 'format', 'onchange' are added to it. <Include SRC="{{DATEBOX_PATH}}datebox.html" /> <WebObject Class="datebox" Name="information_date" value="{{info_date}}" format="YYYY-MM-DD" onchange="check_selected_date(this)" /> <WebObject Class="datebox" Name="proposal_date" /> <WebObject Class="datebox" Name="contact_date" /> etc. The attribute 'value' is used to initialize the datebox with an initial value. If it is not given, then the default is {{{{obj_name}}}} (in the example above it would be {{information_date}}). The attribute 'format' is used to specify the format of the date. The reckognized formats are: YYYY-MM-DD (default) MM/DD/YYYY MM-DD-YYYY DD/MM/YYYY DD-MM-YYYY Actually this is only the format of the display, because the internal format is allways YYYY-MM-DD, the format used by the databases. E.g. if the above datebox webobject is declared inside a form with the name 'editDoc', then "document.editDoc.information_date.value" returns the date in the internal format (in the format YYYY-MM-DD). The attribute 'onchange' (be carefull, all lowercase) is used to call any validation function at the time that the date is changed. If you pass 'this' as a argument to this function, then it refers to the display format. E.g. if 'date' is the parameter to which 'this' is passed, then "d = date.value;" gets the selected date in the display format (which is specified by the attribute 'format'), and "date.value = d;" sets the date of the datebox ('d' should be in the format specified by 'format'). -------------------------------------------------------------------- * - WebObject 'listbox' can now take another attribute, 'onchange' (all lowercase), where the programer can call some JS code when the selected value is changed. -------------------------------------------------------------------- * - PagedRS can also handle the queries which have GROUP BY. Along to the state variable 'rs_id->current_page' which keeps the current page of the PagedRS, there is the state variable 'rs_id->recount' which is set to true by the application when the records need to to be recounted (e.g. when a new record is added in DB, or when a record is deleted). Before, the number of the records in a PagedRS was counted only when current_page was 1, but this is not very convenient. -------------------------------------------------------------------- * - define("DISPLAY_CGI_VARS", false); (at 'config/const.Options.php') When this constant is true, then the CGI vars are displayed at the URL window of the browser. See also SHOW_EXTERNAL_LINK at const.Debug.php. -------------------------------------------------------------------- * - The framework now gets the user variables (browser variables) from $_GET, $_POST and $_REQUEST, in order to comply with PHP 4.2.0 The global object $request (of class Request, declared in /session/class.Request.php) can be used to get the browser variables: sourcePage, targetPage, sessionVars, strEvents, phpVars. -------------------------------------------------------------------- * - Changes in the structure of the files of the application; event_handler/on.firstTime.php is replaced by 'init.php', which is called (if it exists) the first time that the application is opened. define("FIRSTPAGE", "main.html"); in 'config/const.Settings.php' sets the first page of the application. -------------------------------------------------------------------- -------------------------------------------------------------------- -------------------------------------------------------------------- -------------------------------------------------------------------- -------------------------------------------------------------------- -------------------------------------------------------------------- -------------------------------------------------------------------- Index: xhtml_template_specification.txt =================================================================== RCS file: /cvsroot/phpwebapp/web_app/doc/xhtml_template_specification.txt,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** xhtml_template_specification.txt 13 Jul 2004 13:18:08 -0000 1.3 --- xhtml_template_specification.txt 13 Jul 2004 16:15:20 -0000 1.4 *************** *** 5,171 **** * Comments ========== ! <!--# Comments are denoted like this #--> ! <!--# diesis at the beginning, diesis at the end #--> ! <!--# ! Such comments are not included ! in the XHTML file that is generated. ! #--> ! <!-- ! Usual XHTML comments (like this one) are passed to ! the XHTML file that is generated from the template. ! --> * Include elements ================== ! <Include file="{{MSG_BOX}}"/> ! <!--- ! The <Include> element is used to include in templates ! parts that are the same in many templates. It also ! provides flexibility in the sense that the file that ! will be included may be a variable, so different files ! may be included in different cases. ! The file that is included will be processed as if it were ! in the place of the <Include> element (so it may contain ! elements, variables, etc). ! ---> * Repeat elements ================= ! <Repeat RS="art"> ! <!--- IfEmpty is included in XHTML in case that recordset specified has no records ---> ! <IfEmpty> ! <tr> ! <td>No articles found!</td> ! </tr> ! </IfEmpty> ! <!--- Here comes the part that is reapeated for each record in the recordset ---> ! <tr> ! <td> {{TI}} </td> ! <td> {{AU}} </td> ! . . . ! </tr> ! </Repeat> ! <!--- ! The <Repeat> element is connected with a recordset by the attribute ! "RS". Its content is processed for each row of the recordset. Before ! processing the content for a certan row, all the fields of the recordset ! are declared as variables with values taken from the current row. ! In case that the recordset is empty, then the element <IfEmpty> is ! processed instead. (Subject to be discussed). ! Subject to be discussed: should we also include <Header> and <Footer> ! elements? ! ---> * <If> element =============== ! <If condition="!{{PUBLIC_LIBRARY}}"> ! <!--- MyLibrary part comes here ---> ! <!--- . . . . . . . . . . . . . ---> ! </If> ! <!--- ! The content of the <If> element is processed conditionally, ! if the value of the attribute "condition" is true, then it ! is processed, otherwise it is not processed. ! The value of the condition is calculated as a PHP expression ! (after the template variables are replaced). ! ---> * <Recordset> elements ======================= ! <Recordset ID="rsID"> ! <Query> select {{R_NAME}} from table </Query> ! </Recordset> ! <!--- ! Each recordset has a unique ID. Later, when we use ! this recordset (e.g. in a <Repeat> element) we refer ! to it by this ID. It also has a <Query> element, which ! is executed using the default database connection. ! ---> * Recordsets that are displayed over several pages =================================================== ! <Recordset ID="art" RowsPerPage="10"> ! <Query>{{ART_QUERY}}</Query> ! </Recordset> ! <!--- ! Recordsets that have a RowsPerPage attribute are ! recordsets that are displayed over several pages. ! In this case some additional variables are declared ! which show which records are being displayed, how many ! pages are there, and at which page we are currently. ! These variables can be used anywhere in the template. ! Such variables are: {{art_PrevPage}}, {{art_CurrentPage}}, ! {{art_NextPage}}, {{art_NrPages}}, {{art_FirstRecord}}, ! {{art_LastRecord}}, {{art_NrRecords}}, etc. (their names ! are generated using the id of the recordset). ! Some of them are also saved as session variables. In our ! example, {{art_CurrentPage}} is a session variable and is passed ! from this page to the next one. ! ---> * <Var> elements ================= ! <Var name="MSG_SEARCH">"Results of search for: {{SEARCH_TERM}}"</Var> ! <Var name="ROW_COLOR">($Cnt%2 ? 'class="tabgrey"' : 'class="tabwhite"')</Var> ! <!--- ! <Var> elements declare variables that can be used anywhere in the ! template in the current scope and in the scopes inside it. They ! are identified by their name, and their value is calculated using ! their content. The value of a variable is calculated in this way: ! -first, any template variable inside them is found and replaced, ! -second, the resulting string is evaluated as a PHP expression, ! -finally, the resulting value is assigned to the variable. ! (This way of evaluation is subject to be discussed and refined.) ! A variable is evaluated at the time that it is processed, so that ! if a variable is inside a <Repeat> element, then it may have different ! values for different iterations. ! The scopes of the variables are determined by the elements <Repeat>, ! <If>, etc. (each of these elements defines a new scope). If two ! variables have the same name, then the one in the closer scope is ! used. If they are both in the same scope, then the one defined later ! overrides the other. ! ---> * Template variables ===================== ! <!--- ! Anywhere in XML where we can put character data, ! we can also put {{variables}}, which are replaced ! by their string values at the time of template ! processing and convertion to XHTML. ! To find the value of a variable: ! -The current scope is searched for it. ! -If it is not found, then the scope above it is searched, ! and so on until it is found. ! -If it is not found in any scope, then session variables ! are searched for it. ! -If it not found among session variables, then global variables ! of PHP are searched for it. ! -If it still is not found then its name is taken as its value ! (e.g. {{var1}} is replaced by "var1"). ! The order of search is subject to be discussed and refined. ! ---> --- 5,171 ---- * Comments ========== ! <!--# Comments are denoted like this #--> ! <!--# diesis at the beginning, diesis at the end #--> ! <!--# ! Such comments are not included ! in the XHTML file that is generated. ! #--> ! <!-- ! Usual XHTML comments (like this one) are passed to ! the XHTML file that is generated from the template. ! --> * Include elements ================== ! <Include file="{{MSG_BOX}}"/> ! <!--- ! The <Include> element is used to include in templates ! parts that are the same in many templates. It also ! provides flexibility in the sense that the file that ! will be included may be a variable, so different files ! may be included in different cases. ! The file that is included will be processed as if it were ! in the place of the <Include> element (so it may contain ! elements, variables, etc). ! ---> * Repeat elements ================= ! <Repeat RS="art"> ! <!--- IfEmpty is included in XHTML in case that recordset specified has no records ---> ! <IfEmpty> ! <tr> ! <td>No articles found!</td> ! </tr> ! </IfEmpty> ! <!--- Here comes the part that is reapeated for each record in the recordset ---> ! <tr> ! <td> {{TI}} </td> ! <td> {{AU}} </td> ! . . . ! </tr> ! </Repeat> ! <!--- ! The <Repeat> element is connected with a recordset by the attribute ! "RS". Its content is processed for each row of the recordset. Before ! processing the content for a certan row, all the fields of the recordset ! are declared as variables with values taken from the current row. ! In case that the recordset is empty, then the element <IfEmpty> is ! processed instead. (Subject to be discussed). ! Subject to be discussed: should we also include <Header> and <Footer> ! elements? ! ---> * <If> element =============== ! <If condition="!{{PUBLIC_LIBRARY}}"> ! <!--- MyLibrary part comes here ---> ! <!--- . . . . . . . . . . . . . ---> ! </If> ! <!--- ! The content of the <If> element is processed conditionally, ! if the value of the attribute "condition" is true, then it ! is processed, otherwise it is not processed. ! The value of the condition is calculated as a PHP expression ! (after the template variables are replaced). ! ---> * <Recordset> elements ======================= ! <Recordset ID="rsID"> ! <Query> select {{R_NAME}} from table </Query> ! </Recordset> ! <!--- ! Each recordset has a unique ID. Later, when we use ! this recordset (e.g. in a <Repeat> element) we refer ! to it by this ID. It also has a <Query> element, which ! is executed using the default database connection. ! ---> * Recordsets that are displayed over several pages =================================================== ! <Recordset ID="art" RowsPerPage="10"> ! <Query>{{ART_QUERY}}</Query> ! </Recordset> ! <!--- ! Recordsets that have a RowsPerPage attribute are ! recordsets that are displayed over several pages. ! In this case some additional variables are declared ! which show which records are being displayed, how many ! pages are there, and at which page we are currently. ! These variables can be used anywhere in the template. ! Such variables are: {{art_PrevPage}}, {{art_CurrentPage}}, ! {{art_NextPage}}, {{art_NrPages}}, {{art_FirstRecord}}, ! {{art_LastRecord}}, {{art_NrRecords}}, etc. (their names ! are generated using the id of the recordset). ! Some of them are also saved as session variables. In our ! example, {{art_CurrentPage}} is a session variable and is passed ! from this page to the next one. ! ---> * <Var> elements ================= ! <Var name="MSG_SEARCH">"Results of search for: {{SEARCH_TERM}}"</Var> ! <Var name="ROW_COLOR">($Cnt%2 ? 'class="tabgrey"' : 'class="tabwhite"')</Var> ! <!--- ! <Var> elements declare variables that can be used anywhere in the ! template in the current scope and in the scopes inside it. They ! are identified by their name, and their value is calculated using ! their content. The value of a variable is calculated in this way: ! -first, any template variable inside them is found and replaced, ! -second, the resulting string is evaluated as a PHP expression, ! -finally, the resulting value is assigned to the variable. ! (This way of evaluation is subject to be discussed and refined.) ! A variable is evaluated at the time that it is processed, so that ! if a variable is inside a <Repeat> element, then it may have different ! values for different iterations. ! The scopes of the variables are determined by the elements <Repeat>, ! <If>, etc. (each of these elements defines a new scope). If two ! variables have the same name, then the one in the closer scope is ! used. If they are both in the same scope, then the one defined later ! overrides the other. ! ---> * Template variables ===================== ! <!--- ! Anywhere in XML where we can put character data, ! we can also put {{variables}}, which are replaced ! by their string values at the time of template ! processing and convertion to XHTML. ! To find the value of a variable: ! -The current scope is searched for it. ! -If it is not found, then the scope above it is searched, ! and so on until it is found. ! -If it is not found in any scope, then session variables ! are searched for it. ! -If it not found among session variables, then global variables ! of PHP are searched for it. ! -If it still is not found then its name is taken as its value ! (e.g. {{var1}} is replaced by "var1"). ! The order of search is subject to be discussed and refined. ! ---> Index: to_do.txt =================================================================== RCS file: /cvsroot/phpwebapp/web_app/doc/to_do.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** to_do.txt 13 Jul 2004 13:18:08 -0000 1.1 --- to_do.txt 13 Jul 2004 16:15:20 -0000 1.2 *************** *** 1,21 **** * Parse the templates using an XML parser. - Fix the problems with <Repeat>. ! - There is a problem with the Repeat/Header tags, because the ! contents of the <Header> usually is not well-formed xml and ! this breaks the xml parsing. E.g. it may be something like this: ! <repeat rs="rs_id"> ! <header> ! <table> ! </header> ! <tr><td>{{xyz}}</td></tr> ! <footer> ! </table> ! </footer> ! </repeat> ! Think about how to solve this. ! - Handle XML errors (in templates) as gracefully as possible. - Use 'tidy' or any shell scripts for converting from HTML to XHTML. --- 1,21 ---- * Parse the templates using an XML parser. + - Handle XML errors (in templates) as gracefully as possible. + + In case of error, when popping the templates from the stack, + call also the corresponding function (e.g. end_IF()), + according to the type of the template. + + - The xml parser has problems with entities (e.g. < & etc.) + Why? + - Fix the problems with <Repeat>. + + Why the navigation vars work even without a <RSNavig> template? ! - class.WebPage.php::print_dbg_messages() ! Output debug messages using EditableRS and templates. ! ! - Use css styles to the other debug messages as well. ! - Substitute ereg_replace() with preg_replace(). - Use 'tidy' or any shell scripts for converting from HTML to XHTML. *************** *** 29,32 **** --- 29,33 ---- - Improve the output, so that the XHTML page that is generated is well-formed, well-indented, etc. + + fix some problems with the indentation + don't output <br></br>, but <br/> (similar for other empty tags) + don't apply indentation for tags <pre>, <xmp>, etc. *************** *** 37,52 **** conversion tool(s)). - Make any small improvments in the documentation. - Make a new release of phpwebapp that includes the latest changes in the parser any improvments in the docs, etc. - - - * class.WebPage.php::print_dbg_messages() - Output debug messages using EditableRS and templates. - - * Use css styles to the other debug messages as well. - - * Substitute ereg_replace() with preg_replace(). - - * Reformat all the files (automatically with emacs). --- 38,45 ---- conversion tool(s)). + - Reformat all the files (automatically with emacs). + - Make any small improvments in the documentation. - Make a new release of phpwebapp that includes the latest changes in the parser any improvments in the docs, etc. Index: changes.txt =================================================================== RCS file: /cvsroot/phpwebapp/web_app/doc/changes.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** changes.txt 16 Jul 2003 09:27:59 -0000 1.2 --- changes.txt 13 Jul 2004 16:15:20 -0000 1.3 *************** *** 1,450 **** Changes made to the application framework ! that the application developer should know: =========================================== ! -------- afterParse() ---------------------------- ! * - WebObject::afterParse() ! is like WebObject::onParse(), only that it is called after ! the WebObject is parsed. ! ! -------- webobject vars -------------------------- ! * - The framework declares for each webobject these variables: ! {{obj_id}} -- the object id ({{class_name}}::{{obj_name}}) ! {{class_name}} -- the name of the class ! {{obj_name}} -- the name of the object ! {{obj_count}} -- counts the objects of the same class, ! starting from 1 ! These vars can be used inside the template of the webclass, ! if the webclass designer needs them, e.g.: ! <input type="text" name="staff_{{obj_count}}"> ! ! -------- transmitVars() -------------------------- ! * - function transmitVar(var_name, var_value) ! This function sends the var_name (which has the given var_value) ! to the server side as a PHP global variable. It can also be used ! in the template as a tpl variable: {{var_name}}, since all PHP ! global variables can be used as tpl variables. It should be used ! carefully, because any tpl variable with the same name will ! override its value. ! It must be called before GoTo(). ! ! - function transmitVars(var_list) ! Similar to transmitVar() but can transmit more than one variable. ! The format of var_list is: var1=val1&var=val2&var3=val3. ! Must be called before GoTo(). ! ! -------- formWebObj ---------------------------------- ! * - formWebObj is a webobject that makes easy the handling of big ! forms (which have many inputs) and their data connection to the ! databaze. It is used like this: when you have a webbox that ! has a big form, in the PHP code of the webbox you include the ! class 'formWebObj', and then inherit this class, instead of ! inheriting 'WebObject' ('formWebObj' itself extends 'WebObject', ! so this is OK). E.g.: ! ! <WebBox ID="editProject"> ! <form name="bigForm"> ! . . . . . . . . ! <!--# many <input>s, <select>s, etc. here #--> ! . . . . . . . . ! </form> ! </WebBox> ! ---------------------------------------------- ! <? ! include_once FORM_PATH."formWebObj.php"; ! ! class editProject extends formWebObj ! { ! . . . . . . . . . . ! } ! ?> ! ---------------------------------------------- ! <? ! class formWebObj extends WebObject ! { ! . . . . . . . . . . . ! } ! ?> ! ! Then, in the JS code of the webbox you can use these JS functions ! which have been declared and included by the 'formWebObj': ! ! getEventArgs(form); ! /** ! * Returns all the data in the inputs of the given form ! * so that they can be sent as event args, e.g. ! * GoTo("thisPage?event=editProject.save(" + getEventArgs(form) + ")"); ! */ ! ! saveFormData(form); ! /** ! * Transmit the data of the form, so that ! * the changed values are not lost. ! * Must be called before GoTo(). ! */ ! This is useful when the page is refreshed for some reason, ! but you don't want to lose the values that are inputed in it. ! ! There are also these two functions that are used internally by ! 'formWebObj', but you can use them as well, if you need them: ! function getFormData(form) ! //returns all the data filled in the given form ! function setFormData(form, formData) ! //fills the form with the given data ! ! ------------- date WebObject ------------------------------- ! * - The webobject date can be used to select the date from a calendar. ! It can be used like this: ! First include the webclass that defines it: ! <Include SRC="{{DATE_PATH}}date.html" /> ! (DATE_PATH is defined by the framework) ! Then declare as many date objects as needed: ! <WebObject Class="date" Name="information_date" /> ! <WebObject Class="date" Name="contact_date" /> ! etc. ! ! When an object of class date is declared, the framework replaces ! it with this html code: ! <input type="text" class="datebox" onFocus="blur()" ! name="information_date" value="{{information_date}}"> ! <input type="image" ...(the calendar that selects the date)> ! So, it requires a default value {{information_date}}, which can ! be declared in the PHP code of the webox that uses the date object. ! ! If you want to modify it, you can copy it to a path local to ! the application, modify it and use the modified copy, e.g. ! <Include SRC="{{./}}date/date.html" /> ! ! -------------------------------------------------------------- ! * - <Repeat rs="{{tpl_var}}"> ! The attribute rs of the <Repeat> tag can contain variables ! (so that the same repeat can use different recordsets, ! according to the logic of the program). These variables ! are evaluated now in render time (before they were evaluated ! in parse time) because this is more convenient. ! ! ------------- listbox WebObject ------------------------------- ! * - The WebClass "listbox" is used to display a list of values with the ! <select> tag of HTML. These values are taken from a recordset (which ! can be retrieved from DB or can be supplied by PHP code. The recodset ! associated with the listbox must have two fields: 'id' and 'label'. ! 'label' is the field displayed, and 'id' is the value that is selected, ! saved in DB and retrieved from DB. ! ! Recordset example: ! <Recordset ID="listbox::country"> ! <Query> ! SELECT country_id AS id, country_name AS label ! FROM countries ! </Query> ! </Recordset> ! ! Usage example: ! <WebObject Class="listbox" Name="country" rs="rs_id" width="---------------" /> ! ! The attribute "rs" is optional. Its default value (if not specified) is ! {{obj_id}} (in the example above, it would be 'listbox::country'). ! ! The attribute "width" is also optional; it is used as the last line of the ! list, in order to keep the width of the <select> to a certain size (which ! can also be used as a nothing selected (none of the above) value). ! ! This WebClass uses a <select> tag like this: ! <select name="country"> (name="{{obj_name}}") ! . . . . . ! </select> ! So, this should be kept in mind when accessing the selected value ! and when giving an initial value. ! If the 'listbox' is used inside a 'formWebObj' webbox, then it ! takes care of it automatically. ! ! -------------------------------------------------------------------- ! * - The tag <WebObject> can be written in several lines (for making it ! more readable, in case that it has many attributes) and the parser ! can handle it. E.g. ! <WebObject Class = "listbox" Name = "country" ! rs = "rs_id" ! width = "---------------" /> ! ! -------------------------------------------------------------------- ! * - define("VAR_NOT_FOUND", "{var_name}"); ! is added to 'config/const.Settings.php' ! ! This constant sets the format of the error message that is displayed ! when a {{variable}} is not found. 'var_name' is replaced by ! the actual variable name. Examples: "'var_name' is not defined", ! "", "undefined", etc. It cannot contain "{{var_name}}" inside. ! ! -------------------------------------------------------------------- ! * - The recordsets declared by the <Recordset> tag were by default ! of type "StaticRS". Now the default type is "EditableRS", ! because this is more useful (and anyway EditableRS extends StaticRS). ! It can be declared explicitly as "StaticRS" only when the programer ! has strong reasons to disallow the modification of this recordset ! from the PHP code. ! ! -------------------------------------------------------------------- ! * - The JS code of a <WebBox> is included automatically by the ! framework at the <head> of the page. The framework looks for ! the file 'box_id.js' (or 'class_id.js', in case of a <WebClass>) ! in the same folder with the <WebBox>. If it exists there, then ! the framework includes a line like this in the <head> of the page: ! <script language='javascript' src='path/to/box_id.js'></script> ! ! Similarly, for the CSS code, the framework includes a line like ! this: <link type='stylesheet' src='path/to/box_id.css' ....> ! in the <head> of the page. ! ! ---------------- SendEvent() ---------------------------------------- ! * - js function: SendEvent(obj_id, event_name, event_args) ! ! Sends an event to the server-side (PHP) code. ! obj_id -- the object to which the event is sent ! event_name -- the name of the event ! event_args -- the arguments of the event, optional ! ! It is defined in 'func.GoTo.js' which is included automatically ! by the framework in each page. This function uses GoTo() to ! send an event to a webobject (or webbox). Its target is always ! 'thisPage' (so, it cannot switch to another page of the application, ! like GoTo()) and it cannot send global PHP variables (like GoTo()). ! So, GoTo() is more general, but SendEvent() should be more common ! and more frequently used. ! ! ---------------- WebObject table ------------------------------------- ! * - WebObject 'table' is used to display the content of a table inside a page. ! It is used like this: ! ! <Include SRC="{{TABLE_PATH}}table.html" /> ! ! <WebObject Class="table" Name="offices" ! table="offices" ! fields="off_id,name" ! where="off_id < 10" /> ! ! If attribute 'table' is the name of the table that will be displayed. ! If it is not specified, its default value is {{obj_name}} (the value ! of attribute 'Name'). ! ! The attribute 'fields' is the list of fields that will be displayed. ! It is optional and its default value is "*" (all fields). ! ! The attribute 'where' is the select condition for selecting the records. ! It is optional and its default value is "" (all the records). ! ! ---------------- WebObject editableTable --------------------------- ! * - WebObject 'editableTable' is used to display and edit the content ! of a database table inside a page. It is used like this: ! ! <Include SRC="{{EDITABLE_PATH}}editableTable.html" /> ! ! <WebObject Class="editableTable" Name="offices" ! table="offices" ! fields="off_id,name" ! where="off_id < 10" /> ! ! WebObject 'editableTable' is like 'table', but it also allows to ! add new records to the table, to edit the existing records, to delete ! a record from the table, or to remove all the records of the table ! that are displayed. ! ! ---------------- NULL values ----------------------------------------- ! * - For a DB value that was NULL, the framework used to return UNDEFINED ! and, as a result, in the page was displayed {var_name}. ! Now, the constant NULL_VALUE is returned, which can be specified ! in the file 'config/const.Settings.php'. It can be "", "NULL", NULL, etc. ! ! ---------------- leftMenu webobject ---------------------------------- ! * - WebObject 'leftMenu' displays a menu, usually on the left side of the page. ! It is used like this: ! ! <Include SRC="{{LEFTMENU_PATH}}leftMenu.html" /> ! ! <WebObject Class="leftMenu" Name="su" ! items="{{./}}su_menu_items.php" /> ! ! The attribute 'items' is a PHP file that contains the items of the menu, ! like this: ! <? ! /** ! * The $menu_items array contains the items of the leftMenu. ! */ ! $menu_items = array( ! "item1" => " Menu Item 1 ", ! "item2" => " Menu Item 2 ", ! "item3" => " Menu Item 3 ", ! "etc1" => " . . . ", ! "etc2" => " . . . " ! ); ! ?> ! ! The item of the menu that is selected can be retrieved like this: ! $selected = WebApp::getSVar("leftMenu::su->selected_item"); ! ! If you need to change the look of the leftMenu, then make a local ! copy and modify 'leftMenu.css'. ! -------------------------------------------------------------------- ! * - config/const.Settings.php is divided into const.Options.php ! (some constants that can have optional values, depending on the ! application), and const.Debug.php (constants that enable or ! disable several debugging features of the framework). ! -------------------------------------------------------------------- ! * - The GoTo() function accepts only a string of the form ! GoTo("target.html?event=obj_id.event_name(event_args)"); ! Before it was possible to send some global PHP vars, by appending ! them after the event like this: &var1=val1&var2=val2 etc. ! This was deprecated and actually it is almost never used. In the ! rare cases when it is needed to send a global variable to PHP, ! the functions transmitVar() and transmitVars() can be used. ! The values of the event arguments could not contain '&' before, ! but now they can. ! ! They cannot contain ';', because it is used to separate event args ! from each-other, however, the JS function encode_arg_value(str), ! which is defined by the framework, can be used to replace them ! with '#semicolumn#', in cases that they need to contain ';'. ! The decoding (replacing '#semicolumn#' by ';') is done by the ! framework itself. ! -------------------------------------------------------------------- ! * - The expression of the <Var> tag can now be declared in several ! lines, like this: ! <Var name="class"> ! ( ! "{{item}}"=="{{{{obj_id}}->selected_item}}" ? ! "leftMenu-item-selected" ! :"leftMenu-item" ! ) ! </Var> ! ! -------------------------------------------------------------------- ! * - WebObject 'dbTable' is used to display and edit the content ! of a database table inside a page. It is used like this: ! ! <Include SRC="{{DBTABLE_PATH}}dbTable.html" /> ! ! <WebObject Class="dbTable" Name="offices" ! table = "offices" ! fields = "off_id,name" ! where = "off_id < 10" ! editable = "true" ! selectable = "true" /> ! ! It is like 'editableTable' but has two more attributes. ! The attributes 'editable' and 'selectable' have default values of "false". ! In this case the 'dbTable' behaves just like 'table'. ! ! When 'editable' has a value "true", then the table is editable, ! i.e. its records can be added, deleted or modified. ! ! When 'selectable' has a value "true", then it is possible to select ! a record from the displayed ones. The fields of the selected record ! are declared as global template variables and can be used where they ! are needed. ! ! It makes obsolete WebObjects 'table' and 'editableTable', however ! 'table' is still left in the framework because it is simpler than ! 'dbTable' and it can be easier to modify and customize to fit ! the needs of a certain application. ! ! -------------------------------------------------------------------- ! * - config/const.Debug.php: define("SHOW_ERROR_MESSAGES", true); ! ! If this constant is 'false' than the framework suppresses ! all the error and warning messages (that are generated by the ! framework). Usually it should be 'true' during the development and ! should be switched to 'false' when the application is deployed, ! in order not to confuse the users of the application with error ! messages that have no meaning for them. ! ! -------------------------------------------------------------------- ! * - The function: session.isset(var_name) can be used to check ! whether a certain variable egzists in the session or not. ! ! -------------- datebox WebObject ----------------------------------- ! * - The webbox 'date' is renamed to 'datebox' and the attributes ! (parameters) 'value', 'format', 'onchange' are added to it. ! <Include SRC="{{DATEBOX_PATH}}datebox.html" /> ! <WebObject Class="datebox" Name="information_date" ! value="{{info_date}}" ! format="YYYY-MM-DD" ! onchange="check_selected_date(this)" /> ! <WebObject Class="datebox" Name="proposal_date" /> ! <WebObject Class="datebox" Name="contact_date" /> ! etc. ! The attribute 'value' is used to initialize the datebox ! with an initial value. If it is not given, then the ! default is {{{{obj_name}}}} (in the example above it would ! be {{information_date}}). ! The attribute 'format' is used to specify the format of the ! date. The reckognized formats are: ! YYYY-MM-DD (default) ! MM/DD/YYYY ! MM-DD-YYYY ! DD/MM/YYYY ! DD-MM-YYYY ! Actually this is only the format of the display, because the ! internal format is allways YYYY-MM-DD, the format used by ! the databases. E.g. if the above datebox webobject is declared ! inside a form with the name 'editDoc', then ! "document.editDoc.information_date.value" returns the date in ! the internal format (in the format YYYY-MM-DD). ! The attribute 'onchange' (be carefull, all lowercase) is used ! to call any validation function at the time that the date is changed. ! If you pass 'this' as a argument to this function, then it ! refers to the display format. E.g. if 'date' is the parameter to ! which 'this' is passed, then "d = date.value;" gets the selected ! date in the display format (which is specified by the attribute ! 'format'), and "date.value = d;" sets the date of the datebox ! ('d' should be in the format specified by 'format'). ! -------------------------------------------------------------------- ! * - WebObject 'listbox' can now take another attribute, 'onchange' ! (all lowercase), where the programer can call some JS code ! when the selected value is changed. ! -------------------------------------------------------------------- ! * - PagedRS can also handle the queries which have GROUP BY. ! Along to the state variable 'rs_id->current_page' which keeps ! the current page of the PagedRS, there is the state variable ! 'rs_id->recount' which is set to true by the application when ! the records need to to be recounted (e.g. when a new record is ! added in DB, or when a record is deleted). ! Before, the number of the records in a PagedRS was counted only ! when current_page was 1, but this is not very convenient. ! -------------------------------------------------------------------- ! * - define("DISPLAY_CGI_VARS", false); (at 'config/const.Options.php') ! When this constant is true, then the CGI vars are displayed ! at the URL window of the browser. See also SHOW_EXTERNAL_LINK ! at const.Debug.php. ! -------------------------------------------------------------------- ! * - The framework now gets the user variables (browser variables) ! from $_GET, $_POST and $_REQUEST, in order to comply with PHP 4.2.0 ! The global object $request (of class Request, declared in ! /session/class.Request.php) can be used to get the browser variables: ! sourcePage, targetPage, sessionVars, strEvents, phpVars. ! ! -------------------------------------------------------------------- ! * - Changes in the structure of the files of the application; ! event_handler/on.firstTime.php is replaced by 'init.php', which ! is called (if it exists) the first time that the application is ! opened. ! define("FIRSTPAGE", "main.html"); in 'config/const.Settings.php' ! sets the first page of the application. ! -------------------------------------------------------------------- ! -------------------------------------------------------------------- ! -------------------------------------------------------------------- ! -------------------------------------------------------------------- ! -------------------------------------------------------------------- ! -------------------------------------------------------------------- ! -------------------------------------------------------------------- --- 1,69 ---- Changes made to the application framework ! that the framework users should know: =========================================== ! ------------------------------------------------------------------- ! ------------------------------------------------------------------- ! ------------------------------------------------------------------- ! ------------------------------------------------------------------- ! ------------------------------------------------------------------- ! ------------------------------------------------------------------- ! ------------------------------------------------------------------- ! * <Repeat> syntax changed. ! There was a problem with the <Header>/<Footer> tags, because the ! contents of the <Header> usually is not well-formed xml and ! it breaks the xml parsing. E.g. it may be something like this: ! <repeat rs="rs_id"> ! <header> ! <table> ! </header> ! <tr><td>{{xyz}}</td></tr> ! <footer> ! </table> ! </footer> ! </repeat> ! In order to solve this, <Header> and <Footer> tags were removed at all. ! Now it can be done like this (which is well-formed xml): ! <table> ! <repeat rs="rs_id"> ! <tr><td>{{xyz}}</td></tr> ! </repeat> ! </table> ! For the case of paged recordsets, when we need the navigation variables ! (to get the next page, previous page, etc.) a new framework tag was added: ! <RSNavig rs="paged_rs_id"> ... </RSNavig> ! The tags <IfEmpty>, <Separator> and the dummy tag <RepeatBody> can be ! used the same as before. ! ------------------------------------------------------------------- ! * Parsing is done using an XML parser. This means that some ! restrictions that were due to the previous parser, now are remov... [truncated message content] |
From: Dashamir H. <das...@us...> - 2004-07-13 16:15:44
|
Update of /cvsroot/phpwebapp/web_app/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8906/parser Modified Files: parser.txt Log Message: Index: parser.txt =================================================================== RCS file: /cvsroot/phpwebapp/web_app/parser/parser.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** parser.txt 13 Jul 2004 13:18:08 -0000 1.1 --- parser.txt 13 Jul 2004 16:15:20 -0000 1.2 *************** *** 51,59 **** Most of these objects are inheritors of the class 'Template'. ! The Template class has a member variable 'content' that contains the ! string content of the template. It is an array of chunks and references. ! A chunk of data is a string that contains a part of the template; it ! may have new lines inside as well and may not be terminated by a new ! line. A reference is a string like this: '&&tpl_id;;', where tpl_id is the id of the template that is linked (or referenced) in this place. --- 51,57 ---- Most of these objects are inheritors of the class 'Template'. ! The Template class has a member variable 'contents' that contains the ! string contents of the template. It may contain references to other ! templates as well, which are marked like this: '&&tpl_id;;', where tpl_id is the id of the template that is linked (or referenced) in this place. |
From: Dashamir H. <das...@us...> - 2004-07-13 16:14:58
|
Update of /cvsroot/phpwebapp/web_app/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8772/parser Modified Files: package.ParseRender.php class.Template.php class.RepeatTpl.php class.Render.php class.Parser.php Added Files: class.RSNavigTpl.php Log Message: Modified the <Repeat> tag; added the tag <RSNavig. --- NEW FILE: class.RSNavigTpl.php --- <?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 */ /** * Recordset Navigator declares the navigation variables * of a paged recordset: {{PrevPage}}, {{NextPage}}, etc. * @package parser */ class RSNavigTpl extends Template { /** The id of the paged recordset. */ var $rsId; function RSNavigTpl($rs_id) { static $id = "RSNavigTpl_01"; Template::Template($id++, "RSNavigTpl"); //call the constructor of the superclass $this->rsId = $rs_id; } /** for debug */ function attribs2html() { $html = Template::attribs2html() . " <tr> <td bgcolor='#eeeeee' valign='top' align='right'>RS:</td> <td bgcolor='#f9f9f9'>" . $this->rsId ." </td> </tr> "; return $html; } } ?> Index: package.ParseRender.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/parser/package.ParseRender.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** package.ParseRender.php 25 Aug 2003 13:18:32 -0000 1.3 --- package.ParseRender.php 13 Jul 2004 16:14:48 -0000 1.4 *************** *** 32,35 **** --- 32,36 ---- include_once PARSER_PATH."class.IfTpl.php"; include_once PARSER_PATH."class.RepeatTpl.php"; + include_once PARSER_PATH."class.RSNavigTpl.php"; include_once PARSER_PATH."class.WebClassTpl.php"; include_once PARSER_PATH."class.WebObjectTpl.php"; Index: class.Template.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/parser/class.Template.php,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** class.Template.php 13 Jul 2004 13:18:08 -0000 1.8 --- class.Template.php 13 Jul 2004 16:14:48 -0000 1.9 *************** *** 159,163 **** <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'> <tr> <td bgcolor='#eeeeee' align='right' width='1%'>ID:</td> --- 159,176 ---- <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() . " ! <tr><td colspan='2' bgcolor='#f9f9ff'> ! " . $this->contents2html() . " ! </td></tr> ! </table> ! "; ! ! return $htmlTable; ! } ! ! function attribs2html() ! { ! $indent = strtr($this->indent, ' ', '#'); ! $html = " <tr> <td bgcolor='#eeeeee' align='right' width='1%'>ID:</td> *************** *** 174,186 **** </td> </tr> - " . $this->vars2html() . " - <tr><td colspan='2' bgcolor='#f9f9ff'> - " . $this->contents2html() . " - </td></tr> - </table> "; ! ! return $htmlTable; ! } /** @see toHtmlTable() */ --- 187,193 ---- </td> </tr> "; ! return $html; ! } /** @see toHtmlTable() */ *************** *** 214,218 **** { $tpl_id = $matches[1]; ! $tpl = $webPage->getTemplate($tpl_id); //$html .= $tpl->indent; $html .= "<a href='#$tpl_id'>&&$tpl_id;;</a>"; --- 221,225 ---- { $tpl_id = $matches[1]; ! //$tpl = $webPage->getTemplate($tpl_id); //$html .= $tpl->indent; $html .= "<a href='#$tpl_id'>&&$tpl_id;;</a>"; Index: class.RepeatTpl.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/parser/class.RepeatTpl.php,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** class.RepeatTpl.php 25 Aug 2003 13:18:32 -0000 1.5 --- class.RepeatTpl.php 13 Jul 2004 16:14:48 -0000 1.6 *************** *** 33,42 **** var $if_empty; - /** The header template. */ - var $header; - - /** The footer template. */ - var $footer; - /** The separator template. */ var $separator; --- 33,36 ---- *************** *** 49,54 **** $this->rsId = $rs_id; $this->if_empty = new Template($this->id."_IfEmpty", "IfEmpty"); - $this->header = new Template($this->id."_Header", "Header"); - $this->footer = new Template($this->id."_Footer", "Footer"); $this->separator = new Template($this->id."_Separator", "Separator"); } --- 43,46 ---- Index: class.Render.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/parser/class.Render.php,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** class.Render.php 13 Jul 2004 13:18:08 -0000 1.8 --- class.Render.php 13 Jul 2004 16:14:48 -0000 1.9 *************** *** 133,136 **** --- 133,139 ---- $this->render_WebObjectTpl($tpl); break; + case "RSNavigTpl": + $this->render_RSNavigTpl($tpl); + break; case "RepeatTpl": $this->render_RepeatTpl($tpl); *************** *** 188,191 **** --- 191,199 ---- $main_tpl->head->contents .= '</head>'; $main_tpl->body->contents .= '</body>'; + /* + global $webPage; + print $webPage->template_list(); + exit; + */ $this->render_FileTpl($main_tpl); } *************** *** 228,231 **** --- 236,287 ---- /** + * Render it as a normally, but add in the scope of the + * template the page (navigation) variables of the recordset, + * which are: {{NextPage}}, {{PrevPage}}, etc. + */ + function render_RSNavigTpl($tpl) + { + global $webPage, $tplVars; + + //get the recordset id + $rs_id = $tpl->rsId; + $rs_id = WebApp::replaceVars($rs_id); + //get a reference to the recordset of the RepeatTpl + if (isset($webPage->rs_collection[$rs_id])) + { + //we cannot use "$webPage->getRecordset($rs_id);" here + //because we need a reference to the recordset, + //and PHP functions cannot return a reference + $rs = &$webPage->rs_collection[$rs_id]; + } + else //such a recordset does not exist + { + $err_msg = WebApp::error_msg("Recordset '$rs_id' is undefined."); + $this->render_string($err_msg); + $this->render_Template($tpl); + return; + } + + if ($rs->type<>"PagedRS") + { + $err_msg = "Recordset '$rs_id' is not of type PagedRS."; + $this->render_string(WebApp::error_msg($err_msg)); + $this->render_Template($tpl); + return; + } + + $tplVars->pushScope(); //a new scope for the RSNavig element + + //add page vars (PrevPage, NextPage, etc) + $rs->Open(); + $tplVars->addVars($rs->getPageVars()); + + //render the template + $this->render_tpl($tpl); + + $tplVars->popScope(); + } + + /** * Renders the given $tpl of type RepeatTpl. */ *************** *** 253,283 **** } - $tplVars->pushScope(); //a new scope for the Repeat element - //open the recordset ! if ($rs->type=="PagedRS") ! { ! $rs->Open(); ! //add page vars (PrevPage, NextPage, etc) ! $rs_page_vars = $rs->getPageVars(); ! $tplVars->addVars($rs_page_vars); ! } ! else ! { ! $rs->Open(); ! } ! if ($rs->EOF()) { ! //recordset has no records $this->render_Template($tpl->if_empty); - $tplVars->popScope(); return; } ! //render the header ! $this->render_Template($tpl->header); ! ! //repeat the body for each record $row_nr = 1; while ( !$rs->EOF() ) --- 309,322 ---- } //open the recordset ! $rs->Open(); if ($rs->EOF()) { ! //recordset has no records, it is empty $this->render_Template($tpl->if_empty); return; } ! //render the body of repeat for each record $row_nr = 1; while ( !$rs->EOF() ) *************** *** 293,297 **** $tplVars->addVars($rs->Fields()); $tplVars->addVars($tpl->getVars()); ! $this->render_RepeatBody($tpl); if ($row_nr < $rs->count) --- 332,336 ---- $tplVars->addVars($rs->Fields()); $tplVars->addVars($tpl->getVars()); ! $this->render_tpl($tpl); if ($row_nr < $rs->count) *************** *** 301,318 **** } $tplVars->popScope(); $rs->MoveNext(); $row_nr++; } - - //render the footer - $this->render_Template($tpl->footer); - - $tplVars->popScope(); - } - - function render_RepeatBody($tpl) - { - $this->render_tpl($tpl); } } --- 340,348 ---- } + //get ready for the next iteration $tplVars->popScope(); $rs->MoveNext(); $row_nr++; } } } Index: class.Parser.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/parser/class.Parser.php,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** class.Parser.php 13 Jul 2004 13:18:08 -0000 1.9 --- class.Parser.php 13 Jul 2004 16:14:48 -0000 1.10 *************** *** 259,283 **** switch ($name) { - default: - $name = strtolower($name); - $attr_list = $this->get_attr_list($attribs); - $this->append("<${name}${attr_list}>"); - break; - - case 'DUMMYELEM': - case 'REPEATBODY': - //do nothing, just ignore them - break; - - case "IFEMPTY": - case "HEADER": - case "FOOTER": - case "SEPARATOR": - $this->start_Repeat_subtpl($name); - break; - case "TEMPLATE": case "IF": case "REPEAT": case "INCLUDE": case "HEAD": --- 259,268 ---- switch ($name) { case "TEMPLATE": case "IF": case "REPEAT": + case "IFEMPTY": + case "SEPARATOR": + case "RSNAVIG": case "INCLUDE": case "HEAD": *************** *** 292,295 **** --- 277,291 ---- $this->$start_ELEMENT($attribs); break; + + case 'DUMMYELEM': + case 'REPEATBODY': + //do nothing, just ignore them + break; + + default: + $name = strtolower($name); + $attr_list = $this->get_attr_list($attribs); + $this->append("<${name}${attr_list}>"); + break; } } *************** *** 305,332 **** switch ($name) { - default: - $name = strtolower($name); - $this->append("</$name>"); - break; - - case 'DUMMYELEM': - case 'INCLUDE': - case 'REPEATBODY': - //do nothing, just ignore them - break; - case "TEMPLATE": case "IF": case "REPEAT": - $this->end_TEMPLATE(); - break; - case "IFEMPTY": - case "HEADER": - case "FOOTER": case "SEPARATOR": ! $this->end_Repeat_subtpl($name); ! break; ! case "HEAD": case "BODY": --- 301,310 ---- switch ($name) { case "TEMPLATE": case "IF": case "REPEAT": case "IFEMPTY": case "SEPARATOR": ! case "RSNAVIG": case "HEAD": case "BODY": *************** *** 340,343 **** --- 318,332 ---- $this->$end_ELEMENT(); break; + + case 'DUMMYELEM': + case 'INCLUDE': + case 'REPEATBODY': + //do nothing, just ignore them + break; + + default: + $name = strtolower($name); + $this->append("</$name>"); + break; } } *************** *** 473,476 **** --- 462,483 ---- $this->append('&&'.$tpl->id.';;'); } + + function start_INCLUDE($attribs) + { + //get the filename + $tpl_filename = $attribs['SRC']; + $tpl_filename = WebApp::replaceVars($tpl_filename); + + //create a new file template + $tpl = new FileTpl($tpl_filename); + + //parse the file into this FileTpl + $tpl = $this->parse_file($tpl_filename, $tpl); + + if ($tpl<>UNDEFINED) + { + $this->link_template($tpl); + } + } function start_TEMPLATE($attribs) *************** *** 479,483 **** $this->push_current_tpl($tpl); } - function end_TEMPLATE() { --- 486,489 ---- *************** *** 491,494 **** --- 497,505 ---- $this->push_current_tpl($tpl); } + function end_IF() + { + $tpl = $this->pop_current_tpl(); + $this->link_template($tpl); + } function start_REPEAT($attribs) *************** *** 498,542 **** $this->push_current_tpl($tpl); } ! function start_INCLUDE($attribs) { ! //get the filename ! $tpl_filename = $attribs['SRC']; ! $tpl_filename = WebApp::replaceVars($tpl_filename); ! //create a new file template ! $tpl = new FileTpl($tpl_filename); ! //parse the file into this FileTpl ! $tpl = $this->parse_file($tpl_filename, $tpl); ! if ($tpl<>UNDEFINED) { $this->link_template($tpl); } } ! ! /** $tag has the values "IFEMPTY", "HEADER", "FOOTER" or "SEPARATOR" */ ! function start_Repeat_subtpl($tag) { ! switch ($tag) ! { ! case 'IFEMPTY': ! $tpl_type = 'IfEmpty'; ! break; ! case 'HEADER': ! $tpl_type = 'Header'; ! break; ! case 'FOOTER': ! $tpl_type = 'Footer'; ! break; ! case 'SEPARATOR': ! $tpl_type = 'Separator'; ! break; ! } ! $tpl_id = $this->current_tpl->id."_".$tpl_type; //create a new template of this id and this type ! $tpl = new Template($tpl_id, $tpl_type); //the parent of $tpl is the current_tpl --- 509,556 ---- $this->push_current_tpl($tpl); } + function end_REPEAT() + { + $tpl = $this->pop_current_tpl(); + $this->link_template($tpl); + } ! function start_IFEMPTY($attribs) { ! $tpl_id = $this->current_tpl->id.'_IfEmpty'; ! //create a new template of this id and this type ! $tpl = new Template($tpl_id, 'IfEmpty'); ! //the parent of $tpl is the current_tpl ! $tpl->parent = &$this->current_tpl; ! //set $tpl as current_tpl ! $this->push_current_tpl($tpl); ! } ! function end_IFEMPTY() ! { ! $tpl = $this->pop_current_tpl(); ! ! //add the subtemplate to the Repeat template ! if ($this->current_tpl->type=="RepeatTpl") { + $this->current_tpl->if_empty = $tpl; + } + else + { + $msg = "<IfEmpty> element can be used " + ."only inside a <Repeat> element"; + $err_msg = WebApp::error_msg($msg); + $this->append($err_msg); $this->link_template($tpl); } } ! ! function start_SEPARATOR($attribs) { ! $tpl_id = $this->current_tpl->id.'_Separator'; //create a new template of this id and this type ! $tpl = new Template($tpl_id, 'Separator'); //the parent of $tpl is the current_tpl *************** *** 546,559 **** $this->push_current_tpl($tpl); } ! ! /** $tag has the values "IFEMPTY", "HEADER", "FOOTER" or "SEPARATOR" */ ! function end_Repeat_subtpl($tag) { $tpl = $this->pop_current_tpl(); //add the subtemplate to the Repeat template ! if ($this->current_tpl->type<>"RepeatTpl") { ! $msg = "<$tag> element can be used " ."only inside a <Repeat> element"; $err_msg = WebApp::error_msg($msg); --- 560,575 ---- $this->push_current_tpl($tpl); } ! function end_SEPARATOR() { $tpl = $this->pop_current_tpl(); //add the subtemplate to the Repeat template ! if ($this->current_tpl->type=="RepeatTpl") { ! $this->current_tpl->separator = $tpl; ! } ! else ! { ! $msg = "<Separator> element can be used " ."only inside a <Repeat> element"; $err_msg = WebApp::error_msg($msg); *************** *** 561,582 **** $this->link_template($tpl); } ! else ! { ! switch ($tag) ! { ! case "IFEMPTY": ! $this->current_tpl->if_empty = $tpl; ! break; ! case "HEADER": ! $this->current_tpl->header = $tpl; ! break; ! case "FOOTER": ! $this->current_tpl->footer = $tpl; ! break; ! case "SEPARATOR": ! $this->current_tpl->separator = $tpl; ! break; ! } ! } } --- 577,596 ---- $this->link_template($tpl); } ! } ! ! function start_RSNAVIG($attribs) ! { ! $rs_id = $attribs['RS']; ! ! //create a new template of this id and this type ! $tpl = new RSNavigTpl($rs_id); ! ! //set $tpl as current_tpl ! $this->push_current_tpl($tpl); ! } ! function end_RSNAVIG() ! { ! $tpl = $this->pop_current_tpl(); ! $this->link_template($tpl); } *************** *** 597,601 **** $this->push_current_tpl($tpl); } - function end_HEAD() { --- 611,614 ---- *************** *** 629,633 **** $this->append('<body'.$this->get_attr_list($attribs).'>'); } - function end_BODY() { --- 642,645 ---- *************** *** 659,663 **** $this->copy_level = 0; } - function end_WEBBOX() { --- 671,674 ---- *************** *** 716,720 **** $this->copy_level = 0; } - function end_WEBCLASS() { --- 727,730 ---- *************** *** 816,820 **** $this->push_current_tpl($tpl); } - function end_RECORDSET() { --- 826,829 ---- *************** *** 865,869 **** $this->push_current_tpl($tpl); } - function end_DBCOMMAND() { --- 874,877 ---- *************** *** 883,887 **** $this->push_current_tpl($tpl); } - function end_QUERY() { --- 891,894 ---- *************** *** 903,907 **** $this->push_current_tpl($tpl); } - function end_VAR() { --- 910,913 ---- *************** *** 935,943 **** { print "\$this->tpl_stack[$i]"; ! print $this->tpl_stack[$i]->toHtmlTable(); } else { ! print "\$this->tpl_stack[$i]='".$this->tpl_stack[$i]."'<br>\n"; } } --- 941,949 ---- { print "\$this->tpl_stack[$i]"; ! print $this->tpl_stack[$i]->id."\n"; } else { ! print "\$this->tpl_stack[$i]='".$this->tpl_stack[$i]."'\n"; } } |
From: Dashamir H. <das...@us...> - 2004-07-13 13:18:19
|
Update of /cvsroot/phpwebapp/web_app/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4377/parser Modified Files: class.WebPage.php class.WebObjectTpl.php class.Template.php class.Render.php class.Parser.php class.MainTpl.php class.FileTpl.php Added Files: test.php parser.txt Log Message: xml parser --- NEW FILE: test.php --- <?php $str = "test abc&&test1;;def xyz uvt &&test2;; "; //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('/\s*$/', '', $str); //Trim the indentation from the beginning of each line. //get the indentation of each line preg_match_all("/^( *)[^\n]/m", $str, $arr_matches); $arr_indents = $arr_matches[1]; //sort them asort($arr_indents); $arr_indents = array_values($arr_indents); //get the smallest one $smallest_indent = $arr_indents[0]; //remove it from the begining of each line $str = preg_replace("/^$smallest_indent/m", '', $str); //split the string back to the content array $flags = PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE; $arr = preg_split('/(&&[^;]+;;)/', $str, -1, $flags); $str1 = " djdj name='test3' <form jjdjdj name='form1' jd> ksksk name='test2' "; $pattern = '/<form[^>]*name=("|\')([^\\1]+)\\1/'; //ToDo: test it preg_match($pattern, $str1, $matches); $form_name = $matches[2]; $str2 = " hhhsh \n jksksks\n "; preg_match('/([ \t]*)$/', $str2, $matches); $indent = $matches[1]; print "<xmp>\n"; //print "'$form_name'\n"; //print "'$indent'\n"; print "'$str' \n"; print_r($arr); print "</xmp>\n"; ?> --- NEW FILE: parser.txt --- ---------------------------------------------------------------------- There are two parsing modes: 1. Normal mode. During this mode template objects are constructed for the relevant elements and they are added to the structure of the page ($webPage). 2. Copy mode. During this mode no new template objects are constructed and everything that is parsed is copied verbatim to the content of the current template. The copy mode is used for parsing WebClass-es (and WebBox-es, which are a special case of WebClass-es) in order to copy its content for later processing. This is due to the fact that a WebClass by itself does not add anything in the structure of the page. Only when an object (WebObject) of this WebClass is declared, the content of the WebClass is parsed in the normal mode. This content is reparsed for each WebObject that is declared in the page. ---------------------------------------------------------------------- Templates include each-other using the element <include>. For each template that is parsed, a new xml_parser is created. Also, when a <WebObject> element is found in a template, then the content of the corresponding WebClass is parsed as if it was included or pasted in that place. A new xml parser is created too, for parsing the content of the WebClass. Trick: Since the content of a template or the content of a WebClass may not be well-formed xml (because often it does not have a single root element), before sending it to the xml parser it is enclosed in a dummy element, which serves as its root element and which is just ignored by the parser. Sometimes the xml parser needs to know the name of the file that it is parsing, in order to display it in error messages, in case that there are xml errors in the file. For this reason, the name of the file that is being parsed is saved in a global array that keeps data related to each parser. ---------------------------------------------------------------------- The parser reads the templates and constructs an object representation of the web page that will be displayed. This is a tree structure where each object in the tree has the content of a template and references to other objects that are contained in this template. For each framework element like <if>, <repeat>, <webbox> etc. there is an object that represents it in the structure and which keeps its string content. It is like a DOM (Document Object Model) for the framework elements. Most of these objects are inheritors of the class 'Template'. The Template class has a member variable 'content' that contains the string content of the template. It is an array of chunks and references. A chunk of data is a string that contains a part of the template; it may have new lines inside as well and may not be terminated by a new line. A reference is a string like this: '&&tpl_id;;', where tpl_id is the id of the template that is linked (or referenced) in this place. When the parser is parsing a template (e.g. a file), whatever string that it finds is appended to the content of the current_template object. When if finds a framework element that indicates that a new object must be created, then it creates a new template object, pushes the current template in a stack, makes the new template as current, and continues parsing. Now whatever is parsed is appended to the new template object. Once it is done (indicated by a closing tag, e.g. </if>), then the previous template (which is not finished yet) is poped from the stack and made current_template, a reference from the previous template to the new template is added and the new template is added in the page structure, then the parsing of the previous template continues. ---------------------------------------------------------------------- Index: class.WebPage.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/parser/class.WebPage.php,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** class.WebPage.php 25 Aug 2003 13:18:32 -0000 1.8 --- class.WebPage.php 13 Jul 2004 13:18:08 -0000 1.9 *************** *** 68,81 **** } ! /** Append the given line to the content of the <head> element. */ ! function append_to_head($line) { ! $this->tpl_collection["HeadTpl"]->content[] = $line; } ! /** Append the given line to the content of the <body> element. */ ! function append_to_body($line) { ! $this->tpl_collection["BodyTpl"]->content[] = $line; } --- 68,90 ---- } ! /** Append the given string to the content of the <head> element. */ ! function append_to_head($str) { ! $this->tpl_collection["HeadTpl"]->contents .= $str; } ! /** Append the given string to the content of the <body> element. */ ! function append_to_body($str) { ! $this->tpl_collection["BodyTpl"]->contents .= $str; ! } ! ! /** ! * Append a reference to the given template ! * at the end of the content of the <body> element. ! */ ! function link_to_body(&$tpl) ! { ! $this->tpl_collection["BodyTpl"]->contents .= '&&'.$tpl->id.';;'; } Index: class.WebObjectTpl.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/parser/class.WebObjectTpl.php,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** class.WebObjectTpl.php 24 Sep 2003 14:20:08 -0000 1.7 --- class.WebObjectTpl.php 13 Jul 2004 13:18:08 -0000 1.8 *************** *** 42,46 **** /** Helps to render the template with a good indentation. */ ! var $indentation; /** Constructor */ --- 42,46 ---- /** Helps to render the template with a good indentation. */ ! var $indent; /** Constructor */ Index: class.Template.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/parser/class.Template.php,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** class.Template.php 25 Aug 2003 13:18:32 -0000 1.7 --- class.Template.php 13 Jul 2004 13:18:08 -0000 1.8 *************** *** 40,45 **** var $vars; ! /** The lines of the template (array of lines). */ ! var $content; --- 40,48 ---- var $vars; ! /** The contents of the template. */ ! var $contents; ! ! /** The indentation of the template relative to the parent. */ ! var $indent; *************** *** 52,56 **** $this->type = $type; $this->vars = array(); - $this->content = array(); } --- 55,58 ---- *************** *** 74,85 **** return $tplVars; } /**#@+ Debug function. */ function toHtmlTable() { $htmlTable = " <br> <a name='$this->id'> </a>[<a href='javascript: back()'>Back</a>] ! <table width='90%' bgcolor='#aaaaaa' border='0' cellspacing='1' cellpadding='2'> <tr> <td bgcolor='#eeeeee' align='right' width='1%'>ID:</td> --- 76,163 ---- return $tplVars; } + + /** + * Returns an array of ids of the templates that are referenced + * from the contents of this template. + */ + function get_subtemplates() + { + $pattern = '/&&([^;]+);;/'; + preg_match_all($pattern, $this->contents, $matches); + $arr_tpl_id = $matches[1]; + return $arr_tpl_id; + } + + /** Split the contents to an array, according to the references. */ + function get_arr_contents() + { + $pattern = '/(&&[^;]+;;)/'; + $flags = PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE; + $arr_contents = preg_split($pattern, $this->contents, -1, $flags); + return $arr_contents; + } + + /** + * Replaces multiple empty lines by just one empty line, + * trims the indentation from the beginning of each line, etc. + */ + 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 of each line + preg_match_all("/^( *)[^\n]/m", $str, $arr_matches); + $arr_indents = $arr_matches[1]; + //sort them + asort($arr_indents); + $arr_indents = array_values($arr_indents); + //get the smallest one + $smallest_indent = $arr_indents[0]; + //remove it from the begining of each line + $str = preg_replace("/^$smallest_indent/m", '', $str); + + //set the indentation of the subtemplates + global $webPage; + $arr_tpl_id = $this->get_subtemplates(); + for ($i=0; $i < sizeof($arr_tpl_id); $i++) + { + $tpl_id = $arr_tpl_id[$i]; + + //get the indentation of the reference + $pattern = "|^( *)&&{$tpl_id};;|m"; + preg_match($pattern, $str, $matches); + $indent = $matches[1]; + + //remove it from the line of the reference + $str = preg_replace($pattern, "&&$tpl_id;;", $str); + + //set it as the indentation of the subtemplate + $tpl = $webPage->getTemplate($tpl_id); + $tpl->indent = $indent; + $webPage->addTemplate($tpl); + } + + //save the normalized string back to contents + $this->contents = $str; + } /**#@+ Debug function. */ function toHtmlTable() { + $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'> <tr> <td bgcolor='#eeeeee' align='right' width='1%'>ID:</td> *************** *** 90,96 **** <td bgcolor='#f9f9f9'>$this->type</td> </tr> ! " . $this->attribs2html() . " <tr><td colspan='2' bgcolor='#f9f9ff'> ! " . $this->content2html() . " </td></tr> </table> --- 168,180 ---- <td bgcolor='#f9f9f9'>$this->type</td> </tr> ! <tr> ! <td bgcolor='#eeeeee' align='right'>Indent:</td> ! <td bgcolor='#f9f9f9'> ! <pre><span style='background-color: #888888;'>$indent</span></pre> ! </td> ! </tr> ! " . $this->vars2html() . " <tr><td colspan='2' bgcolor='#f9f9ff'> ! " . $this->contents2html() . " </td></tr> </table> *************** *** 101,105 **** /** @see toHtmlTable() */ ! function attribs2html() { reset($this->vars); --- 185,189 ---- /** @see toHtmlTable() */ ! function vars2html() { reset($this->vars); *************** *** 118,137 **** /** @see toHtmlTable() */ ! function content2html() { $html = "\n<pre class='webapp'>"; ! $i = 0; ! while ($i < sizeof($this->content)) { ! $line = $this->content[$i++]; ! if (trim($line)=="##") { ! $line = $this->content[$i++]; ! $tpl_id = trim($line); ! $html .= "<a href='#$tpl_id'>##\n$tpl_id</a>\n"; } else { ! $html .= htmlentities($line); } } --- 202,224 ---- /** @see toHtmlTable() */ ! function contents2html() { + global $webPage; + + $arr_contents = $this->get_arr_contents(); $html = "\n<pre class='webapp'>"; ! for ($i=0; $i < sizeof($arr_contents); $i++) { ! $str = $arr_contents[$i]; ! if (preg_match('/^&&(.+);;$/', $str, $matches)) { ! $tpl_id = $matches[1]; ! $tpl = $webPage->getTemplate($tpl_id); ! //$html .= $tpl->indent; ! $html .= "<a href='#$tpl_id'>&&$tpl_id;;</a>"; } else { ! $html .= htmlentities($str); } } *************** *** 145,149 **** { //don't output the appended boxes ! if (ereg("web_app/append/append.html\$", $this->id)) return; global $webPage; --- 232,236 ---- { //don't output the appended boxes ! if (ereg("append/append.html\$", $this->id)) return; global $webPage; *************** *** 152,183 **** $tree .= $indent."+--<a href='#".$this->id."'>".$this->id."</a>" . " (".$this->type.")\n"; ! $i = 0; ! while ($i < sizeof($this->content)) { ! $line = $this->content[$i++]; ! if (trim($line)=="##") ! { ! $line = $this->content[$i++]; ! $tpl_id = trim($line); ! $tpl = $webPage->getTemplate($tpl_id); ! $tree .= $tpl->to_tree($indent."| "); ! } } return $tree; } - - /** - * Prints a preview of this template only (without processing - * subtemplates), for the benefit of the designer. - */ - function print_preview() - { - for ($i=0; $i < count($this->content); $i++) - { - $line = $this->content[$i]; - $line = WebApp::replaceVars($line); - print "\t\t".$line; - } - } /**#@-*/ } --- 239,252 ---- $tree .= $indent."+--<a href='#".$this->id."'>".$this->id."</a>" . " (".$this->type.")\n"; ! ! $arr_tpl_id = $this->get_subtemplates(); ! for ($i=0; $i < sizeof($arr_tpl_id); $i++) { ! $tpl_id = $arr_tpl_id[$i]; ! $tpl = $webPage->getTemplate($tpl_id); ! $tree .= $tpl->to_tree($indent."| "); } return $tree; } /**#@-*/ } Index: class.Render.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/parser/class.Render.php,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** class.Render.php 24 Sep 2003 14:20:08 -0000 1.7 --- class.Render.php 13 Jul 2004 13:18:08 -0000 1.8 *************** *** 47,61 **** /** ! * Either sends the line to the browser or concats it ! * to the variable $this->html_page. */ ! function print_line($line) { ! if ($this->collect) ! $this->html_page .= $this->indent.$line; ! else ! print $this->indent.$line; } /** * Renders the given template, replacing all variables --- 47,79 ---- /** ! * Replace all {{tpl_vars}} in the given string ! * 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;;' + * If this pattern does not match, than it returns UNDEFINED. + */ + function get_tpl_id($str) + { + $pattern = '/^&&(.+);;$/'; + if (preg_match($pattern, $str, $matches)) + return $matches[1]; + else + return UNDEFINED; + } + /** * Renders the given template, replacing all variables *************** *** 69,89 **** $tplVars->addVars($tpl->getVars()); ! $i = 0; ! while ($i < sizeof($tpl->content)) { ! $line = $tpl->content[$i++]; ! if (chop($line)<>"##") { ! $this->render_line($line); } ! else //subtemplate indicator found { ! //get the subtemplate ! $line = $tpl->content[$i++]; ! $subtpl_id = trim($line); ! $subtpl = $webPage->getTemplate($subtpl_id); ! ! //render the subtemplate $this->render_subtpl($subtpl); } } --- 87,107 ---- $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) { ! $this->render_string($chunk); } ! else { ! //get and render the subtemplate ! $subtpl = $webPage->getTemplate($tpl_id); ! $prev_indent = $this->indent; ! $this->indent .= $subtpl->indent; $this->render_subtpl($subtpl); + $this->indent = $prev_indent; } } *************** *** 92,107 **** } - /** - * Replace all {{tpl_vars}} in the given line - * and then print it out. - */ - function render_line($line) - { - //replace all {{tpl_vars}} - $line = WebApp::replaceVars($line); - //output the line - $this->print_line($line); - } - /** * Dispatcher function: according to the type of --- 110,113 ---- *************** *** 167,181 **** $tpl_path = WebApp::to_url($tpl_path); $tplVars->addVar("./", $tpl_path); - - //increase indentation - $prev_indent = $this->indent; - $this->indent .= $file_tpl->indentation; //render the FileTpl $this->render_tpl($file_tpl); - //revert to previous indentation - $this->indent = $prev_indent; - $tplVars->popScope(); } --- 173,180 ---- *************** *** 186,192 **** function render_MainTpl($main_tpl) { ! array_unshift($main_tpl->head->content, "<head>\n"); ! array_push($main_tpl->head->content, "</head>\n"); ! array_push($main_tpl->body->content, "</body>\n"); $this->render_FileTpl($main_tpl); } --- 185,191 ---- function render_MainTpl($main_tpl) { ! $main_tpl->head->contents = '<head>'.$main_tpl->head->contents; ! $main_tpl->head->contents .= '</head>'; ! $main_tpl->body->contents .= '</body>'; $this->render_FileTpl($main_tpl); } *************** *** 223,235 **** $wobj_tpl->onRender(); - //increase indentation - $prev_indent = $this->indent; - $this->indent .= $wobj_tpl->indentation; - $this->render_tpl($wobj_tpl); //render it to HTML - //revert to previous indentation - $this->indent = $prev_indent; - $tplVars->popScope(); } --- 222,227 ---- *************** *** 256,260 **** { $err_msg = WebApp::error_msg("Recordset '$rs_id' is undefined."); ! $this->print_line($err_msg); $this->render_Template($tpl); return; --- 248,252 ---- { $err_msg = WebApp::error_msg("Recordset '$rs_id' is undefined."); ! $this->render_string($err_msg); $this->render_Template($tpl); return; Index: class.Parser.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/parser/class.Parser.php,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** class.Parser.php 24 Sep 2003 14:20:08 -0000 1.8 --- class.Parser.php 13 Jul 2004 13:18:08 -0000 1.9 *************** *** 21,933 **** ! /** ! * Parses the templates and constructs $webPage, which ! * keeps the structure of the page. ! * ! * @package parser ! * @see WebPage, Render ! */ ! class Parser [...1812 lines suppressed...] ! /** Output the state of the stack. */ ! 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]->toHtmlTable(); ! } ! else ! { ! print "\$this->tpl_stack[$i]='".$this->tpl_stack[$i]."'<br>\n"; ! } ! } ! } ! } ?> \ No newline at end of file Index: class.MainTpl.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/parser/class.MainTpl.php,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** class.MainTpl.php 25 Aug 2003 13:18:32 -0000 1.6 --- class.MainTpl.php 13 Jul 2004 13:18:08 -0000 1.7 *************** *** 53,66 **** . " (".$this->type.")\n"; $i = 0; ! while ($i < sizeof($this->content)) { ! $line = $this->content[$i++]; ! if (trim($line)=="##") ! { ! $line = $this->content[$i++]; ! $tpl_id = trim($line); ! $tpl = $webPage->getTemplate($tpl_id); ! $tree .= $tpl->to_tree($indent." "); ! } } return $tree; --- 53,63 ---- . " (".$this->type.")\n"; $i = 0; ! ! $arr_tpl_id = $this->get_subtemplates(); ! for ($i=0; $i < sizeof($arr_tpl_id); $i++) { ! $tpl_id = $arr_tpl_id[$i]; ! $tpl = $webPage->getTemplate($tpl_id); ! $tree .= $tpl->to_tree($indent." "); } return $tree; Index: class.FileTpl.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/parser/class.FileTpl.php,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** class.FileTpl.php 25 Aug 2003 13:18:32 -0000 1.5 --- class.FileTpl.php 13 Jul 2004 13:18:08 -0000 1.6 *************** *** 29,33 **** { var $filename; ! var $indentation; function FileTpl($filename) --- 29,33 ---- { var $filename; ! var $indent; function FileTpl($filename) *************** *** 37,52 **** Template::Template($id, "FileTpl"); $this->filename = $filename; ! $this->indentation = ""; ! } ! ! /** Trims the indentation from the beginning of each line. */ ! function unindent() ! { ! for ($i=0; $i < sizeof($this->content); $i++) ! { ! $line = $this->content[$i]; ! $line = ereg_replace("^".$this->indentation, "", $line); ! $this->content[$i] = $line; ! } } --- 37,41 ---- Template::Template($id, "FileTpl"); $this->filename = $filename; ! $this->indent = ""; } |