xref: /plugin/siteexport/syntax/aggregate.php (revision fd3853649937bf44ced6193f1cf7e968ddbb52d8)
1<?php
2/**
3 * i-net Download Plugin
4 *
5 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
6 * @author     i-net software <tools@inetsoftware.de>
7 * @author     Gerry Weissbach <gweissbach@inetsoftware.de>
8 */
9
10if(!defined('DOKU_INC')) die();
11if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
12require_once(DOKU_PLUGIN.'syntax.php');
13
14/**
15 * All DokuWiki plugins to extend the parser/rendering mechanism
16 * need to inherit from this class
17 */
18class syntax_plugin_siteexport_aggregate extends DokuWiki_Syntax_Plugin {
19
20    function getType(){ return 'substition';}
21    function getPType(){ return 'block';}
22    function getSort(){ return 300; }
23
24    function connectTo($mode){
25        $this->Lexer->addSpecialPattern('\{\{(?=siteexport|siteexportAGGREGATOR).*?\}\}',$mode,'plugin_siteexport_aggregate');
26    }
27
28    function handle($match, $state, $pos, &$handler){
29
30    	$options = explode(' ', trim(substr($match, 2, -2)));
31        return $options;
32    }
33
34    function render($mode, &$renderer, $data){
35        global $ID, $conf;
36
37        if ($mode == 'xhtml'){
38
39            $renderer->info['toc'] = false;
40            $renderer->nocache();
41
42            $formParams = array( 'id' => sectionID('siteexport_site_aggregator', $renderer->headers), 'action' => wl($ID), 'class' => 'siteexport aggregator' );
43            $form = new Doku_Form($formParams);
44            $functions=& plugin_load('helper', 'siteexport');
45            $values = $functions->__getOrderedListOfPagesForID($ID);
46
47
48			if ( array_shift($data) == 'siteexportAGGREGATOR' ) {
49	        	$form->addHidden('siteexport_aggregate', '1');
50			}
51
52            foreach( $data as $option ) {
53
54	            list($key, $value) = explode('=', $option);
55	        	$form->addHidden($key, $value);
56            }
57
58            $form->addElement(form_makeMenuField('baseID', $values, isset($_REQUEST['baseID']) ? $_REQUEST['baseID'] : $values[0], $this->getLang('AggragateExportPages')/*, $id='', $class='', $attrs=array() */ ));
59            $form->addElement(form_makeButton('submit', 'siteexport', $this->getLang('AggregateSubmitLabel'), array('class' => 'button download' /*, 'onclick' => 'return (new inet_pdfc_request_license(this)).run();'*/)));
60
61	        ob_start();
62	        $form->printForm();
63	        $renderer->doc .= ob_get_contents();
64	        ob_end_clean();
65
66            return true;
67        }
68
69        return false;
70    }
71}
72
73//Setup VIM: ex: et ts=4 enc=utf-8 :