1<?php
2
3namespace dokuwiki\Menu\Item;
4
5/**
6 * Class Permalink
7 */
8class Permalink extends AbstractItem
9{
10
11    /** @inheritdoc */
12    public function __construct()
13    {
14        parent::__construct();
15
16        if (!in_array('permalink', explode(',', tpl_getConf('pageIcons')))) {
17            throw new \RuntimeException("permalink is not available");
18        }
19
20        unset($this->params['do']);
21
22        $this->label = tpl_getLang('permalink');
23        $this->svg   = tpl_incdir() . 'images/menu/link.svg';
24        $this->id    = '#';
25    }
26
27    public function getLink()
28    {
29        global $ID;
30        global $INFO;
31
32        return DOKU_URL . DOKU_SCRIPT . '?id=' . $ID . '&rev=' . $INFO['lastmod'];
33    }
34
35    public function getLinkAttributes($classprefix = 'menuitem ')
36    {
37        $attr           = parent::getLinkAttributes($classprefix);
38        $attr['target'] = '_blank';
39
40        return $attr;
41    }
42}
43