forked from Airmanbzh/php-html-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHtmlTag.php
More file actions
executable file
·57 lines (51 loc) · 1.29 KB
/
HtmlTag.php
File metadata and controls
executable file
·57 lines (51 loc) · 1.29 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
<?php
/*
* @author Airmanbzh
*/
namespace HtmlGenerator;
if (!defined('ENT_HTML5'))
{
define('ENT_HTML5', 48);
}
class HtmlTag extends Markup
{
/** @var int The language convention used for XSS avoiding */
public static $outputLanguage = ENT_HTML5;
protected $autocloseTagsList = array(
'img', 'br', 'hr', 'input', 'area', 'link', 'meta', 'param'
);
/**
* Shortcut to set('id', $value)
* @param string $value
* @return HtmlTag instance
*/
public function id($value)
{
return $this->set('id', $value);
}
/**
* Add a class to classList
* @param string $value
* @return HtmlTag instance
*/
public function addClass($value)
{
if (!isset($this->attributeList['class']) || is_null($this->attributeList['class'])) {
$this->attributeList['class'] = array();
}
$this->attributeList['class'][] = $value;
return $this;
}
/**
* Remove a class from classList
* @param string $value
* @return HtmlTag instance
*/
public function removeClass($value)
{
if (!is_null($this->attributeList['class'])) {
unset($this->attributeList['class'][array_search($value, $this->attributeList['class'])]);
}
return $this;
}
}