1<?php
2/**
3 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
4 * @author     Andreas Gohr <andi@splitbrain.org>
5 * @author     Zahno Silvan <zaswiki@gmail.com>
6 */
7
8// must be run within Dokuwiki
9if(!defined('DOKU_INC')) die();
10
11if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
12require_once(DOKU_PLUGIN.'action.php');
13
14class action_plugin_stars2 extends DokuWiki_Action_Plugin {
15
16    /**
17     * return some info
18     */
19    function getInfo(){
20        return array(
21            'author' => 'Zahno Silvan',
22            'email'  => 'zaswiki@gmail.com',
23            'date'   => '2020-07-07',
24            'name'   => 'Stars2 Plugin',
25            'desc'   => 'Embedding Rating Stars',
26            'url'    => 'https://github.com/tschinz/dokuwiki_stars_plugin',
27        );
28    }
29
30    /**
31     * register the eventhandlers
32     *
33     * @author Andreas Gohr <andi@splitbrain.org>
34     */
35    public function register(Doku_Event_Handler $controller){
36        $controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'handle_toolbar', array (5));
37    }
38
39    function handle_toolbar(&$event, $param) {
40        $event->data[] = array (
41            'type' => 'picker',
42            'title' => $this->getLang('star'),
43            'icon' => '../../plugins/stars2/images/toolbar/star.png',
44            'list' => array(
45                array(
46                    'type'   => 'insert',
47                    'title'  => $this->getLang('star1'),
48                    'icon'   => '../../plugins/stars2/images/toolbar/star1.png',
49                    'insert'=> '{{stars>1/5}}'
50                ),
51                array(
52                    'type'   => 'insert',
53                    'title'  => $this->getLang('star2'),
54                    'icon'   => '../../plugins/stars2/images/toolbar/star2.png',
55                    'insert' => '{{stars>2/5}}'
56                ),
57                array(
58                    'type'   => 'insert',
59                    'title'  => $this->getLang('star3'),
60                    'icon'   => '../../plugins/stars2/images/toolbar/star3.png',
61                    'insert' => '{{stars>3/5}}'
62                ),
63                array(
64                    'type'   => 'insert',
65                    'title'  => $this->getLang('star4'),
66                    'icon'   => '../../plugins/stars2/images/toolbar/star4.png',
67                    'insert' => '{{stars>4/5}}'
68                ),
69                array(
70                    'type'   => 'insert',
71                    'title'  => $this->getLang('star5'),
72                    'icon'   => '../../plugins/stars2/images/toolbar/star5.png',
73                    'insert' => '{{stars>5/5}}'
74                ),
75                array(
76                    'type'   => 'insert',
77                    'title'  => $this->getLang('star_not_rated'),
78                    'icon'   => '../../plugins/stars2/images/toolbar/starnry.png',
79                    'insert' => '{{stars>-1/5}}'
80                ),
81            )
82        );
83    }
84}
85
86