diff --git a/.gitignore b/.gitignore
index 9c6d3c32..bfdce806 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,4 +11,7 @@ Thumbs.db
nbproject/
# Transifex
-.tx/
\ No newline at end of file
+.tx/
+
+# Composer
+vendor/
diff --git a/bin/queue b/bin/queue
index 8daf0492..e1396f49 100755
--- a/bin/queue
+++ b/bin/queue
@@ -12,7 +12,16 @@
*/
define('TL_MODE', 'FE');
-require __DIR__ . '/../../../initialize.php';
+
+if (file_exists(__DIR__ . '/../../../initialize.php')) {
+ // Regular way
+ require_once(__DIR__ . '/../../../initialize.php');
+} else {
+ // Try composer location (see #77)
+ require_once(__DIR__ . '/../../../../../system/initialize.php');
+}
+
+
$queueManager = $GLOBALS['NOTIFICATION_CENTER']['QUEUE_MANAGER'];
$queueManager->sendFromQueue($argv[2], $argv[4]);
diff --git a/classes/tl_form.php b/classes/tl_form.php
index 1fdec747..c34ca78d 100644
--- a/classes/tl_form.php
+++ b/classes/tl_form.php
@@ -79,12 +79,12 @@ public function generateTokens(array $arrData, array $arrForm, array $arrFiles,
$arrTokens['raw_data'] = '';
foreach ($arrData as $k => $v) {
- $this->flatten($v, 'form_'.$k, $arrTokens);
+ \Haste\Util\StringUtil::flatten($v, 'form_'.$k, $arrTokens);
$arrTokens['raw_data'] .= (isset($arrLabels[$k]) ? $arrLabels[$k] : ucfirst($k)) . ': ' . (is_array($v) ? implode(', ', $v) : $v) . "\n";
}
foreach ($arrForm as $k => $v) {
- $this->flatten($v, 'formconfig_'.$k, $arrTokens);
+ \Haste\Util\StringUtil::flatten($v, 'formconfig_'.$k, $arrTokens);
}
// Administrator e-mail
@@ -104,6 +104,9 @@ public function generateTokens(array $arrData, array $arrForm, array $arrFiles,
* @param mixed $varValue
* @param string $strKey
* @param array $arrData
+ *
+ * @deprecated Deprecated since version 1.3.1, to be removed in version 2.
+ * Use Haste\Util\StringUtil::flatten() instead.
*/
public function flatten($varValue, $strKey, &$arrData)
{
diff --git a/classes/tl_nc_language.php b/classes/tl_nc_language.php
index ef744ba6..09554187 100644
--- a/classes/tl_nc_language.php
+++ b/classes/tl_nc_language.php
@@ -155,7 +155,7 @@ public function validateEmailList($varValue, \DataContainer $dc)
foreach ($chunks as $chunk) {
// Skip string with tokens or inserttags
- if (strpos($chunk, '##') !== false || strpos($chunk, '{{') !== false) {
+ if (strpos($chunk, '##') !== false || strpos($chunk, '{{') !== false|| strpos($chunk, '{if') !== false) {
continue;
}
diff --git a/composer.json b/composer.json
index cca7bca0..e8c105f0 100644
--- a/composer.json
+++ b/composer.json
@@ -14,16 +14,18 @@
"php":">=5.3.2",
"contao/core":"^3.2",
"contao-community-alliance/composer-plugin":"2.*",
- "terminal42/contao-namespace-class-loader":"^1.0.1",
- "codefog/contao-haste":"4.*",
+ "codefog/contao-haste":"^4.10.0",
"terminal42/dcawizard":"2.*"
},
"autoload":{
"psr-0": {
"NotificationCenter\\": [
- "/library"
+ "library/"
]
- }
+ },
+ "classmap": [
+ "classes/"
+ ]
},
"replace": {
"contao-legacy/notification_center": "self.version"
diff --git a/config/autoload.php b/config/autoload.php
index ad16b5c2..0a021719 100644
--- a/config/autoload.php
+++ b/config/autoload.php
@@ -11,24 +11,28 @@
/**
* Register PSR-0 namespace
*/
-NamespaceClassLoader::add('NotificationCenter', 'system/modules/notification_center/library');
+if (class_exists('NamespaceClassLoader')) {
+ NamespaceClassLoader::add('NotificationCenter', 'system/modules/notification_center/library');
+}
/**
* Register classes outside the namespace folder
*/
-NamespaceClassLoader::addClassMap(array
-(
- // DCA Helpers
- 'NotificationCenter\tl_form' => 'system/modules/notification_center/classes/tl_form.php',
- 'NotificationCenter\tl_member' => 'system/modules/notification_center/classes/tl_member.php',
- 'NotificationCenter\tl_module' => 'system/modules/notification_center/classes/tl_module.php',
- 'NotificationCenter\tl_nc_gateway' => 'system/modules/notification_center/classes/tl_nc_gateway.php',
- 'NotificationCenter\tl_nc_notification' => 'system/modules/notification_center/classes/tl_nc_notification.php',
- 'NotificationCenter\tl_nc_language' => 'system/modules/notification_center/classes/tl_nc_language.php',
- 'NotificationCenter\tl_nc_message' => 'system/modules/notification_center/classes/tl_nc_message.php',
- 'NotificationCenter\tl_nc_queue' => 'system/modules/notification_center/classes/tl_nc_queue.php'
-));
+if (class_exists('NamespaceClassLoader')) {
+ NamespaceClassLoader::addClassMap(array
+ (
+ // DCA Helpers
+ 'NotificationCenter\tl_form' => 'system/modules/notification_center/classes/tl_form.php',
+ 'NotificationCenter\tl_member' => 'system/modules/notification_center/classes/tl_member.php',
+ 'NotificationCenter\tl_module' => 'system/modules/notification_center/classes/tl_module.php',
+ 'NotificationCenter\tl_nc_gateway' => 'system/modules/notification_center/classes/tl_nc_gateway.php',
+ 'NotificationCenter\tl_nc_notification' => 'system/modules/notification_center/classes/tl_nc_notification.php',
+ 'NotificationCenter\tl_nc_language' => 'system/modules/notification_center/classes/tl_nc_language.php',
+ 'NotificationCenter\tl_nc_message' => 'system/modules/notification_center/classes/tl_nc_message.php',
+ 'NotificationCenter\tl_nc_queue' => 'system/modules/notification_center/classes/tl_nc_queue.php'
+ ));
+}
/**
diff --git a/languages/en/tl_nc_gateway.php b/languages/en/tl_nc_gateway.php
index f3cd2934..dd0aceaa 100644
--- a/languages/en/tl_nc_gateway.php
+++ b/languages/en/tl_nc_gateway.php
@@ -83,4 +83,10 @@
5 * * * * /path/to/contao/system/modules/notification_center/bin/queue -s {gateway_id} -n 30
+/path/to/contao/composer/vendor/terminal42/notification_center/bin/queue ++'; diff --git a/library/NotificationCenter/Gateway/Base.php b/library/NotificationCenter/Gateway/Base.php index 49d450cb..8064eba9 100644 --- a/library/NotificationCenter/Gateway/Base.php +++ b/library/NotificationCenter/Gateway/Base.php @@ -68,18 +68,18 @@ protected function compileRecipients($strRecipients, $arrTokens) } /** - * @deprecated Use String::recursiveReplaceTokensAndTags() + * @deprecated Use \Haste\Util\StringUtil::recursiveReplaceTokensAndTags() */ protected function recursiveReplaceTokensAndTags($strText, $arrTokens, $intTextFlags = 0) { - return String::recursiveReplaceTokensAndTags($strText, $arrTokens, $intTextFlags); + return \Haste\Util\StringUtil::recursiveReplaceTokensAndTags($strText, $arrTokens, $intTextFlags); } /** - * @deprecated Use String::convertToText() + * @deprecated Use \Haste\Util\StringUtil::convertToText() */ protected function convertToText($varValue, $options) { - return String::convertToText($varValue, $options); + return \Haste\Util\StringUtil::convertToText($varValue, $options); } } diff --git a/library/NotificationCenter/Gateway/File.php b/library/NotificationCenter/Gateway/File.php index 8df46146..1bb94b0e 100644 --- a/library/NotificationCenter/Gateway/File.php +++ b/library/NotificationCenter/Gateway/File.php @@ -44,7 +44,7 @@ public function send(Message $objMessage, array $arrTokens, $strLanguage = '') return false; } - $strFileName = String::recursiveReplaceTokensAndTags( + $strFileName = \Haste\Util\StringUtil::recursiveReplaceTokensAndTags( $objLanguage->file_name, $arrTokens, String::NO_TAGS | String::NO_BREAKS @@ -58,7 +58,7 @@ public function send(Message $objMessage, array $arrTokens, $strLanguage = '') } // Preserve all tags here as this is pretty useful in XML :-) - $strContent = String::recursiveReplaceTokensAndTags( + $strContent = \Haste\Util\StringUtil::recursiveReplaceTokensAndTags( $objLanguage->file_content, $arrTokens ); diff --git a/library/NotificationCenter/MessageDraft/EmailMessageDraft.php b/library/NotificationCenter/MessageDraft/EmailMessageDraft.php index 39f6ff87..51514aa3 100644 --- a/library/NotificationCenter/MessageDraft/EmailMessageDraft.php +++ b/library/NotificationCenter/MessageDraft/EmailMessageDraft.php @@ -56,7 +56,7 @@ public function getSenderEmail() { $strSenderAddress = $this->objLanguage->email_sender_address ?: $GLOBALS['TL_ADMIN_EMAIL']; - return String::recursiveReplaceTokensAndTags($strSenderAddress, $this->arrTokens, String::NO_TAGS | String::NO_BREAKS); + return \Haste\Util\StringUtil::recursiveReplaceTokensAndTags($strSenderAddress, $this->arrTokens, String::NO_TAGS | String::NO_BREAKS); } /** @@ -67,7 +67,7 @@ public function getSenderName() { $strSenderName = $this->objLanguage->email_sender_name ?: $GLOBALS['TL_ADMIN_NAME']; - return String::recursiveReplaceTokensAndTags($strSenderName, $this->arrTokens, String::NO_TAGS | String::NO_BREAKS); + return \Haste\Util\StringUtil::recursiveReplaceTokensAndTags($strSenderName, $this->arrTokens, String::NO_TAGS | String::NO_BREAKS); } /** @@ -104,7 +104,7 @@ public function getBccRecipientEmails() public function getReplyToEmail() { if ($this->objLanguage->email_replyTo) { - return String::recursiveReplaceTokensAndTags($this->objLanguage->email_replyTo, $this->arrTokens, String::NO_TAGS | String::NO_BREAKS); + return \Haste\Util\StringUtil::recursiveReplaceTokensAndTags($this->objLanguage->email_replyTo, $this->arrTokens, String::NO_TAGS | String::NO_BREAKS); } return ''; @@ -116,7 +116,7 @@ public function getReplyToEmail() */ public function getSubject() { - return String::recursiveReplaceTokensAndTags($this->objLanguage->email_subject, $this->arrTokens, String::NO_TAGS | String::NO_BREAKS); + return \Haste\Util\StringUtil::recursiveReplaceTokensAndTags($this->objLanguage->email_subject, $this->arrTokens, String::NO_TAGS | String::NO_BREAKS); } /** @@ -140,7 +140,7 @@ public function getPriority() public function getTextBody() { $strText = $this->objLanguage->email_text; - $strText = String::recursiveReplaceTokensAndTags($strText, $this->arrTokens, String::NO_TAGS); + $strText = \Haste\Util\StringUtil::recursiveReplaceTokensAndTags($strText, $this->arrTokens, String::NO_TAGS); return \Controller::convertRelativeUrls($strText, '', true); } @@ -159,7 +159,7 @@ public function getHtmlBody() // Prevent parseSimpleTokens from stripping important HTML tags $GLOBALS['TL_CONFIG']['allowedTags'] .= '
- if ($options & static::NO_TAGS) { - $varValue = strip_tags(preg_replace('{(?!^)<(br|p|/p).*?/?>\n?(?!$)}is', "\n", $varValue)); - } - - // Remove line breaks (e.g. for subject) - if ($options & static::NO_BREAKS) { - $varValue = str_replace(array("\r", "\n"), '', $varValue); - } - - // Restore friendly email after stripping tags - if (!($options & static::NO_EMAILS) && !empty($arrEmails[0])) { - foreach ($arrEmails[0] as $k => $v) { - $varValue = str_replace('%email' . $k . '%', $v, $varValue); - } - } - - return $varValue; + return \Haste\Util\StringUtil::convertToText($varValue, $options); } /** * Gets an array of valid attachments of a token field - * @param string - * @param array Tokens - * @return array + * + * @param string $strAttachmentTokens + * @param array $arrTokens + * + * @return array */ public static function getTokenAttachments($strAttachmentTokens, array $arrTokens) { @@ -145,18 +85,20 @@ public static function getTokenAttachments($strAttachmentTokens, array $arrToken /** * Generate CC or BCC recipients from comma separated string - * @param string + * + * @param string $strRecipients + * @param array $arrTokens + * + * @return array */ public static function compileRecipients($strRecipients, $arrTokens) { // Replaces tokens first so that tokens can contain a list of recipients. - $strRecipients = static::recursiveReplaceTokensAndTags($strRecipients, $arrTokens, static::NO_TAGS | static::NO_BREAKS); + $strRecipients = \Haste\Util\StringUtil::recursiveReplaceTokensAndTags($strRecipients, $arrTokens, static::NO_TAGS | static::NO_BREAKS); $arrRecipients = array(); foreach ((array) trimsplit(',', $strRecipients) as $strAddress) { if ($strAddress != '') { - $strAddress = static::recursiveReplaceTokensAndTags($strAddress, $arrTokens, static::NO_TAGS | static::NO_BREAKS); - list($strName, $strEmail) = \String::splitFriendlyEmail($strAddress); // Address could become empty through invalid insert tag