From bd70fec38232b2f447b441276fac1d4d027b96db Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Thu, 18 Apr 2013 01:41:34 +0200 Subject: [PATCH] Language administration overhaul --- .../install/files/acp/js/WCF.ACP.Language.js | 129 ++++++++++++++ .../files/acp/templates/languageAdd.tpl | 113 +++++-------- .../files/acp/templates/languageImport.tpl | 72 ++++++++ .../acp/templates/languageItemEditDialog.tpl | 31 ++++ .../files/acp/templates/languageItemList.tpl | 119 +++++++++++++ .../files/acp/templates/languageList.tpl | 27 +-- .../files/acp/templates/languageServerAdd.tpl | 2 +- .../lib/acp/form/LanguageAddForm.class.php | 160 ++++++------------ .../lib/acp/form/LanguageEditForm.class.php | 97 +++++++++++ .../lib/acp/form/LanguageImportForm.class.php | 140 +++++++++++++++ .../acp/page/LanguageItemListPage.class.php | 142 ++++++++++++++++ .../item/LanguageItemAction.class.php | 75 ++++++++ wcfsetup/install/lang/de.xml | 18 +- wcfsetup/install/lang/en.xml | 23 ++- 14 files changed, 934 insertions(+), 214 deletions(-) create mode 100644 wcfsetup/install/files/acp/js/WCF.ACP.Language.js create mode 100644 wcfsetup/install/files/acp/templates/languageImport.tpl create mode 100644 wcfsetup/install/files/acp/templates/languageItemEditDialog.tpl create mode 100644 wcfsetup/install/files/acp/templates/languageItemList.tpl create mode 100644 wcfsetup/install/files/lib/acp/form/LanguageEditForm.class.php create mode 100644 wcfsetup/install/files/lib/acp/form/LanguageImportForm.class.php create mode 100644 wcfsetup/install/files/lib/acp/page/LanguageItemListPage.class.php diff --git a/wcfsetup/install/files/acp/js/WCF.ACP.Language.js b/wcfsetup/install/files/acp/js/WCF.ACP.Language.js new file mode 100644 index 0000000000..e36abfda0f --- /dev/null +++ b/wcfsetup/install/files/acp/js/WCF.ACP.Language.js @@ -0,0 +1,129 @@ +/** + * ACP Language related classes. + * + * @author Marcel Werk + * @copyright 2001-2013 WoltLab GmbH + * @license GNU Lesser General Public License + */ +WCF.ACP.Language = { }; + +/** + * Handles language item list management. + */ +WCF.ACP.Language.ItemList = Class.extend({ + /** + * action proxy + * @var WCF.Action.Proxy + */ + _proxy: null, + + /** + * dialog overlay + * @var jQuery + */ + _dialog: null, + + /** + * notification object + * @var WCF.System.Notification + */ + _notification: null, + + /** + * Initializes the WCF.ACP.Style.List class. + */ + init: function() { + this._proxy = new WCF.Action.Proxy({ + success: $.proxy(this._success, this) + }); + + $('.jsLanguageItem').each($.proxy(function(index, button) { + var $button = $(button); + var $languageItemID = $button.data('languageItemID'); + + var self = this; + $button.click(function() { self._click($languageItemID); }); + }, this)); + }, + + /** + * Executes actions. + * + * @param integer languageItemID + */ + _click: function(languageItemID) { + this._proxy.setOption('data', { + actionName: 'prepareEdit', + className: 'wcf\\data\\language\\item\\LanguageItemAction', + objectIDs: [ languageItemID ] + }); + this._proxy.sendRequest(); + }, + + /** + * Handles successful AJAX requests. + * + * @param object data + * @param string textStatus + * @param jQuery jqXHR + */ + _success: function(data, textStatus, jqXHR) { + if (data.returnValues) { + // display template + this._showDialog(data.returnValues.template, data.returnValues.languageItem); + + // bind event listener + this._dialog.find('.jsSubmitLanguageItem').click($.proxy(this._submit, this)); + } + else { + if (this._notification === null) { + this._notification = new WCF.System.Notification(WCF.Language.get('wcf.global.success.edit')); + } + + // show success and close dialog + this._dialog.wcfDialog('close'); + this._notification.show(); + } + }, + + /** + * Displays the dialog overlay. + * + * @param string template + * @param string itemName + */ + _showDialog: function(template, itemName) { + if (this._dialog === null) { + this._dialog = $('#languageItemEdit'); + if (!this._dialog.length) { + this._dialog = $('
').hide().appendTo(document.body); + } + } + + this._dialog.html(template).wcfDialog({ + title: itemName + }).wcfDialog('render'); + }, + + /** + * Submits the form. + */ + _submit: function() { + var $languageItemValue = $('#overlayLanguageItemValue').val(); + var $languageCustomItemValue = $('#overlayLanguageCustomItemValue').val(); + var $languageUseCustomValue = ($('#overlayLanguageUseCustomValue').is(':checked') ? 1 : 0); + var $languageItemID = $('#overlayLanguageItemID').val(); + + this._proxy.setOption('data', { + actionName: 'edit', + className: 'wcf\\data\\language\\item\\LanguageItemAction', + objectIDs: [ $languageItemID ], + parameters: { + languageItemValue: $languageItemValue, + languageCustomItemValue: $languageCustomItemValue, + languageUseCustomValue: $languageUseCustomValue + } + }); + this._proxy.sendRequest(); + } +}); diff --git a/wcfsetup/install/files/acp/templates/languageAdd.tpl b/wcfsetup/install/files/acp/templates/languageAdd.tpl index b9d8875052..8e2c0a279f 100644 --- a/wcfsetup/install/files/acp/templates/languageAdd.tpl +++ b/wcfsetup/install/files/acp/templates/languageAdd.tpl @@ -1,17 +1,8 @@ -{include file='header' pageTitle='wcf.acp.language.add'} - - +{include file='header' pageTitle="wcf.acp.language.$action"}
-

{lang}wcf.acp.language.add{/lang}

+

{lang}wcf.acp.language.{@$action}{/lang}

@@ -20,80 +11,49 @@ {/if} {if $success|isset} -

{lang}wcf.global.success.add{/lang}

+

{lang}wcf.global.success.{@$action}{/lang}

{/if} -
+
- {lang}wcf.acp.language.add.mode{/lang} - -
-
- - -
-
- - {event name='modeFields'} -
- -
- {lang}wcf.acp.language.import.source{/lang} + {lang}wcf.global.form.data{/lang} - -
+ +
- - {if $errorField == 'languageFile'} + + {if $errorField == 'languageName'} {if $errorType == 'empty'} - {lang}wcf.global.error.empty{/lang} + {lang}wcf.global.form.error.empty{/lang} {else} - {lang}wcf.acp.language.import.error{/lang} {$errorType} + {lang}wcf.acp.language.add.languageName.error.{@$errorType}{/lang} {/if} {/if} - {lang}wcf.acp.language.import.source.file.description{/lang} -
- - - -
-
- - {if $errorField == 'languageUpload'} - - {lang}wcf.acp.language.import.error{/lang} {$errorType} - - {/if} + {lang}wcf.acp.language.name.description{/lang}
- {event name='importFields'} -
- -
- {lang}wcf.acp.language.add.new{/lang} -
- + {if $errorField == 'languageCode'} {if $errorType == 'empty'} - {lang}wcf.global.error.empty{/lang} + {lang}wcf.global.form.error.empty{/lang} {else} {lang}wcf.acp.language.add.languageCode.error.{@$errorType}{/lang} {/if} @@ -103,27 +63,30 @@
- -
-
- - {if $errorField == 'sourceLanguageID'} - - {if $errorType == 'empty'} - {lang}wcf.global.error.empty{/lang} - {else} - {lang}wcf.acp.language.add.source.error.{@$errorType}{/lang} - {/if} - - {/if} -
- + {if $action == 'add'} + +
+
+ + {if $errorField == 'sourceLanguageID'} + + {if $errorType == 'empty'} + {lang}wcf.global.form.error.empty{/lang} + {else} + {lang}wcf.acp.language.add.source.error.{@$errorType}{/lang} + {/if} + + {/if} + {lang}wcf.acp.language.add.source.description{/lang} +
+ + {/if} - {event name='copyFields'} + {event name='fields'}
{event name='fieldsets'} diff --git a/wcfsetup/install/files/acp/templates/languageImport.tpl b/wcfsetup/install/files/acp/templates/languageImport.tpl new file mode 100644 index 0000000000..8ba6bd42e5 --- /dev/null +++ b/wcfsetup/install/files/acp/templates/languageImport.tpl @@ -0,0 +1,72 @@ +{include file='header' pageTitle='wcf.acp.language.import'} + +
+
+

{lang}wcf.acp.language.import{/lang}

+
+
+ +{if $errorField} +

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

+{/if} + +{if $success|isset} +

{lang}wcf.global.success.add{/lang}

+{/if} + +
+ +
+ + +
+
+ {lang}wcf.global.form.data{/lang} + + +
+
+ + {if $errorField == 'languageFile'} + + {if $errorType == 'empty'} + {lang}wcf.global.form.error.empty{/lang} + {else} + {lang}wcf.acp.language.import.error{/lang} {$errorType} + {/if} + + {/if} + {lang}wcf.acp.language.import.source.file.description{/lang} +
+ + + +
+
+ + {if $errorField == 'languageUpload'} + + {lang}wcf.acp.language.import.error{/lang} {$errorType} + + {/if} +
+ + + {event name='fields'} +
+ + {event name='fieldsets'} +
+ +
+ +
+ + +{include file='footer'} diff --git a/wcfsetup/install/files/acp/templates/languageItemEditDialog.tpl b/wcfsetup/install/files/acp/templates/languageItemEditDialog.tpl new file mode 100644 index 0000000000..77d904f4e0 --- /dev/null +++ b/wcfsetup/install/files/acp/templates/languageItemEditDialog.tpl @@ -0,0 +1,31 @@ +
+ + +
+
+ +
+
+
+ +{if $item->languageItemOriginIsSystem} +
+ + +
+
+ +
+
+ +
+
+
+
+{/if} + + + +
+ +
\ No newline at end of file diff --git a/wcfsetup/install/files/acp/templates/languageItemList.tpl b/wcfsetup/install/files/acp/templates/languageItemList.tpl new file mode 100644 index 0000000000..9a22112eae --- /dev/null +++ b/wcfsetup/install/files/acp/templates/languageItemList.tpl @@ -0,0 +1,119 @@ +{include file='header' pageTitle="wcf.acp.language.item.list"} + + + + +
+
+

{lang}wcf.acp.language.item.list{/lang}

+
+
+ +
+
+
+ {lang}wcf.acp.language.item.list.filter{/lang} + +
+
+
+ +
+
+ +
+
+
+ +
+
+ +
+
+
+ +
+
+ +
+
+
+ +
+
+ +
+
+ +
+
+
+
+ +
+ +
+
+ +
+ {hascontent} + + {/hascontent} +
+ +{if $objects|count} +
+
    + {foreach from=$objects item=item} +
  1. +
    +
    +
    +

    {$item->languageItem}{if $item->languageCustomItemValue} {/if}

    +
    + +

    {if $item->languageUseCustomValue}{$item->languageCustomItemValue|truncate:255}{else}{$item->languageItemValue|truncate:255}{/if}

    +
    +
    +
  2. + {/foreach} +
+
+ +
+ {hascontent} + + {/hascontent} +
+{else} +

{lang}wcf.acp.language.item.noItems{/lang}

+{/if} + +{include file='footer'} diff --git a/wcfsetup/install/files/acp/templates/languageList.tpl b/wcfsetup/install/files/acp/templates/languageList.tpl index 3aa206bc87..39d7d1f020 100644 --- a/wcfsetup/install/files/acp/templates/languageList.tpl +++ b/wcfsetup/install/files/acp/templates/languageList.tpl @@ -7,21 +7,10 @@ new WCF.Action.SimpleProxy({ action: 'setAsDefault', className: 'wcf\\data\\language\\LanguageAction', - elements: $('.jsLanguageRow .setAsDefaultButton') + elements: $('.jsLanguageRow .jsSetAsDefaultButton') }, { success: function(data, statusText, jqXHR) { - $('.jsLanguageRow').each(function(index, row) { - var $button = $(row).find('.jsSetAsDefaultButton'); - - if (WCF.inArray($($button).data('objectID'), data.objectIDs)) { - $($button).attr('src', '{@$__wcf->getPath()}icon/default.svg'); - $(row).find('.jsDeleteButton').attr('src', '{@$__wcf->getPath()}icon/delete.svg'); - } - else { - $($button).attr('src', '{@$__wcf->getPath()}icon/default1.svg'); - $(row).find('.jsDeleteButton').attr('src', '{@$__wcf->getPath()}icon/delete.svg'); - } - }); + window.location.reload(); } }); }); @@ -39,7 +28,8 @@