-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMeta_manager.php
More file actions
53 lines (46 loc) · 938 Bytes
/
Meta_manager.php
File metadata and controls
53 lines (46 loc) · 938 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
namespace core_view;
/**
*
*/
class Meta_manager
{
private $meta_tags;
function __construct()
{
$this->meta_tags = array();
}
public function add($name, $content)
{
$tag = new Html_tag('meta', false);
$tag->attr('name', $name)->attr('content', $content);
$this->meta_tags[$name] = $tag;
return $this;
}
public function add_property($name, $content)
{
$tag = new Html_tag('meta', false);
$tag->attr('property', $name)->attr('content', $content);
$this->meta_tags['prop_' . $name] = $tag;
return $this;
}
public function canonical($value)
{
$tag = new Html_tag('link', false);
$tag->attr('rel', 'canonical')->attr('href', $value);
$this->meta_tags['canonical'] = $tag;
return $this;
}
public function render()
{
echo $this->__toString();
}
public function __toString()
{
$str = '';
foreach ($this->meta_tags as $tag) {
$str .= $tag->__toString();
}
return $str;
}
}