Re: Package proposal - HTML_FormPersister, HTML_SemiParser
| From: | Alan Knowles | Date: | Tue, 18 Feb 2003 00:48:05 +0000 |
| Subject: | Re: Package proposal - HTML_FormPersister, HTML_SemiParser | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-13430@lists.php.net to get a copy of this message | ||
Funny, thats very similar to what I'm building into HTML_Template_Flexy at the moment.. -
http://devel.akbkhome.com/peardoc2/package.html.html-template-flexy.html
Flexy has a far more powerfull HTML parser in it (and it may be faster, although I've not really checked. - and it does once only parsing as well to speed things up) - It should be possible to add a few more 'if (!$this->enableFlexyTags) to it, and change the token factory method to prefix with a user defined Class, enabling you to create your own HTML Tokenizer quite easily..
You may like to consider merging some of this work into flexy..
Otherwise I'm +1 on this - (although it needs a bit of tidying up :)
Regards
Alan
Dmitry Koteroff wrote:
Good morning. I'd like to propose 2 new packages: HTML_FormPersister HTML_SemiParser Complex demonstration: http://php.dklab.ru/FormPersister/t_formpersister.php Output buffer handle test: http://php.dklab.ru/FormPersister/t_handler.php Source codes (by now) http://php.dklab.ru/FormPersister/HTML/ Short overview -------------- Let's consider that we have a script which prints out the form. The action of this form is pointed to the same script. If the user enters some wrong values into fields (for example, forget to enter his name), script must re-print the form WITH ALL VALUES filled before. Of course, error message should be printed too. I call such fields "persisted". It's a very standard problem, I think. The problem is: how to automatically fill all the fields, including checkboxes, radio buttons and rather selects (andselect-multiples)? Module HTML_FormPersister does ittransparently for application. See example at http://php.dklab.ru/FormPersister/t_handler.php Now supported: - Simple on-the-fly HTML parsing & correcting all the form tag in document. - Automatical setting width, height of all the <img> tags. - Setting default action of <form>. - "Persistemt" fields support for: - input: text, password, checkbox, radio, hidden; - textarea; - select, select multiple; - Support for complex names like a[b][c]. - Support for auto-array fields, example: <input type=checkbox name=chk[] value=1> <input type=checkbox name=chk[] value=2> <input type=checkbox name=chk[] value=3> - Support default values for all fields: <input type=checkbox name=chk[] value=2 default="on"> <input type=text name=txt default="default text"> <input type=radio name=rad value=val1 default="val1"> - Support for "reversed array fields": <select name=sel[] multiple flip><option value=a>aaa <option value=b selected>bbb <option value=c selected>ccc</select> will produce in $_POST array(b => 1, с => 1) If we do not use flip, output will be array(b,c) (automatically post-processing od $_POST etc. if needed) - Support for LABEL attribute: <input type=checkbox label="clock me!"> -> [x]click me! You may clich on label instead of click on checkbox. - Support for ";"-delimited default values: <select name=sel[] multiple default="a;c"><option value=a>aaa <option value=b>bbb <option value=c>ccc</select> The best method to use - ob_start("..."), I think. The HTML parser is very simple, but fast. For example, it cannot process tags like <img src=i.gif alt="2>1">, but can correctly process - <img src=i.gif alt="2>1">. -- Best regards, Dmitry Koteroff (dk@dklab.ru), chief programmer (http://www.dklab.ru).