Skip to content

Commit

Permalink
Tinymce 6.8.3 + новые опции;
Browse files Browse the repository at this point in the history
validate_regexp теперь может показывать любой текст ошибки, в том числе для полей ТК;
исправлена ошибка с мультиязычностью в поле "Группа полей";
исправлена ошибка с механизмом инициализации wysiwyg редакторов.
  • Loading branch information
fuzegit committed Mar 20, 2024
1 parent aae9d6f commit 4accf99
Show file tree
Hide file tree
Showing 94 changed files with 407 additions and 19,848 deletions.
6 changes: 3 additions & 3 deletions install/languages/en/sql/base.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1965,6 +1965,6 @@ CREATE TABLE `{#}wysiwygs_presets` (

INSERT INTO `{#}wysiwygs_presets` (`id`, `wysiwyg_name`, `options`, `title`) VALUES
(1, 'markitup', '{\"buttons\":[\"0\",\"1\",\"2\",\"3\",\"4\",\"5\",\"7\",\"14\"],\"skin\":\"simple\"}', 'Photos'),
(2, 'redactor', '{\"plugins\":[\"smiles\"],\"buttons\":[\"bold\",\"italic\",\"deleted\",\"unorderedlist\",\"image\",\"video\",\"link\"],\"convertVideoLinks\":1,\"convertDivs\":null,\"toolbarFixedBox\":null,\"autoresize\":null,\"pastePlainText\":1,\"removeEmptyTags\":1,\"linkNofollow\":1,\"minHeight\":\"58\",\"placeholder\":\"\\u0412\\u0432\\u0435\\u0434\\u0438\\u0442\\u0435 \\u0441\\u043e\\u043e\\u0431\\u0449\\u0435\\u043d\\u0438\\u0435\"}', 'Editor for private messages'),
(3, 'tinymce', '{\"toolbar\":\"formatselect codesample blockquote | bold italic underline strikethrough numlist bullist | image link unlink media table hr emoticons spoiler-add | fullscreen\",\"quickbars_selection_toolbar\":\"bold italic underline | quicklink h2 h3 blockquote\",\"quickbars_insert_toolbar\":\"quickimage quicktable\",\"plugins\":[\"autoresize\",\"paste\"],\"skin\":\"icms\",\"forced_root_block\":\"p\",\"block_formats\":[\"p\",\"h2\",\"h3\",\"h4\",\"h5\"],\"toolbar_drawer\":\"\",\"image_caption\":null,\"image_title\":1,\"image_description\":null,\"image_dimensions\":null,\"image_advtab\":null,\"statusbar\":null,\"paste_as_text\":1,\"min_height\":350,\"max_height\":900,\"images_preset\":\"big\",\"allow_mime_types\":{\"3\":null,\"4\":null,\"5\":null,\"6\":null}}', 'By default'),
(4, 'tinymce', '{\"toolbar\":\"bold italic underline strikethrough | numlist bullist blockquote | link image media spoiler-add | emoticons\",\"quickbars_selection_toolbar\":\"bold italic underline | quicklink blockquote\",\"quickbars_insert_toolbar\":\"quickimage\",\"plugins\":[\"autoresize\"],\"skin\":\"icms\",\"forced_root_block\":\"p\",\"block_formats\":[\"p\"],\"toolbar_drawer\":\"\",\"image_caption\":null,\"image_title\":null,\"image_description\":null,\"image_dimensions\":null,\"image_advtab\":null,\"statusbar\":null,\"paste_as_text\":1,\"min_height\":350,\"max_height\":700,\"images_preset\":\"big\",\"allow_mime_types\":{\"3\":null,\"4\":null,\"5\":null,\"6\":null}}', 'For comments');
(2, 'redactor', '{\"plugins\":[\"smiles\"],\"buttons\":[\"bold\",\"italic\",\"deleted\",\"unorderedlist\",\"image\",\"video\",\"link\"],\"convertVideoLinks\":1,\"convertDivs\":null,\"toolbarFixedBox\":null,\"autoresize\":null,\"pastePlainText\":1,\"removeEmptyTags\":1,\"linkNofollow\":1,\"minHeight\":\"58\",\"placeholder\":\"Enter a message\"}', 'Editor for private messages'),
(3, 'tinymce', '{\"toolbar\":\"formatselect codesample blockquote | bold italic underline strikethrough numlist bullist | image link unlink media table emoticons spoiler-add | fullscreen\",\"quickbars_selection_toolbar\":\"bold italic underline | quicklink h2 h3 blockquote\",\"quickbars_insert_toolbar\":\"quickimage quicktable\",\"plugins\":[\"autoresize\"],\"skin\":\"icms\",\"forced_root_block\":\"p\",\"block_formats\":[\"p\",\"h2\",\"h3\",\"h4\",\"h5\"],\"toolbar_mode\":\"floating\",\"image_caption\":null,\"image_title\":1,\"image_description\":null,\"image_dimensions\":null,\"image_advtab\":null,\"statusbar\":null,\"min_height\":350,\"max_height\":900,\"images_preset\":\"big\",\"allow_mime_types\":{\"3\":null,\"4\":null,\"5\":null,\"6\":null}}', 'By default'),
(4, 'tinymce', '{\"toolbar\":\"bold italic underline strikethrough | numlist bullist blockquote | link image media spoiler-add | emoticons\",\"quickbars_selection_toolbar\":\"bold italic underline | quicklink blockquote\",\"quickbars_insert_toolbar\":\"quickimage\",\"plugins\":[\"autoresize\"],\"skin\":\"icms\",\"forced_root_block\":\"p\",\"block_formats\":[\"p\"],\"toolbar_mode\":\"floating\",\"image_caption\":null,\"image_title\":null,\"image_description\":null,\"image_dimensions\":null,\"image_advtab\":null,\"statusbar\":null,\"min_height\":350,\"max_height\":700,\"images_preset\":\"big\",\"allow_mime_types\":{\"3\":null,\"4\":null,\"5\":null,\"6\":null}}', 'For comments');
4 changes: 2 additions & 2 deletions install/languages/ru/sql/base.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1965,5 +1965,5 @@ CREATE TABLE `{#}wysiwygs_presets` (
INSERT INTO `{#}wysiwygs_presets` (`id`, `wysiwyg_name`, `options`, `title`) VALUES
(1, 'markitup', '{\"buttons\":[\"0\",\"1\",\"2\",\"3\",\"4\",\"5\",\"7\",\"14\"],\"skin\":\"simple\"}', 'Фотографии'),
(2, 'redactor', '{\"plugins\":[\"smiles\"],\"buttons\":[\"bold\",\"italic\",\"deleted\",\"unorderedlist\",\"image\",\"video\",\"link\"],\"convertVideoLinks\":1,\"convertDivs\":null,\"toolbarFixedBox\":null,\"autoresize\":null,\"pastePlainText\":1,\"removeEmptyTags\":1,\"linkNofollow\":1,\"minHeight\":\"58\",\"placeholder\":\"\\u0412\\u0432\\u0435\\u0434\\u0438\\u0442\\u0435 \\u0441\\u043e\\u043e\\u0431\\u0449\\u0435\\u043d\\u0438\\u0435\"}', 'Редактор для личных сообщений'),
(3, 'tinymce', '{\"toolbar\":\"formatselect codesample blockquote | bold italic underline strikethrough numlist bullist | image link unlink media table hr emoticons spoiler-add | fullscreen\",\"quickbars_selection_toolbar\":\"bold italic underline | quicklink h2 h3 blockquote\",\"quickbars_insert_toolbar\":\"quickimage quicktable\",\"plugins\":[\"autoresize\",\"paste\"],\"skin\":\"icms\",\"forced_root_block\":\"p\",\"block_formats\":[\"p\",\"h2\",\"h3\",\"h4\",\"h5\"],\"toolbar_drawer\":\"\",\"image_caption\":null,\"image_title\":1,\"image_description\":null,\"image_dimensions\":null,\"image_advtab\":null,\"statusbar\":null,\"paste_as_text\":1,\"min_height\":350,\"max_height\":900,\"images_preset\":\"big\",\"allow_mime_types\":{\"3\":null,\"4\":null,\"5\":null,\"6\":null}}', 'По умолчанию'),
(4, 'tinymce', '{\"toolbar\":\"bold italic underline strikethrough | numlist bullist blockquote | link image media spoiler-add | emoticons\",\"quickbars_selection_toolbar\":\"bold italic underline | quicklink blockquote\",\"quickbars_insert_toolbar\":\"quickimage\",\"plugins\":[\"autoresize\"],\"skin\":\"icms\",\"forced_root_block\":\"p\",\"block_formats\":[\"p\"],\"toolbar_drawer\":\"\",\"image_caption\":null,\"image_title\":null,\"image_description\":null,\"image_dimensions\":null,\"image_advtab\":null,\"statusbar\":null,\"paste_as_text\":1,\"min_height\":350,\"max_height\":700,\"images_preset\":\"big\",\"allow_mime_types\":{\"3\":null,\"4\":null,\"5\":null,\"6\":null}}', 'Для комментариев');
(3, 'tinymce', '{\"toolbar\":\"formatselect codesample blockquote | bold italic underline strikethrough numlist bullist | image link unlink media table emoticons spoiler-add | fullscreen\",\"quickbars_selection_toolbar\":\"bold italic underline | quicklink h2 h3 blockquote\",\"quickbars_insert_toolbar\":\"quickimage quicktable\",\"plugins\":[\"autoresize\"],\"skin\":\"icms\",\"forced_root_block\":\"p\",\"block_formats\":[\"p\",\"h2\",\"h3\",\"h4\",\"h5\"],\"toolbar_mode\":\"floating\",\"image_caption\":null,\"image_title\":1,\"image_description\":null,\"image_dimensions\":null,\"image_advtab\":null,\"statusbar\":null,\"min_height\":350,\"max_height\":900,\"images_preset\":\"big\",\"allow_mime_types\":{\"3\":null,\"4\":null,\"5\":null,\"6\":null}}', 'По умолчанию'),
(4, 'tinymce', '{\"toolbar\":\"bold italic underline strikethrough | numlist bullist blockquote | link image media spoiler-add | emoticons\",\"quickbars_selection_toolbar\":\"bold italic underline | quicklink blockquote\",\"quickbars_insert_toolbar\":\"quickimage\",\"plugins\":[\"autoresize\"],\"skin\":\"icms\",\"forced_root_block\":\"p\",\"block_formats\":[\"p\"],\"toolbar_mode\":\"floating\",\"image_caption\":null,\"image_title\":null,\"image_description\":null,\"image_dimensions\":null,\"image_advtab\":null,\"statusbar\":null,\"min_height\":350,\"max_height\":700,\"images_preset\":\"big\",\"allow_mime_types\":{\"3\":null,\"4\":null,\"5\":null,\"6\":null}}', 'Для комментариев');
6 changes: 6 additions & 0 deletions system/controllers/admin/forms/form_ctypes_field.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,12 @@ public function init($do, $ctype_name) {
'hint' => LANG_CP_FIELD_REGEX_TEXT_HINT,
'visible_depend' => ['options:is_regexp' => ['show' => ['1']]]
]),
new fieldString('options:rules_regexp_error', [
'title' => LANG_CP_FIELD_REGEX_ERROR,
'hint' => LANG_CP_FIELD_REGEX_ERROR_HINT,
'multilanguage' => true,
'visible_depend' => ['options:is_regexp' => ['show' => ['1']]]
]),
new fieldCheckbox('options:is_unique', [
'title' => LANG_VALIDATE_UNIQUE,
])
Expand Down
20 changes: 14 additions & 6 deletions system/controllers/comments/actions/get.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,31 @@

class actionCommentsGet extends cmsAction {

public function run(){
public function run() {

if (!$this->request->isAjax()){ cmsCore::error404(); }
if (!cmsUser::isAllowed('comments', 'edit')){ cmsCore::error404(); }
if (!$this->request->isAjax()) {
return cmsCore::error404();
}
if (!cmsUser::isAllowed('comments', 'edit')) {

return $this->cms_template->renderJSON([
'error' => true, 'message' => LANG_ERROR
]);
}

$comment_id = $this->request->get('id', 0);

if (!$comment_id){
if (!$comment_id) {

return $this->cms_template->renderJSON([
'error' => true, 'message' => LANG_ERROR
]);
}

$comment = $this->model->getComment($comment_id);

if (!$comment){
if (!$comment) {

return $this->cms_template->renderJSON([
'error' => true, 'message' => LANG_ERROR
]);
Expand All @@ -40,7 +49,6 @@ public function run(){
list($result, $comment) = cmsEventsManager::hook('comment_before_render_json', [$result, $comment]);

return $this->cms_template->renderJSON($result);

}

}
6 changes: 6 additions & 0 deletions system/controllers/groups/backend/forms/form_field.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,12 @@ public function init($do, $ctype_name) {
'hint' => LANG_CP_FIELD_REGEX_TEXT_HINT,
'visible_depend' => ['options:is_regexp' => ['show' => ['1']]]
]),
new fieldString('options:rules_regexp_error', [
'title' => LANG_CP_FIELD_REGEX_ERROR,
'hint' => LANG_CP_FIELD_REGEX_ERROR_HINT,
'multilanguage' => true,
'visible_depend' => ['options:is_regexp' => ['show' => ['1']]]
]),
new fieldCheckbox('options:is_unique', [
'title' => LANG_VALIDATE_UNIQUE,
])
Expand Down
6 changes: 6 additions & 0 deletions system/controllers/users/backend/forms/form_field.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,12 @@ public function init($do) {
'hint' => LANG_CP_FIELD_REGEX_TEXT_HINT,
'visible_depend' => ['options:is_regexp' => ['show' => ['1']]]
]),
new fieldString('options:rules_regexp_error', [
'title' => LANG_CP_FIELD_REGEX_ERROR,
'hint' => LANG_CP_FIELD_REGEX_ERROR_HINT,
'multilanguage' => true,
'visible_depend' => ['options:is_regexp' => ['show' => ['1']]]
]),
new fieldCheckbox('options:is_unique', [
'title' => LANG_VALIDATE_UNIQUE
])
Expand Down
23 changes: 20 additions & 3 deletions system/core/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -1427,9 +1427,26 @@ public function validate_color($value) {
return ERR_VALIDATE_INVALID;
}

public function validate_regexp($regexp, $value){
if (empty($value)) { return true; }
if (!in_array(gettype($value), ['integer', 'string', 'double']) || !preg_match($regexp, strval($value))){ return ERR_VALIDATE_REGEXP; }
public function validate_regexp($regexp, $value, $set_error_text = false) {

if (empty($value)) {
return true;
}

$error_text = false;

// Если передан, значит $value это $set_error_text, а $set_error_text это $value
// Сделано для совместимости, т.к. в валидаторы
// Значения передются последним аргументом
if($set_error_text){
$error_text = $value;
$value = $set_error_text;
}

if (!in_array(gettype($value), ['integer', 'string', 'double']) || !preg_match($regexp, strval($value))) {
return $error_text ? $error_text : ERR_VALIDATE_REGEXP;
}

return true;
}

Expand Down
Loading

0 comments on commit 4accf99

Please sign in to comment.