1<?php
2/**
3 * DokuWiki Plugin scrapbooktemplate (Action Component)
4 *
5 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
6 * @author  i-net software / Gerry Weißbach <tool@inetsoftware.de>
7 */
8
9// must be run within Dokuwiki
10if(!defined('DOKU_INC')) die();
11
12class action_plugin_scrapbooktemplate_replaceraw extends DokuWiki_Action_Plugin {
13
14    /**
15     * Registers a callback function for a given event
16     *
17     * @param Doku_Event_Handler $controller DokuWiki's event controller object
18     * @return void
19     */
20    public function register(Doku_Event_Handler $controller) {
21
22       $controller->register_hook('ACTION_EXPORT_POSTPROCESS', 'BEFORE', $this, 'handle_action_export_postprocess');
23    }
24
25    /**
26     * [Custom event handler which performs action]
27     *
28     * @param Doku_Event $event  event object by reference
29     * @param mixed      $param  [the parameters passed as fifth argument to register_hook() when this
30     *                           handler was registered]
31     * @return void
32     */
33
34    public function handle_action_export_postprocess(Doku_Event &$event, $param) {
35
36        if ( $event->data['mode'] != 'raw' || empty( $_REQUEST['scrapbookinsert'] ) ) { return; }
37
38        $pageData = array(
39            'tpl' => $event->data['output'],
40            'id' => cleanId($_REQUEST['scrapbookinsert'])
41        );
42        $event->data['output'] = parsePageTemplate($pageData);
43    }
44}
45
46// vim:ts=4:sw=4:et:
47