diff --git a/Classes/Controller/CustomizerController.php b/Classes/Controller/CustomizerController.php new file mode 100644 index 0000000..5af1d1a --- /dev/null +++ b/Classes/Controller/CustomizerController.php @@ -0,0 +1,37 @@ +tsParser->applyToPid($pid, $data, $check); + $this->redirect('customizeTheme'); + + $this->themeRepository->findByUid(array())->getAllPreviewImages(); + } + + /** + * Initialize form + */ + public function customizeThemeAction() { + parent::indexAction(); + } + +} diff --git a/Classes/ViewHelpers/Be/TextToIdForElementViewHelper.php b/Classes/ViewHelpers/Be/TextToIdForElementViewHelper.php new file mode 100644 index 0000000..926c117 --- /dev/null +++ b/Classes/ViewHelpers/Be/TextToIdForElementViewHelper.php @@ -0,0 +1,39 @@ + + * All rights reserved + * This script is part of the TYPO3 project. The TYPO3 project is + * free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * The GNU General Public License can be found at + * http://www.gnu.org/copyleft/gpl.html. + * This script is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * This copyright notice MUST APPEAR in all copies of the script! + ***************************************************************/ +class TextToIdForElementViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper { + + /** + * Iterates through elements of $each and renders child nodes + * + * @param string $text + * + * @return string + */ + public function render($text) { + $text = explode('.', strtolower(str_replace('_', '', $text))); + $text = $text[count($text)-1]; + return $text; + } +} diff --git a/Resources/Private/Language/locallang.xlf b/Resources/Private/Language/locallang.xlf index 56dafc7..1b6e88b 100755 --- a/Resources/Private/Language/locallang.xlf +++ b/Resources/Private/Language/locallang.xlf @@ -24,6 +24,19 @@ Missing font file included from the css + + + Customize Theme + + + Link to Customizer Site + + + http://t3kit.github.io/theme_t3kit_customizer + + + Error: Could not load Customizer for this page. + diff --git a/Resources/Private/Layouts/Backend.html b/Resources/Private/Layouts/Backend.html new file mode 100644 index 0000000..8d44e13 --- /dev/null +++ b/Resources/Private/Layouts/Backend.html @@ -0,0 +1,27 @@ + +
+
+
+
+
+
+ +
+
+
+ +
+
+
+ +
+
+ +
+
+
diff --git a/Resources/Private/Templates/Customizer/CustomizeTheme.html b/Resources/Private/Templates/Customizer/CustomizeTheme.html new file mode 100644 index 0000000..ca18e6e --- /dev/null +++ b/Resources/Private/Templates/Customizer/CustomizeTheme.html @@ -0,0 +1,53 @@ +{namespace themes=KayStrobach\Themes\ViewHelpers} +{namespace tools=T3kit\T3kitExtensionTools\ViewHelpers\Be} + + + + + + + + + + + + + + + + + + + +

+ + +

+ + + + + +
+
+
+ + + +
+
+ + + +
+
diff --git a/Resources/Public/JavaScript/CustomizerBackendModule.js b/Resources/Public/JavaScript/CustomizerBackendModule.js new file mode 100644 index 0000000..ff20c66 --- /dev/null +++ b/Resources/Public/JavaScript/CustomizerBackendModule.js @@ -0,0 +1,85 @@ +/** + * + */ +define(['jquery'], function (jQuery) { + + var Customizer = {}; + + Customizer.initialize = function() { + Customizer.bindCustomizeThemeEvent(); + // Get Constant Configuration To Save + Customizer.bindSaveCustomizedThemeEvent(); + }; + + Customizer.bindCustomizeThemeEvent = function () { + // get url for iframe + // get from localstorage if any + // or use sitedomain + var customizerIframeWrapper = jQuery('#customizerIframeWrapper'); + var localCustomizerUrl = window.localStorage.getItem('customizerUrl'); + var customizerUrl = jQuery('#customizerUrl'); + + if (localCustomizerUrl != null || localCustomizerUrl != '') { + customizerUrl.val(localCustomizerUrl); + } else { + customizerUrl.val(jQuery('#siteDomain').val()); + } + var customizerIframe = ''; + customizerIframeWrapper.append(customizerIframe); + var a = jQuery(customizerIframeWrapper.html()); + // a = jQuery(a); + // jQuery(a[0]).on("message", function(e) { + // console.log(e.origin); + // }); + + // save url to localstorage when URL changes + // and reload + customizerUrl.change(function () { + window.localStorage.setItem('customizerUrl', this.value); + window.location.reload(); + }); + }; + + /** + * Get Constants from Theme Customizer in iframe + * Set Those Values to the Form + */ + Customizer.bindSaveCustomizedThemeEvent = function () { + jQuery('#saveIcon').click(function() { + + // get values + // dummy data + var items = '{"@footer-link-hover-color":"#0D4C62","@border-color":"#0B79A3","@main-text-color":"#B35837"}'; + + // TODO: to solve origin problem to get content in localstorage or have customizer work on real site + // permission problem with cross-origin + // var customizerIframe = document.getElementById("customizerIframe"); + // customizerIframe = (customizerIframe.contentWindow || customizerIframe.contentDocument); + // items = customizerIframe.localStorage.getItem('lessObj'); + + if(items == null || items == '') { + alert('No values to save'); + } else { + // set changed values to form + items = items.replace(/\@|\"|\{|\}/g,''); + items = items.split(','); + for(var i=0; i 'customizeTheme,saveCustomizedTheme', + ), array(// Additional configuration + 'access' => 'user,group', + 'iconIdentifier' => 'module-themes', + 'labels' => 'LLL:EXT:' . $_EXTKEY . '/Resources/Private/Language/locallang.xlf:customizer', + ) + ); +}