Changeset 1247838
- Timestamp:
- 09/17/2015 05:55:59 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
mobile-app-api/trunk/model/class-shoutem-posts-dao.php
r1232731 r1247838 295 295 $content = '<figure>'.$content.'<figcaption class="image-caption">'.$attr['caption'].'</figcaption>'.'</figure>'; 296 296 297 $dom = new DOMDocument(); 298 @$dom->loadHTML(do_shortcode(mb_convert_encoding($content, 'HTML-ENTITIES', 'UTF-8'))); 297 $dom = shoutem_html_load($content); 299 298 foreach ($dom->getElementsByTagName('img') as $img) { 300 299 $img->setAttribute('caption', $attr['caption']); … … 303 302 } 304 303 } 305 306 $output = substr($dom->saveXML($dom->getElementsByTagName('body')->item(0)), 6, -7); 307 return mb_convert_encoding($output, 'HTML-ENTITIES', 'UTF-8'); 304 return shoutem_html_save($dom); 308 305 } 309 306 … … 327 324 } 328 325 329 $dom = new DOMDocument(); 330 // supress warnings caused by HTML5 tags 331 @$dom->loadHTML('<?xml encoding="UTF-8">'.mb_convert_encoding($content, 'HTML-ENTITIES', 'UTF-8')); 326 $dom = shoutem_html_load($content); 332 327 333 328 $nodes_to_wrap = array(); … … 353 348 } 354 349 355 $output = substr($dom->saveXML($dom->getElementsByTagName('body')->item(0)), 6, -7); 356 return mb_convert_encoding($output, 'HTML-ENTITIES', 'UTF-8'); 350 return shoutem_html_save($dom); 351 } 352 353 function shoutem_html_load($html) { 354 if (function_exists('mb_encode_numericentity')) { 355 $html = mb_encode_numericentity($html, array (0x80, 0xffff, 0, 0xffff), 'UTF-8'); 356 } 357 $dom = new DOMDocument(); 358 // supress warnings caused by HTML5 tags 359 @$dom->loadHTML('<?xml encoding="UTF-8">'.$html); 360 return $dom; 361 } 362 363 function shoutem_html_save($dom) { 364 $html = substr($dom->saveXML($dom->getElementsByTagName('body')->item(0)), 6, -7); 365 if (function_exists('mb_decode_numericentity')) { 366 $html = mb_decode_numericentity($html, array (0x80, 0xffff, 0, 0xffff), 'UTF-8'); 367 } 368 return $html; 357 369 } 358 370
Note: See TracChangeset
for help on using the changeset viewer.