1<?php
2
3
4namespace ComboStrap;
5
6
7class PageH1 extends MetadataText
8{
9
10
11    public const H1_PARSED = "h1_parsed";
12    public const PROPERTY_NAME = "h1";
13
14    public static function createForPage($page): PageH1
15    {
16        return (new PageH1())
17            ->setResource($page);
18    }
19
20    public function getTab(): string
21    {
22        return MetaManagerForm::TAB_PAGE_VALUE;
23    }
24
25    public function getDescription(): string
26    {
27        return "The heading 1 (or H1) is the first heading of your page. It may be used in template to make a difference with the title.";
28    }
29
30    public function getLabel(): string
31    {
32        return "H1 (Heading 1)";
33    }
34
35    static public function getName(): string
36    {
37        return self::PROPERTY_NAME;
38    }
39
40    public function getPersistenceType(): string
41    {
42        return Metadata::PERSISTENT_METADATA;
43    }
44
45
46
47    public function getMutable(): bool
48    {
49        return true;
50    }
51
52    public function getDefaultValue(): string
53    {
54        $store = $this->getReadStore();
55        if ($store instanceof MetadataDokuWikiStore) {
56            $h1Parsed = $store->getCurrentFromName( self::H1_PARSED);
57            if (!empty($h1Parsed)) {
58                return $h1Parsed;
59            }
60            // dokuwiki
61            $h1 = $store->getCurrentFromName( "title");
62            if (!empty($h1)) {
63                return $h1;
64            }
65        }
66        $title = PageTitle::createForPage($this->getResource())
67            ->getValue();
68        if (!empty($title)) {
69            return $title;
70        }
71
72        return ResourceName::createForResource($this->getResource())
73            ->getValueOrDefault();
74
75    }
76
77    public function getCanonical(): string
78    {
79        return $this->getName();
80    }
81
82
83}
84