Issues (2407)

engine/library/Document.php (1 issue)

1
<?php
2
/* 	Divine CMS - Open source CMS for widespread use.
3
    Copyright (c) 2019 Mykola Burakov ([email protected])
4
5
    See SOURCE.txt for other and additional information.
6
7
    This file is part of Divine CMS.
8
9
    This program is free software: you can redistribute it and/or modify
10
    it under the terms of the GNU General Public License as published by
11
    the Free Software Foundation, either version 3 of the License, or
12
    (at your option) any later version.
13
14
    This program is distributed in the hope that it will be useful,
15
    but WITHOUT ANY WARRANTY; without even the implied warranty of
16
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
    GNU General Public License for more details.
18
19
    You should have received a copy of the GNU General Public License
20
    along with this program. If not, see <http://www.gnu.org/licenses/>. */
21
22
namespace Divine\Engine\Library;
23
24
class Document
25
{
26
    private $title;
27
    private $robots;
28
    private $description;
29
    private $links = array();
30
    private $stylespreload = array();
31
    private $styles = array();
32
    private $scriptsdefer = array();
33
    private $scriptsasync = array();
34
    private $scripts = array();
35
36
    public function setTitle($title)
0 ignored issues
show
Expected 2 blank lines before function; 1 found
Loading history...
37
    {
38
        $this->title = $title;
39
    }
40
41
    public function getTitle()
42
    {
43
        return $this->title;
44
    }
45
46
    public function setRobots($robots)
47
    {
48
        $this->robots = $robots;
49
    }
50
51
    public function getRobots()
52
    {
53
        return $this->robots;
54
    }
55
56
    public function setDescription($description)
57
    {
58
        $this->description = $description;
59
    }
60
61
    public function getDescription()
62
    {
63
        return $this->description;
64
    }
65
66
    public function addLink($href, $rel)
67
    {
68
        $this->links[$href] = array(
69
            'href' => $href,
70
            'rel'  => $rel
71
        );
72
    }
73
74
    public function getLinks()
75
    {
76
        return $this->links;
77
    }
78
79
    public function addStylePreload($href, $rel = 'preload')
80
    {
81
        $this->stylespreload[$href] = array(
82
            'href'  => $href,
83
            'rel'   => $rel,
84
        );
85
    }
86
87
    public function addStyle($href, $rel = 'stylesheet')
88
    {
89
        $this->styles[$href] = array(
90
            'href'  => $href,
91
            'rel'   => $rel
92
        );
93
    }
94
95
    public function getStylespreload()
96
    {
97
        return $this->stylespreload;
98
    }
99
100
    public function getStyles()
101
    {
102
        return $this->styles;
103
    }
104
105
    public function addScriptAsync($href, $postion = 'header')
106
    {
107
        $this->scriptsasync[$postion][$href] = $href;
108
    }
109
110
    public function addScriptDefer($href, $postion = 'header')
111
    {
112
        $this->scriptsdefer[$postion][$href] = $href;
113
    }
114
115
    public function addScript($href, $postion = 'header')
116
    {
117
        $this->scripts[$postion][$href] = $href;
118
    }
119
120
    public function getScriptsAsync($postion = 'header')
121
    {
122
        if (isset($this->scriptsasync[$postion])) {
123
            return $this->scriptsasync[$postion];
124
        } else {
125
            return array();
126
        }
127
    }
128
129
    public function getScriptsDefer($postion = 'header')
130
    {
131
        if (isset($this->scriptsdefer[$postion])) {
132
            return $this->scriptsdefer[$postion];
133
        } else {
134
            return array();
135
        }
136
    }
137
138
    public function getScripts($postion = 'header')
139
    {
140
        if (isset($this->scripts[$postion])) {
141
            return $this->scripts[$postion];
142
        } else {
143
            return array();
144
        }
145
    }
146
}
147