Skip to content

Commit

Permalink
Version 1.3 - allows different memos for entries and pages
Browse files Browse the repository at this point in the history
  • Loading branch information
padawan committed Mar 21, 2016
1 parent 145b056 commit b6cdfdc
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 27 deletions.
11 changes: 10 additions & 1 deletion Memo/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
5 changes: 4 additions & 1 deletion Memo/lib/Memo/L10N/fr.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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 («&nbsp;Mémo&nbsp;» par défaut).',
'The memo body (in HTML). Hint: <code>&lt;ul&gt;&lt;li&gt;...&lt;/li&gt;&lt;/ul&gt;</code> works best.' => 'Le texte du mémo (en HTML). Suggestion&nbsp;: <code>&lt;ul&gt;&lt;li&gt;...&lt;/li&gt;&lt;/ul&gt;</code> fonctionne le mieux.',
);
Expand Down
17 changes: 13 additions & 4 deletions Memo/lib/Memo/Plugin.pm
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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',
Expand Down
53 changes: 39 additions & 14 deletions Memo/tmpl/blog_config.tmpl
Original file line number Diff line number Diff line change
@@ -1,21 +1,46 @@
<mtapp:setting
id="has_entry_memo"
label="<__trans phrase="Display a memo on Edit Entry/Page screens">"
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">
<input type="checkbox" name="has_entry_memo" id="has_entry_memo" value="1"<mt:if name="has_entry_memo"> checked="checked"</mt:if> />
<input type="checkbox" name="has_entry_memo" id="has_entry_memo" value="1"<mt:if name="has_entry_memo"> checked="checked"</mt:if> onclick="toggleSubPrefs(this)" />
</mtapp:setting>
<div id="has_entry_memo-prefs" <mt:unless name="has_entry_memo">class="hidden"</mt:unless>>
<mtapp:setting
id="entry_memo_title"
label="<__trans phrase="Memo Title">"
hint='<__trans phrase="The title for the memo widget (defaults to “Memo”).">'
show_hint="1">
<input type="text" size="30" name="entry_memo_title" id="entry_memo_title" value="<mt:var name="entry_memo_title" escape="html">" />
</mtapp:setting>
<mtapp:setting
id="entry_memo"
label="<__trans phrase="Memo Body">"
hint="<__trans phrase='The memo body (in HTML). Hint: <code>&lt;ul&gt;&lt;li&gt;...&lt;/li&gt;&lt;/ul&gt;</code> works best.'>"
show_hint="1">
<textarea rows="8" cols="30" name="entry_memo" id="entry_memo"><mt:var name="entry_memo" escape="html"></textarea>
</mtapp:setting>
</div>
<mtapp:setting
id="entry_memo_title"
label="<__trans phrase="Memo Title">"
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">
<input type="text" size="30" name="entry_memo_title" id="entry_memo_title" value="<mt:var name="entry_memo_title" escape="html">" />
<input type="checkbox" name="has_page_memo" id="has_page_memo" value="1"<mt:if name="has_page_memo"> checked="checked"</mt:if> onclick="toggleSubPrefs(this)" />
</mtapp:setting>
<mtapp:setting
id="entry_memo"
label="<__trans phrase="Memo Body">"
hint="<__trans phrase='The memo body (in HTML). Hint: <code>&lt;ul&gt;&lt;li&gt;...&lt;/li&gt;&lt;/ul&gt;</code> works best.'>"
show_hint="1">
<textarea rows="8" cols="30" name="entry_memo" id="entry_memo"><mt:var name="entry_memo" escape="html"></textarea>
</mtapp:setting>
<div id="has_page_memo-prefs" <mt:unless name="has_page_memo">class="hidden"</mt:unless>>
<mtapp:setting
id="page_memo_title"
label="<__trans phrase="Memo Title">"
hint='<__trans phrase="The title for the memo widget (defaults to “Memo”).">'
show_hint="1">
<input type="text" size="30" name="page_memo_title" id="page_memo_title" value="<mt:var name="page_memo_title" escape="html">" />
</mtapp:setting>
<mtapp:setting
id="page_memo"
label="<__trans phrase="Memo Body">"
hint="<__trans phrase='The memo body (in HTML). Hint: <code>&lt;ul&gt;&lt;li&gt;...&lt;/li&gt;&lt;/ul&gt;</code> works best.'>"
show_hint="1">
<textarea rows="8" cols="30" name="page_memo" id="page_memo"><mt:var name="page_memo" escape="html"></textarea>
</mtapp:setting>
</div>
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.

0 comments on commit b6cdfdc

Please sign in to comment.