Update of /cvsroot/phpwebapp/web_app
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18792
Modified Files:
class.WebApp.php
Log Message:
Added function WebApp::GoTo()
Index: class.WebApp.php
===================================================================
RCS file: /cvsroot/phpwebapp/web_app/class.WebApp.php,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** class.WebApp.php 11 Oct 2004 09:50:53 -0000 1.23
--- class.WebApp.php 12 Oct 2004 10:01:10 -0000 1.24
***************
*** 114,117 ****
--- 114,155 ----
/**
+ * This function stops constructing the current page
+ * and starts loading and constructing the given target page.
+ * Similar to the JS function GoTo(), it can also send an event
+ * to the new page that is going to be constructed (actually
+ * modifies the current event).
+ */
+ function GoTo($target_page, $target_object =UNDEFINED,
+ $event_name =UNDEFINED, $event_args =UNDEFINED)
+ {
+ global $event, $webPage, $tplVars, $parser, $render;
+
+ //modify $event according to the given params
+ if ($target_page<>'thisPage' and $target_page<>'')
+ {
+ $event->sourcePage = $event->targetPage;
+ $event->targetPage = $target_page;
+ }
+ if ($target_object<>UNDEFINED) $event->target = $target_object;
+ if ($event_name<>UNDEFINED) $event->name = $event_name;
+ if ($event_args<>UNDEFINED) $event->args = $event_args;
+
+ //create new global vars
+ $webPage = new WebPage;
+ $tplVars = new VarStack;
+ $parser = new Parser;
+ $render = new Render;
+
+ WebApp::constructHtmlPage(TPL.$event->targetPage);
+
+ //after the page is constructed, stop php execution immediately
+ //in order to avoid any side effects of the previous call of
+ //constructHtmlPage() etc. (because this function is called
+ //somewhere in the middle of some functions, and we don't want
+ //the rest of the code of those functions to be executed
+ exit(0);
+ }
+
+ /**
* Constructs an HTML page and returns it as a string.
* Then resumes constructing the previous page.
***************
*** 192,218 ****
}
- /**
- * This function stops loading the current page
- * and starts loading and constructing the given page.
- * If no page is given, reloads the same page again.
- *
- * @todo It doesn't work yet, see how to fix it.
- */
- function reloadPage($tpl_file=UNDEFINED)
- {
- global $webPage, $tplVars;
-
- if ($tpl_file==UNDEFINED) //no parameter given
- {
- //reload again the same template
- $tpl_file = $webPage->tpl_file;
- }
- unset($webPage);
- unset($varStack);
- $webPage = new WebPage;
- $tplVars = new VarStack;
- $webPage->load($tpl_file);
- }
-
/*------ end construct functions ----------------*/
--- 230,233 ----
|