diff --git a/addons/ConfigAssistant.pack/config.yaml b/addons/ConfigAssistant.pack/config.yaml
index 8685531da..7524424e1 100644
--- a/addons/ConfigAssistant.pack/config.yaml
+++ b/addons/ConfigAssistant.pack/config.yaml
@@ -4,9 +4,9 @@ key: ConfigAssistant
author_link: http://openmelody.org/
author_name: "Byrne Reese, Open Melody Software Group"
description: This plugin provides a simple YAML based framework for creating plugin and theme configuration options.
-version: 2.1.9
-static_version: 4
-schema_version: 2
+version: 2.1.15
+static_version: 7
+schema_version: 3
applications:
cms:
diff --git a/addons/ConfigAssistant.pack/lib/ConfigAssistant/Init.pm b/addons/ConfigAssistant.pack/lib/ConfigAssistant/Init.pm
index 6f44fc117..932aa6943 100644
--- a/addons/ConfigAssistant.pack/lib/ConfigAssistant/Init.pm
+++ b/addons/ConfigAssistant.pack/lib/ConfigAssistant/Init.pm
@@ -14,45 +14,37 @@ sub plugin {
sub init_app {
my $plugin = shift;
- my ($app) = @_;
+ my ($app) = @_;
+ my $cfg = $app->config;
return if $app->id eq 'wizard';
- # Disable the AutoPrefs plugin if it's installed. (AutoPrefs has been
- # merged with Config Assistant, so is not needed anymore.)
- my $switch = MT->config('PluginSwitch') || {};
- unless ( ( $switch->{'AutoPrefs'} || '' ) eq '0' ) {
- $switch->{'AutoPrefs'} = 0;
- MT->config( 'PluginSwitch', $switch, 1 );
- MT->config->save_config();
- }
+ # Disable the AutoPrefs plugin if it's still installed. (AutoPrefs has
+ # been merged with Config Assistant, so is not needed anymore.)
+ my $switch = $cfg->PluginSwitch || {};
+ $switch->{'AutoPrefs/config.yaml'} = $switch->{'AutoPrefs'} = 0;
+ $cfg->PluginSwitch( $switch );
+ # FIXME This needs some commentary...
init_options($app);
- my $r = $plugin->registry;
- $r->{tags} = sub { load_tags( $app, $plugin ) };
+
+ # FIXME This looks fishy... Pretty sure we shouldn't be accessing the registry as a hash but instead $plugin->registry('tags', sub { ... })
+ my $r = $plugin->registry->{tags} = sub { load_tags( $app, $plugin ) };
# Static files only get copied during an upgrade.
if ( $app->id eq 'upgrade' ) {
-
- # Because no schema version is set, the upgrade process doesn't run
- # during the plugin's initial install. But, we need it to so that
- # static files will get copied. Check if PluginschemaVersion has been
- # set for Config Assistant. If not, set it. That way, when the upgrade
- # runs it sees it and will run the upgrade_function.
- # If this isn't the upgrade screen, just quit.
- my $cfg = MT->config('PluginSchemaVersion');
-
- # $cfg->{$plugin->id} = '0.1'; ### UNCOMMENT TO TEST UPGRADE ###
- if ( ( $cfg->{ $plugin->id } || '' ) eq '' ) {
-
- # There is no schema version set. Set one!
- $cfg->{ $plugin->id } = '0.1';
- }
+ # Because no schema version is set, the upgrade process does nothing
+ # during the plugin's initial install. So, in order to copy static
+ # files on first run, we set an initial schema version which triggers
+ # the framework.
+ my $schemas = $cfg->PluginSchemaVersion || {};
+ $schemas->{ $plugin->id } ||= '0.1';
+ # $schemas->{$plugin->id} = '0.1'; ## UNCOMMENT TO TEST UPGRADE ##
+ $cfg->PluginSchemaVersion( $schemas );
}
- require Sub::Install;
-
# TODO - This should not have to reinstall a subroutine. It should invoke
# a callback.
+ require Sub::Install;
Sub::Install::reinstall_sub( {
code => \&needs_upgrade,
into => 'MT::Component',
@@ -87,9 +79,9 @@ sub init_options {
my $option
= $r->{'template_sets'}->{$set}->{'options'}->{$opt};
- # To avoid option names that may collide with other
- # options in other template sets settings are derived
- # by combining the name of the template set and the
+ # To avoid option names that may collide with other
+ # options in other template sets settings are derived
+ # by combining the name of the template set and the
# option's key.
my $optname = $set . '_' . $opt;
if ( _option_exists( $sig, $optname ) ) {
@@ -99,7 +91,7 @@ sub init_options {
else {
# if ( my $default = $option->{default} ) {
- # if ( !ref($default)
+ # if ( !ref($default)
# && ( $default =~ /^\s*sub/
# || $default =~ /^\$/)) {
# $default
@@ -118,7 +110,7 @@ sub init_options {
$obj->{'registry'}->{'settings'}->{$optname}
= { scope => 'blog', %$option, };
}
- } ## end else [ if ( _option_exists( $sig...))]
+ }
} ## end foreach my $opt ( keys %{ $r...})
} ## end if ( $r->{'template_sets'...})
} # end foreach (@sets)
@@ -192,7 +184,7 @@ sub load_tags {
class => 'system',
category => 'plugin',
level => MT::Log::ERROR(),
- }
+ }
);
}
}
diff --git a/addons/ConfigAssistant.pack/lib/ConfigAssistant/Plugin.pm b/addons/ConfigAssistant.pack/lib/ConfigAssistant/Plugin.pm
index 563d9922e..e69d6b3be 100644
--- a/addons/ConfigAssistant.pack/lib/ConfigAssistant/Plugin.pm
+++ b/addons/ConfigAssistant.pack/lib/ConfigAssistant/Plugin.pm
@@ -5,12 +5,12 @@ use warnings;
use Carp qw( croak );
use MT::Util
qw( relative_date offset_time offset_time_list epoch2ts
- ts2epoch format_ts encode_html decode_html dirify );
+ ts2epoch format_ts encode_html decode_html dirify );
use ConfigAssistant::Util
qw( find_theme_plugin find_template_def find_option_def
- find_option_plugin process_file_upload );
+ find_option_plugin process_file_upload
+ plugin_static_web_path plugin_static_file_path );
use JSON;
-
# use MT::Log::Log4perl qw( l4mtdump ); use Log::Log4perl qw( :resurrect );
our $logger;
@@ -21,32 +21,29 @@ sub tag_plugin_static_web_path {
if ( !$obj ) {
return
$ctx->error(
- MT->translate(
- "The plugin you specified '[_2]' in '[_1]' "
- . "could not be found.",
- $ctx->stash('tag'),
- $sig
- )
+ MT->translate(
+ "The plugin you specified '[_2]' in '[_1]' "
+ . "could not be found.",
+ $ctx->stash('tag'),
+ $sig
+ )
);
}
elsif ( $obj->registry('static_version') ) {
- my $url = MT->instance->static_path;
- $url .= '/' unless $url =~ m!/$!;
- $url .= 'support/plugins/' . $obj->id . '/';
- return $url;
+ return plugin_static_web_path($obj);
}
else {
# TODO - perhaps this should default to: mt-static/plugins/$sig?
return
$ctx->error(
- MT->translate(
- "The plugin you specified '[_2]' in '[_1]' has not"
- . "registered a static directory. Please use "
- . "
File not found.
"; } } - $html - .= " \n"; + $html .= " \n" . + " \n"; + + $html .= "\n"; + return $html; } ## end sub type_file @@ -1011,7 +1015,7 @@ sub _hdlr_field_category_list { my ( $ctx, $args, $cond ) = @_; my $field = $ctx->stash('field') or return _no_field($ctx); my $value = _get_field_value($ctx); - my @ids = ref($value) eq 'ARRAY' ? @$value : ($value); + my @ids = ref($value) eq 'ARRAY' ? @$value : ($value); my $class = $ctx->stash('obj_class'); my @categories = MT->model($class)->load( { id => \@ids } ); diff --git a/addons/ConfigAssistant.pack/lib/ConfigAssistant/Static.pm b/addons/ConfigAssistant.pack/lib/ConfigAssistant/Static.pm index aaf348285..51f67bee9 100644 --- a/addons/ConfigAssistant.pack/lib/ConfigAssistant/Static.pm +++ b/addons/ConfigAssistant.pack/lib/ConfigAssistant/Static.pm @@ -28,7 +28,6 @@ sub upgrade { # The saved version my $ver = MT->config('PluginStaticVersion'); - # $ver = undef; ### UNCOMMENT TO TEST STATIC UPGRADE ### # Check to see if $plugin->id is valid. If it's not, we need to @@ -69,13 +68,13 @@ sub upgrade { $cfg->set( 'PluginStaticVersion', $plugin_id . '=' . $static_version, 1 ); $self->progress( - $self->translate_escape( - "Plugin '[_1]' upgraded successfully to " - . "version [_2] (static version [_3]).", - $plugin->label, - $plugin->version || '-', - $static_version - ) + $self->translate_escape( + "Plugin '[_1]' upgraded successfully to " + . "version [_2] (static version [_3]).", + $plugin->label, + $plugin->version || '-', + $static_version + ) ); } ## end if ( $static_version >...) } ## end for my $sig ( keys %MT::Plugins) diff --git a/addons/ConfigAssistant.pack/lib/ConfigAssistant/Util.pm b/addons/ConfigAssistant.pack/lib/ConfigAssistant/Util.pm index 08aecb756..78f03169c 100644 --- a/addons/ConfigAssistant.pack/lib/ConfigAssistant/Util.pm +++ b/addons/ConfigAssistant.pack/lib/ConfigAssistant/Util.pm @@ -3,9 +3,11 @@ package ConfigAssistant::Util; use strict; use warnings; use base 'Exporter'; -our @EXPORT_OK = qw( find_theme_plugin find_template_def find_option_def - find_option_plugin process_file_upload - ERROR SUCCESS OVERWRITE NO_UPLOAD ); +our @EXPORT_OK + = qw( find_theme_plugin find_template_def find_option_def + find_option_plugin process_file_upload + plugin_static_web_path plugin_static_file_path + ERROR SUCCESS OVERWRITE NO_UPLOAD ); use MT::Util qw( encode_url ); @@ -14,6 +16,21 @@ sub SUCCESS () {1} sub OVERWRITE () {2} sub NO_UPLOAD () {3} +sub plugin_static_web_path { + my ($plugin) = @_; + my $url = MT->instance->static_path; + $url .= '/' unless $url =~ m!/$!; + $url .= 'support/plugins/' . $plugin->id . '/'; + return $url; +} + +sub plugin_static_file_path { + my ($plugin) = @_; + return File::Spec->catdir( MT->instance->static_file_path, + 'support', 'plugins', $plugin->id ); + +} + sub process_file_upload { my $app = shift; my ( $param_name, $scope, $extra_path, %upload_param ) = @_; diff --git a/addons/ConfigAssistant.pack/static/js/app.js b/addons/ConfigAssistant.pack/static/js/app.js index 34d935862..bceebfae4 100644 --- a/addons/ConfigAssistant.pack/static/js/app.js +++ b/addons/ConfigAssistant.pack/static/js/app.js @@ -1,19 +1,19 @@ $(document).ready( function() { - var active = $('#content-nav ul li.active a').attr('id'); - $('#' + active + '-content').show(); $('h2#page-title span').html( $('#content-nav ul li.active a b').html() ); $('#fieldsets input, #fieldsets select, #fieldsets textarea').change( function () { var changed = $(this).parent().parent().parent().attr('id'); $('#content-nav ul li.'+changed).addClass('changed'); }); $('#content-nav ul li a').click( function() { - var newactive = $(this).attr('id'); + var active = $(this).parents('ul').find('li.active a').attr('id').replace(/-tab$/,''); + var newactive = $(this).attr('id').replace(/-tab$/,''); $('#content-nav li.active').removeClass('active'); - $('#' + active + '-content').hide(); - $('#content-nav li.' + newactive).addClass('active'); - $('#' + newactive + '-content').show(); - $('h2#page-title span').html( $('#content-nav ul li.'+newactive+' a b').html() ); - active = newactive; + $('#' + active + '-tab-content').hide(); + $('#content-nav li.' + newactive+'-tab').addClass('active'); + $('#' + newactive + '-tab-content').show(); + $('h2#page-title span').html( $('#content-nav ul li.'+newactive+'-tab a b').html() ); + document.title = $(this).attr('title'); + window.location.hash = newactive; }); $('.field-type-radio-image li input:checked').each( function() { $(this).parent().addClass('selected'); }); $('.field-type-radio-image li').click( function() { @@ -24,4 +24,10 @@ $(document).ready( function() { var changed = $(this).parent().parent().parent().parent().attr('id'); $('#content-nav ul li.'+changed).addClass('changed'); }); + $.history.init(function(hash){ + if (hash == "") { + hash = $('#content-nav ul li:first-child a').attr('id').replace(/-tab$/,''); + } + $('#content-nav ul li.'+hash+'-tab a').click(); + }); }); diff --git a/addons/ConfigAssistant.pack/static/js/jquery.history.js b/addons/ConfigAssistant.pack/static/js/jquery.history.js new file mode 100644 index 000000000..7f91079d4 --- /dev/null +++ b/addons/ConfigAssistant.pack/static/js/jquery.history.js @@ -0,0 +1,194 @@ +/* + * jQuery history plugin + * + * The MIT License + * + * Copyright (c) 2006-2009 Taku Sano (Mikage Sawatari) + * Copyright (c) 2010 Takayuki Miwa + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +(function($) { + var locationWrapper = { + put: function(hash, win) { + (win || window).location.hash = this.encoder(hash); + }, + get: function(win) { + var hash = ((win || window).location.hash).replace(/^#/, ''); + try { + return $.browser.mozilla ? hash : decodeURIComponent(hash); + } + catch (error) { + return hash; + } + }, + encoder: encodeURIComponent + }; + + var iframeWrapper = { + id: "__jQuery_history", + init: function() { + var html = ''; + $("body").prepend(html); + return this; + }, + _document: function() { + return $("#"+ this.id)[0].contentWindow.document; + }, + put: function(hash) { + var doc = this._document(); + doc.open(); + doc.close(); + locationWrapper.put(hash, doc); + }, + get: function() { + return locationWrapper.get(this._document()); + } + }; + + function initObjects(options) { + options = $.extend({ + unescape: false + }, options || {}); + + locationWrapper.encoder = encoder(options.unescape); + + function encoder(unescape_) { + if(unescape_ === true) { + return function(hash){ return hash; }; + } + if(typeof unescape_ == "string" && + (unescape_ = partialDecoder(unescape_.split(""))) + || typeof unescape_ == "function") { + return function(hash) { return unescape_(encodeURIComponent(hash)); }; + } + return encodeURIComponent; + } + + function partialDecoder(chars) { + var re = new RegExp($.map(chars, encodeURIComponent).join("|"), "ig"); + return function(enc) { return enc.replace(re, decodeURIComponent); }; + } + } + + var implementations = {}; + + implementations.base = { + callback: undefined, + type: undefined, + + check: function() {}, + load: function(hash) {}, + init: function(callback, options) { + initObjects(options); + self.callback = callback; + self._options = options; + self._init(); + }, + + _init: function() {}, + _options: {} + }; + + implementations.timer = { + _appState: undefined, + _init: function() { + var current_hash = locationWrapper.get(); + self._appState = current_hash; + self.callback(current_hash); + setInterval(self.check, 100); + }, + check: function() { + var current_hash = locationWrapper.get(); + if(current_hash != self._appState) { + self._appState = current_hash; + self.callback(current_hash); + } + }, + load: function(hash) { + if(hash != self._appState) { + locationWrapper.put(hash); + self._appState = hash; + self.callback(hash); + } + } + }; + + implementations.iframeTimer = { + _appState: undefined, + _init: function() { + var current_hash = locationWrapper.get(); + self._appState = current_hash; + iframeWrapper.init().put(current_hash); + self.callback(current_hash); + setInterval(self.check, 100); + }, + check: function() { + var iframe_hash = iframeWrapper.get(), + location_hash = locationWrapper.get(); + + if (location_hash != iframe_hash) { + if (location_hash == self._appState) { // user used Back or Forward button + self._appState = iframe_hash; + locationWrapper.put(iframe_hash); + self.callback(iframe_hash); + } else { // user loaded new bookmark + self._appState = location_hash; + iframeWrapper.put(location_hash); + self.callback(location_hash); + } + } + }, + load: function(hash) { + if(hash != self._appState) { + locationWrapper.put(hash); + iframeWrapper.put(hash); + self._appState = hash; + self.callback(hash); + } + } + }; + + implementations.hashchangeEvent = { + _init: function() { + self.callback(locationWrapper.get()); + $(window).bind('hashchange', self.check); + }, + check: function() { + self.callback(locationWrapper.get()); + }, + load: function(hash) { + locationWrapper.put(hash); + } + }; + + var self = $.extend({}, implementations.base); + + if($.browser.msie && ($.browser.version < 8 || document.documentMode < 8)) { + self.type = 'iframeTimer'; + } else if("onhashchange" in window) { + self.type = 'hashchangeEvent'; + } else { + self.type = 'timer'; + } + + $.extend(self, implementations[self.type]); + $.history = self; +})(jQuery); diff --git a/addons/ConfigAssistant.pack/static/js/options.js b/addons/ConfigAssistant.pack/static/js/options.js index 117d1cbf1..53b4ae0e0 100644 --- a/addons/ConfigAssistant.pack/static/js/options.js +++ b/addons/ConfigAssistant.pack/static/js/options.js @@ -27,6 +27,10 @@ function handle_save_click() { function handle_delete_click() { $(this).parent().remove(); return false; }; +function handle_remove_file() { + $(this).parents('.field-content').find('.clear-file').val(1); + $(this).parent().remove(); return false; +}; function render_link_form(label,url) { var dom = '