Skip to content

Commit 226fdbe

Browse files
committed
Update Tag
1 parent b351769 commit 226fdbe

File tree

1 file changed

+46
-49
lines changed

1 file changed

+46
-49
lines changed

src/Tags/Tag.php

Lines changed: 46 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -5,64 +5,61 @@
55

66
class Tag
77
{
8-
public $linkAttr = [
9-
"href",
10-
"codebase",
11-
"cite",
12-
"background",
13-
"action",
14-
"longdesc",
15-
"src",
16-
"usemap",
17-
"classid",
18-
"data",
19-
"formaction",
20-
"icon",
21-
"manifest",
22-
"poster",
23-
];
8+
public $linkAttr = [
9+
"href",
10+
"codebase",
11+
"cite",
12+
"background",
13+
"action",
14+
"longdesc",
15+
"src",
16+
"usemap",
17+
"classid",
18+
"data",
19+
"formaction",
20+
"icon",
21+
"manifest",
22+
"poster",
23+
];
2424

25-
public function __construct( )
26-
{
27-
28-
}
29-
30-
public function cleanURLs( $html, $urlreplace = null )
31-
{
25+
public function __construct()
26+
{
3227

33-
foreach ( $this->linkAttr as $attr ) {
34-
$html = str_replace( "{$attr}=\"//", "{$attr}=\"##", $html );
28+
}
3529

36-
if( $urlreplace ){
37-
$html = str_replace( "{$attr}=\"/", "{$attr}=\"{$urlreplace}", $html );
38-
}
39-
$html = str_replace( "{$attr}=\"##", "{$attr}=\"//", $html );
40-
}
30+
public function cleanURLs($html, $urlreplace = null)
31+
{
4132

42-
return $html;
43-
}
33+
foreach ($this->linkAttr as $attr) {
34+
$html = str_replace("{$attr}=\"//", "{$attr}=\"##", $html);
4435

45-
public function createElement( $tag, $attr = [], $selfClosing = false, $close = false )
46-
{
47-
$element = "<" . (( $close ) ? "/" : "" );
48-
$element .= "$tag";
49-
if( !empty( $attr ) ){
50-
foreach( $attr as $ak => $av ){
51-
$element .= " {$ak}=\"{$av}\" ";
52-
}
36+
if ($urlreplace) {
37+
$html = str_replace("{$attr}=\"/", "{$attr}=\"{$urlreplace}", $html);
5338
}
39+
$html = str_replace("{$attr}=\"##", "{$attr}=\"//", $html);
40+
}
5441

42+
return $html;
43+
}
5544

56-
$element .= (( $selfClosing ) ? "/" : "" ) . ">";
57-
58-
return $element;
45+
public function createElement($tag, $attr = [], $selfClosing = false, $close = false)
46+
{
47+
$element = "<" . (($close) ? "/" : "");
48+
$element .= "$tag";
49+
if (!empty($attr)) {
50+
foreach ($attr as $ak => $av) {
51+
$element .= " {$ak}=\"{$av}\" ";
52+
}
5953
}
54+
$element .= (($selfClosing) ? "/" : "") . ">";
55+
return $element;
56+
}
6057

61-
public function output( $options = [] )
62-
{
63-
ob_start();
64-
echo $this->createElement( $options["tag"], $options["attr"], $options['selfClosing'], $options["close"] );
65-
echo ob_get_clean();
66-
}
58+
public function output($options = [])
59+
{
60+
ob_start();
61+
echo $this->createElement($options["tag"], $options["attr"], $options['selfClosing'], $options["close"]);
62+
echo ob_get_clean();
63+
}
6764

6865
}

0 commit comments

Comments
 (0)