*/ // must be run within Dokuwiki if(!defined('DOKU_INC')) die(); require_once(DOKU_PLUGIN.'syntax.php'); /** * All DokuWiki plugins to extend the parser/rendering mechanism * need to inherit from this class */ class syntax_plugin_datatemplate_filterform extends DokuWiki_Syntax_Plugin { /** * Get the type of syntax this plugin defines. */ function getType(){ return 'substition'; } /** * Define how this plugin is handled regarding paragraphs. */ function getPType(){ return 'block'; } /** * Where to sort in? */ function getSort(){ return 150; } /** * Connect lookup pattern to lexer. */ function connectTo($mode) { $this->Lexer->addSpecialPattern('----+ *filterform(?: [ a-zA-Z0-9_]*)?-+\n.*?\n----+',$mode,'plugin_datatemplate_filterform'); } /** * Handler to prepare matched data for the rendering process. */ function handle($match, $state, $pos, Doku_Handler $handler){ $data = array(); $lines = explode("\n",$match); foreach ( $lines as $num => $line ) { // ignore comments $line = preg_replace('/(?info['cache'] = false; if (isset($_POST['filterform']) && checkSecurityToken()) { $new_flt = ''; if(!empty($_POST['contains'])) { $new_flt = $_POST['field'] . '*~' . $_POST['contains']; if(!isset($_REQUEST['dataflt'])){ $flt = array(); } elseif (!is_array($_REQUEST['dataflt'])){ $flt = (array) $_REQUEST['dataflt']; } else { $flt = $_REQUEST['dataflt']; } if(!empty($new_flt)) $flt[] = $new_flt; $_REQUEST['dataflt'] = $flt; } } $R->doc .= $this->_htmlform($data); return true; } return false; } function _htmlform($data){ global $ID; $form = new Doku_Form(array('class' => 'filterform_plugin', 'action' => wl($ID))); $form->addHidden('filterform', $ID); $form->addElement(form_openfieldset(array('_legend' => $this->getLang('searchfilter'), 'class' => 'filterform'))); $form->addElement(form_makeMenuField('field', $data['fields'], '', '', '', 'cell menu')); $form->addElement(form_makeTextField('contains', '', '', '', 'cell text')); if(count($_REQUEST['dataflt']) > 0) { $form->addElement('