1<?php
2/**
3 * Colorbox Action Plugin
4 *
5 *  Provides the jquery colorbox plugin for lightbox effect
6 *
7 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
8 * @license    MIT (http://opensource.org/licenses/mit-license.php) for Colorbox
9 * @author     Tom Cafferty <tcafferty@glocalfocal.com>
10 */
11
12// must be run within Dokuwiki
13if(!defined('DOKU_INC')) die();
14if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
15require_once DOKU_PLUGIN.'action.php';
16
17class action_plugin_colorbox extends DokuWiki_Action_Plugin {
18
19    /**
20     * Register its handlers with the DokuWiki's event controller
21     */
22    function register(&$controller) {
23        $controller->register_hook('TPL_METAHEADER_OUTPUT', 'BEFORE', $this, 'colorbox_hookjs');
24    }
25
26    /**
27     * Hook js script into page headers.
28     *
29     * @author Tom Cafferty <tcafferty@glocalfocal.com>
30     */
31    function colorbox_hookjs(&$event, $param) {
32        global $INFO;
33        global $ID;
34
35        // keyword colorbox used to include colorbox javascript files
36        if (p_get_metadata($ID, 'plugin colorbox')) {
37            $event->data['link'][] = array(
38                            'rel' => 'stylesheet',
39                            'type'    => 'text/css',
40                            '_data'   => '',
41                            'href'     => DOKU_BASE ."lib/plugins/colorbox/colorbox.css");
42            $event->data['script'][] = array(
43                            'type'    => 'text/javascript',
44                            'charset' => 'utf-8',
45                            '_data'   => '',
46                            'src'     => DOKU_BASE."lib/plugins/colorbox/jquery.colorbox-min.js");
47            $event->data['script'][] = array(
48                            'type'    => 'text/javascript',
49                            'charset' => 'utf-8',
50                            '_data'   => '',
51                            'src'     => DOKU_BASE."lib/plugins/colorbox/linkColorbox.js");
52       }
53    }
54}