|
5 | 5 |
|
6 | 6 | class Tag |
7 | 7 | { |
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 | + ]; |
24 | 24 |
|
25 | | - public function __construct( ) |
26 | | - { |
27 | | - |
28 | | - } |
29 | | - |
30 | | - public function cleanURLs( $html, $urlreplace = null ) |
31 | | - { |
| 25 | + public function __construct() |
| 26 | + { |
32 | 27 |
|
33 | | - foreach ( $this->linkAttr as $attr ) { |
34 | | - $html = str_replace( "{$attr}=\"//", "{$attr}=\"##", $html ); |
| 28 | + } |
35 | 29 |
|
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 | + { |
41 | 32 |
|
42 | | - return $html; |
43 | | - } |
| 33 | + foreach ($this->linkAttr as $attr) { |
| 34 | + $html = str_replace("{$attr}=\"//", "{$attr}=\"##", $html); |
44 | 35 |
|
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); |
53 | 38 | } |
| 39 | + $html = str_replace("{$attr}=\"##", "{$attr}=\"//", $html); |
| 40 | + } |
54 | 41 |
|
| 42 | + return $html; |
| 43 | + } |
55 | 44 |
|
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 | + } |
59 | 53 | } |
| 54 | + $element .= (($selfClosing) ? "/" : "") . ">"; |
| 55 | + return $element; |
| 56 | + } |
60 | 57 |
|
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 | + } |
67 | 64 |
|
68 | 65 | } |
0 commit comments