Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
412 changes: 412 additions & 0 deletions Readme-Abschnitts-Vorlagen-Editor.md

Large diffs are not rendered by default.

482 changes: 482 additions & 0 deletions include/inc_act/ajax_template.php

Large diffs are not rendered by default.

161 changes: 158 additions & 3 deletions include/inc_js/phpwcms.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,9 @@ function bsConfirmFlush(message, callback, customConfirmText, customCancelText)
bsConfirm('flush', message, callback, customConfirmText, customCancelText);
}

function bsAlert(message, callback) {
function bsAlert(message, callback, rawHtml) {
if (window.parent && window.parent !== window && typeof window.parent.bsAlert === 'function') {
window.parent.bsAlert(message, callback);
window.parent.bsAlert(message, callback, rawHtml);
return;
}

Expand Down Expand Up @@ -322,7 +322,13 @@ function bsAlert(message, callback) {
});
}

$modal.find('.confirm-message').html(formatConfirmMessage(message));
// rawHtml=true: the caller already built safe, well-formed HTML (e.g. a
// list of links from the template "in use" check in general.inc.php) and
// it must be inserted as-is - running it through formatConfirmMessage()
// would HTML-escape the markup itself, showing literal tags/entities
// instead of a rendered list. Default (falsy) keeps the normal, safe
// plain-text escaping for ordinary alert messages.
$modal.find('.confirm-message').html(rawHtml ? message : formatConfirmMessage(message));

const bsModalInstance = (typeof bootstrap !== 'undefined' && bootstrap.Modal)
? bootstrap.Modal.getOrCreateInstance($modal[0])
Expand All @@ -346,6 +352,155 @@ function bsAlert(message, callback) {
}
}

