From 77dcb57d80b53898ad71e1aa7c7cecd776f3fc61 Mon Sep 17 00:00:00 2001 From: ProjextSoft-STUDIONIONS Date: Thu, 25 Jun 2026 06:57:32 +0400 Subject: [PATCH 1/5] =?UTF-8?q?=D0=9E=D1=82=D0=B2=D1=8F=D0=B7=D1=8B=D0=B2?= =?UTF-8?q?=D0=B0=D0=B5=D0=BC=20=D0=BE=D1=82=20=D0=B8=D1=81=D0=BF=D0=BE?= =?UTF-8?q?=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F=20=D1=82?= =?UTF-8?q?=D0=BE=D0=BB=D1=8C=D0=BA=D0=BE=20TinyMCE4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/tvs/multitv/includes/multitv.class.php | 26 ++-- assets/tvs/multitv/js/multitv.js | 143 ++++++++++-------- 2 files changed, 94 insertions(+), 75 deletions(-) diff --git a/assets/tvs/multitv/includes/multitv.class.php b/assets/tvs/multitv/includes/multitv.class.php index fd95cec..b31ac52 100644 --- a/assets/tvs/multitv/includes/multitv.class.php +++ b/assets/tvs/multitv/includes/multitv.class.php @@ -6,6 +6,12 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU Public License (GPL) * @author Jako (thomas.jakobi@partout.info) */ +// Закрыть от прямого доступа +if (!defined('MODX_BASE_PATH')): + http_response_code(403); + die('No access'); +endif; + if (!function_exists('renderFormElement')) { include MODX_MANAGER_PATH . 'includes/tmplvars.inc.php'; } @@ -396,11 +402,12 @@ function renderMultiTVFormElement($fieldType, $fieldName, $fieldElements, $field case 'richtext' : if ($this->display == 'datatable' || $this->display == 'dbtable' || $this->options['type'] == 'module') { $this->fieldsrte[] = ($this->options['type'] == 'module') ? $fieldName : "tv" . $this->tvID . $fieldName; - // invoke OnRichTextEditorInit event for TinyMCE4 + // invoke OnRichTextEditorInit event for TinyMCE $fieldId = substr($fieldName, 0, -4); $theme = isset($this->fields[$fieldId]['theme']) ? $this->fields[$fieldId]['theme'] : ''; if ($theme) { - if (in_array($which_editor, array('TinyMCE4', 'CKEditor4'))) { + // Если есть редактор + if ($which_editor != "none") { $evtOut = $this->modx->invokeEvent('OnRichTextEditorInit', array( 'editor' => $which_editor, 'options' => array('theme' => $theme) @@ -412,11 +419,12 @@ function renderMultiTVFormElement($fieldType, $fieldName, $fieldElements, $field $fieldClass[] = 'tabEditor'; } elseif( $this->display == 'vertical' || $this->display == 'single'){ $this->fieldsrte[] = ($this->options['type'] == 'module') ? $fieldName : "tv" . $this->tvID . $fieldName; - // invoke OnRichTextEditorInit event for TinyMCE4 + // invoke OnRichTextEditorInit event for TinyMCE $fieldId = substr($fieldName, 0, -4); $theme = isset($this->fields[$fieldId]['theme']) ? $this->fields[$fieldId]['theme'] : ''; if ($theme) { - if (in_array($which_editor, array('TinyMCE4', 'CKEditor4'))) { + // Если есть редактор + if ($which_editor != "none") { $evtOut = $this->modx->invokeEvent('OnRichTextEditorInit', array( 'editor' => $which_editor, 'options' => array('theme' => $theme) @@ -741,12 +749,12 @@ function generateScript() } foreach ($files['css'] as $file) { - $cssfiles[] = ' '; + $cssfiles[] = ' '; } if ($this->cmsinfo['clipper'] != 'Clipper') { $files['scripts'] = array_merge($files['scripts'], array('js/multitvhelper' . $this->cmsinfo['seturl'] . '.js', 'js/multitv.js')); foreach ($files['scripts'] as $file) { - $scriptfiles[] = ' '; + $scriptfiles[] = ' '; } } else { $files['scripts'] = array_merge($files['scripts'], array( @@ -908,11 +916,11 @@ function generateModuleTab($config) $placeholder['editform'] = $tvelement; foreach ($files['css'] as $file) { - $cssfiles[] = ' '; + $cssfiles[] = ' '; } $files['scripts'] = array_merge($files['scripts'], array('js/multitvhelper' . $this->cmsinfo['seturl'] . '.js', 'js/multitv.js')); foreach ($files['scripts'] as $file) { - $scriptfiles[] = ' '; + $scriptfiles[] = ' '; } $placeholder['cssfiles'] = implode("\r\n", $cssfiles); @@ -1019,7 +1027,7 @@ function getMultiValue($params) break; } $tvOutput = $tvOutput[$this->tvName]; - if(empty($tvOutput)) $tvOutput = '[]'; + if(empty($tvOutput)) $tvOutput = '[]'; $tvOutput = json_decode($tvOutput, true); if (isset($tvOutput['fieldValue'])) { $tvOutput = $tvOutput['fieldValue']; diff --git a/assets/tvs/multitv/js/multitv.js b/assets/tvs/multitv/js/multitv.js index d215710..3b7f6c9 100755 --- a/assets/tvs/multitv/js/multitv.js +++ b/assets/tvs/multitv/js/multitv.js @@ -10,6 +10,49 @@ mtvpath: 'assets/tvs/multitv/' }; + const initTinyMCE = function(editorId, theme, _this) { + // Если нет инициализации дефолтного конфига, то конфигов tinymce нет. + let numTM = tinyMCE.majorVersion; + let bridge = window[`modxRTEbridge_tinymce${numTM}`]; + // Если нет инициализации дефолтного конфига, то конфигов tinymce нет. + if(bridge != undefined){ + // Темы заданной в конфигурации multiTV может не существовать. + console.log(`${theme}`); + console.log(window[`config_tinymce${numTM}_${theme}`]); + var config_theme = typeof window[`config_tinymce${numTM}_${theme}`] != 'undefined' ? window[`config_tinymce${numTM}_${theme}`] : window[bridge.default]; + var configObj = typeof theme != 'undefined' ? config_theme : window[bridge.default]; + var newConfig = {}; + for (var key in configObj) { + newConfig[key] = configObj[key]; + } + // Минимальная высота редактора + if(!newConfig.min_height) { + newConfig.min_height = 230; + } + newConfig['selector'] = '#' + editorId; + newConfig['setup'] = function(ed) { + ed.on("change", function(e) { + documentDirty=true; + tinymce.triggerSave(); + jQuery('#'+_this.tvid).transformField("saveMultiValue"); + }); + }; + tinyMCE.init(newConfig); + }else{ + // Вот здесь уже определяем, как инициализировать tinymce по мажорной версии + // Но что-то я не уверен... Данного поведения добиться не удалось... + if(tinyMCE.majorVersion == 4) { + tinyMCE.execCommand('mceAddEditor', false, editorId); + } else { + tinyMCE.execCommand('mceAddControl', false, editorId); + } + } + //tinyMCE.DOM.setStyle(tinyMCE.DOM.get(editorId + '_ifr'), 'height', '200px'); + //tinyMCE.DOM.setStyle(tinyMCE.DOM.get(editorId + '_tbl'), 'height', 'auto'); + //tinyMCE.DOM.setStyle(tinyMCE.DOM.get(editorId + '_ifr'), 'width', '100%'); + //tinyMCE.DOM.setStyle(tinyMCE.DOM.get(editorId + '_tbl'), 'width', '100%'); + } + // Plugin constructor function Plugin(el, options) { // Extending options @@ -111,26 +154,22 @@ _this.fieldList.sortable({ start: function (e, ui) { $(ui.item).find('.inlineTabEditor').each(function () { - tinymce.execCommand('mceRemoveEditor', false, $(this).attr('id')); + if(typeof tinyMCE == 'object') { + tinymce.execCommand('mceRemoveEditor', false, $(this).attr('id')); + } + // Здесь другие редакторы.... }); }, stop: function (e, ui) { $(ui.item).find('.inlineTabEditor').each(function () { var editorId = $(this).attr('id'); var theme = $(this).data('theme'); - if (tinyMCE.majorVersion == 4) { - if (modxRTEbridge_tinymce4 != undefined) { - - var configObj = theme != undefined ? window['config_tinymce4_'+theme] : window[modxRTEbridge_tinymce4.default]; - configObj['selector'] = '#' + editorId; - configObj['setup'] = function(ed) { ed.on("change", function(e) { documentDirty=true; tinymce.triggerSave(); jQuery('#'+_this.tvid).transformField("saveMultiValue"); }); }; - tinyMCE.init(configObj); - } else { - tinyMCE.execCommand('mceAddEditor', false, editorId); - } - } else { - tinyMCE.execCommand('mceAddControl', false, editorId); + // №1 + // Если нет инициализации дефолтного конфига, то конфигов tinymce нет. + if(typeof tinyMCE == 'object') { + initTinyMCE(editorId, theme, _this); } + // Здесь другие редакторы.... }); _this.saveMultiValue(); }, @@ -339,7 +378,10 @@ break; default: { if (this.type == 'textarea' && self.hasClass('mtv_richtext')) { - tinyMCE.get(self.attr('id')).setContent(''); + if(typeof tinyMCE == 'object') { + tinyMCE.get(self.attr('id')).setContent(''); + } + // Здесь другие редакторы.... break; } @@ -453,29 +495,12 @@ $(this).addClass('initialized'); var editorId = $(this).attr('id'); var theme = $(this).data('theme'); - if (tinyMCE.majorVersion == 4) { - if (modxRTEbridge_tinymce4 != undefined) { - - var configObj = theme != undefined ? window['config_tinymce4_'+theme] : window[modxRTEbridge_tinymce4.default]; - var newConfig = {}; - for (var key in configObj) { - newConfig[key] = configObj[key]; - } - newConfig['selector'] = '#' + editorId; - newConfig['setup'] = function(ed) { ed.on("change", function(e) { documentDirty=true; tinymce.triggerSave(); jQuery('#'+_this.tvid).transformField("saveMultiValue"); }); }; - tinyMCE.init(newConfig); - } else { - tinyMCE.execCommand('mceAddEditor', false, editorId); - } - } else { - tinyMCE.execCommand('mceAddControl', false, editorId); - } - tinyMCE.DOM.setStyle(tinyMCE.DOM.get(editorId + '_ifr'), 'height', '200px'); - tinyMCE.DOM.setStyle(tinyMCE.DOM.get(editorId + '_tbl'), 'height', 'auto'); - tinyMCE.DOM.setStyle(tinyMCE.DOM.get(editorId + '_ifr'), 'width', '100%'); - tinyMCE.DOM.setStyle(tinyMCE.DOM.get(editorId + '_tbl'), 'width', '100%'); + // №2 + initTinyMCE(editorId, theme, _this); }); - } else if (typeof CKEDITOR !== 'undefined' && CKEDITOR.version.substr(0,1) == 4) { + } + // Здесь другие редакторы.... + if (typeof CKEDITOR !== 'undefined' && CKEDITOR.version.substr(0,1) == 4) { $('.inlineTabEditor:not(.initialized)', el).each(function () { $(this).addClass('initialized'); var editorId = $(this).attr('id'); @@ -497,6 +522,7 @@ return false; }, edit: function () { + var _this = this; var clone = this.fieldListElementEmpty.clone(true); this.fieldList.children('li').remove(); this.fieldList.append(clone); @@ -509,26 +535,21 @@ this.fieldList.sortable({ start: function (e, ui) { $(ui.item).find('.inlineTabEditor').each(function () { - tinymce.execCommand('mceRemoveEditor', false, $(this).attr('id')); + if(typeof tinyMCE == 'object') { + tinymce.execCommand('mceRemoveEditor', false, $(this).attr('id')); + } + // Здесь другие редакторы.... }); }, stop: function (e, ui) { $(ui.item).find('.inlineTabEditor').each(function () { var editorId = $(this).attr('id'); var theme = $(this).data('theme'); - if (tinyMCE.majorVersion == 4) { - if (modxRTEbridge_tinymce4 != undefined) { - - var configObj = theme != undefined ? window['config_tinymce4_'+theme] : window[modxRTEbridge_tinymce4.default]; - configObj['selector'] = '#' + editorId; - configObj['setup'] = function(ed) { ed.on("change", function(e) { documentDirty=true; tinymce.triggerSave(); jQuery('#'+_this.tvid).transformField("saveMultiValue"); }); }; - tinyMCE.init(configObj); - } else { - tinyMCE.execCommand('mceAddEditor', false, editorId); - } - } else { - tinyMCE.execCommand('mceAddControl', false, editorId); + // №3 + if(typeof tinyMCE == 'object') { + initTinyMCE(editorId, theme, _this); } + // Здесь другие редакторы.... }); this.saveMultiValue(); }, @@ -873,7 +894,8 @@ tinyMCE.execCommand('mceRemoveControl', false, editorId); } }); - } else if (typeof CKEDITOR !== 'undefined' && CKEDITOR.version.substr(0,1) == 4) { + } + if (typeof CKEDITOR !== 'undefined' && CKEDITOR.version.substr(0,1) == 4) { $('.tabEditor', el).each(function () { var editorId = $(this).attr('id'); CKEDITOR.instances[editorId].destroy(); @@ -1201,23 +1223,12 @@ $('.tabEditor', _this.fieldEditArea).each(function () { var editorId = $(this).attr('id'); var theme = $(this).data('theme'); - if (tinyMCE.majorVersion == 4) { - if (modxRTEbridge_tinymce4 != undefined) { - var configObj = theme != undefined ? window['config_tinymce4_'+theme] : window[modxRTEbridge_tinymce4.default]; - configObj['selector'] = '#' + editorId; - tinyMCE.init(configObj); - } else { - tinyMCE.execCommand('mceAddEditor', false, editorId); - } - } else { - tinyMCE.execCommand('mceAddControl', false, editorId); - } - tinyMCE.DOM.setStyle(tinyMCE.DOM.get(editorId + '_ifr'), 'height', '200px'); - tinyMCE.DOM.setStyle(tinyMCE.DOM.get(editorId + '_tbl'), 'height', 'auto'); - tinyMCE.DOM.setStyle(tinyMCE.DOM.get(editorId + '_ifr'), 'width', '100%'); - tinyMCE.DOM.setStyle(tinyMCE.DOM.get(editorId + '_tbl'), 'width', '100%'); + // №4 + initTinyMCE(editorId, theme, _this); }); - } else if (typeof CKEDITOR !== 'undefined' && CKEDITOR.version.substr(0,1) == 4) { + } + // Другие редакторы + if (typeof CKEDITOR !== 'undefined' && CKEDITOR.version.substr(0,1) == 4) { $('.tabEditor', _this.fieldEditArea).each(function () { var editorId = $(this).attr('id'); var theme = $(this).data('theme'); From 08c43b58035d68ce3a2c7b803819de71f22faff7 Mon Sep 17 00:00:00 2001 From: ProjextSoft-STUDIONIONS Date: Thu, 25 Jun 2026 07:47:30 +0400 Subject: [PATCH 2/5] update version --- install/assets/snippets/multiTV.tpl | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/install/assets/snippets/multiTV.tpl b/install/assets/snippets/multiTV.tpl index a765cce..1213461 100755 --- a/install/assets/snippets/multiTV.tpl +++ b/install/assets/snippets/multiTV.tpl @@ -5,7 +5,20 @@ * Custom Template Variabe containing a sortable multi item list or a datatable * * @category snippet, tv - * @version 2.0.16 + * @version 2.0.17 + * @license http://www.gnu.org/copyleft/gpl.html GNU Public License (GPL) + * @author Jako + * @internal @modx_category Content + * @internal @installset base, sample + */ + +/** + * multiTV + * + * Custom Template Variabe containing a sortable multi item list or a datatable + * + * @category snippet, tv + * @version 2.0.17 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License (GPL) * @author Jako * @internal @modx_category Content From 5b8edfb0fc2bb3fe0b0ec1cb5cbd878acdc1be55 Mon Sep 17 00:00:00 2001 From: ProjextSoft-STUDIONIONS Date: Thu, 25 Jun 2026 07:48:03 +0400 Subject: [PATCH 3/5] add build projects --- .gitattributes | 8 ++++++++ .github/workflows/build.yml | 34 ++++++++++++++++++++++++++++++++++ .gitignore | 8 ++++++++ index.js | 18 ++++++++++++++++++ package.json | 25 +++++++++++++++++++++++++ 5 files changed, 93 insertions(+) create mode 100644 .gitattributes create mode 100644 .github/workflows/build.yml create mode 100644 .gitignore create mode 100644 index.js create mode 100644 package.json diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..37710e7 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,8 @@ +.github export-ignore +.gitignore export-ignore +.gitattributes export-ignore +README.md export-ignore +index.js export-ignore +package.json export-ignore +_config.yml export-ignore +multitv.zip export-ignore diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..33e5364 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,34 @@ +name: Grunt Build +on: + release: + types: [published] +jobs: + build: + name: Сборка проекта + runs-on: ubuntu-latest + strategy: + matrix: + node: [24] + steps: + - uses: actions/checkout@v6 + - name: Установка Node.js + uses: actions/setup-node@v6 + with: + node-version: ${{ matrix.node-version }} + + - name: NPM установка пакетов + run: | + npm run inst + + - name: Сборка плагина + run: | + npm run build + + - name: Загрузка реализа + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: multitv.zip + tag: ${{ github.ref }} + overwrite: true + file_glob: true diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f9d1c71 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +/* +!/.github +!/.gitignore +!/.gitattributes +!/install +!/README* +!/index.js +!/package.json diff --git a/index.js b/index.js new file mode 100644 index 0000000..7945344 --- /dev/null +++ b/index.js @@ -0,0 +1,18 @@ +const zl = require("zip-lib"), + fs = require("node:fs"), + pack = "multitv", + folders = [`assets`, `install`]; + +if(fs.existsSync(`${pack}.zip`)) { + console.log(`Delete file ${pack}.zip`); + fs.unlinkSync(`${pack}.zip`); +} + +const zip = new zl.Zip(); + +for(var value of folders){ + zip.addFolder(`${value}`, `${pack}/${value}`); +} + +zip.archive(`${pack}.zip`); +console.log(`Archive ${pack}.zip`); diff --git a/package.json b/package.json new file mode 100644 index 0000000..489ec93 --- /dev/null +++ b/package.json @@ -0,0 +1,25 @@ +{ + "name": "multitv", + "version": "1.0.0", + "description": "Custom TV for Evolution CMS: Transform a template variables into a sortable multi item list for the Evolution content management framework", + "homepage": "https://github.com/extras-evolution/multitv#readme", + "bugs": { + "url": "https://github.com/extras-evolution/multitv/issues" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/extras-evolution/multitv.git" + }, + "license": "GPL-3.0", + "author": "", + "type": "commonjs", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "inst": "npm i", + "build": "node index.js" + }, + "dependencies": { + "zip-lib": "^1.4.0" + } +} From 7db13228cb56d22e9086d462ff1ddc06a75ffa5d Mon Sep 17 00:00:00 2001 From: ProjextSoft-STUDIONIONS Date: Thu, 25 Jun 2026 07:50:55 +0400 Subject: [PATCH 4/5] update version --- install/assets/snippets/multiTV.tpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install/assets/snippets/multiTV.tpl b/install/assets/snippets/multiTV.tpl index 1213461..d02ed79 100755 --- a/install/assets/snippets/multiTV.tpl +++ b/install/assets/snippets/multiTV.tpl @@ -5,7 +5,7 @@ * Custom Template Variabe containing a sortable multi item list or a datatable * * @category snippet, tv - * @version 2.0.17 + * @version 2.0.18 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License (GPL) * @author Jako * @internal @modx_category Content @@ -18,7 +18,7 @@ * Custom Template Variabe containing a sortable multi item list or a datatable * * @category snippet, tv - * @version 2.0.17 + * @version 2.0.18 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License (GPL) * @author Jako * @internal @modx_category Content From 30e0a7ff839ef9f4b594b1287315b4333a42d826 Mon Sep 17 00:00:00 2001 From: ProjextSoft-STUDIONIONS Date: Fri, 26 Jun 2026 05:29:44 +0400 Subject: [PATCH 5/5] update --- assets/tvs/multitv/css/colorbox.css | 2 +- assets/tvs/multitv/includes/multitv.class.php | 122 +++++++++++++----- assets/tvs/multitv/js/multitv.js | 94 ++++++++++++-- 3 files changed, 172 insertions(+), 46 deletions(-) diff --git a/assets/tvs/multitv/css/colorbox.css b/assets/tvs/multitv/css/colorbox.css index 6d478d1..f366cd5 100755 --- a/assets/tvs/multitv/css/colorbox.css +++ b/assets/tvs/multitv/css/colorbox.css @@ -2,7 +2,7 @@ Colorbox Core Style: The following CSS is consistent between example themes and should not be altered. */ -#colorbox, #cboxOverlay, #cboxWrapper{position:absolute; top:0; left:0; z-index:9999; overflow:hidden;} +#colorbox, #cboxOverlay, #cboxWrapper{position:absolute; top:0; left:0; z-index:100; overflow:hidden;} #cboxWrapper {max-width:none;} #cboxOverlay{position:fixed; width:100%; height:100%;} #cboxMiddleLeft, #cboxBottomLeft{clear:left;} diff --git a/assets/tvs/multitv/includes/multitv.class.php b/assets/tvs/multitv/includes/multitv.class.php index b31ac52..5072406 100644 --- a/assets/tvs/multitv/includes/multitv.class.php +++ b/assets/tvs/multitv/includes/multitv.class.php @@ -53,6 +53,7 @@ class multiTV public $cmsinfo = array(); public $options = array(); private $modx; + private $richeditor = "none"; public $params = []; private $_prepareStore; @@ -66,7 +67,7 @@ function __construct(&$modx, $options) $this->language = $this->loadLanguage($this->modx->config['manager_language']); $this->options = $options; $this->options['modulename'] = isset($this->options['modulename']) ? $this->options['modulename'] : $this->language['modulename']; - + $this->richeditor = $this->modx->config['which_editor']; $version = $this->modx->getVersionData(); switch ($version['branch']) { case 'ClipperCMS': @@ -164,7 +165,7 @@ function runModule($moduleConfigs) if (count($this->fieldsrte)) { $richTextEditor = $this->modx->invokeEvent("OnRichTextEditorInit", array( - 'editor' => $this->modx->config['which_editor'], + 'editor' => $this->richeditor, 'elements' => $this->fieldsrte, 'height' => '200px' ) @@ -370,7 +371,12 @@ function renderTemplate($template, $placeholder) // invoke modx renderFormElement and change the output (to multiTV demands) function renderMultiTVFormElement($fieldType, $fieldName, $fieldElements, $fieldClass, $fieldDefault) { - global $which_editor; + // Такое впечатление, что разрабатывалось при присутствии какогото расширения, которого у меня нет + // Поэтому данная функция будет постепенно дорабатываться к значениям по умолчанию (Значениям системы, а не расширений) + + // $which_editor в 3.x недоступен + // Будем использовать $this->richeditor + // global $which_editor; $fieldName .= '_mtv'; $currentScript = array(); $currentClass = array(); @@ -407,9 +413,9 @@ function renderMultiTVFormElement($fieldType, $fieldName, $fieldElements, $field $theme = isset($this->fields[$fieldId]['theme']) ? $this->fields[$fieldId]['theme'] : ''; if ($theme) { // Если есть редактор - if ($which_editor != "none") { + if ($this->richeditor != "none") { $evtOut = $this->modx->invokeEvent('OnRichTextEditorInit', array( - 'editor' => $which_editor, + 'editor' => $this->richeditor, 'options' => array('theme' => $theme) )); if (is_array($evtOut)) @@ -424,11 +430,13 @@ function renderMultiTVFormElement($fieldType, $fieldName, $fieldElements, $field $theme = isset($this->fields[$fieldId]['theme']) ? $this->fields[$fieldId]['theme'] : ''; if ($theme) { // Если есть редактор - if ($which_editor != "none") { - $evtOut = $this->modx->invokeEvent('OnRichTextEditorInit', array( - 'editor' => $which_editor, - 'options' => array('theme' => $theme) - )); + if ($this->richeditor != "none") { + $evtOut = $this->modx->invokeEvent('OnRichTextEditorInit', [ + 'editor' => $this->richeditor, + 'options' => [ + 'theme' => $theme + ] + ]); if (is_array($evtOut)) $evtOut = implode('', $evtOut); }; @@ -439,41 +447,85 @@ function renderMultiTVFormElement($fieldType, $fieldName, $fieldElements, $field } break; } - $formElement = $evtOut . renderFormElement($fieldType, 0, '', $fieldElements, '', '', array()); - $formElement = ($theme) ? str_replace('id="', 'data-theme="' . $theme . '" id="', $formElement) : $formElement; // add optional richtext-theme - $formElement = preg_replace('/( tvtype=\"[^\"]+\")/', '', $formElement); // remove tvtype attribute - $formElement = preg_replace('/(]*><\/label>)/', '', $formElement); // remove empty labels - $formElement = preg_replace('/( id=\"[^\"]+)/', ' id="[+tvid+]' . $fieldName, $formElement); // change id attributes - $formElement = preg_replace('/( name=\"[^\"]+)/', ' name="[+tvid+]' . $fieldName, $formElement); // change name attributes - preg_match('/()/s', $formElement, $currentScript); // get script - if (isset($currentScript[1])) { // the tv script is only included for the first tv that is using them (tv with image or file type) - $formElement = preg_replace('/()/s', '', $formElement); // remove the script tag + /** + * Отформатированы комментарии для удобства чтения + */ + // $evtOut отсюда. + // $formElement = $evtOut . renderFormElement($fieldType, 0, '', $fieldElements, '', '', array()); + // Сначало работаем непосредственно с элементом $formElement + $formElement = renderFormElement($fieldType, 0, '', $fieldElements, '', '', array()); + // add optional richtext-theme + $formElement = ($theme) ? str_replace('id="', 'data-theme="' . $theme . '" id="', $formElement) : $formElement; + // remove tvtype attribute + $formElement = preg_replace('/( tvtype=\"[^\"]+\")/', '', $formElement); + // remove empty labels + $formElement = preg_replace('/(]*><\/label>)/', '', $formElement); + // change id attributes + $formElement = preg_replace('/( id=\"[^\"]+)/', ' id="[+tvid+]' . $fieldName, $formElement); + // change name attributes + $formElement = preg_replace('/( name=\"[^\"]+)/', ' name="[+tvid+]' . $fieldName, $formElement); + // get script + // Если $evtOut остаётся сверху + // preg_match('/()/s', $formElement, $currentScript); + // the tv script is only included for the first tv that is using them (tv with image or file type) + // Вот это здесь точно не нужно. Если есть переопределение функций - пусть будут. multiTV делаем только под EvolutionCMS + // Зачем то перезаписывается весь скрипт на пустоту. + // Этого не нужно делать, все конфиги вырезаются и тогда получается, что вызов OnRichTextEditorInit просто нафиг не нужен. + /* + if (isset($currentScript[1])) { + // remove the script tag + $formElement = preg_replace('/()/s', '', $formElement); if ($this->cmsinfo['kcfinder'] == 'false' || $this->cmsinfo['seturl'] == 'old') { - $currentScript[1] = preg_replace('/function SetUrl.*script>/s', '', $currentScript[1]); // remove original SetUrl function + // remove original SetUrl function + $currentScript[1] = preg_replace('/function SetUrl.*script>/s', '', $currentScript[1]); } - $formElement = $formElement . $currentScript[1]; // move the script tag to the end + // move the script tag to the end + $formElement = $formElement . $currentScript[1]; } - preg_match('/<.*?class=\"([^\"]*)/s', $formElement, $currentClass); // get current classes - $formElement = preg_replace('/class=\"[^\"]*\"/s', '', $formElement, 1); // remove all classes + */ + // Если $evtOut остаётся сверху + // То не известно, как поведёт себя поиск, т. к. в скриптах script можно найти место с срабатыванием подобной регулярки + // Данное поведение мною было обнаружено на тестах + // get current classes + preg_match('/<.*?class=\"([^\"]*)/s', $formElement, $currentClass); + // remove all classes + $formElement = preg_replace('/class=\"[^\"]*\"/s', '', $formElement, 1); if ($fieldDefault != '') { - $formElement = preg_replace('/(<\w+)/', '$1 alt="' . $fieldDefault . '"', $formElement, 1); // add alt to first tag (the input) + // add alt to first tag (the input) + $formElement = preg_replace('/(<\w+)/', '$1 alt="' . $fieldDefault . '"', $formElement, 1); $fieldClass[] = 'setdefault'; } if (isset($currentClass[1])) { $fieldClass[] = str_replace('DatePicker', 'mtvDatePicker', $currentClass[1]); } $fieldClass = implode(' ', array_unique($fieldClass)); - $formElement = preg_replace('/(<\w+)/', '$1 class="' . $fieldClass . '"', $formElement, 1); // add class to first tag (the input) - $formElement = preg_replace('/