Re: DotWeb - Request for comments
| From: | Stefan Neufeind | Date: | Sun, 06 Jun 2004 23:28:03 +0000 |
| Subject: | Re: DotWeb - Request for comments | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-12959@lists.php.net to get a copy of this message | ||
On 6 Jun 2004 at 21:50, Andreas Heck wrote:
> I was very impressed when I saw the Webforms of ASP.NET for the first
> time. So I decided to implement something similar in PHP.
>
> Please take a look at
>
> http://dotweb.berlios.de/tutorial.html
>
> to get an idea how far it has come until now. You can also get the
> complete code from the svn repository.
>
> The code is just a proof of concept but for that it works pretty well.
> I would be very happy to get some comments and suggestions on this
> projects.
Hmm, the
<dotweb:a id="mylink">
way of doint "templates" looks nice. Is this the usual way that it's
done in ASP? Maybe then it would be interesting for people moving
their (existing) templates from ASP to PHP, or using them for both
where needed.
The part about event-handling for forms also loks interesting, though
it wouldn't be my prefered way of doing it - but that's another
story.
What if you declare a DotWeb-link e.g. using
<dotweb:a id="link0" href="http://www.heise.de/">Heise</dotweb:a>
in the template and don't make an assignment to it - will it just
remain unchanged?
The idea looks nice. However, is this really limited to "forms"? Even
the event-handling-part can also be used with any other kind of
links. And generally it looks like a different approach to a template-
engine for me.
I wonder if templates are done the same way in ASP and therefor might
be compatible. To me it seems like an interesting approach, and I bet
some people might like it.
So generally I think it's a nice idea. However, I'm a bit unsure
about if another template engine might be interesting for PEAR -
there has lately already been another extensive discussions about
template engines in PEAR :-))
Maybe you should provide a link to the webbrowser for the SVN
repository of your project, so people don't have to install
subversion to take a quick look at the source :-)) Simply link it
here:
http://svn.berlios.de/viewcvs/dotweb/trunk/
Hmm, having a look at the source I found a few things that you might
consider to change:
http://svn.berlios.de/viewcvs/dotweb/trunk/dotweb/class.webpage.php?re
v=2&view=markup
- private attributes should imho be prefixed with an underscore (as
you already do for $_tpl)
- printTemplate() - usually it's a good idea to also have a function
to retrieve the template as a string
- registerEventHandler() - maybe make $value optional, so you can
register an eventhandler that triggers when a certain variable is
defined (with any value)?
- consider returning errors (e.g. PEAR_ErrorStack) instead of
printing out errors to the screen
- does the function_exists() in registerEventHandler() work fine as
it is? In your example you registered a handler before defining the
function (which might also be part of an include-file and be declared
later, but surely before the executePage).
- also in registerEventHandler():
event_post / event_get
since you increment add all events one-by-one to the array, maybe it
would be cleaner to have the $varname also added to the array instead
of using it as an index? this also looks a bit strange in the
callEventHandlers
- for the if ($method == "GET") block and other functions as
well:
strip the double-quotes around $varname - that's not good practice :-
)
- in callEventHandlersPost():
use call_user_func instead of eval for calling the function.
- does the default-function always have to be named "on_page_load"?
Maybe it could be set by calling registerEventHandler without values
for get/post-parameters? like:
registerEventHandler('default_page_handler');
This would mean moving $method from the first to the second
parameter.
Some of the things above also apply to the other source-files. But in
general e.g. templateparser looks mostly okay. Please excuse that I
won't review all htmlcontrols as well for now :-)
Hope this input helps you a bit. And maybe others comment as well.
Keep up the good work.
Stefan