From 9b0ffe2a9e058d175b6dd1692d86f0810ec7c285 Mon Sep 17 00:00:00 2001 From: Yasuhito FUTATSUKI at POEM Date: Mon, 9 Jul 2018 05:55:17 +0900 Subject: Add language selecter to "HTML Page Editing" page for multi-lang lists Add back link from editing page to editing page selection page --- Mailman/Cgi/edithtml.py | 41 ++++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) (limited to 'Mailman/Cgi') diff --git a/Mailman/Cgi/edithtml.py b/Mailman/Cgi/edithtml.py index 796d8539..45767418 100644 --- a/Mailman/Cgi/edithtml.py +++ b/Mailman/Cgi/edithtml.py @@ -138,6 +138,13 @@ def main(): Auth.loginpage(mlist, 'admin', msg=msg) return + # See if the user want to see this page in other language + language = cgidata.getfirst('language', '') + if language not in mlist.GetAvailableLanguages(): + language = mlist.preferred_language + i18n.set_language(language) + doc.set_language(language) + realname = mlist.real_name if len(parts) > 1: template_name = parts[1] @@ -169,42 +176,62 @@ def main(): return try: - if cgidata.keys(): + if cgidata.keys() and not cgidata.has_key('langform'): if csrf_checked: - ChangeHTML(mlist, cgidata, template_name, doc) + ChangeHTML(mlist, cgidata, template_name, doc, lang=language) else: doc.addError( _('The form lifetime has expired. (request forgery check)')) - FormatHTML(mlist, doc, template_name, template_info) + FormatHTML(mlist, doc, template_name, template_info, lang=language) finally: doc.AddItem(mlist.GetMailmanFooter()) print doc.Format() -def FormatHTML(mlist, doc, template_name, template_info): +def FormatHTML(mlist, doc, template_name, template_info, lang=None): + if lang not in mlist.GetAvailableLanguages(): + lang = mlist.preferred_language + lcset = Utils.GetCharSet(lang) doc.AddItem(Header(1,'%s:' % mlist.real_name)) doc.AddItem(Header(1, template_info)) doc.AddItem('
') link = Link(mlist.GetScriptURL('admin'), _('View or edit the list configuration information.')) + backlink = Link(mlist.GetScriptURL('edithtml'), + _('Edit the public HTML pages and text files')) doc.AddItem(FontSize("+1", link)) + doc.AddItem(FontSize("+1", backlink)) doc.AddItem('

') doc.AddItem('


') + if len(mlist.GetAvailableLanguages()) > 1: + langform = Form(mlist.GetScriptURL('edithtml') + '/' + template_name, + mlist=mlist, contexts=AUTH_CONTEXTS) + langform.AddItem( + mlist.FormatButton('editlang-button', + text = _("Edit this template for"))) + langform.AddItem(mlist.GetLangSelectBox(lang)) + langform.AddItem(Hidden('langform', 'True')) + doc.AddItem(langform) + doc.AddItem('
') form = Form(mlist.GetScriptURL('edithtml') + '/' + template_name, mlist=mlist, contexts=AUTH_CONTEXTS) - text = Utils.maketext(template_name, raw=1, mlist=mlist) + text = Utils.maketext(template_name, raw=1, lang=lang, mlist=mlist) # MAS: Don't websafe twice. TextArea does it. form.AddItem(TextArea('html_code', text, rows=40, cols=75)) form.AddItem('

' + _('When you are done making changes...')) + if lang != mlist.preferred_language: + form.AddItem(Hidden('language', lang)) form.AddItem(SubmitButton('submit', _('Submit Changes'))) doc.AddItem(form) -def ChangeHTML(mlist, cgi_info, template_name, doc): +def ChangeHTML(mlist, cgi_info, template_name, doc, lang=None): + if lang not in mlist.GetAvailableLanguages(): + lang = mlist.preferred_language if not cgi_info.has_key('html_code'): doc.AddItem(Header(3,_("Can't have empty html page."))) doc.AddItem(Header(3,_("HTML Unchanged."))) @@ -225,7 +252,7 @@ must have shell access to your Mailman server. doc.AddItem(Header(3,_("Page Unchanged."))) doc.AddItem('


') return - langdir = os.path.join(mlist.fullpath(), mlist.preferred_language) + langdir = os.path.join(mlist.fullpath(), lang) # Make sure the directory exists omask = os.umask(0) try: -- cgit v1.2.3