/**
* Text-input counterpart to bsConfirm()/bsAlert() - same modal look (icon/
* color scheme per type), but with a single text field instead of Yes/No
* buttons. Used by the inline template editor (general.inc.php) for
* "Vorlage erstellen"/"Vorlage duplizieren", where a file name has to be
* typed in - phpwcms itself has no built-in input prompt.
*
* @param {string} promptType 'info'|'warning'|'danger'|... (same palette as bsConfirm)
* @param {string} message label shown above the input field
* @param {string} defaultValue pre-filled, pre-selected input value
* @param {function} callback called with the entered (trimmed) string on confirm
* @param {string} [customConfirmText]
* @param {string} [customCancelText]
* @param {function} [cancelCallback]
*/
function bsPrompt(promptType, message, defaultValue, callback, customConfirmText, customCancelText, cancelCallback) {
if (window.parent && window.parent !== window && typeof window.parent.bsPrompt === 'function') {
window.parent.bsPrompt(promptType, message, defaultValue, callback, customConfirmText, customCancelText, cancelCallback);
return;
}

const modalId = 'bootstrapPromptModal';
let $modal = $('#' + modalId);
if ($modal.length === 0) {
const modalHtml =
'<div class="modal fade" id="' + modalId + '" tabindex="-1" role="dialog" aria-hidden="true" style="z-index: 2000;">' +
' <div class="modal-dialog modal-dialog-centered" role="document" style="max-width: 400px;">' +
' <div class="modal-content border-0 bg-transparent">' +
' <div class="alert shadow-lg mb-0 p-4 alert-container" role="alert" style="border-radius: 8px;">' +
' <div class="d-flex align-items-start">' +
' <div class="me-3 icon-container" style="font-size: 2rem; line-height: 1;">' +
' <i></i>' +
' </div>' +
' <div style="flex: 1; min-width: 0;">' +
' <p class="confirm-message mb-2 text-dark fw-bold" style="font-size: 1.1rem;"></p>' +
' <input type="text" class="form-control form-control-sm mb-3 prompt-input">' +
' <div class="d-flex justify-content-end">' +
' <button type="button" class="btn btn-secondary me-2 cancel-btn" data-bs-dismiss="modal"></button>' +
' <button type="button" class="btn confirm-btn fw-bold"></button>' +
' </div>' +
' </div>' +
' </div>' +
' </div>' +
' </div>' +
' </div>' +
'</div>';
$('body').append(modalHtml);
$modal = $('#' + modalId);
$modal.on('hide.bs.modal', function () {
if ($modal.has(document.activeElement).length) {
document.activeElement.blur();
}
});
$modal.find('.prompt-input').on('keydown', function (e) {
if (e.key === 'Enter') {
e.preventDefault();
$modal.find('.confirm-btn').trigger('click');
}
});
}

const cancelText = customCancelText || (window.PHPWCMS_LANG && window.PHPWCMS_LANG.cancel) || 'Cancel';
$modal.find('.cancel-btn').text(cancelText);

const confirmText = customConfirmText || (window.PHPWCMS_LANG && window.PHPWCMS_LANG.ok) || 'OK';
const type = (promptType || 'info').toLowerCase().trim();

let btnClass = 'btn-info text-white';
let textClass = 'text-info';
let iconClass = 'fa-solid fa-info-circle';

if (type === 'danger' || type === 'delete') {
btnClass = 'btn-danger text-white';
textClass = 'text-danger';
iconClass = 'fa-solid fa-trash-alt';
} else if (type === 'primary' || type === 'move') {
btnClass = 'btn-primary text-white';
textClass = 'text-primary';
iconClass = 'fa-solid fa-arrows-alt';
} else if (type === 'warning' || type === 'flush') {
btnClass = 'btn-warning text-dark';
textClass = 'text-warning';
iconClass = 'fa-solid fa-exclamation-triangle';
} else if (type === 'success') {
btnClass = 'btn-success text-white';
textClass = 'text-success';
iconClass = 'fa-solid fa-check-circle';
}

$modal.find('.alert-container')
.removeClass('alert-warning alert-danger alert-primary alert-info alert-success')
.addClass('alert-light')
.css('border', '1px solid #dee2e6');

$modal.find('.icon-container')
.removeClass('text-warning text-danger text-primary text-info text-success')
.addClass(textClass);

$modal.find('.icon-container i')
.removeClass()
.addClass(iconClass);

$modal.find('.confirm-btn')
.removeClass('btn-danger btn-primary btn-info btn-warning btn-success text-white text-dark')
.addClass(btnClass)
.text(confirmText);

$modal.find('.confirm-message').html(formatConfirmMessage(message));

const $input = $modal.find('.prompt-input');
$input.val(defaultValue || '');

const bsModalInstance = (typeof bootstrap !== 'undefined' && bootstrap.Modal)
? bootstrap.Modal.getOrCreateInstance($modal[0])
: null;

let confirmed = false;

$modal.find('.confirm-btn').off('click').on('click', function() {
const value = $input.val();
confirmed = true;
if (bsModalInstance) {
bsModalInstance.hide();
} else {
$modal.modal('hide');
}
if (typeof callback === 'function') {
callback(value);
}
});

$modal.off('hidden.bs.modal').on('hidden.bs.modal', function() {
if (!confirmed && typeof cancelCallback === 'function') {
cancelCallback();
}
confirmed = false;
});

$modal.off('shown.bs.modal').on('shown.bs.modal', function() {
$input.trigger('focus').trigger('select');
});

if (bsModalInstance) {
bsModalInstance.show();
} else {
$modal.modal('show');
}
}

