Extends pQuery to use UTF-8 encoding on older versions of PHP

This commit is contained in:
Vlad
2017-02-13 19:55:39 -05:00
parent a918091977
commit 93f7739f46

View File

@ -0,0 +1,27 @@
<?php
namespace MailPoet\Util\pQuery;
// extend pQuery class to use UTF-8 encoding when getting elements' inner/outer text
class pQuery extends \pQuery {
public static function parseStr($html) {
$parser = new Html5Parser($html);
return $parser->root;
}
}
class Html5Parser extends \pQuery\HtmlParser {
var $root = 'MailPoet\Util\pQuery\DomNode';
}
class DomNode extends \pQuery\DomNode {
var $childClass = 'MailPoet\Util\pQuery\DomNode';
function getInnerText() {
return html_entity_decode($this->toString(true, true, 1), ENT_QUOTES | ENT_HTML5, 'UTF-8');
}
function getOuterText() {
return html_entity_decode($this->toString(), ENT_QUOTES | ENT_HTML5, 'UTF-8');
}
}