1<?php
2/**
3 * Imageflow 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')) die();
12
13if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
14require_once(DOKU_PLUGIN.'action.php');
15
16class action_plugin_imageflow extends DokuWiki_Action_Plugin {
17
18    private $functions = null;
19    private $POSTcheck = 'show_sample';
20
21    function register(Doku_Event_Handler $controller) {
22
23        // Support given via AJAX
24        $controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'toolbar_add_button', array ());
25        $controller->register_hook('DOKUWIKI_STARTED', 'BEFORE', $this, 'metaheader_add_images', array ());
26        $controller->register_hook('POPUPVIEWER_DOKUWIKI_STARTED', 'BEFORE', $this, 'popupviewer_metaheader_add_images', array ());
27    }
28
29    /**
30     * Inserts a toolbar button
31     */
32    function toolbar_add_button( Doku_Event &$event, $param) {
33        $event->data[] = array (
34            'type' => 'format',
35            'title' => $this->getLang('toolbar_picker'),
36            'icon' => '../../plugins/imageflow/images/namespace_picker.png',
37            'open' => '<imageflow ',
38            'sample' => ':namespace:goes:here:',
39            'close' => '></imageflow>',
40        );
41    }
42
43    function metaheader_add_images( Doku_Event &$event, $param ) {
44        global $ID, $JSINFO;
45
46        $metaData = p_get_metadata($ID, "relation imageflow", true);
47        $JSINFO['relation']['imageflow'] = $metaData;
48    }
49
50    function popupviewer_metaheader_add_images( Doku_Event &$event, $param ) {
51        global $ID, $JSINFO;
52
53        $this->metaheader_add_images( $event, $param );
54        if ( empty($JSINFO['relation']['imageflow']) ) {
55            return;
56        }
57
58        $head =& $event->data;
59
60        $script = '(function($){$(function(){$("div.imageflow_wrapper").each(function(){new imageflow_plugin(this);});});})jQuery);';
61
62        $head['script'][] = array( 'type'=>'text/javascript', '_data'=> $script);
63    }
64}