-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathHtmlMetaComponent.php
More file actions
81 lines (75 loc) · 1.99 KB
/
HtmlMetaComponent.php
File metadata and controls
81 lines (75 loc) · 1.99 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
/**
* HTML Meta Component
*
* A CakePHP Component for adding and outputting HTML Meta Elements.
*
* PHP 5
*
* Licensed under The MIT License
* Redistributions of files must retain the below copyright notice.
*
* @author Robert Love <robert@pollenizer.com>
* @copyright Copyright 2012, Pollenizer Pty. Ltd. (http://pollenizer.com)
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
* @since CakePHP(tm) v 2.0.4
*/
App::uses('HtmlHelper', 'View/Helper');
class HtmlMetaComponent extends Component
{
/**
* Attributes
*
* @var array
*/
protected static $_attributes = array();
/**
* Settings
*
* @var array
*/
protected static $_settings = array();
/**
* Construct
*
* @param ComponentCollection $collection The Component collection used on this request
* @param array $settings Array of settings
* @return void
*/
public function __construct(ComponentCollection $collection, $settings = array())
{
self::$_settings = $settings;
}
/**
* Add Element
*
* @param array $attributes Array of HTML attributes
* @return HtmlMetaComponent $this
*/
public function addElement($attributes)
{
if ((is_array($attributes)) && (!empty($attributes))) {
self::$_attributes[] = $attributes;
}
return $this;
}
/**
* Elements
*
* @return string HTML Meta Elements
*/
public static function elements()
{
$elements = null;
self::$_attributes = array_merge(self::$_settings, self::$_attributes);
if (!empty(self::$_attributes)) {
$Html = new HtmlHelper(new View(null));
foreach (self::$_attributes as $attributes) {
if ((is_array($attributes)) && (!empty($attributes))) {
$elements .= $Html->meta($attributes) . "\n";
}
}
}
return $elements;
}
}