1<?php
2/**
3 *
4 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
5 * @author  Myron Turner <turnermm02@shaw.ca>
6 */
7
8// must be run within Dokuwiki
9if(!defined('DOKU_INC')) die();
10class action_plugin_block extends DokuWiki_Action_Plugin {
11    /**
12     * Registers a callback function for a given event
13     *
14     * @param Doku_Event_Handler $controller DokuWiki's event controller object
15     * @return void
16     */
17    public function register(Doku_Event_Handler $controller) {
18
19       $controller->register_hook('AJAX_CALL_UNKNOWN', 'BEFORE', $this, 'handle_ajax_call_unknown');
20       $controller->register_hook('DOKUWIKI_STARTED', 'BEFORE', $this, 'handle_started');
21    }
22
23    /**
24     * @param Doku_Event $event  event object by reference
25     * @param mixed      $param  [the parameters passed as fifth argument to register_hook() when this
26     *                           handler was registered]
27     * @return void
28     */
29
30    public function handle_ajax_call_unknown(Doku_Event &$event, $param) {
31      if ($event->data !== 'block__opts') {
32        return;
33      }
34      $event->stopPropagation();
35      $event->preventDefault();
36      $ar = array('block_width'=>'','bg'=>"",'fg'=>"",'border_color'=>"",'border_style'=>"",'border_width'=> "",'font_family'=> "",'font_size'=> "",'block_align'=> "");
37      $ar_keys = array_keys($ar);
38      foreach($ar_keys as $k) {
39          $ar[$k] = trim($this -> getConf($k));
40      }
41
42         echo  json_encode($ar);
43    }
44
45    public function handle_started(Doku_Event &$event, $param) {
46        global $ACT,$JSINFO;
47        $JSINFO['block'] = 'block';
48        $JSINFO['act'] = $ACT;
49    }
50}