Feature Proposal: Allowing local JSCalendarContrib configuration

Motivation

Sometimes you need JSCalendarContrib to behave differently on two different webs.

Description and Documentation

My proposal is to use JSCALENDARCONTRIB_* preferences with a higher priority than the $Foswiki::cfg{JSCalendarContrib}{*}.

Examples

Impact

%WHATDOESITAFFECT%
edit

Implementation

diff --git a/lib/Foswiki/Contrib/JSCalendarContrib.pm b/lib/Foswiki/Contrib/JSCalendarContrib.pm
index 5101b1a..d971450 100644
--- a/lib/Foswiki/Contrib/JSCalendarContrib.pm
+++ b/lib/Foswiki/Contrib/JSCalendarContrib.pm
@@ -79,7 +79,7 @@ my $toDate = Foswiki::Contrib::JSCalendarContrib::renderDateForEdit(
 sub renderDateForEdit {
     my ( $name, $value, $format, $options ) = @_;

-    $format ||= $Foswiki::cfg{JSCalendarContrib}{format} || '%e %B %Y';
+    $format ||= Foswiki::Func::getPreferencesValue('JSCALENDARCONTRIB_FORMAT') || $Foswiki::cfg{JSCalendarContrib}{format} || '%e %B %Y';

     addHEAD('foswiki');

@@ -188,8 +188,8 @@ An alternative to =commonTagsHandler= is =postRenderingHandler= which is more ef
 sub addHEAD {
     my $setup = shift;
     $setup ||= 'calendar-setup';
-    my $style = $Foswiki::cfg{JSCalendarContrib}{style} || 'blue';
-    my $lang  = $Foswiki::cfg{JSCalendarContrib}{lang}  || 'en';
+    my $style = Foswiki::Func::getPreferencesValue('JSCALENDARCONTRIB_STYLE') || $Foswiki::cfg{JSCalendarContrib}{style} || 'blue';
+    my $lang  = Foswiki::Func::getPreferencesValue('JSCALENDARCONTRIB_LANG') || $Foswiki::cfg{JSCalendarContrib}{lang}  || 'en';
     my $base  = '%PUBURLPATH%/%SYSTEMWEB%/JSCalendarContrib';
     eval {
         require Foswiki::Contrib::BehaviourContrib;
diff --git a/lib/Foswiki/Form/Date.pm b/lib/Foswiki/Form/Date.pm
index 5687c17..8993e2d 100644
--- a/lib/Foswiki/Form/Date.pm
+++ b/lib/Foswiki/Form/Date.pm
@@ -41,7 +41,7 @@ sub renderForEdit {
                 : 'foswikiInputField foswikiEditFormDateField'
                }
        );
-    my $ifFormat = $Foswiki::cfg{JSCalendarContrib}{format} || '%e %b %Y';
+    my $ifFormat = Foswiki::Func::getPreferencesValue('JSCALENDARCONTRIB_FORMAT') || $Foswiki::cfg{JSCalendarContrib}{format} || '%e %b %Y';
     Foswiki::Contrib::JSCalendarContrib::addHEAD('foswiki');
     my $button .= CGI::image_button(
         -name    => 'calendar',

-- Contributors: AntonioTerceiro - 11 Mar 2010

Discussion

I noted that JSCalendarContrib uses two different format strings: '%e %b %Y' (lowercase B, abbreviated month name) and '%e %B %Y' (capital B, full month name). Is it on purpose, or is it a bug?

-- AntonioTerceiro - 11 Mar 2010

Accepted by 14-day rule

-- KennethLavrsen - 30 Mar 2010
Topic revision: r5 - 06 Dec 2010, GeorgeClark
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy