|
Posted by Henk verhoeven on 07/02/07 19:33
djdole@gmail.com schreef:
> I know that you can create custom UI components with JSF,
> but does anyone know if the same (or something similar) can be done
> with PHP?
>
All you need is to set up a front controller, have it instantiate the
right UI component class, then follow the composition by inclusion and
callback pattern. For the principle see:
http://www.phppeanuts.org/site/index_php/Pagina/26
For the pattern see:
http://www.phppeanuts.org/site/index_php/Pagina/195
BTW, if you use a request parameter to hold the name of the primary UI
component class, make sure you only include files from you own server.
Php can include files from http, ftp etc coming from other servers, and
that is happily used by hackers to run their own code on your server to
take control. Some servers nowadays are protected, but you better check
that class name not to hold any trickery:
if ($name&& preg_match("'[^A-Za-z0-9_]'", $name))
trigger_error("Non alphanumerical characters in component class
name", E_USER_ERROR);
Success,
Henk Verhoeven,
www.phpPeanuts.org.
PhpPeanuts has several widget and component types, and of course you can
add your own types too, eventualle extending the existing ones.
To browse the widgets:
http://www.phppeanuts.org/site/index_php/HcodePackage/pnt.web.widgets
and the parts:
http://www.phppeanuts.org/site/index_php/HcodePackage/pnt.web.parts
[Back to original message]
|