From b6348a7ee7e99005b905de91b0e41ea231f1f708 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Wed, 28 Sep 2011 09:25:07 +0200 Subject: [PATCH] Makes form errors more customizable for plugins See http://www.woltlab.com/bugtracker/index.php?page=Bug&bugID=1496 --- .../files/acp/templates/cronjobAdd.tpl | 17 +++++++----- .../install/files/acp/templates/login.tpl | 19 +++++++++----- .../files/acp/templates/masterPassword.tpl | 7 +++-- .../acp/templates/masterPasswordInit.tpl | 14 +++++++--- .../files/acp/templates/optionImport.tpl | 8 +++--- .../acp/templates/packageStartInstall.tpl | 21 +++++++-------- .../files/acp/templates/updateServerAdd.tpl | 7 +++-- .../install/files/acp/templates/userAdd.tpl | 26 ++++++++++++------- .../files/acp/templates/userGroupAdd.tpl | 6 ++++- .../install/files/acp/templates/userMail.tpl | 24 ++++++++++++++--- 10 files changed, 99 insertions(+), 50 deletions(-) diff --git a/wcfsetup/install/files/acp/templates/cronjobAdd.tpl b/wcfsetup/install/files/acp/templates/cronjobAdd.tpl index 20903dc849..2024f86043 100644 --- a/wcfsetup/install/files/acp/templates/cronjobAdd.tpl +++ b/wcfsetup/install/files/acp/templates/cronjobAdd.tpl @@ -40,8 +40,11 @@ {if $errorField == 'className'} - {if $errorType == 'empty'}{lang}wcf.global.form.error.empty{/lang}{/if} - {if $errorType == 'doesNotExist'}{lang}wcf.acp.cronjob.error.className.doesNotExist{/lang}{/if} + {if $errorType == 'empty'} + {lang}wcf.global.form.error.empty{/lang} + {else} + {lang}wcf.acp.cronjob.error.className.{@$errorType}{/lang} + {/if} {/if} {lang}wcf.acp.cronjob.className.description{/lang} @@ -67,7 +70,7 @@ {if $errorField == 'startMinute'} - {if $errorType == 'notValid'}{lang}wcf.acp.cronjob.error.timing.notValid{/lang}{/if} + {lang}wcf.acp.cronjob.error.timing.{@$errorType}{/lang} {/if} {lang}wcf.acp.cronjob.startMinute.description{/lang} @@ -81,7 +84,7 @@ {if $errorField == 'startHour'} - {if $errorType == 'notValid'}{lang}wcf.acp.cronjob.error.timing.notValid{/lang}{/if} + {lang}wcf.acp.cronjob.error.timing.{@$errorType}{/lang} {/if} {lang}wcf.acp.cronjob.startHour.description{/lang} @@ -95,7 +98,7 @@ {if $errorField == 'startDom'} - {if $errorType == 'notValid'}{lang}wcf.acp.cronjob.error.timing.notValid{/lang}{/if} + {lang}wcf.acp.cronjob.error.timing.{@$errorType}{/lang} {/if} {lang}wcf.acp.cronjob.startDom.description{/lang} @@ -109,7 +112,7 @@ {if $errorField == 'startMonth'} - {if $errorType == 'notValid'}{lang}wcf.acp.cronjob.error.timing.notValid{/lang}{/if} + {lang}wcf.acp.cronjob.error.timing.{@$errorType}{/lang} {/if} {lang}wcf.acp.cronjob.startMonth.description{/lang} @@ -123,7 +126,7 @@ {if $errorField == 'startDow'} - {if $errorType == 'notValid'}{lang}wcf.acp.cronjob.error.timing.notValid{/lang}{/if} + {lang}wcf.acp.cronjob.error.timing.{@$errorType}{/lang} {/if} {lang}wcf.acp.cronjob.startDow.description{/lang} diff --git a/wcfsetup/install/files/acp/templates/login.tpl b/wcfsetup/install/files/acp/templates/login.tpl index 939b4b722a..c59782dfc6 100644 --- a/wcfsetup/install/files/acp/templates/login.tpl +++ b/wcfsetup/install/files/acp/templates/login.tpl @@ -14,7 +14,7 @@ -{if $errorField != ''} +{if $errorField}

{lang}wcf.global.form.error{/lang}

