Version 4.1.2
This commit is contained in:
1 parent
3ba79295ee
commit
28bd025b35
1131 files changed
+63658
-20579
No files matched your search
+71
-62
@@ -577,7 +577,7 @@ abstract class _Email
|
||||
* @see <a href='http://www.faqs.org/rfcs/rfc2369.html'>RFC 2369 describes the List-Unsubscribe header</a>
|
||||
*/
|
||||
public function send( $to, $cc=array(), $bcc=array() )
|
||||
{
|
||||
{
|
||||
/* Parse the recipients - do this first in order to extract the language key in case we need it */
|
||||
$this->recipients = array();
|
||||
|
||||
@@ -620,34 +620,14 @@ abstract class _Email
|
||||
}
|
||||
|
||||
/* Replace language stack keys with actual content */
|
||||
$this->language->parseOutputForDisplay( $this->emailBody['plain'] );
|
||||
$this->language->parseOutputForDisplay( $this->emailBody['html'] );
|
||||
$this->language->parseEmail( $this->emailBody['plain'] );
|
||||
$this->language->parseEmail( $this->emailBody['html'] );
|
||||
$this->language->parseOutputForDisplay( $this->subject );
|
||||
|
||||
/* Replace attachment and emoticon URLs */
|
||||
\IPS\Output::i()->parseFileObjectUrls( $this->emailBody['html'] );
|
||||
\IPS\Output::i()->parseFileObjectUrls( $this->emailBody['plain'] );
|
||||
|
||||
/* Outlook can't handle protocol-relative URLs, so we need to switch them out */
|
||||
foreach( $this->emailBody as $type => $content )
|
||||
{
|
||||
$this->emailBody[ $type ] = preg_replace_callback( "/\s+?src=(['\"])\/\/([^'\"]+?)(['\"])/ims", function( $matches ){
|
||||
$baseUrl = parse_url( \IPS\Settings::i()->base_url );
|
||||
|
||||
/* Try to preserve http vs https */
|
||||
if( isset( $baseUrl['scheme'] ) )
|
||||
{
|
||||
$url = $baseUrl['scheme'] . '://' . $matches[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
$url = 'http://' . $matches[2];
|
||||
}
|
||||
|
||||
return " src={$matches[1]}{$url}{$matches[1]}";
|
||||
}, $content );
|
||||
}
|
||||
|
||||
$this->parseFileObjectUrls( $this->emailBody['html'] );
|
||||
$this->parseFileObjectUrls( $this->emailBody['plain'] );
|
||||
|
||||
/* Now build the actual email body and send */
|
||||
$boundary = "--==_mimepart_" . md5( uniqid() );
|
||||
|
||||
@@ -694,6 +674,33 @@ abstract class _Email
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse file object URLs and fix protocol relative URLs
|
||||
*
|
||||
* @param string $body Content
|
||||
* @return string
|
||||
*/
|
||||
public function parseFileObjectUrls( &$body )
|
||||
{
|
||||
\IPS\Output::i()->parseFileObjectUrls( $body );
|
||||
|
||||
$body = preg_replace_callback( "/\s+?(srcset|src)=(['\"])\/\/([^'\"]+?)(['\"])/ims", function( $matches ){
|
||||
$baseUrl = parse_url( \IPS\Settings::i()->base_url );
|
||||
|
||||
/* Try to preserve http vs https */
|
||||
if( isset( $baseUrl['scheme'] ) )
|
||||
{
|
||||
$url = $baseUrl['scheme'] . '://' . $matches[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
$url = 'http://' . $matches[3];
|
||||
}
|
||||
|
||||
return " {$matches[1]}={$matches[2]}{$url}{$matches[2]}";
|
||||
}, $body );
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge and Send
|
||||
*
|
||||
@@ -711,6 +718,10 @@ abstract class _Email
|
||||
$vars = array();
|
||||
foreach ( $_vars as $k => $v )
|
||||
{
|
||||
if ( $k === 'unsubscribe_blurb' )
|
||||
{
|
||||
$this->language->parseOutputForDisplay( $v );
|
||||
}
|
||||
$vars[] = array( 'name' => $k, 'content' => $v );
|
||||
}
|
||||
|
||||
@@ -722,10 +733,10 @@ abstract class _Email
|
||||
$body = $this->body['html'];
|
||||
$subject = $this->subject;
|
||||
|
||||
/* Replace attachment and emoticon URLs */
|
||||
\IPS\Output::i()->parseFileObjectUrls( $body );
|
||||
/* Replace attachment and emoticon URLs, fix protocol relative URLs and clean up HTML */
|
||||
$this->parseFileObjectUrls( $body );
|
||||
|
||||
$this->language->parseOutputForDisplay( $body );
|
||||
$this->language->parseEmail( $body );
|
||||
$this->language->parseOutputForDisplay( $subject );
|
||||
|
||||
$response = \IPS\Email::mandrill( 'messages_send', \IPS\Settings::i()->mandrill_api_key, array(
|
||||
@@ -754,12 +765,12 @@ abstract class _Email
|
||||
$subject = $this->subject;
|
||||
|
||||
/* Replace attachment and emoticon URLs */
|
||||
\IPS\Output::i()->parseFileObjectUrls( $content['html'] );
|
||||
\IPS\Output::i()->parseFileObjectUrls( $content['plain'] );
|
||||
$this->parseFileObjectUrls( $content['html'] );
|
||||
$this->parseFileObjectUrls( $content['plain'] );
|
||||
|
||||
/* Replace language stack keys with actual content */
|
||||
$this->language->parseOutputForDisplay( $content['html'] );
|
||||
$this->language->parseOutputForDisplay( $content['plain'] );
|
||||
$this->language->parseEmail( $content['html'] );
|
||||
$this->language->parseEmail( $content['plain'] );
|
||||
$this->language->parseOutputForDisplay( $subject );
|
||||
|
||||
foreach ( $vars as $k => $v )
|
||||
@@ -993,7 +1004,7 @@ abstract class _Email
|
||||
*/
|
||||
public function parseTextForEmail( $text )
|
||||
{
|
||||
\IPS\Output::i()->parseFileObjectUrls( $text );
|
||||
$this->parseFileObjectUrls( $text );
|
||||
|
||||
try
|
||||
{
|
||||
@@ -1038,30 +1049,6 @@ abstract class _Email
|
||||
{
|
||||
$parent = $node->parentNode;
|
||||
|
||||
/* Outlook cannot handle protocol-relative URLs like //site.com/image.jpg - it hangs the client and freezes */
|
||||
if ( $node->tagName == 'img' )
|
||||
{
|
||||
if ( $node->getAttribute('src') )
|
||||
{
|
||||
if ( mb_substr( $node->getAttribute('src'), 0, 2 ) === '//' )
|
||||
{
|
||||
$baseUrl = parse_url( \IPS\Settings::i()->base_url );
|
||||
|
||||
/* Try to preserve http vs https */
|
||||
if( isset( $baseUrl['scheme'] ) )
|
||||
{
|
||||
$url = $baseUrl['scheme'] . ':' . $node->getAttribute('src');
|
||||
}
|
||||
else
|
||||
{
|
||||
$url = 'http:' . $node->getAttribute('src');
|
||||
}
|
||||
|
||||
$node->setAttribute( 'src', $url );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $node->getAttribute('class') )
|
||||
{
|
||||
foreach ( explode( ' ', $node->getAttribute('class') ) as $class )
|
||||
@@ -1074,9 +1061,12 @@ abstract class _Email
|
||||
$cell = $this->_createContainerTable( $parent, $node );
|
||||
$cell->setAttribute( 'style', "font-family: 'Helvetica Neue', helvetica, sans-serif; line-height: 1.5; font-size: 14px; margin: 0;border: 1px solid #e0e0e0;border-left: 3px solid #adadad;position: relative;font-size: 13px;background: #fdfdfd" );
|
||||
|
||||
$citation = $this->_createContainerTable( $cell );
|
||||
$citation->setAttribute( 'style', "font-family: 'Helvetica Neue', helvetica, sans-serif; line-height: 1.5; font-size: 14px; background: #f5f5f5;padding: 8px 15px;color: #000;font-weight: bold;font-size: 13px;display: block;" );
|
||||
$citation->appendChild( new \DOMText( $node->getAttribute('data-cite') ) );
|
||||
if ( $node->getAttribute('data-cite') )
|
||||
{
|
||||
$citation = $this->_createContainerTable( $cell );
|
||||
$citation->setAttribute( 'style', "font-family: 'Helvetica Neue', helvetica, sans-serif; line-height: 1.5; font-size: 14px; background: #f5f5f5;padding: 8px 15px;color: #000;font-weight: bold;font-size: 13px;display: block;" );
|
||||
$citation->appendChild( new \DOMText( $node->getAttribute('data-cite') ) );
|
||||
}
|
||||
|
||||
$containerCell = $this->_createContainerTable( $cell );
|
||||
$containerCell->setAttribute( 'style', "font-family: 'Helvetica Neue', helvetica, sans-serif; line-height: 1.5; font-size: 14px; padding-left:15px" );
|
||||
@@ -1084,7 +1074,12 @@ abstract class _Email
|
||||
while( $node->childNodes->length )
|
||||
{
|
||||
foreach ( $node->childNodes as $child )
|
||||
{
|
||||
{
|
||||
if ( $child instanceof \DOMElement and $child->getAttribute('class') == 'ipsQuote_citation' )
|
||||
{
|
||||
$child->setAttribute( 'style', "font-family: 'Helvetica Neue', helvetica, sans-serif; line-height: 1.5; font-size: 14px; background: #f3f3f3; margin: 0px -15px; padding: 5px 15px; color: #222; font-weight: bold; font-size: 13px; display: block;" );
|
||||
}
|
||||
|
||||
$containerCell->appendChild( $child );
|
||||
}
|
||||
}
|
||||
@@ -1092,6 +1087,7 @@ abstract class _Email
|
||||
$parent->removeChild( $node );
|
||||
break;
|
||||
|
||||
|
||||
/* Make code look good */
|
||||
case 'ipsCode':
|
||||
$cell = $this->_createContainerTable( $parent, $node );
|
||||
@@ -1113,6 +1109,7 @@ abstract class _Email
|
||||
|
||||
/* Remove spoilers */
|
||||
case 'ipsStyle_spoiler':
|
||||
case 'ipsSpoiler':
|
||||
$cell = $this->_createContainerTable( $parent, $node );
|
||||
$cell->setAttribute( 'style', "font-family: 'Helvetica Neue', helvetica, sans-serif; line-height: 1.5; font-size: 14px; margin: 0;padding: 10px;background: #363636;color: #d8d8d8;" );
|
||||
$cell->appendChild( new \DOMText( $this->language->addToStack('email_spoiler_line') ) );
|
||||
@@ -1148,6 +1145,18 @@ abstract class _Email
|
||||
{
|
||||
$url = $url->stripQueryString( 'do' );
|
||||
}
|
||||
|
||||
/* Convert embedDo and embedComment if present */
|
||||
if ( isset( $url->queryString['embedDo'] ) )
|
||||
{
|
||||
$url = $url->setQueryString( 'do', $url->queryString['embedDo'] )->stripQueryString( 'embedDo' );
|
||||
}
|
||||
|
||||
if ( isset( $url->queryString['embedComment'] ) )
|
||||
{
|
||||
$url = $url->setQueryString( 'comment', $url->queryString['embedComment'] )->stripQueryString( 'embedComment' );
|
||||
}
|
||||
|
||||
|
||||
$a = new \DOMElement( 'a' );
|
||||
$parent->insertBefore( $a, $node );
|
||||
|
||||
Reference in new issue
Block a user