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 * for backward compatability 19 * @see inc/DokuWiki_Plugin#getInfo() 20 */ 21 function getInfo(){ 22 if ( method_exists(parent, 'getInfo')) { 23 $info = parent::getInfo(); 24 } 25 return is_array($info) ? $info : confToHash(dirname(__FILE__).'/../plugin.info.txt'); 26 } 27 28 /** 29 * Register Plugin in DW 30 **/ 31 function register(&$controller) { 32 $controller->register_hook('TPL_ACT_RENDER', 'BEFORE', $this, 'siteexport_aggregate'); 33 $controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'siteexport_aggregate_button', array ()); 34 } 35 36 function siteexport_aggregate(&$event) 37 { 38 global $ID; 39 40 //if ( $event->data != 'siteexport_aggregate' ) { return true; } 41 if ( !isset($_REQUEST['siteexport_aggregate']) ) { return true; } 42 43 $exportBase = cleanID($_REQUEST['baseID']); 44 $functions=& plugin_load('helper', 'siteexport'); 45 $values = $functions->__getOrderedListOfPagesForID($ID, $exportBase); 46 47 // Generate a TOC that can be exported 48 $TOC = "<toc merge mergeheader>\n"; 49 foreach( $values as $value ) { 50 list($id, $title, $sort) = $value; 51 $TOC .= " * [[{$title}]]\n"; 52 } 53 54 $TOC .= "</toc>\n"; 55 $info = null; 56 print p_render('xhtml', p_get_instructions($TOC),$info); 57 58 $event->preventDefault(); 59 return false; 60 } 61 62 /** 63 * Inserts a toolbar button 64 */ 65 function siteexport_aggregate_button(& $event, $param) { 66 $event->data[] = array ( 67 'type' => 'mediapopup', 68 'title' => $this->getLang('toolbarButton'), 69 'icon' => '../../plugins/siteexport/images/toolbar.png', 70 'url' => 'lib/plugins/siteexport/inc/siteexportmanager.php?ns=', 71 'options' => 'width=750,height=500,left=20,top=20,scrollbars=yes,resizable=yes', 72 'block' => false, 73 ); 74 } 75}