// Global alert override
window.alert = function(msg) {
bsAlert(msg);
Expand Down
2 changes: 1 addition & 1 deletion include/inc_js/phpwcms.min.js

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions include/inc_lang/backend/ar/lang.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -1864,3 +1864,25 @@
$BL['be_security_detail_token_fallback'] = 'form_token_key فارغ؛ يُستخدم db_user + db_pass.';
$BL['be_security_detail_token_ok'] = 'تم إعداد form_token_key مخصص.';
$BL['be_security_detail_setup_present'] = 'setup/ ما زال موجودًا؛ احذفه أو احظره.';

$BL['be_cnt_template_edit'] = 'تحرير القالب المحدد';
$BL['be_cnt_template_create'] = 'إنشاء قالب';
$BL['be_cnt_template_duplicate'] = 'نسخ القالب';
$BL['be_cnt_template_delete'] = 'حذف القالب';
$BL['be_cnt_template_edit_hint'] = 'تنبيه: تؤثر التغييرات على جميع أجزاء المحتوى التي تستخدم هذا القالب. يتم الحفظ عند النقر على "تحديث" أو "حفظ".';
$BL['be_cnt_template_edit_close'] = 'إغلاق';
$BL['be_cnt_template_edit_none'] = 'لم يتم تحديد أي قالب.';
$BL['be_cnt_template_edit_error'] = 'تعذر تحميل القالب.';
$BL['be_cnt_template_edit_standard'] = 'لا يمكن تحرير القالب الافتراضي. لتحريره، يرجى إنشاء نسخة منه أولاً.';
$BL['be_cnt_template_create_prompt'] = 'اسم القالب الجديد:';
$BL['be_cnt_template_create_error'] = 'تعذر إنشاء القالب.';
$BL['be_cnt_template_duplicate_prompt'] = 'اسم النسخة:';
$BL['be_cnt_template_duplicate_error'] = 'تعذر نسخ القالب.';
$BL['be_cnt_template_duplicate_exists'] = 'يوجد بالفعل قالب بهذا الاسم.';
$BL['be_cnt_template_duplicate_invalid'] = 'يرجى إدخال اسم ملف صالح.';
$BL['be_cnt_template_delete_confirm'] = 'هل تريد فعلاً حذف القالب "%s"؟';
$BL['be_cnt_template_delete_confirm_unverified'] = 'لا يمكن التحقق تلقائياً من استخدام هذا القالب. هل تريد حذفه رغم ذلك؟';
$BL['be_cnt_template_delete_error'] = 'تعذر حذف القالب.';
$BL['be_cnt_template_delete_inuse'] = 'لا يزال هذا القالب قيد الاستخدام:';
$BL['be_cnt_template_delete_inuse_section'] = 'معرّف الجزء';
$BL['be_cnt_template_delete_standard'] = 'لا يمكن حذف القالب الافتراضي.';
22 changes: 22 additions & 0 deletions include/inc_lang/backend/bg/lang.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -1874,3 +1874,25 @@
$BL['be_security_detail_token_fallback'] = 'form_token_key е празен; използва се db_user + db_pass.';
$BL['be_security_detail_token_ok'] = 'Конфигуриран е отделен form_token_key.';
$BL['be_security_detail_setup_present'] = 'setup/ все още съществува; премахнете или блокирайте.';

$BL['be_cnt_template_edit'] = 'редактиране на избрания шаблон';
$BL['be_cnt_template_create'] = 'създаване на шаблон';
$BL['be_cnt_template_duplicate'] = 'дублиране на шаблон';
$BL['be_cnt_template_delete'] = 'изтриване на шаблон';
$BL['be_cnt_template_edit_hint'] = 'Внимание: промените засягат всички съдържателни части, които използват този шаблон. Запазва се при натискане на „Актуализиране“ или „Запис“.';
$BL['be_cnt_template_edit_close'] = 'затвори';
$BL['be_cnt_template_edit_none'] = 'Не е избран шаблон.';
$BL['be_cnt_template_edit_error'] = 'Шаблонът не можа да бъде зареден.';
$BL['be_cnt_template_edit_standard'] = 'Редактирането на стандартния шаблон не е възможно. За редактиране моля създайте дубликат.';
$BL['be_cnt_template_create_prompt'] = 'Име за новия шаблон:';
$BL['be_cnt_template_create_error'] = 'Шаблонът не можа да бъде създаден.';
$BL['be_cnt_template_duplicate_prompt'] = 'Име за копието:';
$BL['be_cnt_template_duplicate_error'] = 'Шаблонът не можа да бъде дублиран.';
$BL['be_cnt_template_duplicate_exists'] = 'Вече съществува шаблон с това име.';
$BL['be_cnt_template_duplicate_invalid'] = 'Моля въведете валидно име на файл.';
$BL['be_cnt_template_delete_confirm'] = 'Наистина ли да се изтрие шаблонът „%s“?';
$BL['be_cnt_template_delete_confirm_unverified'] = 'Използването на този шаблон не може да бъде проверено автоматично. Да се изтрие ли въпреки това?';
$BL['be_cnt_template_delete_error'] = 'Шаблонът не можа да бъде изтрит.';
$BL['be_cnt_template_delete_inuse'] = 'Този шаблон все още се използва:';
$BL['be_cnt_template_delete_inuse_section'] = 'ID на раздела';
$BL['be_cnt_template_delete_standard'] = 'Стандартният шаблон не може да бъде изтрит.';
22 changes: 22 additions & 0 deletions include/inc_lang/backend/bn/lang.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -1874,3 +1874,25 @@
$BL['be_security_detail_token_fallback'] = 'form_token_key খালি; db_user + db_pass ব্যবহৃত হয়।';
$BL['be_security_detail_token_ok'] = 'একটি নির্দিষ্ট form_token_key কনফিগার করা আছে।';
$BL['be_security_detail_setup_present'] = 'setup/ এখনও আছে; সরান বা ব্লক করুন।';

$BL['be_cnt_template_edit'] = 'নির্বাচিত টেমপ্লেট সম্পাদনা করুন';
$BL['be_cnt_template_create'] = 'টেমপ্লেট তৈরি করুন';
$BL['be_cnt_template_duplicate'] = 'টেমপ্লেট কপি করুন';
$BL['be_cnt_template_delete'] = 'টেমপ্লেট মুছুন';
$BL['be_cnt_template_edit_hint'] = 'মনোযোগ: পরিবর্তনগুলি এই টেমপ্লেট ব্যবহারকারী সব কনটেন্ট অংশকে প্রভাবিত করে। "আপডেট" বা "সংরক্ষণ" ক্লিক করলে সংরক্ষিত হয়।';
$BL['be_cnt_template_edit_close'] = 'বন্ধ করুন';
$BL['be_cnt_template_edit_none'] = 'কোনো টেমপ্লেট নির্বাচিত নেই।';
$BL['be_cnt_template_edit_error'] = 'টেমপ্লেটটি লোড করা যায়নি।';
$BL['be_cnt_template_edit_standard'] = 'ডিফল্ট টেমপ্লেট সম্পাদনা করা সম্ভব নয়। সম্পাদনার জন্য প্রথমে একটি কপি তৈরি করুন।';
$BL['be_cnt_template_create_prompt'] = 'নতুন টেমপ্লেটের নাম:';
$BL['be_cnt_template_create_error'] = 'টেমপ্লেট তৈরি করা যায়নি।';
$BL['be_cnt_template_duplicate_prompt'] = 'কপির নাম:';
$BL['be_cnt_template_duplicate_error'] = 'টেমপ্লেট কপি করা যায়নি।';
$BL['be_cnt_template_duplicate_exists'] = 'এই নামে একটি টেমপ্লেট ইতিমধ্যে আছে।';
$BL['be_cnt_template_duplicate_invalid'] = 'অনুগ্রহ করে একটি সঠিক ফাইলের নাম দিন।';
$BL['be_cnt_template_delete_confirm'] = 'সত্যিই কি "%s" টেমপ্লেটটি মুছতে চান?';
$BL['be_cnt_template_delete_confirm_unverified'] = 'এই টেমপ্লেটের ব্যবহার স্বয়ংক্রিয়ভাবে যাচাই করা যায় না। তবুও মুছবেন?';
$BL['be_cnt_template_delete_error'] = 'টেমপ্লেট মোছা যায়নি।';
$BL['be_cnt_template_delete_inuse'] = 'এই টেমপ্লেটটি এখনও ব্যবহৃত হচ্ছে:';
$BL['be_cnt_template_delete_inuse_section'] = 'অংশ আইডি';
$BL['be_cnt_template_delete_standard'] = 'ডিফল্ট টেমপ্লেট মোছা যায় না।';
22 changes: 22 additions & 0 deletions include/inc_lang/backend/bs/lang.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -1845,3 +1845,25 @@
$BL['be_security_detail_token_fallback'] = 'form_token_key je prazan; koristi se db_user + db_pass.';
$BL['be_security_detail_token_ok'] = 'Konfigurisan je namjenski form_token_key.';
$BL['be_security_detail_setup_present'] = 'setup/ još postoji; uklonite ili blokirajte.';

$BL['be_cnt_template_edit'] = 'uredi odabrani predložak';
$BL['be_cnt_template_create'] = 'kreiraj predložak';
$BL['be_cnt_template_duplicate'] = 'dupliciraj predložak';
$BL['be_cnt_template_delete'] = 'obriši predložak';
$BL['be_cnt_template_edit_hint'] = 'Napomena: Izmjene utiču na sve dijelove sadržaja koji koriste ovaj predložak. Sprema se klikom na „Ažuriraj“ ili „Sačuvaj“.';
$BL['be_cnt_template_edit_close'] = 'zatvori';
$BL['be_cnt_template_edit_none'] = 'Nije odabran predložak.';
$BL['be_cnt_template_edit_error'] = 'Predložak se nije mogao učitati.';
$BL['be_cnt_template_edit_standard'] = 'Uređivanje zadanog predloška nije moguće. Za uređivanje prvo napravite duplikat.';
$BL['be_cnt_template_create_prompt'] = 'Naziv za novi predložak:';
$BL['be_cnt_template_create_error'] = 'Predložak se nije mogao kreirati.';
$BL['be_cnt_template_duplicate_prompt'] = 'Naziv za kopiju:';
$BL['be_cnt_template_duplicate_error'] = 'Predložak se nije mogao duplicirati.';
$BL['be_cnt_template_duplicate_exists'] = 'Predložak s ovim nazivom već postoji.';
$BL['be_cnt_template_duplicate_invalid'] = 'Molimo unesite važeći naziv datoteke.';
$BL['be_cnt_template_delete_confirm'] = 'Zaista obrisati predložak „%s“?';
$BL['be_cnt_template_delete_confirm_unverified'] = 'Upotreba ovog predloška se ne može automatski provjeriti. Ipak obrisati?';
$BL['be_cnt_template_delete_error'] = 'Predložak se nije mogao obrisati.';
$BL['be_cnt_template_delete_inuse'] = 'Ovaj predložak se još uvijek koristi:';
$BL['be_cnt_template_delete_inuse_section'] = 'ID dijela sadržaja';
$BL['be_cnt_template_delete_standard'] = 'Zadani predložak se ne može obrisati.';
22 changes: 22 additions & 0 deletions include/inc_lang/backend/ca/lang.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -1876,3 +1876,25 @@
$BL['be_security_detail_token_fallback'] = 'form_token_key és buit; s’usa db_user + db_pass.';
$BL['be_security_detail_token_ok'] = 'Hi ha un form_token_key dedicat configurat.';
$BL['be_security_detail_setup_present'] = 'setup/ encara hi és; elimineu-lo o bloquegeu-lo.';

$BL['be_cnt_template_edit'] = 'edita la plantilla seleccionada';
$BL['be_cnt_template_create'] = 'crea una plantilla';
$BL['be_cnt_template_duplicate'] = 'duplica la plantilla';
$BL['be_cnt_template_delete'] = 'elimina la plantilla';
$BL['be_cnt_template_edit_hint'] = 'Atenció: els canvis afecten totes les parts de contingut que utilitzen aquesta plantilla. Es desa en clicar "Actualitza" o "Desa".';
$BL['be_cnt_template_edit_close'] = 'tanca';
$BL['be_cnt_template_edit_none'] = 'No s\'ha seleccionat cap plantilla.';
$BL['be_cnt_template_edit_error'] = 'No s\'ha pogut carregar la plantilla.';
$BL['be_cnt_template_edit_standard'] = 'No es pot editar la plantilla per defecte. Per editar-la, creeu primer un duplicat.';
$BL['be_cnt_template_create_prompt'] = 'Nom per a la nova plantilla:';
$BL['be_cnt_template_create_error'] = 'No s\'ha pogut crear la plantilla.';
$BL['be_cnt_template_duplicate_prompt'] = 'Nom per a la còpia:';
$BL['be_cnt_template_duplicate_error'] = 'No s\'ha pogut duplicar la plantilla.';
$BL['be_cnt_template_duplicate_exists'] = 'Ja existeix una plantilla amb aquest nom.';
$BL['be_cnt_template_duplicate_invalid'] = 'Introduïu un nom de fitxer vàlid.';
$BL['be_cnt_template_delete_confirm'] = 'Segur que voleu eliminar la plantilla "%s"?';
$BL['be_cnt_template_delete_confirm_unverified'] = 'No es pot comprovar automàticament l\'ús d\'aquesta plantilla. Voleu eliminar-la igualment?';
$BL['be_cnt_template_delete_error'] = 'No s\'ha pogut eliminar la plantilla.';
$BL['be_cnt_template_delete_inuse'] = 'Aquesta plantilla encara s\'utilitza:';
$BL['be_cnt_template_delete_inuse_section'] = 'ID de la part de contingut';
$BL['be_cnt_template_delete_standard'] = 'No es pot eliminar la plantilla per defecte.';
Loading