From b6cdfdcd369b4f7a9acd352eb5a0e8797bfeb188 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franc=CC=A7ois=20Nonnenmacher?= Date: Mon, 21 Mar 2016 10:50:32 +0900 Subject: [PATCH] Version 1.3 - allows different memos for entries and pages --- Memo/config.yaml | 11 +++++++- Memo/lib/Memo/L10N/fr.pm | 5 +++- Memo/lib/Memo/Plugin.pm | 17 +++++++++--- Memo/tmpl/blog_config.tmpl | 53 ++++++++++++++++++++++++++++---------- README.md | 13 +++++----- 5 files changed, 72 insertions(+), 27 deletions(-) diff --git a/Memo/config.yaml b/Memo/config.yaml index 094e3c6..967f573 100644 --- a/Memo/config.yaml +++ b/Memo/config.yaml @@ -4,7 +4,7 @@ author_name: François Nonnenmacher, Ubiquitic author_link: http://ubiquitic.com/ plugin_link: http://ubiquitic.com/memo-movable-type-plugin.html description: <__trans phrase="Display a memo on Edit Entry/Page screens, or a global one."> -version: 1.2 +version: 1.3 l10n_class: Memo::L10N system_config_template: sys_config.tmpl @@ -14,12 +14,21 @@ settings: has_entry_memo: Default: 0 Scope: blog + has_page_memo: + Default: 0 + Scope: blog entry_memo_title: Default: '' Scope: blog + page_memo_title: + Default: '' + Scope: blog entry_memo: Default: '' Scope: blog + page_memo: + Default: '' + Scope: blog has_global_memo: Default: 0 Scope: system diff --git a/Memo/lib/Memo/L10N/fr.pm b/Memo/lib/Memo/L10N/fr.pm index fda3804..c9d69da 100644 --- a/Memo/lib/Memo/L10N/fr.pm +++ b/Memo/lib/Memo/L10N/fr.pm @@ -15,7 +15,10 @@ use vars qw( %Lexicon ); 'Display a memo on Edit Entry/Page screens, or a global one.' => 'Affiche un mémo partout ou sur les écrans d\'édition des pages et des notes', 'Memo Title' => 'Titre du mémo', 'Memo Body' => 'Texte du mémo', - 'Check to display a memo widget on all Entry/Page edit screens.' => 'Cocher pour afficher un mémo sur les écrans d\'édition des pages et des notes.', + 'Display on Edit Entry screens' => 'Afficher sur les écrans d\'édition des notes', + 'Display on Edit Page screens' => 'Afficher sur les écrans d\'édition des pages', + 'Check to display a memo widget on all Entry edit screens.' => 'Cocher pour afficher un mémo sur les écrans d\'édition des notes.', + 'Check to display a memo widget on all Page edit screens.' => 'Cocher pour afficher un mémo sur les écrans d\'édition des pages.', 'The title for the memo widget (defaults to “Memo”).' => 'Le titre du mémo (« Mémo » par défaut).', 'The memo body (in HTML). Hint: <ul><li>...</li></ul> works best.' => 'Le texte du mémo (en HTML). Suggestion : <ul><li>...</li></ul> fonctionne le mieux.', ); diff --git a/Memo/lib/Memo/Plugin.pm b/Memo/lib/Memo/Plugin.pm index d766768..e359a15 100644 --- a/Memo/lib/Memo/Plugin.pm +++ b/Memo/lib/Memo/Plugin.pm @@ -1,5 +1,5 @@ # Memo - Displays a memo on the Edit Entry/Page screens -# Release : v1.2 2012-01-08 +# Release: v1.3 2016-03-21 # Copyright © François Nonnenmacher, Ubiquitic package Memo::Plugin; @@ -9,13 +9,22 @@ use MT; sub update_edit_entry { my ($cb, $app, $param, $tmpl) = @_; + my $title = ''; + my $memo = ''; my $plugin = $cb->plugin; my $cfg = $plugin->get_config_hash('blog:'.$app->blog->id); - return unless ($cfg->{has_entry_memo}); + if ($app->param('_type') eq 'entry' && $cfg->{has_entry_memo}) { + $title = $cfg->{entry_memo_title} || $plugin->translate('Memo'); + $memo = $cfg->{entry_memo}; + } else { + if ($app->param('_type') eq 'page' && $cfg->{has_page_memo}) { + $title = $cfg->{page_memo_title} || $plugin->translate('Memo'); + $memo = $cfg->{page_memo}; + } + } + return unless ($memo); my $header_node = $tmpl->getElementById('header_include'); return unless $header_node; - my $title = $cfg->{entry_memo_title} || $plugin->translate('Memo'); - my $memo = $cfg->{entry_memo}; $tmpl->insertAfter( $tmpl->createElement('var', { name => 'related_content', diff --git a/Memo/tmpl/blog_config.tmpl b/Memo/tmpl/blog_config.tmpl index fe86acc..b522826 100755 --- a/Memo/tmpl/blog_config.tmpl +++ b/Memo/tmpl/blog_config.tmpl @@ -1,21 +1,46 @@ " - hint='<__trans phrase="Check to display a memo widget on all Entry/Page edit screens.">' + label="<__trans phrase="Display on Edit Entry screens">" + hint='<__trans phrase="Check to display a memo widget on all Entry edit screens.">' show_hint="1"> - checked="checked" /> + checked="checked" onclick="toggleSubPrefs(this)" /> +
class="hidden"> + " + hint='<__trans phrase="The title for the memo widget (defaults to “Memo”).">' + show_hint="1"> + " /> + + " + hint="<__trans phrase='The memo body (in HTML). Hint: <ul><li>...</li></ul> works best.'>" + show_hint="1"> + + +
" - hint='<__trans phrase="The title for the memo widget (defaults to “Memo”).">' + id="has_page_memo" + label="<__trans phrase="Display on Edit Page screens">" + hint='<__trans phrase="Check to display a memo widget on all Page edit screens.">' show_hint="1"> - " /> + checked="checked" onclick="toggleSubPrefs(this)" /> -" - hint="<__trans phrase='The memo body (in HTML). Hint: <ul><li>...</li></ul> works best.'>" - show_hint="1"> - - \ No newline at end of file +
class="hidden"> + " + hint='<__trans phrase="The title for the memo widget (defaults to “Memo”).">' + show_hint="1"> + " /> + + " + hint="<__trans phrase='The memo body (in HTML). Hint: <ul><li>...</li></ul> works best.'>" + show_hint="1"> + + +
\ No newline at end of file diff --git a/README.md b/README.md index ecfe36f..6b76481 100644 --- a/README.md +++ b/README.md @@ -4,14 +4,12 @@ Memo can: * display a global message on top of every CMS screen; -* place a text box on top of the other widgets in the right column of the entries and pages edit screen. The memo display and text are customizable per blog. +* display a text box on top of the other widgets in the right column of the entries and/or pages edit screens. The memo display and text are customizable per site and blog. ## Requirements -* MT 4.x -* MT 5.x -* Melody 1.0 +* MT 4.x, 5.x or 6.x ## Installation @@ -44,15 +42,16 @@ Ce plugin parle français. ;-) ## Version history -* Current: 1.2 — Added the option to display a global message. +* Current: 1.3 — Added the option to display different messages for entries and pages. +* 1.2 — Added the option to display a global message. * 1.1 — Removed Perl version check, added hints and improved the widget HTML code to respect the system CSS margins. * 1.0 — First public release. ## Credits -Author: [Ubiquitic](http://ubiquitic.com/). -Copyright: 2011 Ubiquitic. +Author: [Ubiquitic](http://ubiquitic.com/). +Copyright: Ubiquitic. License: [Artistic License 2.0](http://www.opensource.org/licenses/artistic-license-2.0.php) This free software is provided as-is WITHOUT ANY KIND OF GUARANTEE; you can redistribute it and/or modify it under the same terms as Perl itself.