1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace hemio\html; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* The <code>head</code> element collects the document’s metadata. |
7
|
|
|
* |
8
|
|
|
* @since version 1.0 |
9
|
|
|
* @url http://www.w3.org/TR/html5/document-metadata.html#the-head-element |
10
|
|
|
*/ |
11
|
|
|
class Head extends Abstract_\ElementContent |
12
|
|
|
{ |
13
|
|
|
|
14
|
|
|
use Trait_\DefaultElementContent; |
15
|
|
|
|
16
|
|
|
public static function tagName() |
17
|
|
|
{ |
18
|
|
|
return 'head'; |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
function __construct(Interface_\ContentModelText $objTitleContent) |
|
|
|
|
22
|
|
|
{ |
23
|
|
|
$this['_TITLE'] = new Title; |
24
|
|
|
$this['_TITLE'][] = $objTitleContent; |
25
|
|
|
$this['_BASE'] = new Nothing(); |
26
|
|
|
$objCharset = ($this['_CHARSET'] = new Meta); |
27
|
|
|
$objCharset->setAttribute('charset', 'utf-8'); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* |
32
|
|
|
* @param string $strName |
33
|
|
|
* @param string $strContent |
34
|
|
|
* @return \hemio\html\Meta |
35
|
|
|
*/ |
36
|
|
|
function addMeta($strName, $strContent) |
|
|
|
|
37
|
|
|
{ |
38
|
|
|
$objMeta = new Meta(); |
39
|
|
|
$this->addChild($objMeta); |
40
|
|
|
|
41
|
|
|
$objMeta->setAttribute('name', $strName); |
42
|
|
|
$objMeta->setAttribute('content', $strContent); |
43
|
|
|
return $objMeta; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* |
48
|
|
|
* @param string $strFilename |
49
|
|
|
*/ |
50
|
|
|
function addCssFile($strFilename) |
|
|
|
|
51
|
|
|
{ |
52
|
|
|
$link = new Link(); |
53
|
|
|
$link->setAttribute('rel', 'stylesheet'); |
54
|
|
|
$link->setAttribute('type', 'text/css'); |
55
|
|
|
$link->setAttribute('href', $strFilename); |
56
|
|
|
|
57
|
|
|
$this['_CSS_'.$strFilename] = $link; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* |
62
|
|
|
* @param string $url |
63
|
|
|
*/ |
64
|
|
|
function addJsFile($url) |
|
|
|
|
65
|
|
|
{ |
66
|
|
|
$script = new Script(); |
67
|
|
|
$script->setAttribute('type', 'text/javascript'); |
68
|
|
|
$script->setAttribute('src', $url); |
69
|
|
|
|
70
|
|
|
$this['_JS_'.$url] = $script; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* |
75
|
|
|
* @param type $url |
76
|
|
|
* @todo URL |
77
|
|
|
*/ |
78
|
|
|
public function setBaseUrl($url) |
79
|
|
|
{ |
80
|
|
|
$base = new Base(); |
81
|
|
|
$base->setAttribute('href', $url); |
82
|
|
|
$this['_BASE'] = $base; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
public function blnIsBlock() |
86
|
|
|
{ |
87
|
|
|
return true; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
public function isValidChild(Interface_\HtmlCode $child) |
91
|
|
|
{ |
92
|
|
|
return $child instanceof Interface_\ContentModelMetadata; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
public function addChild(Interface_\ContentModelMetadata $child) |
96
|
|
|
{ |
97
|
|
|
return $this->addChildInternal($child); |
98
|
|
|
} |
99
|
|
|
} |
100
|
|
|
|
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.