From e2e8c155da8b54690190c4d96a87f4c30e64fe78 Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Mon, 24 Aug 2020 01:01:43 +0200 Subject: [PATCH] Template plugin for the assignment of language variables in javascript code Closes #3530 --- .../templates/__commentJavaScript.tpl | 22 +-- .../templates/__labelFormField.tpl | 4 +- .../templates/__messageFormPoll.tpl | 4 +- .../templates/__messageFormPollInline.tpl | 10 +- .../templates/__messageQuoteManager.tpl | 16 +- .../__multipleSelectionFormField.tpl | 14 +- .../templates/__pollOptionsFormField.tpl | 6 +- .../templates/__singleSelectionFormField.tpl | 14 +- .../__wysiwygAttachmentFormField.tpl | 22 +-- .../templates/__wysiwygCmsToolbar.tpl | 20 +- .../templates/__wysiwygPreviewFormButton.tpl | 2 +- com.woltlab.wcf/templates/aclPermissions.tpl | 12 +- com.woltlab.wcf/templates/article.tpl | 4 +- com.woltlab.wcf/templates/articleAdd.tpl | 10 +- .../templates/articleAddDialog.tpl | 2 +- com.woltlab.wcf/templates/articleList.tpl | 4 +- com.woltlab.wcf/templates/avatarEdit.tpl | 12 +- .../templates/boxRecentActivity.tpl | 4 +- .../templates/categoryArticleList.tpl | 6 +- com.woltlab.wcf/templates/codeMetaCode.tpl | 4 +- .../templates/fontAwesomeJavaScript.tpl | 8 +- .../templates/googleMapsJavaScript.tpl | 28 +-- com.woltlab.wcf/templates/groupedUserList.tpl | 10 +- .../templates/groupedUserReactionList.tpl | 10 +- com.woltlab.wcf/templates/headInclude.tpl | 2 +- .../templates/headIncludeJavaScript.tpl | 172 +++++++++--------- com.woltlab.wcf/templates/imageViewer.tpl | 18 +- com.woltlab.wcf/templates/mediaJavaScript.tpl | 44 ++--- com.woltlab.wcf/templates/membersList.tpl | 8 +- .../templates/messageFormAttachments.tpl | 22 +-- .../templates/messageFormPreviewButton.tpl | 4 +- .../templates/moderationActivation.tpl | 14 +- .../templates/moderationReport.tpl | 18 +- .../multipleLanguageInputJavascript.tpl | 2 +- .../templates/notificationList.tpl | 4 +- .../templates/notificationSettings.tpl | 6 +- com.woltlab.wcf/templates/pageHeaderUser.tpl | 6 +- .../templates/recentActivities.tpl | 4 +- .../templates/recentActivityList.tpl | 4 +- com.woltlab.wcf/templates/register.tpl | 16 +- .../templates/scrollablePageCheckboxList.tpl | 14 +- com.woltlab.wcf/templates/signatureEdit.tpl | 2 +- com.woltlab.wcf/templates/spoilerMetaCode.tpl | 4 +- com.woltlab.wcf/templates/team.tpl | 8 +- .../templates/unreadArticleList.tpl | 4 +- .../templates/uploadFieldComponent.tpl | 4 +- com.woltlab.wcf/templates/user.tpl | 84 ++++----- .../templates/userBirthdayList.tpl | 8 +- .../templates/userProfileLikes.tpl | 6 +- .../templates/userProfilePreview.tpl | 8 +- com.woltlab.wcf/templates/usersOnlineList.tpl | 8 +- .../templates/watchedArticleList.tpl | 4 +- com.woltlab.wcf/templates/wysiwyg.tpl | 150 +++++++-------- .../files/acp/templates/__boxAddContent.tpl | 10 +- .../files/acp/templates/__boxPipGui.tpl | 4 +- ...vtoolsProjectExcludedPackagesFormField.tpl | 14 +- ..._devtoolsProjectInstallationJavaScript.tpl | 4 +- ...__devtoolsProjectInstructionsFormField.tpl | 24 +-- ...vtoolsProjectOptionalPackagesFormField.tpl | 14 +- ...vtoolsProjectRequiredPackagesFormField.tpl | 14 +- .../files/acp/templates/__labelFormField.tpl | 4 +- .../files/acp/templates/__menuPipGui.tpl | 4 +- .../acp/templates/__messageQuoteManager.tpl | 16 +- .../__multipleSelectionFormField.tpl | 14 +- .../acp/templates/__objectTypePipGui.tpl | 6 +- .../acp/templates/__optionEmailSmtpTest.tpl | 14 +- .../acp/templates/__optionRewriteRules.tpl | 6 +- .../acp/templates/__optionRewriteTest.tpl | 6 +- .../files/acp/templates/__pageAddContent.tpl | 10 +- .../acp/templates/__pollOptionsFormField.tpl | 6 +- .../templates/__singleSelectionFormField.tpl | 14 +- .../__wysiwygAttachmentFormField.tpl | 22 +-- .../acp/templates/__wysiwygCmsToolbar.tpl | 20 +- .../templates/__wysiwygPreviewFormButton.tpl | 2 +- .../files/acp/templates/aclPermissions.tpl | 12 +- .../files/acp/templates/articleAdd.tpl | 10 +- .../files/acp/templates/articleAddDialog.tpl | 2 +- .../files/acp/templates/articleList.tpl | 6 +- .../install/files/acp/templates/boxAdd.tpl | 14 +- .../files/acp/templates/boxAddDialog.tpl | 2 +- .../files/acp/templates/cronjobLogList.tpl | 4 +- .../files/acp/templates/dataImport.tpl | 6 +- .../templates/devtoolsNotificationTest.tpl | 2 +- .../templates/devtoolsProjectPipEntryList.tpl | 6 +- .../acp/templates/devtoolsProjectSync.tpl | 4 +- .../acp/templates/fontAwesomeJavaScript.tpl | 8 +- .../install/files/acp/templates/header.tpl | 148 +++++++-------- .../files/acp/templates/imageViewer.tpl | 18 +- .../files/acp/templates/languageItemList.tpl | 2 +- .../files/acp/templates/mediaJavaScript.tpl | 44 ++--- .../install/files/acp/templates/mediaList.tpl | 4 +- .../files/acp/templates/menuItemAdd.tpl | 12 +- .../multipleLanguageInputJavascript.tpl | 2 +- .../templates/notificationPresetSettings.tpl | 6 +- .../install/files/acp/templates/package.tpl | 2 +- .../templates/packageInstallationConfirm.tpl | 8 +- .../templates/packageInstallationSetup.tpl | 2 +- .../files/acp/templates/packageList.tpl | 14 +- .../acp/templates/packageStartInstall.tpl | 4 +- .../files/acp/templates/packageUpdate.tpl | 6 +- .../install/files/acp/templates/pageAdd.tpl | 16 +- .../files/acp/templates/pageAddDialog.tpl | 2 +- .../files/acp/templates/pageBoxOrder.tpl | 4 +- .../templates/pluginStorePurchasedItems.tpl | 8 +- .../templates/scrollablePageCheckboxList.tpl | 14 +- wcfsetup/install/files/acp/templates/stat.tpl | 10 +- .../install/files/acp/templates/styleAdd.tpl | 12 +- .../files/acp/templates/templateGroupAdd.tpl | 12 +- .../install/files/acp/templates/trophyAdd.tpl | 18 +- .../acp/templates/uploadFieldComponent.tpl | 4 +- .../acp/templates/userActivityPointOption.tpl | 4 +- .../install/files/acp/templates/userAdd.tpl | 12 +- .../files/acp/templates/userGroupAdd.tpl | 14 +- .../install/files/acp/templates/userList.tpl | 24 +-- .../install/files/acp/templates/userMail.tpl | 2 +- .../install/files/acp/templates/wysiwyg.tpl | 150 +++++++-------- .../install/files/lib/system/WCF.class.php | 4 +- .../JslangCompilerTemplatePlugin.class.php | 41 +++++ .../JslangPrefilterTemplatePlugin.class.php | 41 +++++ 119 files changed, 973 insertions(+), 891 deletions(-) create mode 100644 wcfsetup/install/files/lib/system/template/plugin/JslangCompilerTemplatePlugin.class.php create mode 100644 wcfsetup/install/files/lib/system/template/plugin/JslangPrefilterTemplatePlugin.class.php diff --git a/com.woltlab.wcf/templates/__commentJavaScript.tpl b/com.woltlab.wcf/templates/__commentJavaScript.tpl index 3e6d952a8a..aa34a48960 100644 --- a/com.woltlab.wcf/templates/__commentJavaScript.tpl +++ b/com.woltlab.wcf/templates/__commentJavaScript.tpl @@ -1,17 +1,17 @@ diff --git a/com.woltlab.wcf/templates/__wysiwygPreviewFormButton.tpl b/com.woltlab.wcf/templates/__wysiwygPreviewFormButton.tpl index 6501f1538e..d61999dfcd 100644 --- a/com.woltlab.wcf/templates/__wysiwygPreviewFormButton.tpl +++ b/com.woltlab.wcf/templates/__wysiwygPreviewFormButton.tpl @@ -7,7 +7,7 @@ \ No newline at end of file + diff --git a/com.woltlab.wcf/templates/article.tpl b/com.woltlab.wcf/templates/article.tpl index 0f9968fc49..f4f44b5078 100644 --- a/com.woltlab.wcf/templates/article.tpl +++ b/com.woltlab.wcf/templates/article.tpl @@ -375,8 +375,8 @@ \ No newline at end of file + diff --git a/com.woltlab.wcf/templates/groupedUserReactionList.tpl b/com.woltlab.wcf/templates/groupedUserReactionList.tpl index 25a5a5d0c2..e55095362c 100644 --- a/com.woltlab.wcf/templates/groupedUserReactionList.tpl +++ b/com.woltlab.wcf/templates/groupedUserReactionList.tpl @@ -24,13 +24,13 @@ \ No newline at end of file + diff --git a/com.woltlab.wcf/templates/headInclude.tpl b/com.woltlab.wcf/templates/headInclude.tpl index f54caa9768..744e17f52c 100644 --- a/com.woltlab.wcf/templates/headInclude.tpl +++ b/com.woltlab.wcf/templates/headInclude.tpl @@ -14,7 +14,7 @@ {assign var=__imageViewerLoaded value=true} -{/if} \ No newline at end of file +{/if} diff --git a/com.woltlab.wcf/templates/mediaJavaScript.tpl b/com.woltlab.wcf/templates/mediaJavaScript.tpl index 609991a1bf..b9016db077 100644 --- a/com.woltlab.wcf/templates/mediaJavaScript.tpl +++ b/com.woltlab.wcf/templates/mediaJavaScript.tpl @@ -1,28 +1,28 @@ {if $__wcf->session->getPermission('admin.content.cms.canUseMedia')} require(['Language', 'Permission'], function(Language, Permission) { Language.addObject({ - 'wcf.global.button.insert': '{lang}wcf.global.button.insert{/lang}', - 'wcf.media.button.replaceFile': '{lang}wcf.media.button.replaceFile{/lang}', - 'wcf.media.button.select': '{lang}wcf.media.button.select{/lang}', - 'wcf.media.delete.confirmMessage': '{lang __encode=true __literal=true}wcf.media.delete.confirmMessage{/lang}', - 'wcf.media.imageDimensions.value': '{lang __literal=true}wcf.media.imageDimensions.value{/lang}', - 'wcf.media.insert': '{lang}wcf.media.insert{/lang}', - 'wcf.media.insert.imageSize': '{lang}wcf.media.insert.imageSize{/lang}', - 'wcf.media.insert.imageSize.small': '{lang}wcf.media.insert.imageSize.small{/lang}', - 'wcf.media.insert.imageSize.medium': '{lang}wcf.media.insert.imageSize.medium{/lang}', - 'wcf.media.insert.imageSize.large': '{lang}wcf.media.insert.imageSize.large{/lang}', - 'wcf.media.insert.imageSize.original': '{lang}wcf.media.insert.imageSize.original{/lang}', - 'wcf.media.manager': '{lang}wcf.media.manager{/lang}', - 'wcf.media.edit': '{lang}wcf.media.edit{/lang}', - 'wcf.media.button.insert': '{lang}wcf.media.button.insert{/lang}', - 'wcf.media.search.info.searchStringThreshold': '{lang __literal=true}wcf.media.search.info.searchStringThreshold{/lang}', - 'wcf.media.search.noResults': '{lang}wcf.media.search.noResults{/lang}', - 'wcf.media.upload.error.differentFileExtension': '{lang}wcf.media.upload.error.differentFileExtension{/lang}', - 'wcf.media.upload.error.differentFileType': '{lang}wcf.media.upload.error.differentFileType{/lang}', - 'wcf.media.upload.error.noImage': '{lang}wcf.media.upload.error.noImage{/lang}', - 'wcf.media.upload.error.uploadFailed': '{lang}wcf.media.upload.error.uploadFailed{/lang}', - 'wcf.media.upload.success': '{lang}wcf.media.upload.success{/lang}', - 'wcf.media.setCategory': '{lang}wcf.media.setCategory{/lang}' + 'wcf.global.button.insert': '{jslang}wcf.global.button.insert{/jslang}', + 'wcf.media.button.replaceFile': '{jslang}wcf.media.button.replaceFile{/jslang}', + 'wcf.media.button.select': '{jslang}wcf.media.button.select{/jslang}', + 'wcf.media.delete.confirmMessage': '{jslang __encode=true __literal=true}wcf.media.delete.confirmMessage{/jslang}', + 'wcf.media.imageDimensions.value': '{jslang __literal=true}wcf.media.imageDimensions.value{/jslang}', + 'wcf.media.insert': '{jslang}wcf.media.insert{/jslang}', + 'wcf.media.insert.imageSize': '{jslang}wcf.media.insert.imageSize{/jslang}', + 'wcf.media.insert.imageSize.small': '{jslang}wcf.media.insert.imageSize.small{/jslang}', + 'wcf.media.insert.imageSize.medium': '{jslang}wcf.media.insert.imageSize.medium{/jslang}', + 'wcf.media.insert.imageSize.large': '{jslang}wcf.media.insert.imageSize.large{/jslang}', + 'wcf.media.insert.imageSize.original': '{jslang}wcf.media.insert.imageSize.original{/jslang}', + 'wcf.media.manager': '{jslang}wcf.media.manager{/jslang}', + 'wcf.media.edit': '{jslang}wcf.media.edit{/jslang}', + 'wcf.media.button.insert': '{jslang}wcf.media.button.insert{/jslang}', + 'wcf.media.search.info.searchStringThreshold': '{jslang __literal=true}wcf.media.search.info.searchStringThreshold{/jslang}', + 'wcf.media.search.noResults': '{jslang}wcf.media.search.noResults{/jslang}', + 'wcf.media.upload.error.differentFileExtension': '{jslang}wcf.media.upload.error.differentFileExtension{/jslang}', + 'wcf.media.upload.error.differentFileType': '{jslang}wcf.media.upload.error.differentFileType{/jslang}', + 'wcf.media.upload.error.noImage': '{jslang}wcf.media.upload.error.noImage{/jslang}', + 'wcf.media.upload.error.uploadFailed': '{jslang}wcf.media.upload.error.uploadFailed{/jslang}', + 'wcf.media.upload.success': '{jslang}wcf.media.upload.success{/jslang}', + 'wcf.media.setCategory': '{jslang}wcf.media.setCategory{/jslang}' }); Permission.add('admin.content.cms.canManageMedia', {if $__wcf->session->getPermission('admin.content.cms.canManageMedia')}true{else}false{/if}); diff --git a/com.woltlab.wcf/templates/membersList.tpl b/com.woltlab.wcf/templates/membersList.tpl index cc0f1a0c6a..9fc6744d36 100644 --- a/com.woltlab.wcf/templates/membersList.tpl +++ b/com.woltlab.wcf/templates/membersList.tpl @@ -133,10 +133,10 @@ \ No newline at end of file + diff --git a/com.woltlab.wcf/templates/moderationActivation.tpl b/com.woltlab.wcf/templates/moderationActivation.tpl index d819d9f673..4c1bd05f0c 100644 --- a/com.woltlab.wcf/templates/moderationActivation.tpl +++ b/com.woltlab.wcf/templates/moderationActivation.tpl @@ -80,13 +80,13 @@ \ No newline at end of file + diff --git a/wcfsetup/install/files/acp/templates/__optionEmailSmtpTest.tpl b/wcfsetup/install/files/acp/templates/__optionEmailSmtpTest.tpl index 6a22dc1a4a..d591f5266a 100644 --- a/wcfsetup/install/files/acp/templates/__optionEmailSmtpTest.tpl +++ b/wcfsetup/install/files/acp/templates/__optionEmailSmtpTest.tpl @@ -2,13 +2,13 @@ diff --git a/wcfsetup/install/files/acp/templates/__wysiwygPreviewFormButton.tpl b/wcfsetup/install/files/acp/templates/__wysiwygPreviewFormButton.tpl index 6501f1538e..d61999dfcd 100644 --- a/wcfsetup/install/files/acp/templates/__wysiwygPreviewFormButton.tpl +++ b/wcfsetup/install/files/acp/templates/__wysiwygPreviewFormButton.tpl @@ -7,7 +7,7 @@ \ No newline at end of file + diff --git a/wcfsetup/install/files/acp/templates/articleAdd.tpl b/wcfsetup/install/files/acp/templates/articleAdd.tpl index e7bec299fb..962ee2d86b 100644 --- a/wcfsetup/install/files/acp/templates/articleAdd.tpl +++ b/wcfsetup/install/files/acp/templates/articleAdd.tpl @@ -52,10 +52,10 @@ {assign var=__imageViewerLoaded value=true} -{/if} \ No newline at end of file +{/if} diff --git a/wcfsetup/install/files/acp/templates/languageItemList.tpl b/wcfsetup/install/files/acp/templates/languageItemList.tpl index f2da135f2d..f037ff9153 100644 --- a/wcfsetup/install/files/acp/templates/languageItemList.tpl +++ b/wcfsetup/install/files/acp/templates/languageItemList.tpl @@ -3,7 +3,7 @@