@@ -8,19 +8,19 @@ |
||
8 | 8 | |
9 | 9 | |
10 | 10 | $EM_CONF[$_EXTKEY] = array( |
11 | - 'title' => 'Ink', |
|
12 | - 'description' => 'Build stable and flexible newsletter templates. Incl. also the plain text rendering for plain text e-Mails. Please contribute at https://github.com/lochmueller/ink', |
|
13 | - 'category' => 'fe', |
|
14 | - 'version' => '0.1.1', |
|
15 | - 'state' => 'beta', |
|
16 | - 'clearcacheonload' => 1, |
|
17 | - 'author' => 'Tim Lochmüller', |
|
18 | - 'author_email' => '[email protected]', |
|
19 | - 'constraints' => array( |
|
20 | - 'depends' => array( |
|
21 | - 'typo3' => '6.2.0-7.99.99', |
|
22 | - 'css_styled_content' => '6.2.0-7.99.99', |
|
23 | - 'autoloader' => '1.6.0-0.0.0', |
|
24 | - ), |
|
25 | - ), |
|
11 | + 'title' => 'Ink', |
|
12 | + 'description' => 'Build stable and flexible newsletter templates. Incl. also the plain text rendering for plain text e-Mails. Please contribute at https://github.com/lochmueller/ink', |
|
13 | + 'category' => 'fe', |
|
14 | + 'version' => '0.1.1', |
|
15 | + 'state' => 'beta', |
|
16 | + 'clearcacheonload' => 1, |
|
17 | + 'author' => 'Tim Lochmüller', |
|
18 | + 'author_email' => '[email protected]', |
|
19 | + 'constraints' => array( |
|
20 | + 'depends' => array( |
|
21 | + 'typo3' => '6.2.0-7.99.99', |
|
22 | + 'css_styled_content' => '6.2.0-7.99.99', |
|
23 | + 'autoloader' => '1.6.0-0.0.0', |
|
24 | + ), |
|
25 | + ), |
|
26 | 26 | ); |
@@ -12,31 +12,31 @@ |
||
12 | 12 | */ |
13 | 13 | class Configuration { |
14 | 14 | |
15 | - /** |
|
16 | - * get the plaintext width |
|
17 | - * |
|
18 | - * @return int |
|
19 | - */ |
|
20 | - static public function getPlainTextWith() { |
|
21 | - return isset($GLOBALS['TSFE']->config['config']['plainTextWith']) ? (int)$GLOBALS['TSFE']->config['config']['plainTextWith'] : 76; |
|
22 | - } |
|
15 | + /** |
|
16 | + * get the plaintext width |
|
17 | + * |
|
18 | + * @return int |
|
19 | + */ |
|
20 | + static public function getPlainTextWith() { |
|
21 | + return isset($GLOBALS['TSFE']->config['config']['plainTextWith']) ? (int)$GLOBALS['TSFE']->config['config']['plainTextWith'] : 76; |
|
22 | + } |
|
23 | 23 | |
24 | - /** |
|
25 | - * get the table mode |
|
26 | - * |
|
27 | - * @return string |
|
28 | - */ |
|
29 | - static public function getTableMode() { |
|
30 | - return isset($GLOBALS['TSFE']->config['config']['tableMode']) && trim($GLOBALS['TSFE']->config['config']['tableMode']) !== '' ? trim($GLOBALS['TSFE']->config['config']['tableMode']) : 'default'; |
|
31 | - } |
|
24 | + /** |
|
25 | + * get the table mode |
|
26 | + * |
|
27 | + * @return string |
|
28 | + */ |
|
29 | + static public function getTableMode() { |
|
30 | + return isset($GLOBALS['TSFE']->config['config']['tableMode']) && trim($GLOBALS['TSFE']->config['config']['tableMode']) !== '' ? trim($GLOBALS['TSFE']->config['config']['tableMode']) : 'default'; |
|
31 | + } |
|
32 | 32 | |
33 | - /** |
|
34 | - * check if the plain tables are 100 displayed |
|
35 | - * |
|
36 | - * @return string |
|
37 | - */ |
|
38 | - static public function isPlainTable100() { |
|
39 | - return isset($GLOBALS['TSFE']->config['config']['plainTable100']) && trim($GLOBALS['TSFE']->config['config']['plainTable100']) !== '' ? (bool)$GLOBALS['TSFE']->config['config']['plainTable100'] : TRUE; |
|
40 | - } |
|
33 | + /** |
|
34 | + * check if the plain tables are 100 displayed |
|
35 | + * |
|
36 | + * @return string |
|
37 | + */ |
|
38 | + static public function isPlainTable100() { |
|
39 | + return isset($GLOBALS['TSFE']->config['config']['plainTable100']) && trim($GLOBALS['TSFE']->config['config']['plainTable100']) !== '' ? (bool)$GLOBALS['TSFE']->config['config']['plainTable100'] : TRUE; |
|
40 | + } |
|
41 | 41 | |
42 | 42 | } |
43 | 43 | \ No newline at end of file |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * @return int |
19 | 19 | */ |
20 | 20 | static public function getPlainTextWith() { |
21 | - return isset($GLOBALS['TSFE']->config['config']['plainTextWith']) ? (int)$GLOBALS['TSFE']->config['config']['plainTextWith'] : 76; |
|
21 | + return isset($GLOBALS['TSFE']->config['config']['plainTextWith']) ? (int) $GLOBALS['TSFE']->config['config']['plainTextWith'] : 76; |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * @return string |
37 | 37 | */ |
38 | 38 | static public function isPlainTable100() { |
39 | - return isset($GLOBALS['TSFE']->config['config']['plainTable100']) && trim($GLOBALS['TSFE']->config['config']['plainTable100']) !== '' ? (bool)$GLOBALS['TSFE']->config['config']['plainTable100'] : TRUE; |
|
39 | + return isset($GLOBALS['TSFE']->config['config']['plainTable100']) && trim($GLOBALS['TSFE']->config['config']['plainTable100']) !== '' ? (bool) $GLOBALS['TSFE']->config['config']['plainTable100'] : TRUE; |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | } |
43 | 43 | \ No newline at end of file |
@@ -12,15 +12,15 @@ |
||
12 | 12 | */ |
13 | 13 | class RemoveJavaScript implements PostprocessingInterface { |
14 | 14 | |
15 | - /** |
|
16 | - * Run the replacement |
|
17 | - * |
|
18 | - * @param string $content |
|
19 | - * |
|
20 | - * @return string |
|
21 | - * @todo remove also onchange etc. |
|
22 | - */ |
|
23 | - public function process($content) { |
|
24 | - return preg_replace('#<script(.*?)>(.*?)</script>#is', '', $content); |
|
25 | - } |
|
15 | + /** |
|
16 | + * Run the replacement |
|
17 | + * |
|
18 | + * @param string $content |
|
19 | + * |
|
20 | + * @return string |
|
21 | + * @todo remove also onchange etc. |
|
22 | + */ |
|
23 | + public function process($content) { |
|
24 | + return preg_replace('#<script(.*?)>(.*?)</script>#is', '', $content); |
|
25 | + } |
|
26 | 26 | } |
@@ -12,14 +12,14 @@ |
||
12 | 12 | */ |
13 | 13 | class RemoveGenerator implements PostprocessingInterface { |
14 | 14 | |
15 | - /** |
|
16 | - * Remove the generator tag |
|
17 | - * |
|
18 | - * @param string $content |
|
19 | - * |
|
20 | - * @return string |
|
21 | - */ |
|
22 | - public function process($content) { |
|
23 | - return preg_replace('/<meta name="?generator"?.+?>/is', '', $content); |
|
24 | - } |
|
15 | + /** |
|
16 | + * Remove the generator tag |
|
17 | + * |
|
18 | + * @param string $content |
|
19 | + * |
|
20 | + * @return string |
|
21 | + */ |
|
22 | + public function process($content) { |
|
23 | + return preg_replace('/<meta name="?generator"?.+?>/is', '', $content); |
|
24 | + } |
|
25 | 25 | } |
@@ -12,14 +12,14 @@ |
||
12 | 12 | */ |
13 | 13 | class RemoveHtmlComments implements PostprocessingInterface { |
14 | 14 | |
15 | - /** |
|
16 | - * Run the replacement of the comments |
|
17 | - * |
|
18 | - * @param string $content |
|
19 | - * |
|
20 | - * @return string |
|
21 | - */ |
|
22 | - public function process($content) { |
|
23 | - return preg_replace('/<!--(.*?)-->/s', '', $content); |
|
24 | - } |
|
15 | + /** |
|
16 | + * Run the replacement of the comments |
|
17 | + * |
|
18 | + * @param string $content |
|
19 | + * |
|
20 | + * @return string |
|
21 | + */ |
|
22 | + public function process($content) { |
|
23 | + return preg_replace('/<!--(.*?)-->/s', '', $content); |
|
24 | + } |
|
25 | 25 | } |
@@ -12,14 +12,14 @@ |
||
12 | 12 | */ |
13 | 13 | class RemoveMultipleEmptyLines implements PostprocessingInterface { |
14 | 14 | |
15 | - /** |
|
16 | - * Run the cleanup of the empty lines |
|
17 | - * |
|
18 | - * @param string $content |
|
19 | - * |
|
20 | - * @return string |
|
21 | - */ |
|
22 | - public function process($content) { |
|
23 | - return preg_replace('/\n{4,}/', "\n\n\n", $content); |
|
24 | - } |
|
15 | + /** |
|
16 | + * Run the cleanup of the empty lines |
|
17 | + * |
|
18 | + * @param string $content |
|
19 | + * |
|
20 | + * @return string |
|
21 | + */ |
|
22 | + public function process($content) { |
|
23 | + return preg_replace('/\n{4,}/', "\n\n\n", $content); |
|
24 | + } |
|
25 | 25 | } |
@@ -18,49 +18,49 @@ |
||
18 | 18 | */ |
19 | 19 | class InlineCss implements PostprocessingInterface { |
20 | 20 | |
21 | - /** |
|
22 | - * Call the inliner CSS processor |
|
23 | - * |
|
24 | - * @param string $content |
|
25 | - * |
|
26 | - * @return string |
|
27 | - */ |
|
28 | - public function process($content) { |
|
29 | - GeneralUtility::requireOnce(ExtensionManagementUtility::extPath('ink', 'Resources/Private/Php/vendor/autoload.php')); |
|
30 | - $pattern = '%<(link|style)(?=[^<>]*?(?:type="(text/css)"|>))(?=[^<>]*?(?:media="([^<>"]*)"|>))(?=[^<>]*?(?:href="(.*?)"|>))(?=[^<>]*(?:rel="([^<>"]*)"|>))(?:.*?</\1>|[^<>]*>)%si'; |
|
31 | - $matches = array(); |
|
32 | - $css = ''; |
|
33 | - preg_match_all($pattern, $content, $matches); |
|
34 | - if (isset($matches[0])) { |
|
35 | - foreach ($matches[0] as $key => $match) { |
|
36 | - if ($matches[1][$key] === 'style') { |
|
37 | - $css .= strip_tags($match); |
|
38 | - } elseif (strpos($match, 'type="text/css"') !== FALSE) { |
|
21 | + /** |
|
22 | + * Call the inliner CSS processor |
|
23 | + * |
|
24 | + * @param string $content |
|
25 | + * |
|
26 | + * @return string |
|
27 | + */ |
|
28 | + public function process($content) { |
|
29 | + GeneralUtility::requireOnce(ExtensionManagementUtility::extPath('ink', 'Resources/Private/Php/vendor/autoload.php')); |
|
30 | + $pattern = '%<(link|style)(?=[^<>]*?(?:type="(text/css)"|>))(?=[^<>]*?(?:media="([^<>"]*)"|>))(?=[^<>]*?(?:href="(.*?)"|>))(?=[^<>]*(?:rel="([^<>"]*)"|>))(?:.*?</\1>|[^<>]*>)%si'; |
|
31 | + $matches = array(); |
|
32 | + $css = ''; |
|
33 | + preg_match_all($pattern, $content, $matches); |
|
34 | + if (isset($matches[0])) { |
|
35 | + foreach ($matches[0] as $key => $match) { |
|
36 | + if ($matches[1][$key] === 'style') { |
|
37 | + $css .= strip_tags($match); |
|
38 | + } elseif (strpos($match, 'type="text/css"') !== FALSE) { |
|
39 | 39 | |
40 | - $file = preg_replace('/^(.+)\.(\d+)\.css$/', '$1.css', $matches[4][$key]); |
|
41 | - $parts = parse_url($file); |
|
42 | - if (isset($parts['query'])) { |
|
43 | - unset($parts['query']); |
|
44 | - } |
|
45 | - if (!isset($parts['host'])) { |
|
46 | - $parts['path'] = ltrim($parts['path'], '/'); |
|
47 | - } |
|
40 | + $file = preg_replace('/^(.+)\.(\d+)\.css$/', '$1.css', $matches[4][$key]); |
|
41 | + $parts = parse_url($file); |
|
42 | + if (isset($parts['query'])) { |
|
43 | + unset($parts['query']); |
|
44 | + } |
|
45 | + if (!isset($parts['host'])) { |
|
46 | + $parts['path'] = ltrim($parts['path'], '/'); |
|
47 | + } |
|
48 | 48 | |
49 | - if($parts['host'] === GeneralUtility::getIndpEnv('TYPO3_HOST_ONLY')) { |
|
50 | - unset($parts['scheme']); |
|
51 | - unset($parts['host']); |
|
52 | - $parts['path'] = ltrim($parts['path'], '/'); |
|
53 | - } |
|
49 | + if($parts['host'] === GeneralUtility::getIndpEnv('TYPO3_HOST_ONLY')) { |
|
50 | + unset($parts['scheme']); |
|
51 | + unset($parts['host']); |
|
52 | + $parts['path'] = ltrim($parts['path'], '/'); |
|
53 | + } |
|
54 | 54 | |
55 | - $file = HttpUtility::buildUrl($parts); |
|
56 | - $css .= GeneralUtility::getUrl($file); |
|
57 | - } else { |
|
58 | - continue; |
|
59 | - } |
|
60 | - $content = str_replace($match, '', $content); |
|
61 | - } |
|
62 | - } |
|
63 | - $format = new CssToInlineStyles($content, $css); |
|
64 | - return $format->convert(); |
|
65 | - } |
|
55 | + $file = HttpUtility::buildUrl($parts); |
|
56 | + $css .= GeneralUtility::getUrl($file); |
|
57 | + } else { |
|
58 | + continue; |
|
59 | + } |
|
60 | + $content = str_replace($match, '', $content); |
|
61 | + } |
|
62 | + } |
|
63 | + $format = new CssToInlineStyles($content, $css); |
|
64 | + return $format->convert(); |
|
65 | + } |
|
66 | 66 | } |
@@ -46,7 +46,7 @@ |
||
46 | 46 | $parts['path'] = ltrim($parts['path'], '/'); |
47 | 47 | } |
48 | 48 | |
49 | - if($parts['host'] === GeneralUtility::getIndpEnv('TYPO3_HOST_ONLY')) { |
|
49 | + if ($parts['host'] === GeneralUtility::getIndpEnv('TYPO3_HOST_ONLY')) { |
|
50 | 50 | unset($parts['scheme']); |
51 | 51 | unset($parts['host']); |
52 | 52 | $parts['path'] = ltrim($parts['path'], '/'); |
@@ -11,13 +11,13 @@ |
||
11 | 11 | */ |
12 | 12 | interface PostprocessingInterface { |
13 | 13 | |
14 | - /** |
|
15 | - * Run the process |
|
16 | - * |
|
17 | - * @param string $content |
|
18 | - * |
|
19 | - * @return string |
|
20 | - */ |
|
21 | - public function process($content); |
|
14 | + /** |
|
15 | + * Run the process |
|
16 | + * |
|
17 | + * @param string $content |
|
18 | + * |
|
19 | + * @return string |
|
20 | + */ |
|
21 | + public function process($content); |
|
22 | 22 | |
23 | 23 | } |
24 | 24 | \ No newline at end of file |
@@ -16,24 +16,24 @@ |
||
16 | 16 | */ |
17 | 17 | class TypoScriptFrontend { |
18 | 18 | |
19 | - /** |
|
20 | - * Call the end of rendering hook |
|
21 | - * |
|
22 | - * @hook TYPO3_CONF_VARS|SC_OPTIONS|tslib/class.tslib_fe.php|hook_eofe |
|
23 | - * |
|
24 | - * @param array $params |
|
25 | - * @param TypoScriptFrontendController $obj |
|
26 | - */ |
|
27 | - public function endOfRendering(array $params, TypoScriptFrontendController $obj) { |
|
28 | - if (!isset($obj->config['config']['newsletterPostprocessing.']) || !is_array($obj->config['config']['newsletterPostprocessing.'])) { |
|
29 | - return; |
|
30 | - } |
|
19 | + /** |
|
20 | + * Call the end of rendering hook |
|
21 | + * |
|
22 | + * @hook TYPO3_CONF_VARS|SC_OPTIONS|tslib/class.tslib_fe.php|hook_eofe |
|
23 | + * |
|
24 | + * @param array $params |
|
25 | + * @param TypoScriptFrontendController $obj |
|
26 | + */ |
|
27 | + public function endOfRendering(array $params, TypoScriptFrontendController $obj) { |
|
28 | + if (!isset($obj->config['config']['newsletterPostprocessing.']) || !is_array($obj->config['config']['newsletterPostprocessing.'])) { |
|
29 | + return; |
|
30 | + } |
|
31 | 31 | |
32 | - foreach ($obj->config['config']['newsletterPostprocessing.'] as $postprocessorClass) { |
|
33 | - /** @var PostprocessingInterface $processor */ |
|
34 | - $processor = GeneralUtility::makeInstance($postprocessorClass); |
|
35 | - $obj->content = $processor->process($obj->content); |
|
36 | - } |
|
37 | - } |
|
32 | + foreach ($obj->config['config']['newsletterPostprocessing.'] as $postprocessorClass) { |
|
33 | + /** @var PostprocessingInterface $processor */ |
|
34 | + $processor = GeneralUtility::makeInstance($postprocessorClass); |
|
35 | + $obj->content = $processor->process($obj->content); |
|
36 | + } |
|
37 | + } |
|
38 | 38 | |
39 | 39 | } |