4
4
5
5
class HtmlDiff
6
6
{
7
+ public static $ defaultSpecialCaseTags = array ('strong ' , 'b ' , 'i ' , 'big ' , 'small ' , 'u ' , 'sub ' , 'sup ' , 'strike ' , 's ' , 'p ' );
8
+ public static $ defaultSpecialCaseChars = array ('. ' , ', ' , '( ' , ') ' , '\'' );
9
+ public static $ defaultGroupDiffs = true ;
10
+
7
11
private $ content ;
8
12
private $ oldText ;
9
13
private $ newText ;
@@ -13,19 +17,27 @@ class HtmlDiff
13
17
private $ encoding ;
14
18
private $ specialCaseOpeningTags = array ();
15
19
private $ specialCaseClosingTags = array ();
16
- private $ specialCaseTags = array ('strong ' , 'b ' , 'i ' , 'big ' , 'small ' , 'u ' , 'sub ' , 'sup ' , 'strike ' , 's ' , 'p ' );
17
- private $ specialCaseChars = array ('. ' , ', ' , '( ' , ') ' , '\'' );
18
- private $ groupDiffs = true ;
19
-
20
- public function __construct ($ oldText , $ newText , $ encoding = 'UTF-8 ' , $ specialCaseTags = array (), $ groupDiffs = true )
21
- {
20
+ private $ specialCaseTags ;
21
+ private $ specialCaseChars ;
22
+ private $ groupDiffs ;
23
+
24
+ public function __construct ($ oldText , $ newText , $ encoding = 'UTF-8 ' , $ specialCaseTags = null , $ groupDiffs = null )
25
+ {
26
+ if ($ specialCaseTags === null ) {
27
+ $ specialCaseTags = static ::$ defaultSpecialCaseTags ;
28
+ }
29
+
30
+ if ($ groupDiffs === null ) {
31
+ $ groupDiffs = static ::$ defaultGroupDiffs ;
32
+ }
33
+
22
34
$ this ->oldText = $ this ->purifyHtml (trim ($ oldText ));
23
35
$ this ->newText = $ this ->purifyHtml (trim ($ newText ));
24
36
$ this ->encoding = $ encoding ;
25
37
$ this ->content = '' ;
26
38
$ this ->groupDiffs = $ groupDiffs ;
27
-
28
39
$ this ->setSpecialCaseTags ($ specialCaseTags );
40
+ $ this ->setSpecialCaseChars (static ::$ defaultSpecialCaseChars );
29
41
}
30
42
31
43
public function setSpecialCaseChars (array $ chars )
0 commit comments