Wiki source for DreckfehlerArchive
note: the following patches are only documented for "historical reasons" (that means for my own vanity). to make these patches to be at your service you just have to download the actual version of wikka.
====bug in formatter: forced links in square brackets====
[''Note: Forced links in square brackets is now fixed in Wikka by default starting with **Wikka 1.1.3.1**'']
think about a ""[[forced | link]]"" set into square brackets like this: ""[""[[dreckfehler]]]. it wouldn't work without a trick, because wakkawiki don't know how to deal with three subsequent brackets. obviously it should render the innermost brackets but it takes the leftmost. to solve this behaviour we have to assure that the formatter uses only those opening brackets which are not followed by more square brackets. refer to the formatters/wakka.php and look for the huge regular expression which is stored in the variable $text and steers the parsing-process. change the line dealing with the forced links
the old version:
%%(php)<?php
"\[\[.*?\]\]|".
?>%%
and the new one:
%%(php)<?php
"\[\[[^\[].*?\]\]|".
?>%%
and you're done. the corresponding regex within the callback-function doesn't need any changes, because it will never get three subsequent opening brackets to match.
====unnamed parameters====
===action googleform===
[''Note: The googleform action is now in Wikka by default starting with **Wikka 1.1.3.1**'']
little stupid example for the unnamed parameters below ;) but it's sometimes quite useful. i leave such a googleform on every page that is considered "under construction". this gives me quick access to further research on a topic.
%%(php)<?php if (!$q) $q = $this->tag(); ?>
<p><FORM action="http://www.google.com/search" method=get name=f target=_blank>
<INPUT type=text value='<?=$q ?>' framewidth='4' name='q' size='30'> <INPUT name='btnG' type='submit' value='Google'>
</FORM>%%
save this snippet as "googleform.php" in the actions-folder. after that you can call anywhere ""{{googleform}}"" to show a searchform which is preset with the page-title. if you want to offer another search-term as default, call ""{{googleform q="wikkawiki"}}"".
===unnamed parameters===
[''Note: The unnamed parameters modification is now in Wikka by default starting with **Wikka 1.1.3.1**'']
lots of actions need only one parameter and there is no need to distinguish it from others. additionally in some cases (like the googleform above) quotation marks are useful within the parameter, which isn't recognized by the action-api. the solution is to define an extra variable that contains the whole parameterstring. the old mechanism to pass over parameters (i.e. var_name="value") will still work.
we need to modify the function $wakka->Action():
old version (wikkawiki v. 1.1.3):
%%(php)<?php
// stupid attributes check
if (stristr($action, "=\"")) {
// extract $action and $vars_temp ("raw" attributes)
preg_match("/^([A-Za-z0-9]*)(.*)$/", $action, $matches);
list(, $action, $vars_temp) = $matches;
// match all attributes (key and value)
preg_match_all("/([A-Za-z0-9]*)=\"(.*)\"/U", $vars_temp, $matches);
// prepare an array for extract() to work with (in $this->IncludeBuffered())
if (is_array($matches)) {
for ($a = 0; $a < count($matches[0]); $a++) {
$vars[$matches[1][$a]] = $matches[2][$a];
// ?? $vars[$a] = $matches[2][$a];
}
}
}
?>%%
modify it as follows:
%%(php)<?php
// stupid attributes check
// if (stristr($action, "=\"")) { <<<<<<< this is not needed, we'll do this check in the following preg_match
// extract $action and $vars_temp ("raw" attributes)
if (preg_match("/^([A-Za-z0-9]*)\s+(.*)$/", $action, $matches);) { // <<<<<<< treat everything after the first whitespace as parameter
list(, $action, $vars_temp) = $matches;
if (!$action) return "<span class='error'><i>unknown action, the action-name must not contain special chars!</i></span>"; // <<<<<<< the pattern ([A-Za-z0-9])\s+ didn't match!
// match all attributes (key and value)
preg_match_all("/([A-Za-z0-9]*)=\"(.*)\"/U", $vars_temp, $matches);
// prepare an array for extract() to work with (in $this->IncludeBuffered())
if (is_array($matches)) {
for ($a = 0; $a < count($matches[0]); $a++) {
$vars[$matches[1][$a]] = $matches[2][$a];
}
}
$vars["wakka_vars"] = trim($vars_temp); // <<<<<<< add the buffered parameter-string to the array
}
?>%%
now we can refer to the whole parameter-string in $wakka_vars even if it doesn't follow the pattern **var="value" ...** how to treat this feature belongs to the actions itself.
let's have a look at the googleform-action from above:
%%(php)<?php
if (!$q) { //leave the old syntax untouched. you may omit this if-clause when you never used the former action-call (or want to change every appereance of it in your wiki ;) )
if ($wakka_vars) $q = $wakka_vars;
else $q = $this->tag();
}
?>
<p><FORM action="http://www.google.com/search" method=get name=f target=_blank>
<INPUT type=text value='<?=$q ?>' framewidth='4' name='q' size='30'> <INPUT name='btnG' type='submit' value='Google'>
</FORM>%%
now you can offer a more convinient syntax: ""{{googleform searchstring}}"". even double-quotes are passed to the input field, i.e. ""{{googleform "search phrase"}}"" will search for a connected phrase instead of two separate words.
====bug in formatter: forced links in square brackets====
[''Note: Forced links in square brackets is now fixed in Wikka by default starting with **Wikka 1.1.3.1**'']
think about a ""[[forced | link]]"" set into square brackets like this: ""[""[[dreckfehler]]]. it wouldn't work without a trick, because wakkawiki don't know how to deal with three subsequent brackets. obviously it should render the innermost brackets but it takes the leftmost. to solve this behaviour we have to assure that the formatter uses only those opening brackets which are not followed by more square brackets. refer to the formatters/wakka.php and look for the huge regular expression which is stored in the variable $text and steers the parsing-process. change the line dealing with the forced links
the old version:
%%(php)<?php
"\[\[.*?\]\]|".
?>%%
and the new one:
%%(php)<?php
"\[\[[^\[].*?\]\]|".
?>%%
and you're done. the corresponding regex within the callback-function doesn't need any changes, because it will never get three subsequent opening brackets to match.
====unnamed parameters====
===action googleform===
[''Note: The googleform action is now in Wikka by default starting with **Wikka 1.1.3.1**'']
little stupid example for the unnamed parameters below ;) but it's sometimes quite useful. i leave such a googleform on every page that is considered "under construction". this gives me quick access to further research on a topic.
%%(php)<?php if (!$q) $q = $this->tag(); ?>
<p><FORM action="http://www.google.com/search" method=get name=f target=_blank>
<INPUT type=text value='<?=$q ?>' framewidth='4' name='q' size='30'> <INPUT name='btnG' type='submit' value='Google'>
</FORM>%%
save this snippet as "googleform.php" in the actions-folder. after that you can call anywhere ""{{googleform}}"" to show a searchform which is preset with the page-title. if you want to offer another search-term as default, call ""{{googleform q="wikkawiki"}}"".
===unnamed parameters===
[''Note: The unnamed parameters modification is now in Wikka by default starting with **Wikka 1.1.3.1**'']
lots of actions need only one parameter and there is no need to distinguish it from others. additionally in some cases (like the googleform above) quotation marks are useful within the parameter, which isn't recognized by the action-api. the solution is to define an extra variable that contains the whole parameterstring. the old mechanism to pass over parameters (i.e. var_name="value") will still work.
we need to modify the function $wakka->Action():
old version (wikkawiki v. 1.1.3):
%%(php)<?php
// stupid attributes check
if (stristr($action, "=\"")) {
// extract $action and $vars_temp ("raw" attributes)
preg_match("/^([A-Za-z0-9]*)(.*)$/", $action, $matches);
list(, $action, $vars_temp) = $matches;
// match all attributes (key and value)
preg_match_all("/([A-Za-z0-9]*)=\"(.*)\"/U", $vars_temp, $matches);
// prepare an array for extract() to work with (in $this->IncludeBuffered())
if (is_array($matches)) {
for ($a = 0; $a < count($matches[0]); $a++) {
$vars[$matches[1][$a]] = $matches[2][$a];
// ?? $vars[$a] = $matches[2][$a];
}
}
}
?>%%
modify it as follows:
%%(php)<?php
// stupid attributes check
// if (stristr($action, "=\"")) { <<<<<<< this is not needed, we'll do this check in the following preg_match
// extract $action and $vars_temp ("raw" attributes)
if (preg_match("/^([A-Za-z0-9]*)\s+(.*)$/", $action, $matches);) { // <<<<<<< treat everything after the first whitespace as parameter
list(, $action, $vars_temp) = $matches;
if (!$action) return "<span class='error'><i>unknown action, the action-name must not contain special chars!</i></span>"; // <<<<<<< the pattern ([A-Za-z0-9])\s+ didn't match!
// match all attributes (key and value)
preg_match_all("/([A-Za-z0-9]*)=\"(.*)\"/U", $vars_temp, $matches);
// prepare an array for extract() to work with (in $this->IncludeBuffered())
if (is_array($matches)) {
for ($a = 0; $a < count($matches[0]); $a++) {
$vars[$matches[1][$a]] = $matches[2][$a];
}
}
$vars["wakka_vars"] = trim($vars_temp); // <<<<<<< add the buffered parameter-string to the array
}
?>%%
now we can refer to the whole parameter-string in $wakka_vars even if it doesn't follow the pattern **var="value" ...** how to treat this feature belongs to the actions itself.
let's have a look at the googleform-action from above:
%%(php)<?php
if (!$q) { //leave the old syntax untouched. you may omit this if-clause when you never used the former action-call (or want to change every appereance of it in your wiki ;) )
if ($wakka_vars) $q = $wakka_vars;
else $q = $this->tag();
}
?>
<p><FORM action="http://www.google.com/search" method=get name=f target=_blank>
<INPUT type=text value='<?=$q ?>' framewidth='4' name='q' size='30'> <INPUT name='btnG' type='submit' value='Google'>
</FORM>%%
now you can offer a more convinient syntax: ""{{googleform searchstring}}"". even double-quotes are passed to the input field, i.e. ""{{googleform "search phrase"}}"" will search for a connected phrase instead of two separate words.