1<?php
2/**
3 * Delete Button plugin
4 *
5 * @copyright (c) 2020 Cody Ernesti
6 * @license GPLv2 or later (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
7 * @author  Cody Ernesti
8 *
9 *  Modified from: https://github.com/dregad/dokuwiki-plugin-deletepagebutton
10 *
11 *   Original license info:
12 *
13 * @copyright (c) 2020 Damien Regad
14 * @license GPLv2 or later (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
15 * @author  Damien Regad
16 */
17namespace dokuwiki\plugin\pagebuttons;
18use dokuwiki\Menu\Item\AbstractItem;
19
20/**
21 * Class DeletePageButton
22 *
23 * Implements the plugin's Delete button for DokuWiki's menu system
24 *
25 * @package dokuwiki\plugin\pagebuttons
26 */
27class DeletePageButton extends AbstractItem {
28
29    /** @var string icon file */
30    protected $svg = __DIR__ . '/images/trash-can-outline.svg';
31
32    /** @inheritdoc */
33    public function __construct($label) {
34        parent::__construct();
35        $this->label = $label;
36        $this->params['sectok'] = getSecurityToken();
37    }
38
39    /**
40     * Get label from plugin language file
41     *
42     * @return string
43     */
44    public function getLabel() {
45        return $this->label;
46    }
47
48    public function getLinkAttributes($classprefix = 'menuitem ') {
49        $attr = parent::getLinkAttributes($classprefix);
50        if (empty($attr['class'])) {
51            $attr['class'] = '';
52        }
53        $attr['class'] .= ' plugin_pagebuttons_deletepage ';
54        return $attr;
55    }
56
57}
58