{/if} @@ -27,8 +27,12 @@
{if $errorField == 'username'} - {if $errorType == 'empty'}{lang}wcf.global.form.error.empty{/lang}{/if} - {if $errorType == 'notFound'}{lang}wcf.user.error.username.notFound{/lang}{/if} + + {if $errorType == 'empty'} + {lang}wcf.global.form.error.empty{/lang} + {else} + {lang}wcf.user.error.username.{@$errorType}{/lang} + {/if} {/if}
@@ -39,9 +43,12 @@
{if $errorField == 'password'} - - {if $errorType == 'empty'}{lang}wcf.global.form.error.empty{/lang}{/if} - {if $errorType == 'false'}{lang}wcf.user.error.password.false{/lang}{/if} + + {if $errorType == 'empty'} + {lang}wcf.global.form.error.empty{/lang} + {else} + {lang}wcf.user.error.password.{@$errorType}{/lang} + {/if} {/if}
diff --git a/wcfsetup/install/files/acp/templates/masterPassword.tpl b/wcfsetup/install/files/acp/templates/masterPassword.tpl index 0506a35824..89ddf8fb7c 100644 --- a/wcfsetup/install/files/acp/templates/masterPassword.tpl +++ b/wcfsetup/install/files/acp/templates/masterPassword.tpl @@ -24,8 +24,11 @@ {if $errorField == 'masterPassword'} - {if $errorType == 'empty'}{lang}wcf.global.form.error.empty{/lang}{/if} - {if $errorType == 'invalid'}{lang}wcf.acp.masterPassword.error.invalid{/lang}{/if} + {if $errorType == 'empty'} + {lang}wcf.global.form.error.empty{/lang} + {else} + {lang}wcf.acp.masterPassword.error.{@$errorType}{/lang} + {/if} {/if} {lang}wcf.acp.masterPassword.enter.description{/lang} diff --git a/wcfsetup/install/files/acp/templates/masterPasswordInit.tpl b/wcfsetup/install/files/acp/templates/masterPasswordInit.tpl index 87f2b86122..72599b54c7 100644 --- a/wcfsetup/install/files/acp/templates/masterPasswordInit.tpl +++ b/wcfsetup/install/files/acp/templates/masterPasswordInit.tpl @@ -36,8 +36,11 @@ {if $errorField == 'masterPassword'} - {if $errorType == 'empty'}{lang}wcf.global.form.error.empty{/lang}{/if} - {if $errorType == 'notSecure'}{lang}wcf.acp.masterPassword.error.notSecure{/lang}{/if} + {if $errorType == 'empty'} + {lang}wcf.global.form.error.empty{/lang} + {else} + {lang}wcf.acp.masterPassword.error.{@$errorType}{/lang} + {/if} {/if} {lang}wcf.acp.masterPassword.init.description{/lang} @@ -51,8 +54,11 @@ {if $errorField == 'confirmMasterPassword'} - {if $errorType == 'empty'}{lang}wcf.global.form.error.empty{/lang}{/if} - {if $errorType == 'notEqual'}{lang}wcf.acp.masterPassword.error.notEqual{/lang}{/if} + {if $errorType == 'empty'} + {lang}wcf.global.form.error.empty{/lang} + {else} + {lang}wcf.acp.masterPassword.error.{@$errorType}{/lang} + {/if} {/if} diff --git a/wcfsetup/install/files/acp/templates/optionImport.tpl b/wcfsetup/install/files/acp/templates/optionImport.tpl index f5c3109244..603e16078c 100644 --- a/wcfsetup/install/files/acp/templates/optionImport.tpl +++ b/wcfsetup/install/files/acp/templates/optionImport.tpl @@ -28,9 +28,11 @@ {if $errorField == 'optionImport'} - {if $errorType == 'empty'}{lang}wcf.global.form.error.empty{/lang}{/if} - {if $errorType == 'importFailed'}{lang}wcf.acp.option.import.error.importFailed{/lang}{/if} - {if $errorType == 'uploadFailed'}{lang}wcf.acp.option.import.error.uploadFailed{/lang}{/if} + {if $errorType == 'empty'} + {lang}wcf.global.form.error.empty{/lang} + {else} + {lang}wcf.acp.option.import.error.{@$errorType}{/lang} + {/if} {/if} {lang}wcf.acp.option.import.upload.description{/lang} diff --git a/wcfsetup/install/files/acp/templates/packageStartInstall.tpl b/wcfsetup/install/files/acp/templates/packageStartInstall.tpl index f625074114..86c717e818 100644 --- a/wcfsetup/install/files/acp/templates/packageStartInstall.tpl +++ b/wcfsetup/install/files/acp/templates/packageStartInstall.tpl @@ -40,13 +40,14 @@ {if $errorField == 'uploadPackage'} - {if $errorType == 'empty'}{lang}wcf.global.form.error.empty{/lang}{/if} - {if $errorType == 'noValidPackage'}{lang}wcf.acp.package.startInstall.error.noValidPackage{/lang}{/if} - {if $errorType == 'noValidUpdate'}{lang}wcf.acp.package.startInstall.error.noValidUpdate{/lang}{/if} - {if $errorType == 'noValidInstall'}{lang}wcf.acp.package.startInstall.error.noValidInstall{/lang}{/if} - {if $errorType == 'uploadFailed'}{lang}wcf.acp.package.startInstall.error.uploadFailed{/lang}{/if} - {if $errorType == 'uniqueAlreadyInstalled'}{lang}wcf.acp.package.startInstall.error.uniqueAlreadyInstalled{/lang}{/if} - {if $errorType == 'phpRequirements'}
{$phpRequirements|print_r}
{/if} + {if $errorType == 'empty'} + {lang}wcf.global.form.error.empty{/lang} + {elseif $errorType == 'phpRequirements'} + {* todo: use language variable (-> else) *} +
{$phpRequirements|print_r}
+ {else} + {lang}wcf.acp.package.startInstall.error.{@$errorType}{/lang} + {/if}
{/if} {lang}wcf.acp.package.startInstall.source.upload.description{/lang} @@ -60,11 +61,7 @@ {if $errorField == 'downloadPackage'} - {if $errorType == 'notFound'}{lang}wcf.acp.package.startInstall.error.notFound{/lang}{/if} - {if $errorType == 'noValidPackage'}{lang}wcf.acp.package.startInstall.error.noValidPackage{/lang}{/if} - {if $errorType == 'noValidUpdate'}{lang}wcf.acp.package.startInstall.error.noValidUpdate{/lang}{/if} - {if $errorType == 'noValidInstall'}{lang}wcf.acp.package.startInstall.error.noValidInstall{/lang}{/if} - {if $errorType == 'uniqueAlreadyInstalled'}{lang}wcf.acp.package.startInstall.error.uniqueAlreadyInstalled{/lang}{/if} + {lang}wcf.acp.package.startInstall.error.{@$errorType}{/lang} {/if} {lang}wcf.acp.package.startInstall.source.download.description{/lang} diff --git a/wcfsetup/install/files/acp/templates/updateServerAdd.tpl b/wcfsetup/install/files/acp/templates/updateServerAdd.tpl index 467720a121..677b079579 100644 --- a/wcfsetup/install/files/acp/templates/updateServerAdd.tpl +++ b/wcfsetup/install/files/acp/templates/updateServerAdd.tpl @@ -38,8 +38,11 @@ {if $errorField == 'serverURL'} - {if $errorType == 'empty'}{lang}wcf.global.form.error.empty{/lang}{/if} - {if $errorType == 'notValid'}{lang}wcf.acp.updateServer.serverURL.error.notValid{/lang}{/if} + {if $errorType == 'empty'} + {lang}wcf.global.form.error.empty{/lang} + {else} + {lang}wcf.acp.updateServer.serverURL.error.{@$errorType}{/lang} + {/if} {/if} {lang}wcf.acp.updateServer.serverURL.description{/lang} diff --git a/wcfsetup/install/files/acp/templates/userAdd.tpl b/wcfsetup/install/files/acp/templates/userAdd.tpl index f72eb5f309..c2a22eb116 100644 --- a/wcfsetup/install/files/acp/templates/userAdd.tpl +++ b/wcfsetup/install/files/acp/templates/userAdd.tpl @@ -88,9 +88,11 @@ {if $errorType.username|isset} - {if $errorType.username == 'empty'}{lang}wcf.global.form.error.empty{/lang}{/if} - {if $errorType.username == 'notValid'}{lang}wcf.user.error.username.notValid{/lang}{/if} - {if $errorType.username == 'notUnique'}{lang}wcf.user.error.username.notUnique{/lang}{/if} + {if $errorType.username == 'empty'} + {lang}wcf.global.form.error.empty{/lang} + {else} + {lang}wcf.user.error.username.{@$errorType.username}{/lang} + {/if} {/if} @@ -126,9 +128,11 @@ {if $errorType.email|isset} - {if $errorType.email == 'empty'}{lang}wcf.global.form.error.empty{/lang}{/if} - {if $errorType.email == 'notValid'}{lang}wcf.user.error.email.notValid{/lang}{/if} - {if $errorType.email == 'notUnique'}{lang}wcf.user.error.email.notUnique{/lang}{/if} + {if $errorType.email == 'empty'} + {lang}wcf.global.form.error.empty{/lang} + {else} + {lang}wcf.user.error.email.{@$errorType.email}{/lang} + {/if} {/if} @@ -141,7 +145,7 @@ {if $errorType.confirmEmail|isset} - {if $errorType.confirmEmail == 'notEqual'}{lang}wcf.user.error.confirmEmail.notEqual{/lang}{/if} + {lang}wcf.user.error.confirmEmail.{@$errorType.confirmEmail}{/lang} {/if} @@ -160,7 +164,11 @@ {if $errorType.password|isset} - {if $errorType.password == 'empty'}{lang}wcf.global.form.error.empty{/lang}{/if} + {if $errorType.password == 'empty'} + {lang}wcf.global.form.error.empty{/lang} + {else} + {lang}wcf.user.error.password.{@$errorType.password}{/lang} + {/if} {/if} @@ -173,7 +181,7 @@ {if $errorType.confirmPassword|isset} - {if $errorType.confirmPassword == 'notEqual'}{lang}wcf.user.error.confirmPassword.notEqual{/lang}{/if} + {lang}wcf.user.error.confirmPassword.{@$errorType.confirmPassword}{/lang} {/if} diff --git a/wcfsetup/install/files/acp/templates/userGroupAdd.tpl b/wcfsetup/install/files/acp/templates/userGroupAdd.tpl index 6be83ef450..800507c1ae 100644 --- a/wcfsetup/install/files/acp/templates/userGroupAdd.tpl +++ b/wcfsetup/install/files/acp/templates/userGroupAdd.tpl @@ -53,7 +53,11 @@ {if $errorType.groupName|isset} - {if $errorType.groupName == 'empty'}{lang}wcf.global.form.error.empty{/lang}{/if} + {if $errorType.groupName == 'empty'} + {lang}wcf.global.form.error.empty{/lang} + {else} + {lang}wcf.acp.group.groupName.error.{@$errorType}{/lang} + {/if} {/if} {lang}wcf.acp.group.groupName.description{/lang} diff --git a/wcfsetup/install/files/acp/templates/userMail.tpl b/wcfsetup/install/files/acp/templates/userMail.tpl index e7e31d34a3..c65cd0ddcd 100644 --- a/wcfsetup/install/files/acp/templates/userMail.tpl +++ b/wcfsetup/install/files/acp/templates/userMail.tpl @@ -75,7 +75,11 @@ {if $errorField == 'groupIDs'} - {if $errorType == 'empty'}{lang}wcf.global.form.error.empty{/lang}{/if} + {if $errorType == 'empty'} + {lang}wcf.global.form.error.empty{/lang} + {else} + {lang}wcf.acp.user.sendMail.groups.error.{@$errorType}{/lang} + {/if} {/if} @@ -93,7 +97,11 @@ {if $errorField == 'subject'} - {if $errorType == 'empty'}{lang}wcf.global.form.error.empty{/lang}{/if} + {if $errorType == 'empty'} + {lang}wcf.global.form.error.empty{/lang} + {else} + {lang}wcf.acp.user.sendMail.subject.error.{@$errorType}{/lang} + {/if} {/if} {lang}wcf.acp.user.sendMail.subject.description{/lang} @@ -107,7 +115,11 @@ {if $errorField == 'from'} - {if $errorType == 'empty'}{lang}wcf.global.form.error.empty{/lang}{/if} + {if $errorType == 'empty'} + {lang}wcf.global.form.error.empty{/lang} + {else} + {lang}wcf.acp.user.sendMail.subject.from.{@$errorType}{/lang} + {/if} {/if} {lang}wcf.acp.user.sendMail.from.description{/lang} @@ -121,7 +133,11 @@ {if $errorField == 'text'} - {if $errorType == 'empty'}{lang}wcf.global.form.error.empty{/lang}{/if} + {if $errorType == 'empty'} + {lang}wcf.global.form.error.empty{/lang} + {else} + {lang}wcf.acp.user.sendMail.text.error.{@$errorType}{/lang} + {/if} {/if} {lang}wcf.acp.user.sendMail.text.description{/lang} -- 2.20.1