aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc/JSLikeHTMLElement.php
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2013-07-31 17:19:50 +0200
committerNicolas LÅ“uillet <nicolas@loeuillet.org>2013-07-31 17:19:50 +0200
commit85ebc80c7eaf88e4d57a52adb8e4c32d8cc34b64 (patch)
tree0012345c93b1fe8a242963bede0db370598d6f2b /inc/JSLikeHTMLElement.php
parent6588517b2d46cbc524260758d1fafd92b19ab681 (diff)
parent6d37de5f828b700843567a91418671919eed4be4 (diff)
downloadwallabag-85ebc80c7eaf88e4d57a52adb8e4c32d8cc34b64.tar.gz
wallabag-85ebc80c7eaf88e4d57a52adb8e4c32d8cc34b64.tar.zst
wallabag-85ebc80c7eaf88e4d57a52adb8e4c32d8cc34b64.zip
Merge branch 'dev'0.3
Diffstat (limited to 'inc/JSLikeHTMLElement.php')
-rw-r--r--inc/JSLikeHTMLElement.php15
1 files changed, 7 insertions, 8 deletions
diff --git a/inc/JSLikeHTMLElement.php b/inc/JSLikeHTMLElement.php
index 0557205f..dfcc1be5 100644
--- a/inc/JSLikeHTMLElement.php
+++ b/inc/JSLikeHTMLElement.php
@@ -4,7 +4,7 @@
4* 4*
5* This class extends PHP's DOMElement to allow 5* This class extends PHP's DOMElement to allow
6* users to get and set the innerHTML property of 6* users to get and set the innerHTML property of
7* HTML elements in the same way it's done in 7* HTML elements in the same way it's done in
8* JavaScript. 8* JavaScript.
9* 9*
10* Example usage: 10* Example usage:
@@ -15,16 +15,16 @@
15* $doc->registerNodeClass('DOMElement', 'JSLikeHTMLElement'); 15* $doc->registerNodeClass('DOMElement', 'JSLikeHTMLElement');
16* $doc->loadHTML('<div><p>Para 1</p><p>Para 2</p></div>'); 16* $doc->loadHTML('<div><p>Para 1</p><p>Para 2</p></div>');
17* $elem = $doc->getElementsByTagName('div')->item(0); 17* $elem = $doc->getElementsByTagName('div')->item(0);
18* 18*
19* // print innerHTML 19* // print innerHTML
20* echo $elem->innerHTML; // prints '<p>Para 1</p><p>Para 2</p>' 20* echo $elem->innerHTML; // prints '<p>Para 1</p><p>Para 2</p>'
21* echo "\n\n"; 21* echo "\n\n";
22* 22*
23* // set innerHTML 23* // set innerHTML
24* $elem->innerHTML = '<a href="http://fivefilters.org">FiveFilters.org</a>'; 24* $elem->innerHTML = '<a href="http://fivefilters.org">FiveFilters.org</a>';
25* echo $elem->innerHTML; // prints '<a href="http://fivefilters.org">FiveFilters.org</a>' 25* echo $elem->innerHTML; // prints '<a href="http://fivefilters.org">FiveFilters.org</a>'
26* echo "\n\n"; 26* echo "\n\n";
27* 27*
28* // print document (with our changes) 28* // print document (with our changes)
29* echo $doc->saveXML(); 29* echo $doc->saveXML();
30* @endcode 30* @endcode
@@ -59,7 +59,7 @@ class JSLikeHTMLElement extends DOMElement
59 $value = mb_convert_encoding($value, 'HTML-ENTITIES', 'UTF-8'); 59 $value = mb_convert_encoding($value, 'HTML-ENTITIES', 'UTF-8');
60 // Using <htmlfragment> will generate a warning, but so will bad HTML 60 // Using <htmlfragment> will generate a warning, but so will bad HTML
61 // (and by this point, bad HTML is what we've got). 61 // (and by this point, bad HTML is what we've got).
62 // We use it (and suppress the warning) because an HTML fragment will 62 // We use it (and suppress the warning) because an HTML fragment will
63 // be wrapped around <html><body> tags which we don't really want to keep. 63 // be wrapped around <html><body> tags which we don't really want to keep.
64 // Note: despite the warning, if loadHTML succeeds it will return true. 64 // Note: despite the warning, if loadHTML succeeds it will return true.
65 $result = @$f->loadHTML('<htmlfragment>'.$value.'</htmlfragment>'); 65 $result = @$f->loadHTML('<htmlfragment>'.$value.'</htmlfragment>');
@@ -86,7 +86,7 @@ class JSLikeHTMLElement extends DOMElement
86 * @code 86 * @code
87 * $string = $div->innerHTML; 87 * $string = $div->innerHTML;
88 * @endcode 88 * @endcode
89 */ 89 */
90 public function __get($name) 90 public function __get($name)
91 { 91 {
92 if ($name == 'innerHTML') { 92 if ($name == 'innerHTML') {
@@ -106,5 +106,4 @@ class JSLikeHTMLElement extends DOMElement
106 { 106 {
107 return '['.$this->tagName.']'; 107 return '['.$this->tagName.']';
108 } 108 }
109} 109} \ No newline at end of file
110?> \ No newline at end of file