From 168d991a8c49b786f6c241c334c5a30e86f09298 Mon Sep 17 00:00:00 2001 From: Andreas Dziemba Date: Mon, 15 Jan 2018 16:38:48 +0100 Subject: [PATCH 1/7] Totally rework for Contao 4 Signed-off-by: Andreas Dziemba --- .../x-editors/LICENSE.txt => LICENSE.txt | 0 README.md | 24 +++++++++++++++ composer.json | 20 ++++++------- .../Contao/InsertTags.php | 10 +++---- src/ContaoManager/Plugin.php | 26 +++++++++++++++++ .../ExtendedEditorsExtension.php | 29 +++++++++++++++++++ src/ExtendedEditorsBundle.php | 12 ++++++++ src/Resources/contao/config/config.php | 18 ++++++++++++ .../Resources/contao}/dca/tl_form_field.php | 0 .../contao}/languages/de/modules.php | 0 .../contao}/languages/en/modules.php | 0 system/modules/x-editors/config/.htaccess | 2 -- system/modules/x-editors/config/autoload.php | 18 ------------ system/modules/x-editors/config/config.php | 16 ---------- system/modules/x-editors/dca/.htaccess | 2 -- .../modules/x-editors/languages/de/.htaccess | 2 -- .../modules/x-editors/languages/en/.htaccess | 2 -- 17 files changed, 124 insertions(+), 57 deletions(-) rename system/modules/x-editors/LICENSE.txt => LICENSE.txt (100%) create mode 100644 README.md rename system/modules/x-editors/mawExtendedInsertTags.php => src/Contao/InsertTags.php (92%) create mode 100644 src/ContaoManager/Plugin.php create mode 100644 src/DependencyInjection/ExtendedEditorsExtension.php create mode 100644 src/ExtendedEditorsBundle.php create mode 100644 src/Resources/contao/config/config.php rename {system/modules/x-editors => src/Resources/contao}/dca/tl_form_field.php (100%) rename {system/modules/x-editors => src/Resources/contao}/languages/de/modules.php (100%) rename {system/modules/x-editors => src/Resources/contao}/languages/en/modules.php (100%) delete mode 100644 system/modules/x-editors/config/.htaccess delete mode 100644 system/modules/x-editors/config/autoload.php delete mode 100644 system/modules/x-editors/config/config.php delete mode 100644 system/modules/x-editors/dca/.htaccess delete mode 100644 system/modules/x-editors/languages/de/.htaccess delete mode 100644 system/modules/x-editors/languages/en/.htaccess diff --git a/system/modules/x-editors/LICENSE.txt b/LICENSE.txt similarity index 100% rename from system/modules/x-editors/LICENSE.txt rename to LICENSE.txt diff --git a/README.md b/README.md new file mode 100644 index 0000000..06f4401 --- /dev/null +++ b/README.md @@ -0,0 +1,24 @@ +ExtendedEditors +=============== + +About +----- + +extendedEditors provides additional Insert Tags for external URLs and current language + +Following additional Tags are available: + +- HTTP +- cache_http +- https +- cache_https +- anchor +- anchor_open +- anchor_close +- comments +- download + +Troubleshooting +--------------- + +If you are having problems using syncCto, please visit the issue tracker at https://github.com/menatwork-ia/extendedEditors/issues \ No newline at end of file diff --git a/composer.json b/composer.json index c06a551..5e4cbc8 100644 --- a/composer.json +++ b/composer.json @@ -13,27 +13,27 @@ }, { "name":"Stefan Heimes", - "email":"maack@men-at-work.de", + "email":"heimes@men-at-work.de", "homepage":"http://www.men-at-work.de", "role":"Developer" } ], "require":{ - "php":">=5.3", - "contao/core":">=2.11,<4", - "contao-community-alliance/composer-installer":"*" + "php":"^7.0", + "contao/core":"^4.4.2" }, + "autoload":{ - "classmap":["system/"] + "psr-4": { + "MenAtWork\\ExtendedEditorsBundle\\": "src/" + } }, + "replace":{ "contao-legacy/extendededitors":"*" }, + "extra":{ - "contao":{ - "sources":{ - "system/modules/x-editors":"system/modules/x-editors" - } - } + "contao-manager-plugin": "MenAtWork\\ExtendedEditorsBundle\\ContaoManager\\Plugin" } } \ No newline at end of file diff --git a/system/modules/x-editors/mawExtendedInsertTags.php b/src/Contao/InsertTags.php similarity index 92% rename from system/modules/x-editors/mawExtendedInsertTags.php rename to src/Contao/InsertTags.php index 8daff3c..71652f7 100644 --- a/system/modules/x-editors/mawExtendedInsertTags.php +++ b/src/Contao/InsertTags.php @@ -8,16 +8,16 @@ * @license GNU/LGPL * @filesource */ - +namespace MenAtWork\ExtendedEditorsBundle\Contao; /** * Class mawExtendedInsertTags * - * @copyright MEN AT WORK 2014 + * @copyright MEN AT WORK 2018 * @package Frontend */ -class mawExtendedInsertTags +class InsertTags { - public function mawReplaceInsertTags($strTag) + public function ReplaceInsertTags($strTag) { $arrSplit = explode('::', $strTag); @@ -79,7 +79,7 @@ protected function countComments($strParentTable, $intParentId) return $objResult->mycount; } - public function mawReplaceLanguageTags($strTag) + public function ReplaceLanguageTags($strTag) { if ($strTag == 'actlang') { return $GLOBALS['TL_LANGUAGE']; diff --git a/src/ContaoManager/Plugin.php b/src/ContaoManager/Plugin.php new file mode 100644 index 0000000..4b1735c --- /dev/null +++ b/src/ContaoManager/Plugin.php @@ -0,0 +1,26 @@ +setLoadAfter([ContaoCoreBundle::class]), + ]; + } +} \ No newline at end of file diff --git a/src/DependencyInjection/ExtendedEditorsExtension.php b/src/DependencyInjection/ExtendedEditorsExtension.php new file mode 100644 index 0000000..485bd59 --- /dev/null +++ b/src/DependencyInjection/ExtendedEditorsExtension.php @@ -0,0 +1,29 @@ + 'system/modules/x-editors/mawExtendedInsertTags.php' -)); diff --git a/system/modules/x-editors/config/config.php b/system/modules/x-editors/config/config.php deleted file mode 100644 index 95e3596..0000000 --- a/system/modules/x-editors/config/config.php +++ /dev/null @@ -1,16 +0,0 @@ - Date: Mon, 15 Jan 2018 16:49:53 +0100 Subject: [PATCH 2/7] update composer requierments Signed-off-by: Andreas Dziemba --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 5e4cbc8..9daf14e 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ ], "require":{ "php":"^7.0", - "contao/core":"^4.4.2" + "contao/core-bundle":"^4.4.0" }, "autoload":{ From c5618764e8f7a9ba9dccdf77bf6191c47daa635d Mon Sep 17 00:00:00 2001 From: Andreas Dziemba Date: Mon, 15 Jan 2018 17:03:30 +0100 Subject: [PATCH 3/7] update classpath of ExtendedEditorsBundle class Signed-off-by: Andreas Dziemba --- src/ContaoManager/Plugin.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ContaoManager/Plugin.php b/src/ContaoManager/Plugin.php index 4b1735c..fff4802 100644 --- a/src/ContaoManager/Plugin.php +++ b/src/ContaoManager/Plugin.php @@ -7,6 +7,7 @@ namespace MenAtWork\ExtendedEditorsBundle\ContaoManager; +use MenAtWork\ExtendedEditorsBundle\ExtendedEditorsBundle; use Contao\ManagerPlugin\Bundle\BundlePluginInterface; use Contao\ManagerPlugin\Bundle\Config\BundleConfig; use Contao\ManagerPlugin\Bundle\Parser\ParserInterface; From a21ec374c31d642c13059c72b4ed80dc779dd82c Mon Sep 17 00:00:00 2001 From: Andreas Dziemba Date: Mon, 15 Jan 2018 17:23:32 +0100 Subject: [PATCH 4/7] Totally rework for Contao 4 Signed-off-by: Andreas Dziemba --- src/Contao/table/FormField.php | 61 ++++++++++++++++++++++ src/ExtendedEditorsBundle.php | 2 + src/Resources/contao/config/config.php | 6 +-- src/Resources/contao/dca/tl_form_field.php | 53 +------------------ 4 files changed, 66 insertions(+), 56 deletions(-) create mode 100644 src/Contao/table/FormField.php diff --git a/src/Contao/table/FormField.php b/src/Contao/table/FormField.php new file mode 100644 index 0000000..6c002fa --- /dev/null +++ b/src/Contao/table/FormField.php @@ -0,0 +1,61 @@ + + * @package Controller + */ +class FormField +{ + + /** + * Add the type of input field + * @param array + * @return string + */ + public function listFormFields($arrRow) + { + $key = $arrRow['invisible'] ? 'unpublished' : 'published'; + + $strType = ' +
' . $GLOBALS['TL_LANG']['FFL'][$arrRow['type']][0] . ($arrRow['mandatory'] ? ' * ' : ''). ($arrRow['name'] ? ' (' . $arrRow['name'] . ')' : '') . ($arrRow['class'] ? ' [' . $arrRow['class'] . ']' : '') . '
+
'; + + $strClass = $GLOBALS['TL_FFL'][$arrRow['type']]; + + if (!class_exists($strClass)) + { + return ''; + } + + $objWidget = new $strClass($arrRow); + + $strWidget = $objWidget->parse(); + $strWidget = preg_replace('/ name="[^"]+"/i', '', $strWidget); + $strWidget = str_replace('type="submit"', 'type="button"', $strWidget); + + if ($objWidget instanceof FormHidden) + { + return $strType . "\n" . $objWidget->value . "\n
\n"; + } + + return $strType . ' + +'.$strWidget.'
+' . "\n"; + } + +} \ No newline at end of file diff --git a/src/ExtendedEditorsBundle.php b/src/ExtendedEditorsBundle.php index 0e43f93..2bb4867 100644 --- a/src/ExtendedEditorsBundle.php +++ b/src/ExtendedEditorsBundle.php @@ -7,6 +7,8 @@ namespace MenAtWork\ExtendedEditorsBundle; +use Symfony\Component\HttpKernel\Bundle\Bundle; + class ExtendedEditorsBundle extends Bundle { } \ No newline at end of file diff --git a/src/Resources/contao/config/config.php b/src/Resources/contao/config/config.php index 62794bd..84c9afa 100644 --- a/src/Resources/contao/config/config.php +++ b/src/Resources/contao/config/config.php @@ -9,10 +9,8 @@ * @filesource */ -namespace MenAtWork\ExtendedEditorsBundle\Resources\contao\config; - /** * Hooks */ -$GLOBALS['TL_HOOKS']['replaceInsertTags'][] = array('InsertTags', 'ReplaceInsertTags'); -$GLOBALS['TL_HOOKS']['replaceInsertTags'][] = array('InsertTags', 'ReplaceLanguageTags'); \ No newline at end of file +$GLOBALS['TL_HOOKS']['replaceInsertTags'][] = array('MenAtWork\ExtendedEditorsBundle\Contao\InsertTags', 'ReplaceInsertTags'); +$GLOBALS['TL_HOOKS']['replaceInsertTags'][] = array('MenAtWork\ExtendedEditorsBundle\Contao\InsertTags', 'ReplaceLanguageTags'); \ No newline at end of file diff --git a/src/Resources/contao/dca/tl_form_field.php b/src/Resources/contao/dca/tl_form_field.php index ce4549e..3e26d02 100644 --- a/src/Resources/contao/dca/tl_form_field.php +++ b/src/Resources/contao/dca/tl_form_field.php @@ -12,55 +12,4 @@ /** * Table maw_tl_form_field */ -$GLOBALS['TL_DCA']['tl_form_field']['list']['sorting']['child_record_callback'] = array('maw_tl_form_field', 'listFormFields'); - - -/** - * Class maw_tl_form_field - * - * Provide miscellaneous methods that are used by the data configuration array. - * @copyright MEN AT WORK 2011 - * @author MEN AT WORK - * @package Controller - */ -class maw_tl_form_field extends tl_form_field -{ - - /** - * Add the type of input field - * @param array - * @return string - */ - public function listFormFields($arrRow) - { - $key = $arrRow['invisible'] ? 'unpublished' : 'published'; - - $strType = ' -
' . $GLOBALS['TL_LANG']['FFL'][$arrRow['type']][0] . ($arrRow['mandatory'] ? ' * ' : ''). ($arrRow['name'] ? ' (' . $arrRow['name'] . ')' : '') . ($arrRow['class'] ? ' [' . $arrRow['class'] . ']' : '') . '
-
'; - - $strClass = $GLOBALS['TL_FFL'][$arrRow['type']]; - - if (!$this->classFileExists($strClass)) - { - return ''; - } - - $objWidget = new $strClass($arrRow); - - $strWidget = $objWidget->parse(); - $strWidget = preg_replace('/ name="[^"]+"/i', '', $strWidget); - $strWidget = str_replace('type="submit"', 'type="button"', $strWidget); - - if ($objWidget instanceof FormHidden) - { - return $strType . "\n" . $objWidget->value . "\n
\n"; - } - - return $strType . ' - -'.$strWidget.'
-' . "\n"; - } - -} \ No newline at end of file +$GLOBALS['TL_DCA']['tl_form_field']['list']['sorting']['child_record_callback'] = array('MenAtWork\ExtendedEditorsBundle\Contao\Table\FormField', 'listFormFields'); From 22dd00e4cd60f72359ebc77a553d8f812f30a4ce Mon Sep 17 00:00:00 2001 From: Andreas Dziemba Date: Mon, 15 Jan 2018 17:28:28 +0100 Subject: [PATCH 5/7] Update Classpath Signed-off-by: Andreas Dziemba --- src/ContaoManager/Plugin.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ContaoManager/Plugin.php b/src/ContaoManager/Plugin.php index fff4802..585be80 100644 --- a/src/ContaoManager/Plugin.php +++ b/src/ContaoManager/Plugin.php @@ -8,6 +8,7 @@ namespace MenAtWork\ExtendedEditorsBundle\ContaoManager; use MenAtWork\ExtendedEditorsBundle\ExtendedEditorsBundle; +use Contao\CoreBundle\ContaoCoreBundle; use Contao\ManagerPlugin\Bundle\BundlePluginInterface; use Contao\ManagerPlugin\Bundle\Config\BundleConfig; use Contao\ManagerPlugin\Bundle\Parser\ParserInterface; From 9edf1b9a713e2f455a2eb64dbdc94e20824aa702 Mon Sep 17 00:00:00 2001 From: Andreas Dziemba Date: Tue, 16 Jan 2018 10:21:07 +0100 Subject: [PATCH 6/7] changed type to contao-bundle add author Signed-off-by: Andreas Dziemba --- composer.json | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 9daf14e..3d33e14 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name":"menatwork/extendededitors", "description":"New inserttags for external URLs and current language", "keywords":["editors", "inserttag", "language"], - "type":"contao-module", + "type":"contao-bundle", "license":"LGPL-3.0+", "authors":[ { @@ -16,6 +16,12 @@ "email":"heimes@men-at-work.de", "homepage":"http://www.men-at-work.de", "role":"Developer" + }, + { + "name":"Andreas Dziemba", + "email":"dziemba@men-at-work.de", + "homepage":"http://www.men-at-work.de", + "role":"Developer" } ], "require":{ From 71fe43df82fb6ab7f109fb654f14c9210397e63f Mon Sep 17 00:00:00 2001 From: Andreas Dziemba Date: Tue, 16 Jan 2018 12:10:28 +0100 Subject: [PATCH 7/7] adding service.yml to register service Signed-off-by: Andreas Dziemba --- composer.json | 2 +- src/DependencyInjection/ExtendedEditorsExtension.php | 7 ++++++- src/Resources/config/services.yml | 3 +++ src/Resources/contao/config/config.php | 4 ++-- 4 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 src/Resources/config/services.yml diff --git a/composer.json b/composer.json index 3d33e14..cd63bf6 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,7 @@ "autoload":{ "psr-4": { - "MenAtWork\\ExtendedEditorsBundle\\": "src/" + "MenAtWork\\ExtendedEditorsBundle\\": "src" } }, diff --git a/src/DependencyInjection/ExtendedEditorsExtension.php b/src/DependencyInjection/ExtendedEditorsExtension.php index 485bd59..9d451f2 100644 --- a/src/DependencyInjection/ExtendedEditorsExtension.php +++ b/src/DependencyInjection/ExtendedEditorsExtension.php @@ -9,7 +9,7 @@ use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Extension\Extension; +use Symfony\Component\HttpKernel\DependencyInjection\Extension; use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; /** @@ -24,6 +24,11 @@ class ExtendedEditorsExtension extends Extension */ public function load(array $mergedConfig, ContainerBuilder $container) { + $loader = new YamlFileLoader( + $container, + new FileLocator(__DIR__.'/../Resources/config') + ); + $loader->load('services.yml'); } } \ No newline at end of file diff --git a/src/Resources/config/services.yml b/src/Resources/config/services.yml new file mode 100644 index 0000000..0b8dccf --- /dev/null +++ b/src/Resources/config/services.yml @@ -0,0 +1,3 @@ +services: + maw.extendededitorsbundle.listener.replaceInsertTags: + class: MenAtWork\ExtendedEditorsBundle\Contao\InsertTags \ No newline at end of file diff --git a/src/Resources/contao/config/config.php b/src/Resources/contao/config/config.php index 84c9afa..e92858a 100644 --- a/src/Resources/contao/config/config.php +++ b/src/Resources/contao/config/config.php @@ -12,5 +12,5 @@ /** * Hooks */ -$GLOBALS['TL_HOOKS']['replaceInsertTags'][] = array('MenAtWork\ExtendedEditorsBundle\Contao\InsertTags', 'ReplaceInsertTags'); -$GLOBALS['TL_HOOKS']['replaceInsertTags'][] = array('MenAtWork\ExtendedEditorsBundle\Contao\InsertTags', 'ReplaceLanguageTags'); \ No newline at end of file +$GLOBALS['TL_HOOKS']['replaceInsertTags'][] = array('maw.extendededitorsbundle.listener.replaceInsertTags', 'ReplaceInsertTags'); +$GLOBALS['TL_HOOKS']['replaceInsertTags'][] = array('maw.extendededitorsbundle.listener.replaceInsertTags', 'ReplaceLanguageTags'); \ No newline at end of file