doku code
or
doku codedoku code
''[condition_list]'' is a set of ''[condition]'' records separated by logical operators ''%%(&&, and, ||, or, ^, xor for now)%%'', use of parenthesis is allowed, negation is achieved by using heading ''!'' ''%%(ex !foo=bar or !(a=b || c
You are **connected**You must identify yourself to do something
You are not a manager
It's New Year's Eve
You are in a local network
not VIP (equivalent of not VIP )
...
===== Download and Installation =====
Search and install the plugin using the [[plugin:extension|Extension Manager]]. Refer to [[:Plugins]] on how to install plugins manually.
* Latest Version: [[https://github.com/gamma/dokuwiki-plugin-condition/archive/master.zip]] (GitHub)
* Old Version: [[http://dokuwiki.yent.eu/condition.zip]]
===== Sources =====
Attention: there is also a third-party source [[https://github.com/gamma/dokuwiki-plugin-condition|at GitHub]]
==== syntax.php ====
and trailing
added by p_render xhtml to acheive inline behavior function _stripp($data) { $data = preg_replace('`^\s*]*>\s*`', '', $data); $data = preg_replace('`\s*
]*>\s*$`', '', $data); return $data; } // evaluates the logical result from a set of blocks function _processblocks($b, &$bug) { for($i=0; $i
To add the test with the key "foo" just add the test method:
function test_foo($b, &$bug, $lop=false) {
if($lop) return array('\=\=?', '\!\=', '\:'); // list of accepted test operators, pcre style regexp
// Here we accept test operators : =, ==, !=, :
switch($b['test']) {
case '=' :
case '==' :
return ($b['value'] == 'bar'); break;
case '!=' :
return ($b['value'] != 'bar'); break;
case ':' :
// ...
default :
$bug = true;
return false;
}
}
So that test can be used as:
foo = barfoo != bar
foo = barfoo != bar
foo = barfoo != bar
...
If your test don't take a parameter you can define it as follows:
function test_foo($b, &$bug, $lop=false) {
if($lop) return array(); // no test operators
global $ID;
return preg_match('`^([^\:]+\:)?bar(\:[^\:]+)?$`', $ID);
}
This test is valid if "bar" is a parent namespace of the page:
Page is under "bar" namespace
==== TODO ====
* Allow multiple user custom test files (plugin style)?
* Ensure this works well with top-level containers
* clean-up and simplify code (mainly reduce calls to preg_replace/match) because it is a bit slow...
==== While discussion isn't working ====
I installed Condition in our production wiki, version 2009-02-14 running on RedHat Enterprise Linux ES 4.0u6 with PHP 4.3.9, and the plugin doesn't seem to work in that environment. Basically, the wiki breaks down immediately after installation and no pages are rendered at all, even before using Condition in any page. Removing the plugin (manually from the file system) restored functionality.
I tested the plugin in a CentOS 5.5/PHP 5.1.6 environment before adding it to our production wiki and it worked without problems.
Is there a known problem with older DokuWiki and/or PHP versions?
> Dunno, can you get apache's error log ? There could be some hints about the bug in it.
==== PHP Errors after saving a changed page with conditions ====
I get the following warnings on all pages with conditions:
Warning: array_merge() [function.array-merge]: Argument #1 is not an array in /hp/ab/ac/va/www/Wiki/lib/plugins/condition/syntax.php on line 261
Warning: array_merge() [function.array-merge]: Argument #2 is not an array in /hp/ab/ac/va/www/Wiki/lib/plugins/condition/syntax.php on line 261
Warning: Cannot modify header information - headers already sent by (output started at /hp/ab/ac/va/www/Wiki/lib/plugins/condition/syntax.php:261) in /hp/ab/ac/va/www/Wiki/inc/common.php on line 1543
The page is actually saved correctly. It obviously happens when the changed page is to be rendered. Is this a known issue?
//2010-10-06 [[rainer@doerrer.net|Rainer]]//
This error exists in %%~~NOTOC~~%% pages.
For fixed: into syntax.php search 261 line and add condition before:
if (is_array( $renderer->meta['description']['tableofcontents']))
//2010-11-22 [[zefir-cs@ukr.net|Zefir]]//
:!: I have the same error, but this code doesn´t solve the problem. If I use the condition-plugin some where in the page all headings get lost for the TOC up to the line where you use the condition plugin. The next heading is used as first heading. If no heading is left, filename is used.
//2011-07-03 anonymous//
:!: The plugin **does not** work with my installation. I traced the [[https://github.com/gamma/dokuwiki-plugin-condition/issues/1|issue in github]].
//2014-09-23 11:01 [[user>cinlloc|cinlloc]] //