xref: /plugin/siteexport/syntax/aggregate.php (revision ba092c97dbb1709a7fb9c7bd411069949079fb9c)
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
46			if ( array_shift($data) == 'siteexportAGGREGATOR' ) {
47	        	$form->addHidden('siteexport_aggregate', '1');
48			}
49
50			$namespace = $ID;
51            foreach( $data as $option ) {
52
53	            list($key, $value) = explode('=', $option);
54	            if ($key == "namespace") {
55		            $namespace = $value . ':';
56		            continue;
57	            }
58
59	        	$form->addHidden($key, $value);
60            }
61
62            $values = $functions->__getOrderedListOfPagesForID($namespace);
63            if ( empty($values) ) {
64	            $renderer->doc .= '<span style="color: #a00">'.$this->getLang('NoEntriesFoundHint').'</span>';
65            } else {
66	            $form->addElement(form_makeMenuField('baseID', $values, isset($_REQUEST['baseID']) ? $_REQUEST['baseID'] : $values[0], $this->getLang('AggragateExportPages')/*, $id='', $class='', $attrs=array() */ ));
67	            $form->addElement(form_makeButton('submit', 'siteexport', $this->getLang('AggregateSubmitLabel'), array('class' => 'button download' /*, 'onclick' => 'return (new inet_pdfc_request_license(this)).run();'*/)));
68
69		        ob_start();
70		        $form->printForm();
71		        $renderer->doc .= ob_get_contents();
72		        ob_end_clean();
73            }
74
75            return true;
76        }
77
78        return false;
79    }
80}
81
82//Setup VIM: ex: et ts=4 enc=utf-8 :