[pmwiki-users] 2.0beta6

Martin Fick mogulguy at yahoo.com
Sat Sep 23 23:11:38 CDT 2006

On Saturday 23 September 2006 08:47, you wrote:
> if you like to take a look at the code of AddDeleteLine2... I have no
> uploaded a new version in which I renamed some of the variables to make
> more sense and added a few comments.

I have looked at it and I have some suggestions to fix some things that I 
think are actually broken.  I will send you an updated version (2.0beta6M1) 
so that you can update it if you feel that they are good fixes;  I have 
tested them.  Mainly the fixes have to do with the way that you encode/decode 
some things.

To start with, form data does not need to be urlencoded, that is only required 
for URLs, in fact it messes things up.  This is true even if the form uses 
the GET method, the browser will take care of encoding the URL on submission.  
This also means that there is no need to urldecode PHP POST or GET variables, 
it will already be done for you by PHP.  

What you probably want to use instead for forms is htmlentities() so that no 
one can insert html and subvert your form (probably what you were trying to 
prevent).  This means that you should then use html_entity_decode() to decode 
things later on.  We do actually want to be able to insert < and > and other 
html entities into the wiki text, it will get converted on rendering (it is 
safe to insert any text into the wikitext, afterall, any editor can just as 
easily insert anything they want anyway.)

> Maybe there is a way of making the code more modular, so that it is
> easier to write extensions. For example a variable function call to a
> function that fills in the values of the $_POST[]-Array or something
> like that.

I will suggest anything that I think makes sense, but so far it is fairly 
simple.  The only thing that might make sense is to maybe split out the 
entire section where you do template replacements (in AdlHandleAddLine) into 
its own function (basically, the first 5 lines that begin with $addstring= ).

I will also send you a working addition of multi values which needs (and 
includes) the above mentioned fixes to work  (2.0beta6M2).  Multi line entry 
form elements must be named with [] at the end, ie. (:input checkbox 
name="Page[]":).  They then can be inserted in the template like 
this:  "{Page[]}".  This will loop over each entry and repeat the template 
for it.  \n must be in the template if each entry needs to be on a separate 
line.  This looping only occurs for a single (the first) multi entry found.  
Any subsequent entries will be ignored.  If anyone can suggest a way to use 
mutli-multi entries feel free to suggest it, but I can't think of any.

Now with this I can create wiki trails with a form and the following simple 
pagelist template:

(:input checkbox Page[] {=$FullName}:) {=$FullName}\\

I love it! :)  Thanks for your recipe, more to follow I hope,


More information about the pmwiki-users mailing list