1<?php
2/**
3 * DokuWiki Plugin ocr (Action Component)
4 *
5 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
6 * @author  dodotori <dodotori@localhost>
7 */
8class action_plugin_ocr extends \dokuwiki\Extension\ActionPlugin
9{
10
11    /** @inheritDoc */
12    public function register(Doku_Event_Handler $controller)
13    {
14        $controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'handle_toolbar_define',array());
15        $controller->register_hook('TPL_METAHEADER_OUTPUT', 'BEFORE', $this,'_hookjs');
16
17
18    }
19
20
21
22    /**
23     * FIXME Event handler for
24     *
25     * @param Doku_Event $event  event object by reference
26     * @param mixed      $param  optional parameter passed when event was registered
27     * @return void
28     */
29    public function handle_toolbar_define(Doku_Event $event, $param)
30    {
31         $event->data[] = array (
32            'type' => 'ocr',
33            'title' => $this->getLang('qb_abutton'),
34            'icon' => '../../plugins/ocr/ocr.png',
35          );
36    }
37
38
39    public function _hookjs(Doku_Event $event, $param) {
40        $event->data['script'][] = array(
41                            'type'    => 'text/javascript',
42                            'charset' => 'utf-8',
43                            '_data'   => '',
44                            'src'     => 'https://unpkg.com/tesseract.js@2.1.5/dist/tesseract.min.js');
45    }
46
47
48
49
50}