Skip to content

Commit

Permalink
[#371 state:resolved] Updating Theme Manager to the very latest, v0.9.23
Browse files Browse the repository at this point in the history
  • Loading branch information
jayallen committed Oct 24, 2010
1 parent 25075a9 commit e520945
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 16 deletions.
2 changes: 1 addition & 1 deletion plugins/ThemeManager/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ key: ThemeManager
author_link: http://endevver.com/
author_name: Endevver
description: 'A comprehensive theme management plugin!'
version: 0.9.22
version: 0.9.23
schema_version: 3
static_version: 4

Expand Down
7 changes: 3 additions & 4 deletions plugins/ThemeManager/lib/ThemeManager/Init.pm
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ sub _translate {
# This is basically lifted right from MT::CMS::Template (from Movable Type
# version 4.261), with some necessary changes to work with Theme Manager.
my $c = shift;
use Data::Dumper;
my $handles = MT->request('l10n_handle') || {};
my $h = $handles->{ $c->id };
unless ($h) {
Expand All @@ -49,9 +48,9 @@ sub _translate {
# translations.
my $app = MT->instance;
my $q = $app->can('query') ? $app->query : $app->param;
# This first check for $app->param is necessary so that
# run-periodic-tasks doesn't throw errors.
if ( eval{$q->param} && $q->param('__mode') ) {
# This first check for $q is necessary so that run-periodic-tasks
# doesn't throw errors.
if ( eval{$q} && $q->param('__mode') ) {
if ( $q->param('__mode') eq 'setup_theme' ) {
# The user is applying a new theme.
$c = find_theme_plugin( $q->param('theme_id') );
Expand Down
13 changes: 9 additions & 4 deletions plugins/ThemeManager/lib/ThemeManager/Plugin.pm
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ sub update_page_actions {
}

sub theme_dashboard {
my $app = MT::App->instance;
my $app = MT->instance;
my $q = $app->can('query') ? $app->query : $app->param;
# Since there is no Theme Dashboard at the system level, capture and
# redirect to the System Dashboard, if necessary.
Expand Down Expand Up @@ -219,7 +219,7 @@ sub select_theme {

my $app = shift;
my $q = $app->can('query') ? $app->query : $app->param;

# If the user is applying a theme to many blogs, they've come from a list
# action, and the ID parameter is full of blog IDs. Pass these along to
# the template.
Expand Down Expand Up @@ -299,6 +299,7 @@ sub select_theme {
sub setup_theme {
my $app = shift;
my $q = $app->can('query') ? $app->query : $app->param;

my $ts_id = $q->param('theme_id');
my $plugin_sig = $q->param('plugin_sig');

Expand Down Expand Up @@ -619,6 +620,7 @@ sub _make_thumbnail {
# We want a custom thumbnail to display on the Theme Options About tab.
my ($ts_id, $plugin) = @_;
my $app = MT->instance;
my $q = $app->can('query') ? $app->query : $app->param;

# Craft the destination path and URL.
use File::Spec;
Expand Down Expand Up @@ -686,7 +688,9 @@ sub _check_thumbalizr_result {

sub _make_mini {
my $app = MT->instance;
my $tm = MT->component('ThemeManager');
my $q = $app->can('query') ? $app->query : $app->param;
my $tm = MT->component('ThemeManager');

use File::Spec;
my $dest_path = File::Spec->catfile( _theme_thumb_path(), $app->blog->id.'-mini.jpg' );
my $dest_url = caturl($app->static_path,'support','plugins',$tm->id,'theme_thumbs',
Expand Down Expand Up @@ -735,7 +739,7 @@ sub unlink_templates {
my $q = $app->can('query') ? $app->query : $app->param;
my $blog_id = $q->param('blog_id');
my $iter = MT->model('template')->load_iter({ blog_id => $blog_id,
linked_file => '*', });
linked_file => '*', });
while ( my $tmpl = $iter->() ) {
$tmpl->linked_file(undef);
$tmpl->linked_file_mtime(undef);
Expand Down Expand Up @@ -782,6 +786,7 @@ sub xfrm_disable_tmpl_link {
# them, because that "breaks the seal" and lets them modify the template,
# so upgrades are no longer easy.
my ($cb, $app, $tmpl) = @_;
my $q = $app->can('query') ? $app->query : $app->param;
my $linked = MT->model('template')->load(
{ id => $q->param('id'),
linked_file => '*', });
Expand Down
7 changes: 4 additions & 3 deletions plugins/ThemeManager/lib/ThemeManager/TemplateInstall.pm
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ sub _refresh_all_templates {
# version 4.261), with some necessary changes to work with Theme Manager.
my ($ts_id, $blog_id, $app) = @_;
my $q = $app->can('query') ? $app->query : $app->param;

my $t = time;

my @id = ( scalar $blog_id );
Expand Down Expand Up @@ -229,7 +230,7 @@ sub template_filter {

# If a new blog is being created/saved, we don't want to run this callback.
return if (
eval{$q->param}
eval{$q}
&& eval{$q->param('__mode')}
&& ($q->param('__mode') eq 'save')
&& ($q->param('_type') eq 'blog')
Expand All @@ -238,7 +239,7 @@ sub template_filter {
# context won't be set properly.
return unless eval{$app->blog};

my $blog_id = $app->can('blog')
my $blog_id = $q->can('blog')
? $app->blog->id
: return; # Only work on blog-specific widgets and widget sets

Expand Down Expand Up @@ -312,7 +313,7 @@ sub template_set_change {
# that templates are linked by default.
my $tm = MT->component('ThemeManager');
my $mode = $tm->get_config_value('tm_mode', 'system');
if ($mode eq 'Production Mode') {
if ($mode eq 'Designer and Developer Mode') {
# Link installed templates to theme files
_link_templates(@_);
}
Expand Down
12 changes: 8 additions & 4 deletions plugins/ThemeManager/lib/ThemeManager/Util.pm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ our @EXPORT_OK = qw( theme_label theme_thumbnail_url theme_preview_url
theme_paypal_email theme_version theme_link theme_doc_link
about_designer theme_docs _theme_thumb_path _theme_thumb_url );

my $app = MT::App->instance();
my $app = MT->instance;
my $tm = MT->component('ThemeManager');

sub theme_label {
Expand Down Expand Up @@ -161,15 +161,19 @@ sub theme_docs {

sub _theme_thumb_path {
my @path = ($app->config('StaticFilePath'), 'support', 'plugins', $tm->id, 'theme_thumbs');
return File::Spec->catfile( @path );
my $dest_path = File::Spec->catfile( @path );
# If the destination directory doesn't exist, we need to create it.
if (!-w $dest_path) {
mkdir $dest_path;
}
return $dest_path;
}

sub _theme_thumb_url {
return caturl( $app->static_path , 'support' , 'plugins', $tm->id, 'theme_thumbs',
$app->blog->id.'.jpg' );
}



1;

__END__

0 comments on commit e520945

Please sign in to comment.