1<?php
2/**
3 * Copyright (c) 2021. ComboStrap, Inc. and its affiliates. All Rights Reserved.
4 *
5 * This source code is licensed under the GPL license found in the
6 * COPYING  file in the root directory of this source tree.
7 *
8 * @license  GPL 3 (https://www.gnu.org/licenses/gpl-3.0.en.html)
9 * @author   ComboStrap <support@combostrap.com>
10 *
11 */
12
13namespace ComboStrap;
14
15use dokuwiki\Menu\Item\AbstractItem;
16
17/**
18 * Class MenuItem
19 * @package ComboStrap
20 *
21 */
22class MetaManagerMenuItem extends AbstractItem
23{
24
25    const CLASS_HTML = "combo_metadata_item";
26    const CANONICAL = "metadata";
27
28    /**
29     * MetadataMenuItem constructor.
30     */
31    public function __construct()
32    {
33        $snippetManager = PluginUtility::getSnippetManager();
34        $snippetManager->attachJavascriptComboLibrary();
35        $snippetManager->attachJavascriptSnippetForRequest(self::CANONICAL);
36        parent::__construct();
37    }
38
39
40    /**
41     *
42     * @return string
43     */
44    public function getLabel(): string
45    {
46        return "Metadata Manager";
47    }
48
49    public function getLinkAttributes($classprefix = 'menuitem '): array
50    {
51        $linkAttributes = parent::getLinkAttributes($classprefix);
52        /**
53         * A class and not an id
54         * because a menu item can be found twice on
55         * a page (For instance if you want to display it in a layout at a
56         * breakpoint and at another in another breakpoint
57         */
58        $linkAttributes['class'] = self::CLASS_HTML;
59
60        return $linkAttributes;
61    }
62
63    public function getTitle(): string
64    {
65        return "Show and update the Page Metadata";
66    }
67
68    public function getSvg(): string
69    {
70        /** @var string icon file */
71        return Site::getComboImagesDirectory()->resolve('tag-text.svg')->toString();
72    }
73
74
75}
76