@@ -7,8 +7,8 @@ discard block |
||
7 | 7 | */ |
8 | 8 | function maintenance() |
9 | 9 | { |
10 | - include __DIR__ . '/maintenance.php'; |
|
11 | - exit; |
|
10 | + include __DIR__ . '/maintenance.php'; |
|
11 | + exit; |
|
12 | 12 | } |
13 | 13 | /** |
14 | 14 | * Debug Error |
@@ -17,6 +17,6 @@ discard block |
||
17 | 17 | */ |
18 | 18 | function show_error() |
19 | 19 | { |
20 | - error_reporting(E_ALL); |
|
21 | - ini_set('display_errors', 'On'); |
|
20 | + error_reporting(E_ALL); |
|
21 | + ini_set('display_errors', 'On'); |
|
22 | 22 | } |
@@ -37,83 +37,83 @@ |
||
37 | 37 | */ |
38 | 38 | class JSLikeHTMLElement extends DOMElement |
39 | 39 | { |
40 | - /** |
|
41 | - * Used for setting innerHTML like it's done in JavaScript:. |
|
42 | - * |
|
43 | - * @code |
|
44 | - * $div->innerHTML = '<h2>Chapter 2</h2><p>The story begins...</p>'; |
|
45 | - * @endcode |
|
46 | - */ |
|
47 | - public function __set($name, $value) |
|
48 | - { |
|
49 | - if ('innerHTML' == $name) { |
|
50 | - // first, empty the element |
|
51 | - for ($x = $this->childNodes->length - 1; $x >= 0; --$x) { |
|
52 | - $this->removeChild($this->childNodes->item($x)); |
|
53 | - } |
|
54 | - // $value holds our new inner HTML |
|
55 | - if ('' != $value) { |
|
56 | - $f = $this->ownerDocument->createDocumentFragment(); |
|
57 | - // appendXML() expects well-formed markup (XHTML) |
|
58 | - $result = @$f->appendXML($value); // @ to suppress PHP warnings |
|
59 | - if ($result) { |
|
60 | - if ($f->hasChildNodes()) { |
|
61 | - $this->appendChild($f); |
|
62 | - } |
|
63 | - } else { |
|
64 | - // $value is probably ill-formed |
|
65 | - $f = new DOMDocument(); |
|
66 | - $value = mb_convert_encoding($value, 'HTML-ENTITIES', 'UTF-8'); |
|
67 | - // Using <htmlfragment> will generate a warning, but so will bad HTML |
|
68 | - // (and by this point, bad HTML is what we've got). |
|
69 | - // We use it (and suppress the warning) because an HTML fragment will |
|
70 | - // be wrapped around <html><body> tags which we don't really want to keep. |
|
71 | - // Note: despite the warning, if loadHTML succeeds it will return true. |
|
72 | - $result = @$f->loadHTML('<htmlfragment>' . $value . '</htmlfragment>'); |
|
73 | - if ($result) { |
|
74 | - $import = $f->getElementsByTagName('htmlfragment')->item(0); |
|
75 | - foreach ($import->childNodes as $child) { |
|
76 | - $importedNode = $this->ownerDocument->importNode($child, true); |
|
77 | - $this->appendChild($importedNode); |
|
78 | - } |
|
79 | - } else { |
|
80 | - // oh well, we tried, we really did. :( |
|
81 | - // this element is now empty |
|
82 | - } |
|
83 | - } |
|
84 | - } |
|
85 | - } else { |
|
86 | - $trace = debug_backtrace(); |
|
87 | - trigger_error('Undefined property via __set(): ' . $name . ' in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line'], E_USER_NOTICE); |
|
88 | - } |
|
89 | - } |
|
40 | + /** |
|
41 | + * Used for setting innerHTML like it's done in JavaScript:. |
|
42 | + * |
|
43 | + * @code |
|
44 | + * $div->innerHTML = '<h2>Chapter 2</h2><p>The story begins...</p>'; |
|
45 | + * @endcode |
|
46 | + */ |
|
47 | + public function __set($name, $value) |
|
48 | + { |
|
49 | + if ('innerHTML' == $name) { |
|
50 | + // first, empty the element |
|
51 | + for ($x = $this->childNodes->length - 1; $x >= 0; --$x) { |
|
52 | + $this->removeChild($this->childNodes->item($x)); |
|
53 | + } |
|
54 | + // $value holds our new inner HTML |
|
55 | + if ('' != $value) { |
|
56 | + $f = $this->ownerDocument->createDocumentFragment(); |
|
57 | + // appendXML() expects well-formed markup (XHTML) |
|
58 | + $result = @$f->appendXML($value); // @ to suppress PHP warnings |
|
59 | + if ($result) { |
|
60 | + if ($f->hasChildNodes()) { |
|
61 | + $this->appendChild($f); |
|
62 | + } |
|
63 | + } else { |
|
64 | + // $value is probably ill-formed |
|
65 | + $f = new DOMDocument(); |
|
66 | + $value = mb_convert_encoding($value, 'HTML-ENTITIES', 'UTF-8'); |
|
67 | + // Using <htmlfragment> will generate a warning, but so will bad HTML |
|
68 | + // (and by this point, bad HTML is what we've got). |
|
69 | + // We use it (and suppress the warning) because an HTML fragment will |
|
70 | + // be wrapped around <html><body> tags which we don't really want to keep. |
|
71 | + // Note: despite the warning, if loadHTML succeeds it will return true. |
|
72 | + $result = @$f->loadHTML('<htmlfragment>' . $value . '</htmlfragment>'); |
|
73 | + if ($result) { |
|
74 | + $import = $f->getElementsByTagName('htmlfragment')->item(0); |
|
75 | + foreach ($import->childNodes as $child) { |
|
76 | + $importedNode = $this->ownerDocument->importNode($child, true); |
|
77 | + $this->appendChild($importedNode); |
|
78 | + } |
|
79 | + } else { |
|
80 | + // oh well, we tried, we really did. :( |
|
81 | + // this element is now empty |
|
82 | + } |
|
83 | + } |
|
84 | + } |
|
85 | + } else { |
|
86 | + $trace = debug_backtrace(); |
|
87 | + trigger_error('Undefined property via __set(): ' . $name . ' in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line'], E_USER_NOTICE); |
|
88 | + } |
|
89 | + } |
|
90 | 90 | |
91 | - /** |
|
92 | - * Used for getting innerHTML like it's done in JavaScript:. |
|
93 | - * |
|
94 | - * @code |
|
95 | - * $string = $div->innerHTML; |
|
96 | - * @endcode |
|
97 | - */ |
|
98 | - public function __get($name) |
|
99 | - { |
|
100 | - if ('innerHTML' == $name) { |
|
101 | - $inner = ''; |
|
102 | - foreach ($this->childNodes as $child) { |
|
103 | - $inner .= $this->ownerDocument->saveXML($child); |
|
104 | - } |
|
91 | + /** |
|
92 | + * Used for getting innerHTML like it's done in JavaScript:. |
|
93 | + * |
|
94 | + * @code |
|
95 | + * $string = $div->innerHTML; |
|
96 | + * @endcode |
|
97 | + */ |
|
98 | + public function __get($name) |
|
99 | + { |
|
100 | + if ('innerHTML' == $name) { |
|
101 | + $inner = ''; |
|
102 | + foreach ($this->childNodes as $child) { |
|
103 | + $inner .= $this->ownerDocument->saveXML($child); |
|
104 | + } |
|
105 | 105 | |
106 | - return $inner; |
|
107 | - } |
|
106 | + return $inner; |
|
107 | + } |
|
108 | 108 | |
109 | - $trace = debug_backtrace(); |
|
110 | - trigger_error('Undefined property via __get(): ' . $name . ' in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line'], E_USER_NOTICE); |
|
109 | + $trace = debug_backtrace(); |
|
110 | + trigger_error('Undefined property via __get(): ' . $name . ' in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line'], E_USER_NOTICE); |
|
111 | 111 | |
112 | - return null; |
|
113 | - } |
|
112 | + return null; |
|
113 | + } |
|
114 | 114 | |
115 | - public function __toString() |
|
116 | - { |
|
117 | - return '[' . $this->tagName . ']'; |
|
118 | - } |
|
115 | + public function __toString() |
|
116 | + { |
|
117 | + return '[' . $this->tagName . ']'; |
|
118 | + } |
|
119 | 119 | } |