', $content);
$content = $i[0];
$else = implode('', array_slice($i, 1));
}
// Process condition blocks
$bug = false;
$this->_loadtester();
$ok = $this->_processblocks($blocks, $bug);
// Render content if all went well
$metatoc = $renderer->meta['description']['tableofcontents'];
if(!$bug) {
$instr = p_get_instructions($ok ? $content : $else);
foreach($instr as $instruction) {
if ( in_array($instruction[0], array('document_start', 'document_end') ) ) continue;
call_user_func_array(array(&$renderer, $instruction[0]), $instruction[1]);
}
}
if ( !is_array($renderer->meta['description']['tableofcontents']) ) {
$renderer->meta['description']['tableofcontents'] = array();
}
$renderer->meta['description']['tableofcontents'] = array_merge($metatoc, $renderer->meta['description']['tableofcontents']);
return true;
}
return false;
}
// Strips the heading 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_processblocks($b[$i]['value'], $bug);
if($b[$i]['type'] == 'nblock') $b[$i]['r'] = !$b[$i]['r'];
}else{
$b[$i]['r'] = $this->_evaluate($b[$i], $bug);
}
}
if(!count($b)) $bug = true; // no condition in block
if($bug) return false;
// assemble conditions
/* CUSTOMISATION :
* You can add custom mixing operators here, don't forget to add them to
* the "allowedoperators" list at the top of this file
*/
$r = $b[0]['r'];
for($i=1; $itester) {
$bug = true;
return false;
}
return $this->tester->run($b, $bug);
}
// tries to load user defined tester, then base tester if previous failed
function _loadtester() {
global $conf;
$this->tester = null;
include_once(DOKU_PLUGIN.'condition/base_tester.php');
if(@file_exists(DOKU_INC.'lib/tpl/'.$conf['template'].'/condition_plugin_custom_tester.php')) {
include_once(DOKU_INC.'lib/tpl/'.$conf['template'].'/condition_plugin_custom_tester.php');
if(class_exists('condition_plugin_custom_tester')) {
$this->tester = new condition_plugin_custom_tester();
}
}
if(!$this->tester) {
if(class_exists('condition_plugin_base_tester')) {
$this->tester = new condition_plugin_base_tester();
}
}
}
} //class
?>