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/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 fd95cec..5072406 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'; } @@ -47,6 +53,7 @@ class multiTV public $cmsinfo = array(); public $options = array(); private $modx; + private $richeditor = "none"; public $params = []; private $_prepareStore; @@ -60,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': @@ -158,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' ) @@ -364,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(); @@ -396,13 +408,14 @@ 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 ($this->richeditor != "none") { $evtOut = $this->modx->invokeEvent('OnRichTextEditorInit', array( - 'editor' => $which_editor, + 'editor' => $this->richeditor, 'options' => array('theme' => $theme) )); if (is_array($evtOut)) @@ -412,15 +425,18 @@ 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'))) { - $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); }; @@ -431,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('/