- Removes php-simple-html-dom-parser dependency
- Updates CSS inliner to use pQuery DOM parser
This commit is contained in:
@ -10,7 +10,6 @@
|
|||||||
"twig/twig": "1.*",
|
"twig/twig": "1.*",
|
||||||
"phpmailer/phpmailer": "~5.2",
|
"phpmailer/phpmailer": "~5.2",
|
||||||
"cerdic/css-tidy": "*",
|
"cerdic/css-tidy": "*",
|
||||||
"sunra/php-simple-html-dom-parser": "*",
|
|
||||||
"tburry/pquery": "*",
|
"tburry/pquery": "*",
|
||||||
"j4mie/paris": "1.5.4",
|
"j4mie/paris": "1.5.4",
|
||||||
"swiftmailer/swiftmailer": "^5.4",
|
"swiftmailer/swiftmailer": "^5.4",
|
||||||
@ -34,4 +33,4 @@
|
|||||||
"Sudzy\\": "lib/Util/Sudzy"
|
"Sudzy\\": "lib/Util/Sudzy"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -187,13 +187,8 @@ class CSS {
|
|||||||
*/
|
*/
|
||||||
function inlineCSS($url, $contents=null)
|
function inlineCSS($url, $contents=null)
|
||||||
{
|
{
|
||||||
// Download the HTML if it was not provided
|
$html = \pQuery::parseStr($contents);
|
||||||
if($contents === null) {
|
// $html = HtmlDomParser::str_get_html($contents, true, true, DEFAULT_TARGET_CHARSET, false, DEFAULT_BR_TEXT, DEFAULT_SPAN_TEXT);
|
||||||
$html = HtmlDomParser::file_get_html($url, false, null, -1, -1, true, true, DEFAULT_TARGET_CHARSET, false, DEFAULT_BR_TEXT, DEFAULT_SPAN_TEXT);
|
|
||||||
} else {
|
|
||||||
// use the data provided!
|
|
||||||
$html = HtmlDomParser::str_get_html($contents, true, true, DEFAULT_TARGET_CHARSET, false, DEFAULT_BR_TEXT, DEFAULT_SPAN_TEXT);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!is_object($html)) {
|
if(!is_object($html)) {
|
||||||
return false;
|
return false;
|
||||||
@ -202,13 +197,13 @@ class CSS {
|
|||||||
$css_blocks = '';
|
$css_blocks = '';
|
||||||
|
|
||||||
// Find all <style> blocks and cut styles from them (leaving media queries)
|
// Find all <style> blocks and cut styles from them (leaving media queries)
|
||||||
foreach($html->find('style') as $style) {
|
foreach($html->query('style') as $style) {
|
||||||
list($_css_to_parse, $_css_to_keep) = self::splitMediaQueries($style->innertext());
|
list($_css_to_parse, $_css_to_keep) = self::splitMediaQueries($style->getInnerText());
|
||||||
$css_blocks .= $_css_to_parse;
|
$css_blocks .= $_css_to_parse;
|
||||||
if(!empty($_css_to_keep)) {
|
if(!empty($_css_to_keep)) {
|
||||||
$style->innertext = $_css_to_keep;
|
$style->setInnerText($_css_to_keep);
|
||||||
} else {
|
} else {
|
||||||
$style->outertext = '';
|
$style->setOuterText('');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -225,7 +220,7 @@ class CSS {
|
|||||||
// We loop over each rule by increasing order of specificity, find the nodes matching the selector
|
// We loop over each rule by increasing order of specificity, find the nodes matching the selector
|
||||||
// and apply the CSS properties
|
// and apply the CSS properties
|
||||||
foreach ($rules as $rule) {
|
foreach ($rules as $rule) {
|
||||||
foreach($html->find($rule['selector']) as $node) {
|
foreach($html->query($rule['selector']) as $node) {
|
||||||
// I'm leaving this for debug purposes, it has proved useful.
|
// I'm leaving this for debug purposes, it has proved useful.
|
||||||
/*
|
/*
|
||||||
if($node->already_styled === 'yes')
|
if($node->already_styled === 'yes')
|
||||||
|
Reference in New Issue
Block a user