1<?php 2/** 3 * Site Export 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 10// must be run within Dokuwiki 11if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); 12if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 13require_once(DOKU_PLUGIN.'action.php'); 14 15class action_plugin_siteexport_aggregate extends DokuWiki_Action_Plugin { 16 17 18 /** 19 * Register Plugin in DW 20 **/ 21 function register(&$controller) { 22 $controller->register_hook('TPL_ACT_RENDER', 'BEFORE', $this, 'siteexport_aggregate'); 23 $controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'siteexport_aggregate_button', array ()); 24 } 25 26 function siteexport_aggregate(&$event) 27 { 28 global $ID, $INFO; 29 30 //if ( $event->data != 'siteexport_aggregate' ) { return true; } 31 if ( !isset($_REQUEST['siteexport_aggregate']) ) { return true; } 32 $event->preventDefault(); 33 34 $exportBase = cleanID($_REQUEST['baseID']); 35 $functions=& plugin_load('helper', 'siteexport'); 36 $values = $functions->__getOrderedListOfPagesForID(getNs($exportBase), $exportBase); 37 38 // Generate a TOC that can be exported 39 $TOC = "~~NOCACHE~~\n<toc merge mergeheader>\n"; 40 foreach( $values as $value ) { 41 list($id, $title, $sort) = $value; 42 $TOC .= " * [[{$id}|{$title}]]\n"; 43 } 44 45 $TOC .= "</toc>"; 46 47 $info = null; 48 $html = p_render('xhtml', p_get_instructions($TOC),$info); 49 $html = html_secedit($html,false); 50 if($INFO['prependTOC']) $html = tpl_toc(true).$html; 51 echo $html; 52 53 return false; 54 } 55 56 /** 57 * Inserts a toolbar button 58 */ 59 function siteexport_aggregate_button(& $event, $param) { 60 $event->data[] = array ( 61 'type' => 'mediapopup', 62 'title' => $this->getLang('toolbarButton'), 63 'icon' => '../../plugins/siteexport/images/toolbar.png', 64 'url' => 'lib/plugins/siteexport/exe/siteexportmanager.php?ns=', 65 'options' => 'width=750,height=500,left=20,top=20,scrollbars=yes,resizable=yes', 66 'block' => false, 67 ); 68 } 69}