updated mimemail
This commit is contained in:
@@ -6,9 +6,8 @@ dependencies[] = trigger
|
||||
core = 7.x
|
||||
|
||||
|
||||
; Information added by Drupal.org packaging script on 2015-08-02
|
||||
version = "7.x-1.0-beta4"
|
||||
; Information added by Drupal.org packaging script on 2018-10-17
|
||||
version = "7.x-1.1"
|
||||
core = "7.x"
|
||||
project = "mimemail"
|
||||
datestamp = "1438530555"
|
||||
|
||||
datestamp = "1539793390"
|
||||
|
||||
@@ -26,7 +26,8 @@ function mimemail_send_email_action($entity, $context) {
|
||||
if (empty($context['node'])) {
|
||||
if (get_class($entity) == 'OgMembership') {
|
||||
$context['user'] = user_load($entity->etid);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$context['node'] = $entity;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ class mimemail_compress {
|
||||
private $css = '';
|
||||
private $unprocessable_tags = array('wbr');
|
||||
|
||||
public function mimemail_compress($html = '', $css = '') {
|
||||
public function __construct($html = '', $css = '') {
|
||||
$this->html = $html;
|
||||
$this->css = $css;
|
||||
}
|
||||
@@ -144,7 +144,7 @@ class mimemail_compress {
|
||||
$node->setAttribute('style', $style);
|
||||
|
||||
// Convert float to align for images.
|
||||
$float = preg_match ('/float:(left|right)/', $style, $matches);
|
||||
$float = preg_match('/float:(left|right)/', $style, $matches);
|
||||
if ($node->nodeName == 'img' && $float) {
|
||||
$node->setAttribute('align', $matches[1]);
|
||||
$node->setAttribute('vspace', 5);
|
||||
@@ -196,6 +196,23 @@ class mimemail_compress {
|
||||
return $precedence;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace callback function that matches ID attributes.
|
||||
*/
|
||||
private static function replace_id_attributes($m) {
|
||||
return (strlen($m[1]) ? $m[1] : '*') . '[@id="' . $m[2] . '"]';
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace callback function that matches class attributes.
|
||||
*/
|
||||
private static function replace_class_attributes($m) {
|
||||
return (strlen($m[1]) ? $m[1] : '*') .
|
||||
'[contains(concat(" ",normalize-space(@class)," "),concat(" ","' .
|
||||
implode('"," "))][contains(concat(" ",normalize-space(@class)," "),concat(" ","', explode('.', substr($m[2], 1))) .
|
||||
'"," "))]';
|
||||
}
|
||||
|
||||
/**
|
||||
* Right now we only support CSS 1 selectors, but include CSS2/3 selectors are fully possible.
|
||||
*
|
||||
@@ -206,6 +223,7 @@ class mimemail_compress {
|
||||
// Already an XPath expression.
|
||||
return $selector;
|
||||
}
|
||||
|
||||
// Returns an Xpath selector.
|
||||
$search = array(
|
||||
'/\s+>\s+/', // Matches any F element that is a child of an element E.
|
||||
@@ -213,8 +231,6 @@ class mimemail_compress {
|
||||
'/\s+/', // Matches any F element that is a descendant of an E element.
|
||||
'/(\w)\[(\w+)\]/', // Matches element with attribute.
|
||||
'/(\w)\[(\w+)\=[\'"]?(\w+)[\'"]?\]/', // Matches element with EXACT attribute.
|
||||
'/(\w+)?\#([\w\-]+)/e', // Matches id attributes.
|
||||
'/(\w+|\*)?((\.[\w\-]+)+)/e', // Matches class attributes.
|
||||
);
|
||||
$replace = array(
|
||||
'/',
|
||||
@@ -222,10 +238,13 @@ class mimemail_compress {
|
||||
'//',
|
||||
'\\1[@\\2]',
|
||||
'\\1[@\\2="\\3"]',
|
||||
"(strlen('\\1') ? '\\1' : '*').'[@id=\"\\2\"]'",
|
||||
"(strlen('\\1') ? '\\1' : '*').'[contains(concat(\" \",normalize-space(@class),\" \"),concat(\" \",\"'.implode('\",\" \"))][contains(concat(\" \",normalize-space(@class),\" \"),concat(\" \",\"',explode('.',substr('\\2',1))).'\",\" \"))]'",
|
||||
);
|
||||
return '//' . preg_replace($search, $replace, trim($selector));
|
||||
|
||||
$result = preg_replace($search, $replace, trim($selector));
|
||||
$result = preg_replace_callback('/(\w+)?\#([\w\-]+)/', 'mimemail_compress::replace_id_attributes', $result);
|
||||
$result = preg_replace_callback('/(\w+|\*)?((\.[\w\-]+)+)/', 'mimemail_compress::replace_class_attributes', $result);
|
||||
|
||||
return '//' . $result;
|
||||
}
|
||||
|
||||
private function css_style_to_array($style) {
|
||||
|
||||
@@ -6,9 +6,8 @@ core = 7.x
|
||||
|
||||
files[] = mimemail_compress.inc
|
||||
|
||||
; Information added by Drupal.org packaging script on 2015-08-02
|
||||
version = "7.x-1.0-beta4"
|
||||
; Information added by Drupal.org packaging script on 2018-10-17
|
||||
version = "7.x-1.1"
|
||||
core = "7.x"
|
||||
project = "mimemail"
|
||||
datestamp = "1438530555"
|
||||
|
||||
datestamp = "1539793390"
|
||||
|
||||
@@ -4,9 +4,8 @@ dependencies[] = mimemail
|
||||
package = Example modules
|
||||
core = 7.x
|
||||
|
||||
; Information added by Drupal.org packaging script on 2015-08-02
|
||||
version = "7.x-1.0-beta4"
|
||||
; Information added by Drupal.org packaging script on 2018-10-17
|
||||
version = "7.x-1.1"
|
||||
core = "7.x"
|
||||
project = "mimemail"
|
||||
datestamp = "1438530555"
|
||||
|
||||
datestamp = "1539793390"
|
||||
|
||||
Reference in New Issue
Block a user