File tree 2 files changed +31
-11
lines changed
2 files changed +31
-11
lines changed Original file line number Diff line number Diff line change @@ -103,12 +103,22 @@ public function getShorContent()
103
103
104
104
if ($ p = mb_strpos ($ content , $ pageBraker )) {
105
105
$ content = mb_substr ($ content , 0 , $ p );
106
+ try {
107
+ libxml_use_internal_errors (true );
108
+ $ dom = new \DOMDocument ();
109
+ $ dom ->loadHTML ('<?xml encoding="UTF-8"> ' . $ content );
110
+ $ body = $ dom ->getElementsByTagName ('body ' );
111
+ if ( $ body && $ body ->length > 0 ) {
112
+ $ body = $ body ->item (0 );
113
+ $ _content = new \DOMDocument ;
114
+ foreach ($ body ->childNodes as $ child ){
115
+ $ _content ->appendChild ($ _content ->importNode ($ child , true ));
116
+ }
117
+ $ content = $ _content ->saveHTML ();
118
+ }
119
+ } catch (\Exception $ e ) {}
106
120
}
107
121
108
- $ dom = new \DOMDocument ();
109
- $ dom ->loadHTML ('<?xml encoding="UTF-8"> ' . $ content );
110
- $ content = $ dom ->saveHTML ();
111
-
112
122
return $ content ;
113
123
}
114
124
Original file line number Diff line number Diff line change @@ -131,19 +131,29 @@ public function getCategory()
131
131
*/
132
132
public function getShorContent ($ post )
133
133
{
134
- $ content = $ post ->getContent ();
134
+ $ content = $ this ->_filterProvider ->getPageFilter ()->filter (
135
+ $ post ->getContent ()
136
+ );
135
137
$ pageBraker = '<!-- pagebreak --> ' ;
136
138
137
139
if ($ p = mb_strpos ($ content , $ pageBraker )) {
138
140
$ content = mb_substr ($ content , 0 , $ p );
141
+ try {
142
+ libxml_use_internal_errors (true );
143
+ $ dom = new \DOMDocument ();
144
+ $ dom ->loadHTML ('<?xml encoding="UTF-8"> ' . $ content );
145
+ $ body = $ dom ->getElementsByTagName ('body ' );
146
+ if ( $ body && $ body ->length > 0 ) {
147
+ $ body = $ body ->item (0 );
148
+ $ _content = new \DOMDocument ;
149
+ foreach ($ body ->childNodes as $ child ){
150
+ $ _content ->appendChild ($ _content ->importNode ($ child , true ));
151
+ }
152
+ $ content = $ _content ->saveHTML ();
153
+ }
154
+ } catch (\Exception $ e ) {}
139
155
}
140
156
141
- $ content = $ this ->_filterProvider ->getPageFilter ()->filter ($ content );
142
-
143
- $ dom = new \DOMDocument ();
144
- $ dom ->loadHTML ('<?xml encoding="UTF-8"> ' . $ content );
145
- $ content = $ dom ->saveHTML ();
146
-
147
157
return $ content ;
148
158
}
149
159
}
You can’t perform that action at this time.
0 commit comments