Changeset 3082

Show
Ignore:
Timestamp:
10/03/08 01:07:01 (9 months ago)
Author:
bchoate
Message:

Merging fireball branch changes to-date to trunk: svn merge -r2974:3081 http://code.sixapart.com/svn/movabletype/branches/fireball .

Location:
trunk
Files:
36 modified

Legend:

Unmodified
Added
Removed
  • trunk/build/Build.pm

    r1681 r3082  
    152152    ($self->{'short-lang=s'} = $self->{'lang=s'}) =~ s/([a-z]{2})_[A-Z]{2}$/$1/o; 
    153153 
    154     $self->{'pack=s'} ||= 'MT'; 
     154    $self->{'pack=s'} ||= 'MTOS'; 
    155155    $ENV{BUILD_PACKAGE}  = $self->{'pack=s'}; 
    156156    $ENV{BUILD_LANGUAGE} = $self->{'lang=s'}; 
  • trunk/lib/MT.pm

    r3019 r3082  
    3232    ( $VERSION, $SCHEMA_VERSION ) = ( '4.21', '4.0068' ); 
    3333    ( $PRODUCT_NAME, $PRODUCT_CODE, $PRODUCT_VERSION, $VERSION_ID, $PORTAL_URL ) = ( 
    34         '__PRODUCT_NAME__', 'MT', 
     34        'Movable Type Pro', 'MT', 
    3535        '4.21', '4.21', 
    36         '__PORTAL_URL__' 
     36        'http://www.sixapart.com/movabletype/' 
    3737    ); 
    3838 
     
    108108 
    109109sub build_id { 
    110     my $build_id = '__BUILD_ID__'; 
     110    my $build_id = '-en-trunk-r3063-20081002'; 
    111111    $build_id = '' if $build_id eq '__BUILD_' . 'ID__'; 
    112112    return $build_id; 
  • trunk/lib/MT/App.pm

    r3017 r3082  
    24202420    if ( $type eq 'dialog' ) { 
    24212421        $param->{name}   ||= $app->{name}   || 'dialog'; 
    2422         $param->{goback} ||= $app->{goback} || 'closeDialog()'; 
     2422        $param->{goback} ||= "window.location='" . $app->{goback} . "'" || 'closeDialog()'; 
    24232423        $param->{value}  ||= $app->{value}  || $app->translate("Close"); 
    24242424        $param->{dialog} = 1; 
    24252425    } 
    24262426    else { 
    2427         $param->{goback} ||= $app->{goback} || 'history.back()'; 
     2427        $param->{goback} ||= "window.location='" . $app->{goback} . "'" || 'history.back()'; 
    24282428        $param->{value}  ||= $app->{value}  || $app->translate("Go Back"); 
    24292429    } 
  • trunk/lib/MT/App/CMS.pm

    r3039 r3082  
    748748                handler => sub { 
    749749                    my ( $terms, $args ) = @_; 
    750                     my $ts = time - 10 * 24 * 60 * 60; 
     750                    my $ts = time - 7 * 24 * 60 * 60; 
    751751                    $ts = epoch2ts( MT->app->blog, $ts ); 
    752752                    $args->{join} = MT::Comment->join_on( 
     
    10501050                    $terms->{created_on}            = [ $from, $to ]; 
    10511051                    $args->{range_incl}{created_on} = 1; 
    1052                 }, 
    1053             }, 
    1054         }, 
    1055         template => { 
    1056             index_templates => { 
    1057                 label   => "Index Templates", 
    1058                 order   => 100, 
    1059                 handler => sub { 
    1060                     my ( $terms, $args ) = @_; 
    1061  
    1062                     # FIXME: enumeration of types 
    1063                     $terms->{type} = 'index'; 
    1064                 }, 
    1065                 condition => sub { 
    1066                     $app->param('blog_id'); 
    1067                 }, 
    1068             }, 
    1069             archive_templates => { 
    1070                 label   => "Archive Templates", 
    1071                 order   => 200, 
    1072                 handler => sub { 
    1073                     my ( $terms, $args ) = @_; 
    1074                     $terms->{type} 
    1075                         = [ 'individual', 'page', 'archive', 'category' ]; 
    1076                 }, 
    1077                 condition => sub { 
    1078                     $app->param('blog_id'); 
    1079                 }, 
    1080             }, 
    1081             module_templates => { 
    1082                 label   => "Template Modules", 
    1083                 order   => 400, 
    1084                 handler => sub { 
    1085                     my ($terms) = @_; 
    1086                     $terms->{type} = 'custom'; 
    1087                 }, 
    1088             }, 
    1089             email_templates => { 
    1090                 label   => "E-mail Templates", 
    1091                 order   => 300, 
    1092                 handler => sub { 
    1093                     my ($terms) = @_; 
    1094                     $terms->{type} = 'email'; 
    1095                 }, 
    1096                 condition => sub { 
    1097                     !$app->param('blog_id'); 
    1098                 }, 
    1099             }, 
    1100             system_templates => { 
    1101                 label   => "System Templates", 
    1102                 order   => 200, 
    1103                 handler => sub { 
    1104                     my ($terms) = @_; 
    1105                     my $scope; 
    1106                     my $set; 
    1107                     if ( my $blog_id = $app->param('blog_id') ) { 
    1108                         my $blog = $app->model('blog')->load($blog_id); 
    1109                         $set = $blog->template_set; 
    1110                         $scope .= 'system'; 
    1111                     } 
    1112                     else { 
    1113                         $terms->{blog_id} = 0; 
    1114                         $scope = 'global:system'; 
    1115                     } 
    1116                     my @tmpl_path 
    1117                         = ( $set && ( $set ne 'mt_blog' ) ) 
    1118                         ? ( "template_sets", $set, 'templates', $scope ) 
    1119                         : ( "default_templates", $scope ); 
    1120                     my $sys_tmpl = MT->registry(@tmpl_path) || {}; 
    1121                     $terms->{type} = [ keys %$sys_tmpl ]; 
    1122                 }, 
    1123                 condition => sub { 
    1124                     $app->param('blog_id'); 
    11251052                }, 
    11261053            }, 
     
    24382365 
    24392366            # this is the template that likely caused the rebuild error 
    2440             push @{ $param->{button_loop} ||= [] }, 
    2441                 { 
    2442                 link => $app->uri( 
    2443                     mode => 'view', 
    2444                     args => { 
    2445                         blog_id => $tmpl->blog_id, 
    2446                         '_type' => 'template', 
    2447                         id      => $tmpl->id 
     2367            my $tmpl_edit_link = $app->uri( 
     2368                        mode => 'view', 
     2369                        args => { 
     2370                            blog_id => $tmpl->blog_id, 
     2371                            '_type' => 'template', 
     2372                            id      => $tmpl->id 
     2373                        } 
     2374                    ); 
     2375 
     2376            if ( $app->param('fs') ) { 
     2377                $param->{fs} = 1; 
     2378                if ( exists $app->{goback} ) { 
     2379                    $param->{goback} = "window.location='" . $app->{goback} . "'"; 
     2380                    if ( $tmpl_edit_link ne $app->{goback} ) { 
     2381                        push @{ $param->{button_loop} ||= [] }, 
     2382                          { 
     2383                            link => $tmpl_edit_link, 
     2384                            label => $app->translate("Edit Template"), 
     2385                          }; 
    24482386                    } 
    2449                 ), 
    2450                 label => $app->translate("Edit Template"), 
    2451                 }; 
    2452         } 
    2453  
    2454         my $blog_id = $app->param('blog_id'); 
    2455         my $url     = $app->uri( 
    2456             mode => 'rebuild_confirm', 
    2457             args => { blog_id => $blog_id } 
    2458         ); 
    2459         $param->{goback} ||= qq{window.location='$url'}; 
    2460         $param->{value}  ||= $app->translate('Go Back'); 
     2387                } 
     2388                else { 
     2389                    $param->{goback} = "window.location='$tmpl_edit_link'"; 
     2390                } 
     2391            } 
     2392            else { 
     2393                push @{ $param->{button_loop} ||= [] }, 
     2394                  { 
     2395                    link => $tmpl_edit_link, 
     2396                    label => $app->translate("Edit Template"), 
     2397                  }; 
     2398            } 
     2399        } 
     2400 
     2401        if ( !exists( $param->{goback} ) && exists( $app->{goback} ) ) { 
     2402            $param->{goback} = "window.location='" . $app->{goback} . "'"; 
     2403        } 
     2404        else { 
     2405            my $blog_id = $app->param('blog_id'); 
     2406            my $url     = $app->uri( 
     2407                mode => 'rebuild_confirm', 
     2408                args => { blog_id => $blog_id } 
     2409            ); 
     2410            $param->{goback} ||= qq{window.location='$url'}; 
     2411        } 
     2412        $param->{value} ||= $app->{value} || $app->translate('Go Back'); 
    24612413    } 
    24622414 
  • trunk/lib/MT/App/Search.pm

    r2991 r3082  
    227227            else { 
    228228                $blog_id =~ s/\D+//g;    # only numeric values. 
    229                 $blog_list{$type}{$blog_id} = 1; 
     229                $blog_list{$type}{$blog_id} = 1 if $blog_id; 
    230230            } 
    231231        } 
  • trunk/lib/MT/Asset/Image.pm

    r2635 r3082  
    231231 
    232232    require MT::Util; 
    233     my $format = $param{Format} || MT->translate('%f-thumb-%wx%h%x'); 
     233    my $format = $param{Format} || MT->translate('%f-thumb-%wx%h-%i%x'); 
    234234    my $width  = $param{Width}  || 'auto'; 
    235235    my $height = $param{Height} || 'auto'; 
     
    550550                    $app->translate( "Invalid basename '[_1]'", $rel_path ) ); 
    551551            } 
     552            $rel_path .= '-' . $asset->id; 
    552553            my $ext = $blog->file_extension || ''; 
    553554            $ext = '.' . $ext if $ext ne ''; 
     
    567568              File::Spec->catfile( $root_path, $rel_path . $ext ); 
    568569 
    569             ## If the popup filename already exists, we don't want to overwrite 
    570             ## it, because it could contain valuable data; so we'll just make 
    571             ## sure to generate the name uniquely. 
    572570            my ( $i, $rel_path_ext ) = ( 0, $rel_path . $ext ); 
    573             while ( $fmgr->exists($abs_file_path) ) { 
    574                 $rel_path_ext = $rel_path . ++$i . $ext; 
    575                 $abs_file_path = 
    576                   File::Spec->catfile( $root_path, $rel_path_ext ); 
    577             } 
    578571            $pseudo_path = File::Spec->catfile( $pseudo_path, $rel_path_ext ); 
    579572            my ( $vol, $dirs, $basename ) = 
     
    600593                $original   = $asset_html->clone; 
    601594                $asset_html->blog_id($blog_id); 
    602                 $asset_html->url($pseudo_path); 
     595                my $pseudo_url = $pseudo_path; 
     596                $pseudo_url  =~ s!\\!/!g; 
     597                $asset_html->url($pseudo_url); 
    603598                $asset_html->label($app->translate("Popup Page for [_1]", $asset->label || $asset->file_name)); 
    604599                $asset_html->file_path($pseudo_path); 
     
    610605            } else { 
    611606                $original   = $asset_html->clone; 
    612             }                 
     607            } 
    613608 
    614609            # Select back the real URL for callbacks 
  • trunk/lib/MT/Blog.pm

    r2606 r3082  
    870870        ); 
    871871        while (my $tmpl = $iter->()) { 
     872            my @old_widgets = split /,/, $tmpl->modulesets; 
    872873            $tmpl_processor->($new_blog_id, \$counter, $tmpl, \%tmpl_map); 
    873             my @old_widgets = split /,/, $tmpl->modulesets; 
    874874            my @new_widgets; 
    875875            push @new_widgets, $tmpl_map{$_} 
  • trunk/lib/MT/CMS/Asset.pm

    r2802 r3082  
    151151            push @blog_ids, $_->blog_id 
    152152              foreach grep { $_->can_edit_assets } @perms; 
    153             $terms{blog_id} = \@blog_ids; 
     153            $terms{blog_id} = @blog_ids ? \@blog_ids : 0; 
    154154        } 
    155155    } 
  • trunk/lib/MT/CMS/Blog.pm

    r3001 r3082  
    532532    my $type = $app->param('_type') || 'entry'; 
    533533    my @ids  = $app->param('id'); 
    534     $app->{goback} = "window.location='" . $app->return_uri . "'"; 
     534    $app->{goback} = $app->return_uri; 
    535535    $app->{value} ||= $app->translate('Go Back'); 
    536536    if ( $type eq 'entry' ) { 
     
    611611                $edit_type = $entry ? $entry->class : 'entry'; 
    612612            } 
    613             $app->{goback} = 
    614               "window.location='" 
    615               . $app->object_edit_uri( $edit_type, $obj_id ) . "'"; 
     613            $app->{goback} = $app->object_edit_uri( $edit_type, $obj_id ); 
    616614            $app->{value} ||= $app->translate('Go Back'); 
    617615        } 
     
    691689    elsif ($type) { 
    692690        my $special = 0; 
    693         my @options = $app->{rebuild_options} ||= {}; 
     691        my @options; 
     692        my $opts = $app->registry("rebuild_options") || {}; 
     693        if ($opts) { 
     694            foreach my $opt ( keys %$opts ) { 
     695                $opts->{$opt}{key} ||= $opt; 
     696                push @options, $opts->{$opt}; 
     697            } 
     698        } 
    694699        $app->run_callbacks( 'rebuild_options', $app, \@options ); 
    695700        for my $optn (@options) { 
    696701            if ( ( $optn->{key} || '' ) eq $type ) { 
     702                my $code = $optn->{code}; 
     703                unless ( ref($code) eq 'CODE' ) { 
     704                    $code = MT->handler_to_coderef($code); 
     705                    $optn->{code} = $code; 
     706                } 
    697707                $optn->{code}->(); 
    698708                $special = 1; 
  • trunk/lib/MT/CMS/Common.pm

    r3039 r3082  
    961961        } 
    962962        elsif ( $type eq 'category' ) { 
    963             my @kids = MT::Category->load( { parent => $id } ); 
    964             return $app->errtrans( 
    965 "You can't delete that category because it has sub-categories. Move or delete the sub-categories first if you want to delete this one." 
    966             ) if @kids; 
    967963            if ( $app->config('DeleteFilesAtRebuild') ) { 
    968964                require MT::Blog; 
  • trunk/lib/MT/CMS/Dashboard.pm

    r2812 r3082  
    404404 
    405405    my $terms = {}; 
     406    my $args = {}; 
    406407    $terms->{blog_id} = $blog_id if $blog_id; 
    407408    $terms->{object_datasource} = 'entry'; 
    408     my $args = {}; 
    409409    $args->{group} = [ 'tag_id' ]; 
    410410    $args->{sort} = '1'; # sort by count(*) 
    411411    $args->{direction} = 'descend'; 
    412412    $args->{limit} = 100; 
     413    $args->{join} = MT::Tag->join_on(undef, { id => \'= objecttag_tag_id', is_private => 1 }, 
     414        { not => { is_private => 1 } } ); 
    413415 
    414416    my $iter = $app->model('objecttag')->count_group_by($terms, $args); 
    415417    my @tag_loop; 
     418    my @tag_ids; 
    416419    my $ntags = 0; 
    417420    my $min = undef; 
    418421    my $max = undef; 
    419422    while (my ($count, $tag_id) = $iter->()) { 
    420         my $tag = MT::Tag->load($tag_id) or next; 
    421         next if $tag->is_private; # weed these from the dashboard 
    422423        $ntags += $count; 
    423424        $min = defined $min ? ($count < $min ? $count : $min) : $count; 
    424425        $max = defined $max ? ($count > $max ? $count : $max) : $count; 
    425         push @tag_loop, { name => $tag->name, count => $count }; 
     426        push @tag_loop, { id => $tag_id, count => $count }; 
     427        push @tag_ids, $tag_id; 
     428    } 
     429 
     430    if ( @tag_ids ) { 
     431        my $iter = MT::Tag->load_iter( { id => \@tag_ids } ); 
     432        my %tags; 
     433        while ( my $t = $iter->() ) { 
     434            $tags{ $t->id } = $t->name; 
     435        } 
     436        $_->{name} = $tags{$_->{id}} for @tag_loop; 
    426437    } 
    427438 
  • trunk/lib/MT/CMS/Entry.pm

    r2994 r3082  
    676676    $param{list_filters}        = $app->list_filters('entry'); 
    677677    $param{can_power_edit}      = $blog_id && !$is_power_edit; 
    678     $param{can_republish}       = $blog_id ? $perms->can_rebuild : 1; 
     678    $param{can_republish}       = $blog_id 
     679                                    ? $perms->can_rebuild 
     680                                    : $app->user->is_superuser 
     681                                        ? 1 
     682                                        : 0; 
    679683    $param{is_power_edit}       = $is_power_edit; 
    680684    $param{saved_deleted}       = $q->param('saved_deleted'); 
     
    10581062 
    10591063    my $class = $app->model($type) 
    1060       or retrun $app->errtrans("Invalid parameter"); 
     1064      or return $app->errtrans("Invalid parameter"); 
    10611065 
    10621066    my $cat_class = $app->model( $class->container_type ); 
  • trunk/lib/MT/L10N/ja.pm

    r2923 r3082  
    730730        'Error converting image: [_1]' => '画像を倉換できたせんでした: [_1]', 
    731731        'Error creating thumbnail file: [_1]' => 'サムネヌルを䜜成できたせんでした: [_1]', 
    732         '%f-thumb-%wx%h%x' => '%f-thumb-%wx%h%x', 
     732        '%f-thumb-%wx%h-%i%x' => '%f-thumb-%wx%h-%i%x', 
    733733        'Can\'t load image #[_1]' => 'ID:[_1]の画像をロヌドできたせんでした。', 
    734734        'View image' => '衚瀺', 
     
    852852        'Writing to \'[_1]\' failed: [_2]' => '\'[_1]\'に曞き蟌めたせんでした: [_2]', 
    853853        'Renaming tempfile \'[_1]\' failed: [_2]' => 'テンポラリファむル\'[_1]\'の名前を倉曎できたせんでした: [_2]', 
     854        'Blog, BlogID or Template param must be specified.' => 'Blog, BlogID, たたはTemplateのいずれかを指定しおください。', 
    854855        'Template \'[_1]\' does not have an Output File.' => 'テンプレヌト\'[_1]\'には出力ファむルの蚭定がありたせん。', 
    855856        'An error occurred while publishing scheduled entries: [_1]' => '日時指定されたブログ蚘事の再構築䞭に゚ラヌが発生したした: [_1]', 
     
    11391140        'IP Banning' => 'IP犁止リスト', 
    11401141        'Removing tag failed: [_1]' => 'タグを削陀できたせんでした: [_1]', 
    1141         'You can\'t delete that category because it has sub-categories. Move or delete the sub-categories first if you want to delete this one.' => 'サブカテゎリのあるカテゎリは削陀できたせん。サブカテゎリをå 
    1142 ˆã«å‰Šé™€ã™ã‚‹ã‹ã€ç§»å‹•しおください。', 
    11431142        'Loading MT::LDAP failed: [_1].' => 'MT::LDAPの読み蟌みに倱敗したした: [_1]', 
    11441143        'System templates can not be deleted.' => 'システムテンプレヌトは削陀できたせん。', 
     
    18741873        'Mapping template ID [_1] to [_2].' => 'テンプレヌト(ID:[_1])を[_2]にマッピングしおいたす...', 
    18751874        'Error loading class: [_1].' => 'クラスをロヌドできたせんでした: [_1]', 
    1876         'Error saving [_1] record # [_3]: [_2]... [_4].' => '[_1](ID: [_3])の保存䞭に゚ラヌが発生したした: [_2]... [_4]', 
     1875        'Assigning entry comment and TrackBack counts...' => 'コメントずトラックバックの件数を蚭定しおいたす....', 
     1876        'Error saving [_1] record # [_3]: [_2]...' => '[_1]のレコヌド(ID:[_3])を保存できたせんでした: [_2]', 
    18771877        'Creating entry category placements...' => 'ブログ蚘事ずカテゎリの関連付けを䜜成しおいたす...', 
    18781878        'Updating category placements...' => 'カテゎリの関連付けを曎新しおいたす...', 
     
    19261926        'Assigning blog page layout...' => 'ブログにペヌゞレむアりトを蚭定しおいたす...', 
    19271927        'Assigning author basename...' => 'ナヌザヌにベヌスネヌムを蚭定しおいたす...', 
    1928         'Assigning entry comment and TrackBack counts...' => 'コメントずトラックバックの件数を蚭定しおいたす....', 
    19291928        'Assigning embedded flag to asset placements...' => 'アむテムの関連付けの有無を蚭定しおいたす...', 
    19301929        'Updating template build types...' => 'テンプレヌトのビルドオプションを蚭定しおいたす...', 
     
    21052104¥åŠ›', 
    21062105        'Batch Edit Entries' => 'ブログ蚘事の䞀括線集', 
    2107         'Publish Pages' => 'りェブペヌゞをå 
    2108 ¬é–‹', 
    21092106        'Unpublish Pages' => 'りェブペヌゞのå 
    21102107¬é–‹ã‚’取り消し', 
     
    21522149        'Comments in the last 7 days' => '最近7日間以冠
    21532150のコメント', 
    2154         'E-mail Templates' => 'メヌルテンプレヌト', 
    21552151        'Tags with entries' => 'ブログ蚘事のタグ', 
    21562152        'Tags with pages' => 'りェブペヌゞのタグ', 
     
    37943790        'You must set a valid Site URL.' => '有効なサむトURLを指定しおください。', 
    37953791        'You must set a valid Local Site Path.' => '有効なサむトパスを指定しおください。', 
     3792        'You must set Local Archive Path.' => 'アヌカむブパスを指定する忠
     3793芁がありたす。', 
     3794        'You must set a valid Archive URL.' => '有効なアヌカむブURLを指定しおください。', 
     3795        'You must set a valid Local Archive Path.' => '有効なアヌカむブパスを指定しおください。', 
    37963796        'Publishing Paths' => 'å 
    37973797¬é–‹ãƒ‘ス', 
  • trunk/lib/MT/ObjectDriver/Driver/DBI.pm

    r2664 r3082  
    580580=item * post_group_by 
    581581 
    582     callback($class, \$value, \@retrunvals) 
     582    callback($class, \$value, \@returnvals) 
    583583 
    584584Callback issued prior to returning the number and additional return 
  • trunk/lib/MT/Permission.pm

    r2099 r3082  
    8585} 
    8686 
     87sub global_perms { 
     88    my $perm = shift; 
     89 
     90    return undef unless $perm->author_id; 
     91    return $perm unless $perm->blog_id; 
     92 
     93    $perm->cache_property( 
     94        'global_perms', 
     95        sub { 
     96            __PACKAGE__->load( { author_id => $perm->author_id, blog_id => 0 }); 
     97        } 
     98    ); 
     99} 
     100 
    87101# Legend: 
    88102# author_id || blog_id || permissions 
     
    289303                        && $author->is_superuser ); 
    290304                    return 1 
    291                       if ( ( $set eq 'blog' ) 
     305                      if ( ( $_[0]->blog_id ) 
    292306                        && $_[0]->has('administer_blog') ); 
    293307                } 
    294308            } 
     309            # return negative if a restriction is present 
    295310            return undef 
    296311              if $_[0]->restrictions && $_[0]->restrictions =~ /'$perm'/i; 
    297             ( defined($cur_perm) && $cur_perm =~ /'$perm'/i ) ? 1 : undef; 
     312            # return positive if permission is set in this permission set 
     313            return 1 if defined($cur_perm) && $cur_perm =~ /'$perm'/i; 
     314            # test for global-level permission 
     315            return 1 
     316              if $_[0]->author_id 
     317              && $_[0]->blog_id 
     318              && $_[0]->global_perms 
     319              && $_[0]->global_perms->has($perm); 
     320            return undef; 
    298321        }; 
    299322    } 
  • trunk/lib/MT/Tag.pm

    r2632 r3082  
    176176        object_datasource => $datasource 
    177177    }, { unique => 1, %jargs }); 
    178     my @tags = MT::Tag->load($terms, $args); 
     178    my @tags; 
     179    my $iter = MT::Tag->load_iter($terms, $args); 
     180    while ( my $tag = $iter->() ) { 
     181        push @tags, $tag; 
     182    } 
    179183    @tags; 
    180184} 
     
    335339    } else { 
    336340        require MT::ObjectTag; 
    337         @tags = MT::Tag->search(undef, {   
     341        my $iter = MT::Tag->load_iter(undef, { 
    338342            sort => 'name',   
    339343            join => [ 'MT::ObjectTag', 'tag_id', { object_id => $obj->id, 
    340344                object_datasource => $obj->datasource }, { unique => 1 } ],        
    341345        }); 
     346        while ( my $tag = $iter->() ) { 
     347            push @tags, $tag; 
     348        } 
    342349        $cache->set($memkey, [ map { $_->id } @tags ], TAG_CACHE_TIME); 
    343350    } 
  • trunk/lib/MT/Template.pm

    r2973 r3082  
    335335    $obj->modulesets( join ',', @ids ) 
    336336        if scalar @ids != scalar @inst; 
    337     $obj->text($text) if $text; 
     337    $obj->text($text); 
    338338    return $obj->SUPER::save; 
    339339} 
  • trunk/lib/MT/Template/Context.pm

    r3035 r3082  
    321321    # If no blog IDs specified, use the current blog 
    322322    if ( ! $blog_ids ) { 
    323         $terms->{$col} = $blog_id if $col eq 'blog_id'; 
     323        $terms->{$col} = $blog_id if $blog_id && $col eq 'blog_id'; 
    324324    }  
    325325    # If exclude blogs, set the terms and the NOT arg for load 
  • trunk/lib/MT/Template/ContextHandlers.pm

    r3062 r3082  
    721721sub _fltr_setvar { 
    722722    my ($str, $arg, $ctx) = @_; 
    723     $ctx->var($arg, $str); 
     723    if ( my $hash = $ctx->{__inside_set_hashvar} ) { 
     724        $hash->{$arg} = $str; 
     725    } 
     726    else { 
     727        $ctx->var($arg, $str); 
     728    } 
    724729    return ''; 
    725730} 
     
    1014410149    unless (ref $blog) { 
    1014510150        my $blog_id = $blog || $args->{offset_blog_id}; 
    10146         if ($blog) { 
     10151        if ($blog_id) { 
    1014710152            $blog = MT->model('blog')->load($blog_id); 
    1014810153            return $ctx->error( MT->translate( 'Can\'t load blog #[_1].', $blog_id ) ) 
     
    1015510160        my($y, $mo, $d, $h, $m, $s) = $ts =~ /(\d\d\d\d)[^\d]?(\d\d)[^\d]?(\d\d)[^\d]?(\d\d)[^\d]?(\d\d)[^\d]?(\d\d)/; 
    1015610161        $mo--; 
    10157         my $server_offset = $blog->server_offset; 
     10162        my $server_offset = ($blog && $blog->server_offset) || MT->config->TimeOffset; 
    1015810163        if ((localtime (timelocal ($s, $m, $h, $d, $mo, $y )))[8]) { 
    1015910164            $server_offset += 1; 
     
    1017310178        my $tz = 'Z'; 
    1017410179        unless ($args->{utc}) { 
    10175             my $so = $blog->server_offset; 
     10180            my $so = ($blog && $blog->server_offset) || MT->config->TimeOffset; 
    1017610181            my $partial_hour_offset = 60 * abs($so - int($so)); 
    1017710182            if ($format eq 'rfc822') { 
     
    1594815953    if (my $ext = $args->{file_ext}) { 
    1594915954        my @exts = split(',', $args->{file_ext}); 
    15950         if (!$assets) { 
     15955        if ($assets) { 
    1595115956            push @filters, sub { my $a = $_[0]->file_ext; grep(m/$a/, @exts) }; 
    1595215957        } else { 
  • trunk/lib/MT/TemplateMap.pm

    r2966 r3082  
    107107            } 
    108108        } 
     109        elsif ( $_[0] && $_[0]->{blog_id} ) { 
     110            # for cases where we remove with a blog_id parameter 
     111            $blog_id = $_[0]->{blog_id}; 
     112        } 
    109113 
    110114        my $maps_iter = MT::TemplateMap->count_group_by( 
  • trunk/lib/MT/Upgrade.pm

    r3013 r3082  
    166166        $code = MT->handler_to_coderef($code); 
    167167        my $result = $code->($self, %param, %update_params, step => $name); 
    168         if ((defined $result) && ($result > 1)) { 
     168        if (ref $result eq 'HASH') { 
     169            $param{$_} = $result->{$_} for keys %$result; 
     170            $result = 1; 
     171            $self->add_step($name, %param); 
     172        } 
     173        elsif ((defined $result) && ($result > 1)) { 
    169174            $param{offset} = $result; $result = 1; 
    170175            $self->add_step($name, %param); 
     
    216221        my $fn = \%MT::Upgrade::functions; 
    217222        my @these_steps = @steps; 
     223 
    218224        while (@these_steps) { 
    219225            my $step = shift @these_steps; 
     
    225231                                      $fn->{$b->[0]}->{priority} } @these_steps; 
    226232            } 
     233 
     234            # Reset the request to eliminate any caching that may be 
     235            # happening there (objects tend to cache into the request 
     236            # with the 'cache_property' method) 
     237            MT->request->reset; 
    227238        } 
    228239        return 1; 
     
    838849} 
    839850 
     851sub core_update_entry_counts { 
     852    my $self = shift; 
     853    my (%param) = @_; 
     854 
     855    my $class = MT->model('entry'); 
     856    return $self->error($self->translate_escape("Error loading class: [_1].", $param{type})) 
     857        unless $class; 
     858 
     859    my $msg = $self->translate_escape("Assigning entry comment and TrackBack counts..."); 
     860    my $offset = $param{offset} || 0; 
     861    my $count = $param{count}; 
     862    if (!$count) { 
     863        $count = $class->count({ class => '*' }); 
     864    } 
     865    return unless $count; 
     866    if ($offset) { 
     867        $self->progress(sprintf("$msg (%d%%)", ($offset/$count*100)), $param{step}); 
     868    } else { 
     869        $self->progress($msg, $param{step}); 
     870    } 
     871 
     872    my $continue = 0; 
     873    my $driver = $class->driver; 
     874 
     875    my $iter = $class->load_iter({ class => '*' }, { offset => $offset, limit => $MAX_ROWS+1 }); 
     876    my $start = time; 
     877    my ( %touched, %c, %tb ); 
     878    my $rows = 0; 
     879    while (my $e = $iter->()) { 
     880        $rows++; 
     881        $c{$e->id} = $e; 
     882        if (my $tb = $e->trackback) { 
     883            $tb{$tb->id} = $e; 
     884        } 
     885        $continue = 1, last if scalar $rows == $MAX_ROWS; 
     886    } 
     887    if ( $continue ) { 
     888        $iter->end; 
     889        $offset += $rows; 
     890    } 
     891 
     892    # now gather counts -- comments 
     893    if (my $grp_iter = MT::Comment->count_group_by({ 
     894        visible => 1, 
     895        entry_id => [ keys %c ], 
     896    }, { 
     897        group => ['entry_id'], 
     898    })) { 
     899        while (my ($count, $id) = $grp_iter->()) { 
     900            my $e = $c{$id} or next; 
     901            if ((!defined $e->comment_count) || (($e->comment_count || 0) != $count)) { 
     902                $e->comment_count($count); 
     903                $touched{$e->id} = $e; 
     904            } 
     905        } 
     906    } 
     907 
     908    # pings 
     909    if ( %tb ) { 
     910        if (my $grp_iter = MT::TBPing->count_group_by({ 
     911            visible => 1, 
     912            tb_id => [ keys %tb ], 
     913        }, { 
     914            group => ['tb_id'], 
     915        })) { 
     916            while (my ($count, $id) = $grp_iter->()) { 
     917                my $e = $tb{$id} or next; 
     918                if ((!defined $e->ping_count) || (($e->ping_count || 0) != $count)) { 
     919                    $e->ping_count($count); 
     920                    $touched{$e->id} = $e; 
     921                } 
     922            } 
     923        } 
     924    } 
     925 
     926    foreach my $e (values %touched) { 
     927        $e->save; 
     928    } 
     929 
     930    if ($continue) { 
     931        return { offset => $offset, count => $count }; 
     932    } else { 
     933        $self->progress("$msg (100%)", $param{step}); 
     934    } 
     935    1; 
     936} 
     937 
    840938sub core_update_records { 
    841939    my $self = shift; 
     
    858956    } 
    859957    my $offset = $param{offset}; 
     958    my $count = $param{count}; 
     959    if (!$count) { 
     960        $count = $class->count; 
     961    } 
     962    return unless $count; 
    860963    if ($offset) { 
    861         my $count = $class->count; 
    862         return unless $count; 
    863964        $self->progress(sprintf("$msg (%d%%)", ($offset/$count*100)), $param{step}); 
    864965    } else { 
     
    893994            } 
    894995            $code->($obj); 
    895             use Data::Dumper; 
    896996            $obj->save() 
    897                 or return $self->error($self->translate_escape("Error saving [_1] record # [_3]: [_2]... [_4].", $class_label, $obj->errstr, $obj->id, Dumper($obj))); 
     997                or return $self->error($self->translate_escape("Error saving [_1] record # [_3]: [_2]...", $class_label, $obj->errstr, $obj->id)); 
    898998            $continue = 1, last if time > $start + $MAX_TIME; 
    899999        } 
    9001000    } 
    9011001    if ($continue) { 
    902         return $offset; 
     1002        return { offset => $offset, count => $count }; 
    9031003    } else { 
    9041004        $self->progress("$msg (100%)", $param{step}); 
  • trunk/lib/MT/Upgrade/v4.pm

    r3014 r3082  
    350350            version_limit => 4.0047, 
    351351            priority      => 3.2, 
    352             updater       => { 
    353                 type      => 'entry', 
    354                 label     => 'Assigning entry comment and TrackBack counts...', 
    355                 condition => sub { 
    356                     require MT::Comment; 
    357                     my $comment_count = MT::Comment->count( 
    358                         { 
    359                             entry_id => $_[0]->id, 
    360                             visible  => 1, 
    361                         } 
    362                     ); 
    363                     $_[0]->comment_count($comment_count); 
    364                     require MT::Trackback; 
    365                     require MT::TBPing; 
    366                     my $tb = MT::Trackback->load( { entry_id => $_[0]->id } ); 
    367                     my $ping_count; 
    368                     if ($tb) { 
    369                         my $ping_count = MT::TBPing->count( 
    370                             { 
    371                                 tb_id   => $tb->id, 
    372                                 visible => 1, 
    373                             } 
    374                         ); 
    375                         $_[0]->ping_count($ping_count); 
    376                     } 
    377                     ( $comment_count || $ping_count ); 
    378                 }, 
    379                 # only count once and set it, so code do nothing. 
    380                 # it doesn't have the unnecessary save. 
    381                 code => sub { 1; }, 
    382             }, 
     352            code          => \&core_update_entry_counts, 
    383353        }, 
    384354        'core_assign_object_embedded' => { 
     
    490460                    $file_template =~ s/%-C/<MTCategoryLabel dirify="-">/g; 
    491461                    $map->file_template($file_template); 
    492                 }, 
    493             }, 
    494         }, 
    495         'core_assign_all_permisssions_blog_admin' => { 
    496             version_limit => 4.0063, 
    497             priority => 3.4, 
    498             updater => { 
    499                 type => 'permission', 
    500                 label => 'Assigning all permissions to blog administrator...', 
    501                 condition => sub { 
    502                     $_[0]->can_administer_blog && $_[0]->blog_id; 
    503                 }, 
    504                 code => sub { 
    505                     my ($perm) = shift; 
    506                     $perm->set_full_permissions; 
    507                 }, 
    508             }, 
    509         }, 
    510         'core_recover_sysadmin_permissions' => { 
    511             version_limit => 4.0066, 
    512             priority => 3.5, 
    513             updater => { 
    514                 type => 'permission', 
    515                 label => 'Recover permissions of system administrators...', 
    516                 condition => sub { 
    517                     !$_[0]->blog_id && !$_[0]->has('administer') && $_[0]->can_administer_blog; 
    518                 }, 
    519                 code => sub { 
    520                     my ($perm) = shift; 
    521                     $perm->set_permissions('system'); 
    522462                }, 
    523463            }, 
     
    10621002        'limit'      => 101, 
    10631003        'fetchonly' => [ 'id' ],  # meta is added to the select list separately 
     1004        'sort'      => 'id', 
     1005        'direction' => 'ascend', 
    10641006        $offset ? ( 'offset' => $offset ) : () 
    10651007    }; 
     
    11881130} 
    11891131 
     1132sub core_update_entry_counts { 
     1133    my $self = shift; 
     1134    my (%param) = @_; 
     1135 
     1136    my $class = MT->model('entry'); 
     1137    return $self->error($self->translate_escape("Error loading class: [_1].", $param{type})) 
     1138        unless $class; 
     1139 
     1140    my $msg = $self->translate_escape("Assigning entry comment and TrackBack counts..."); 
     1141    my $offset = $param{offset} || 0; 
     1142    my $count = $param{count}; 
     1143    if (!$count) { 
     1144        $count = $class->count({ class => '*' }); 
     1145    } 
     1146    return unless $count; 
     1147    if ($offset) { 
     1148        $self->progress(sprintf("$msg (%d%%)", ($offset/$count*100)), $param{step}); 
     1149    } else { 
     1150        $self->progress($msg, $param{step}); 
     1151    } 
     1152 
     1153    my $continue = 0; 
     1154    my $driver = $class->driver; 
     1155 
     1156    my $iter = $class->load_iter({ class => '*' }, { offset => $offset, limit => $MAX_ROWS+1 }); 
     1157    my $start = time; 
     1158    my ( %touched, %c, %tb ); 
     1159    my $rows = 0; 
     1160    while (my $e = $iter->()) { 
     1161        $rows++; 
     1162        $c{$e->id} = $e; 
     1163        if (my $tb = $e->trackback) { 
     1164            $tb{$tb->id} = $e; 
     1165        } 
     1166        $continue = 1, last if scalar $rows == $MAX_ROWS; 
     1167    } 
     1168    if ( $continue ) { 
     1169        $iter->end; 
     1170        $offset += $rows; 
     1171    } 
     1172 
     1173    # now gather counts -- comments 
     1174    if (my $grp_iter = MT::Comment->count_group_by({ 
     1175        visible => 1, 
     1176        entry_id => [ keys %c ], 
     1177    }, { 
     1178        group => ['entry_id'], 
     1179    })) { 
     1180        while (my ($count, $id) = $grp_iter->()) { 
     1181            my $e = $c{$id} or next; 
     1182            if ((!defined $e->comment_count) || (($e->comment_count || 0) != $count)) { 
     1183                $e->comment_count($count); 
     1184                $touched{$e->id} = $e; 
     1185            } 
     1186        } 
     1187    } 
     1188 
     1189    # pings 
     1190    if ( %tb ) { 
     1191        if (my $grp_iter = MT::TBPing->count_group_by({ 
     1192            visible => 1, 
     1193            tb_id => [ keys %tb ], 
     1194        }, { 
     1195            group => ['tb_id'], 
     1196        })) { 
     1197            while (my ($count, $id) = $grp_iter->()) { 
     1198                my $e = $tb{$id} or next; 
     1199                if ((!defined $e->ping_count) || (($e->ping_count || 0) != $count)) { 
     1200                    $e->ping_count($count); 
     1201                    $touched{$e->id} = $e; 
     1202                } 
     1203            } 
     1204        } 
     1205    } 
     1206 
     1207    foreach my $e (values %touched) { 
     1208        $e->save; 
     1209    } 
     1210 
     1211    if ($continue) { 
     1212        return { offset => $offset, count => $count }; 
     1213    } else { 
     1214        $self->progress("$msg (100%)", $param{step}); 
     1215    } 
     1216    1; 
     1217} 
     1218 
    119012191; 
  • trunk/lib/MT/WeblogPublisher.pm

    r3001 r3082  
    14161416    require MT::Template::Context; 
    14171417    require MT::Entry; 
     1418 
    14181419    my $blog; 
    1419     unless ( $blog = $param{Blog} ) { 
     1420    $blog = $param{Blog} 
     1421        if defined $param{Blog}; 
     1422    if (!$blog && defined $param{BlogID}) { 
    14201423        my $blog_id = $param{BlogID}; 
    14211424        $blog = MT::Blog->load($blog_id) 
     
    14281431    } 
    14291432    my $tmpl = $param{Template}; 
    1430     unless ($blog) { 
     1433    if ($tmpl && (!$blog || $blog->id != $tmpl->blog_id)) { 
    14311434        $blog = MT::Blog->load( $tmpl->blog_id ); 
    14321435    } 
     1436 
     1437    return $mt->error( 
     1438        MT->translate( 
     1439            "Blog, BlogID or Template param must be specified.") 
     1440    ) unless $blog; 
     1441 
    14331442    return 1 if $blog->is_dynamic; 
    14341443    my $iter; 
  • trunk/mt-static/js/archetype_editor.js

    r2560 r3082  
    427427        html = html.replace(/<(br|img|input|param)([^>]+)?([^\/])?>/g, "<$1$2$3 />"); 
    428428 
    429         // #4 - get absolute path and delete from converted URL  
    430         var d = this.document.createElement('div'); 
    431         d.innerHTML = '<a href="dummy.html"></a>'; 
    432         var path = d.innerHTML; 
    433         path = path.toLowerCase(); 
    434         path = path.replace(/<a href="(.*)dummy.html"><\/a>/, "$1"); 
     429        // #4 - get absolute path and delete from converted URL 
     430        var path = this.document.URL; 
     431        path = path.replace(/(.*)editor-content.html.*/, "$1"); 
    435432        var regex = new RegExp(path, "g"); 
     433        html = html.replace(regex, ""); 
     434        /* XXX for save on ff */ 
     435        regex = new RegExp(path.replace(/~/, "%7E"), "g"); 
    436436        html = html.replace(regex, ""); 
    437437 
  • trunk/php/lib/MTUtil.php

    r3034 r3082  
    13011301    $dest; 
    13021302    $thumb_name = $static_file_path.DIRECTORY_SEPARATOR.$image_path.DIRECTORY_SEPARATOR.$format; 
    1303     if (!$thumb->get_thumbnail($dest, $thumb_w, $thumb_h, $scale, $thumb_name, 'png')) { 
     1303    if (!$thumb->get_thumbnail($dest, $thumb_w, $thumb_h, $asset['asset_id'], $scale, $thumb_name, 'png')) { 
    13041304        return ''; 
    13051305    } 
     
    13141314 
    13151315# for compatibility... 
    1316 function make_thumbnail_file($src, $dest, $width, $height, $scale = 0, $dest_type = 'auto') { 
     1316function make_thumbnail_file($src, $dest, $width, $height, $scale = 0, $dest_type = 'auto', $id = 0) { 
    13171317    require_once('thumbnail_lib.php'); 
    13181318    $thumb = new Thumbnail($src); 
     
    13201320    $thumb_w = $width; 
    13211321    $thumb_h = $height; 
    1322     $thumb->get_thumbnail($dest, $thumb_w, $thumb_h, $scale, null, $dest_type); 
     1322    $thumb->get_thumbnail($dest, $thumb_w, $thumb_h, $id, $scale, null, $dest_type); 
    13231323 
    13241324    return array($thumb_w, $thumb_h); 
    13251325} 
    13261326 
    1327 function get_thumbnail_file($asset, $blog, $width = 0, $height = 0, $scale = 0, $format = '%f-thumb-%wx%h%x') { 
     1327function get_thumbnail_file($asset, $blog, $width = 0, $height = 0, $scale = 0, $format = '%f-thumb-%wx%h-%i%x') { 
    13281328    # Get parameter 
    13291329    $site_path = $blog['blog_site_path']; 
     
    13381338    $ts = preg_replace('![^0-9]!', '', $asset['asset_created_on']); 
    13391339    $date_stamp = format_ts('%Y/%m', $ts, $blog); 
    1340     $cache_dir = $site_path . DIRECTORY_SEPARATOR . $cache_path . DIRECTORY_SEPARATOR . $date_stamp . DIRECTORY_SEPARATOR; 
     1340    $base_path = $site_path; 
     1341    if (preg_match('/^%a/', $asset['asset_file_path']) && !empty($blog['blog_archive_path'])) { 
     1342        $base_path = $blog['blog_archive_path']; 
     1343        $base_path = preg_replace('/\/$/', '', $base_path); 
     1344    } 
     1345 
     1346    $cache_dir = $base_path . DIRECTORY_SEPARATOR . $cache_path . DIRECTORY_SEPARATOR . $date_stamp . DIRECTORY_SEPARATOR; 
    13411347    $thumb_name = $cache_dir . $format; 
    1342   
     1348 
    13431349    # generate thumbnail 
    13441350    require_once('thumbnail_lib.php'); 
     
    13471353    $thumb_h = $height; 
    13481354    $dest; 
    1349     if (!$thumb->get_thumbnail($dest, $thumb_w, $thumb_h, $scale, $thumb_name)) { 
     1355    if (!$thumb->get_thumbnail($dest, $thumb_w, $thumb_h, $asset['asset_id'], $scale, $thumb_name)) { 
    13501356        return ''; 
    13511357    } 
     
    13531359    # make url 
    13541360    $basename = basename($dest); 
    1355     $site_url = $blog['blog_site_url']; 
    1356     if (!preg_match('!/$!', $site_url)) 
    1357         $site_url .= '/'; 
    1358  
    1359     $thumb_url = $site_url . $cache_path . '/' . $date_stamp . '/' . $basename; 
     1361    $base_url = $blog['blog_site_url']; 
     1362    if (preg_match('/^%a/', $asset['asset_file_path']) && !empty($blog['blog_archive_url'])) 
     1363        $base_url = $blog['blog_archive_url']; 
     1364    if (!preg_match('!/$!', $base_url)) 
     1365        $base_url .= '/'; 
     1366 
     1367    $thumb_url = $base_url . $cache_path . '/' . $date_stamp . '/' . $basename; 
    13601368 
    13611369    return array($thumb_url, $thumb_w, $thumb_h, $thumb_name); 
  • trunk/php/lib/function.mtvar.php

    r2873 r3082  
    111111                } 
    112112            } 
     113            else { 
     114                if (array_key_exists('to_json', $args) && $args['to_json']) { 
     115                    if (function_exists('json_encode')) { 
     116                        $return_val = json_encode($value); 
     117                    } else { 
     118                        $return_val = ''; 
     119                    } 
     120                } 
     121            } 
    113122        } 
    114123        elseif (is_array($value)) { 
     
    140149            } 
    141150            else { 
    142                 if (!array_key_exists('to_json', $args) && $args['to_json']) { 
    143                     $glue = $args['glue']; 
    144                     if (!isset($glue)) 
    145                         $glue = ''; 
    146                     $return_val = implode($glue, $value); 
     151                if (array_key_exists('to_json', $args) && $args['to_json']) { 
     152                    if (function_exists('json_encode')) { 
     153                        $return_val = json_encode($value); 
     154                    } else { 
     155                        $return_val = ''; 
     156                    } 
    147157                } 
    148158            } 
  • trunk/php/lib/modifier.setvar.php

    r1174 r3082  
    99    global $mt; 
    1010    $ctx =& $mt->context(); 
    11     $vars =& $ctx->__stash['vars']; 
     11    if (array_key_exists('__inside_set_hashvar', $ctx->__stash)) { 
     12        $vars =& $ctx->__stash['__inside_set_hashvar']; 
     13    } else { 
     14        $vars =& $ctx->__stash['vars']; 
     15    } 
    1216    $vars[$name] = $text; 
    1317    return ''; 
    1418} 
    15 ?> 
  • trunk/php/lib/sanitize_lib.php

    r1098 r3082  
    3838                $inside = preg_replace('!/?>$!', '', $inside); 
    3939                $attrs = ''; 
    40                 if (preg_match_all('/\s*(\w+)\s*=(?:([\'"])(.*?)\2|([^\s]+))\s*/', $inside, $matches, PREG_SET_ORDER)) { 
     40                if (preg_match_all('/\s*(\w+)\s*=(?:([\'"])(.*?)\2|([^\s]+))\s*/s', $inside, $matches, PREG_SET_ORDER)) { 
    4141                    foreach ($matches as $match) { 
    4242                        $attr = strtolower($match[1]); 
     
    5555                                $dec_val = preg_replace('/&#0*58(?:=;|[^0-9])/', ':', $dec_val); 
    5656                                $dec_val = preg_replace('/&#x0*3[Aa](?:=;|[^a-fA-F0-9])/', ':', $dec_val); 
    57                                 if (preg_match('/^(.+?):/', $dec_val, $proto_match)) { 
     57                                if (preg_match('/^([\s\S]+?):/', $dec_val, $proto_match)) { 
    5858                                    $proto = $proto_match[1]; 
    5959                                    if (preg_match('/[\r\n\t]/', $proto)) { 
  • trunk/php/lib/thumbnail_lib.php

    r2691 r3082  
    5656    } 
    5757 
    58     function _make_dest_name ($w, $h, $format, $dest_type) { 
     58    function _make_dest_name ($w, $h, $format, $dest_type, $id) { 
    5959        $output = $this->src_type; 
    6060        if ($dest_type != 'auto') { 
     
    8282        $patterns[1] = '/%h/'; 
    8383        $patterns[2] = '/%f/'; 
    84         $patterns[3] = '/%x/'; 
     84        $patterns[3] = '/%i/'; 
     85        $patterns[4] = '/%x/'; 
    8586        $replacement[0] = $w; 
    8687        $replacement[1] = $h; 
    8788        $replacement[2] = $basename; 
    88         $replacement[3] = $ext; 
     89        $replacement[3] = $id; 
     90        $replacement[4] = $ext; 
    8991 
    9092        return preg_replace($patterns, $replacement, $format); 
     
    9294 
    9395    # Load or generate a thumbnail. 
    94     function get_thumbnail (&$dest, &$width, &$height, $scale = 0, $format = '%f-thumb-%wx%h%x', $dest_type = 'auto') { 
     96    function get_thumbnail (&$dest, &$width, &$height, $id, $scale = 0, $format = '%f-thumb-%wx%h-%i%x', $dest_type = 'auto') { 
    9597        if (empty($this->src_file)) return false; 
    9698        if (!file_exists($this->src_file)) return false; 
     
    130132        # Decide a destination file name 
    131133        if (empty($dest)) { 
    132             $dest = $this->_make_dest_name($thumb_w_name, $thumb_h_name, $format, $dest_type); 
     134            $dest = $this->_make_dest_name($thumb_w_name, $thumb_h_name, $format, $dest_type, $id); 
    133135        } 
    134136 
  • trunk/php/mt.php

    r3019 r3082  
    1010define('PRODUCT_VERSION', '4.21'); 
    1111 
    12 $PRODUCT_NAME = '__PRODUCT_NAME__'; 
     12$PRODUCT_NAME = 'Movable Type Pro'; 
    1313if($PRODUCT_NAME == '__PRODUCT' . '_NAME__') 
    1414    $PRODUCT_NAME = 'Movable Type'; 
  • trunk/t/35-tags.dat

    r2696 r3082  
    323323{ "r" : "1", "t" : "<MTAssets lastn='1'><$MTAssetProperty property='description'$></MTAssets>", "e" : "This is a test photo."}, #271 
    324324{ "r" : "1", "t" : "<MTAssets lastn='1'><$MTAssetFileExt$></MTAssets>", "e" : "jpg"}, #272 
    325 { "r" : "1", "t" : "<MTAssets lastn='1'><$MTAssetThumbnailURL width='160'$></MTAssets>", "e" : "http://narnia.na/nana/assets_c/CURRENT_YEAR/CURRENT_MONTH/test-thumb-160xauto.jpg"}, #273 
    326 { "r" : "1", "t" : "<MTAssets lastn='1'><$MTAssetThumbnailURL height='240'$></MTAssets>", "e" : "http://narnia.na/nana/assets_c/CURRENT_YEAR/CURRENT_MONTH/test-thumb-autox240.jpg"}, #274 
    327 { "r" : "1", "t" : "<MTAssets lastn='1'><$MTAssetThumbnailURL scale='75'$></MTAssets>", "e" : "http://narnia.na/nana/assets_c/CURRENT_YEAR/CURRENT_MONTH/test-thumb-480x360.jpg"}, #275 
     325{ "r" : "1", "t" : "<MTAssets lastn='1'><$MTAssetThumbnailURL width='160'$></MTAssets>", "e" : "http://narnia.na/nana/assets_c/CURRENT_YEAR/CURRENT_MONTH/test-thumb-160xauto-1.jpg"}, #273 
     326{ "r" : "1", "t" : "<MTAssets lastn='1'><$MTAssetThumbnailURL height='240'$></MTAssets>", "e" : "http://narnia.na/nana/assets_c/CURRENT_YEAR/CURRENT_MONTH/test-thumb-autox240-1.jpg"}, #274 
     327{ "r" : "1", "t" : "<MTAssets lastn='1'><$MTAssetThumbnailURL scale='75'$></MTAssets>", "e" : "http://narnia.na/nana/assets_c/CURRENT_YEAR/CURRENT_MONTH/test-thumb-480x360-1.jpg"}, #275 
    328328{ "r" : "1", "t" : "<MTAssets lastn='1'><$MTAssetLink$></MTAssets>", "e" : "<a href=\"http://narnia.na/nana/images/test.jpg\">test.jpg</a>"}, #276 
    329 { "r" : "1", "t" : "<MTAssets lastn='1'><$MTAssetThumbnailLink$></MTAssets>", "e" : "<a href=\"http://narnia.na/nana/images/test.jpg\"><img src=\"http://narnia.na/nana/assets_c/CURRENT_YEAR/CURRENT_MONTH/test-thumb-640x480.jpg\" width=\"640\" height=\"480\" alt=\"\" /></a>"}, #277 
    330 { "r" : "1", "t" : "<MTAssets lastn='1'><$MTAssetThumbnailLink width='160'$></MTAssets>", "e" : "<a href=\"http://narnia.na/nana/images/test.jpg\"><img src=\"http://narnia.na/nana/assets_c/CURRENT_YEAR/CURRENT_MONTH/test-thumb-160xauto.jpg\" width=\"160\" height=\"120\" alt=\"\" /></a>"}, #278 
    331 { "r" : "1", "t" : "<MTAssets lastn='1'><$MTAssetThumbnailLink height='240'$></MTAssets>", "e" : "<a href=\"http://narnia.na/nana/images/test.jpg\"><img src=\"http://narnia.na/nana/assets_c/CURRENT_YEAR/CURRENT_MONTH/test-thumb-autox240.jpg\" width=\"320\" height=\"240\" alt=\"\" /></a>"}, #279 
    332 { "r" : "1", "t" : "<MTAssets lastn='1'><$MTAssetThumbnailLink scale='100'$></MTAssets>", "e" : "<a href=\"http://narnia.na/nana/images/test.jpg\"><img src=\"http://narnia.na/nana/assets_c/CURRENT_YEAR/CURRENT_MONTH/test-thumb-640x480.jpg\" width=\"640\" height=\"480\" alt=\"\" /></a>"}, #280 
     329{ "r" : "1", "t" : "<MTAssets lastn='1'><$MTAssetThumbnailLink$></MTAssets>", "e" : "<a href=\"http://narnia.na/nana/images/test.jpg\"><img src=\"http://narnia.na/nana/assets_c/CURRENT_YEAR/CURRENT_MONTH/test-thumb-640x480-1.jpg\" width=\"640\" height=\"480\" alt=\"\" /></a>"}, #277 
     330{ "r" : "1", "t" : "<MTAssets lastn='1'><$MTAssetThumbnailLink width='160'$></MTAssets>", "e" : "<a href=\"http://narnia.na/nana/images/test.jpg\"><img src=\"http://narnia.na/nana/assets_c/CURRENT_YEAR/CURRENT_MONTH/test-thumb-160xauto-1.jpg\" width=\"160\" height=\"120\" alt=\"\" /></a>"}, #278 
     331{ "r" : "1", "t" : "<MTAssets lastn='1'><$MTAssetThumbnailLink height='240'$></MTAssets>", "e" : "<a href=\"http://narnia.na/nana/images/test.jpg\"><img src=\"http://narnia.na/nana/assets_c/CURRENT_YEAR/CURRENT_MONTH/test-thumb-autox240-1.jpg\" width=\"320\" height=\"240\" alt=\"\" /></a>"}, #279 
     332{ "r" : "1", "t" : "<MTAssets lastn='1'><$MTAssetThumbnailLink scale='100'$></MTAssets>", "e" : "<a href=\"http://narnia.na/nana/images/test.jpg\"><img src=\"http://narnia.na/nana/assets_c/CURRENT_YEAR/CURRENT_MONTH/test-thumb-640x480-1.jpg\" width=\"640\" height=\"480\" alt=\"\" /></a>"}, #280 
    333333{ "r" : "1", "t" : "<MTAssets lastn='1'><$MTAssetLink new_window='1'$></MTAssets>", "e" : "<a href=\"http://narnia.na/nana/images/test.jpg\" target=\"_blank\">test.jpg</a>"}, #281 
    334 { "r" : "1", "t" : "<MTAssets lastn='1'><$MTAssetThumbnailLink new_window='1'$></MTAssets>", "e" : "<a href=\"http://narnia.na/nana/images/test.jpg\" target=\"_blank\"><img src=\"http://narnia.na/nana/assets_c/CURRENT_YEAR/CURRENT_MONTH/test-thumb-640x480.jpg\" width=\"640\" height=\"480\" alt=\"\" /></a>"}, #282 
    335 { "r" : "1", "t" : "<MTAssets lastn='1'><$MTAssetThumbnailLink new_window='1' width='160'$></MTAssets>", "e" : "<a href=\"http://narnia.na/nana/images/test.jpg\" target=\"_blank\"><img src=\"http://narnia.na/nana/assets_c/CURRENT_YEAR/CURRENT_MONTH/test-thumb-160xauto.jpg\" width=\"160\" height=\"120\" alt=\"\" /></a>"}, #283 
    336 { "r" : "1", "t" : "<MTAssets lastn='1'><$MTAssetThumbnailLink new_window='1' scale='100'$></MTAssets>", "e" : "<a href=\"http://narnia.na/nana/images/test.jpg\" target=\"_blank\"><img src=\"http://narnia.na/nana/assets_c/CURRENT_YEAR/CURRENT_MONTH/test-thumb-640x480.jpg\" width=\"640\" height=\"480\" alt=\"\" /></a>"}, #284 
    337 { "r" : "1", "t" : "<MTAssets lastn='1'><$MTAssetThumbnailLink new_window='1' scale='100'$></MTAssets>", "e" : "<a href=\"http://narnia.na/nana/images/test.jpg\" target=\"_blank\"><img src=\"http://narnia.na/nana/assets_c/CURRENT_YEAR/CURRENT_MONTH/test-thumb-640x480.jpg\" width=\"640\" height=\"480\" alt=\"\" /></a>"}, #285 
     334{ "r" : "1", "t" : "<MTAssets lastn='1'><$MTAssetThumbnailLink new_window='1'$></MTAssets>", "e" : "<a href=\"http://narnia.na/nana/images/test.jpg\" target=\"_blank\"><img src=\"http://narnia.na/nana/assets_c/CURRENT_YEAR/CURRENT_MONTH/test-thumb-640x480-1.jpg\" width=\"640\" height=\"480\" alt=\"\" /></a>"}, #282 
     335{ "r" : "1", "t" : "<MTAssets lastn='1'><$MTAssetThumbnailLink new_window='1' width='160'$></MTAssets>", "e" : "<a href=\"http://narnia.na/nana/images/test.jpg\" target=\"_blank\"><img src=\"http://narnia.na/nana/assets_c/CURRENT_YEAR/CURRENT_MONTH/test-thumb-160xauto-1.jpg\" width=\"160\" height=\"120\" alt=\"\" /></a>"}, #283 
     336{ "r" : "1", "t" : "<MTAssets lastn='1'><$MTAssetThumbnailLink new_window='1' scale='100'$></MTAssets>", "e" : "<a href=\"http://narnia.na/nana/images/test.jpg\" target=\"_blank\"><img src=\"http://narnia.na/nana/assets_c/CURRENT_YEAR/CURRENT_MONTH/test-thumb-640x480-1.jpg\" width=\"640\" height=\"480\" alt=\"\" /></a>"}, #284 
     337{ "r" : "1", "t" : "<MTAssets lastn='1'><$MTAssetThumbnailLink new_window='1' scale='100'$></MTAssets>", "e" : "<a href=\"http://narnia.na/nana/images/test.jpg\" target=\"_blank\"><img src=\"http://narnia.na/nana/assets_c/CURRENT_YEAR/CURRENT_MONTH/test-thumb-640x480-1.jpg\" width=\"640\" height=\"480\" alt=\"\" /></a>"}, #285 
    338338{ "r" : "1", "t" : "<$MTAssetCount$>", "e" : "2"}, #286 
    339339{ "r" : "1", "t" : "<MTAssets lastn='1'><MTAssetTags><$MTTagName$>; </MTAssetTags></MTAssets>", "e" : "alpha; beta; gamma; "}, #287 
  • trunk/tmpl/cms/cfg_archives.tmpl

    r2213 r3082  
    116116        return false; 
    117117    } 
     118    if (f.enable_archive_paths.checked) { 
     119        if (!f.archive_path.value) { 
     120            alert('<__trans phrase="You must set Local Archive Path." escape="singlequotes">'); 
     121            return false; 
     122        } else if (!is_valid_url(f.archive_url.value)){ 
     123            alert('<__trans phrase="You must set a valid Archive URL." escape="singlequotes">'); 
     124            return false; 
     125        } else if (!is_valid_path(f.archive_path.value)){ 
     126            alert('<__trans phrase="You must set a valid Local Archive Path." escape="singlequotes">'); 
     127            return false; 
     128        } 
     129    } 
    118130    f.site_url.disabled = false; 
    119131    f.site_path.disabled = false; 
     
    126138} 
    127139function is_valid_path(path_){ 
    128     for(i = 0; i < path_.length; i++){ 
    129         var buf = escape(path_.substr(i, 1)); 
    130         if (buf.match(/^%u.*/)){ 
    131             return false; 
    132         } 
    133         if (buf.match(/(%.{2}){2}?/)){ 
    134                 return false; 
    135         } 
     140    var str = path_.replace(/[ "%<>\[\\\]\^`{\|}~]/g, ""); 
     141    str = encodeURI(str); 
     142    if (str.indexOf('%') != -1) { 
     143        return false; 
     144    } 
     145    if (str.match(/\.\./)) { 
     146        return false; 
    136147    } 
    137148    return true; 
  • trunk/tmpl/cms/error.tmpl

    r2784 r3082  
    2424                <mt:if name="dialog"> 
    2525                onclick="if ( window.opener ) { window.close(); } else { window.parent.closeDialog('<mt:var name="link" escape="js">'); }; return false;" 
     26                <mt:elseif name="fs"> 
     27                onclick="window.location='<mt:var name="link" escape="js">'; return false;" 
    2628                <mt:else> 
    2729                onclick="if ( window.opener ) { window.opener.location.href='<mt:var name="link" escape="js">'; window.close(); } else { window.open('<mt:var name="link" escape="js">') }; return false;" 
  • trunk/tmpl/cms/include/template_table.tmpl

    r2934 r3082  
    2525    <mt:if name="template_type" eq="index"> 
    2626        <a href="javascript:void(0)" 
    27             onclick="doForMarkedInThisWindow(getByID('<$mt:var name="template_type"$>-listing-form'), '<__trans phrase="template" escape="js">', '<__trans phrase="templates" escape="js">', 'id', 'publish_index_templates', {}, '<__trans phrase="to publish" escape="js">'); return false;" 
     27            onclick="doForMarkedInThisWindow(getByID('<$mt:var name="template_type" default="template"$>-listing-form'), '<__trans phrase="template" escape="js">', '<__trans phrase="templates" escape="js">', 'id', 'publish_index_templates', {}, '<__trans phrase="to publish" escape="js">'); return false;" 
    2828            accesskey="a" 
    2929            title="<__trans phrase="Publish selected templates (a)">" 
     
    3131    <mt:else if name="template_type" eq="archive"> 
    3232        <a href="javascript:void(0)" 
    33             onclick="doForMarkedInThisWindow(getByID('<$mt:var name="template_type"$>-listing-form'), '<__trans phrase="template" escape="js">', '<__trans phrase="templates" escape="js">', 'id', 'publish_archive_templates', {}, '<__trans phrase="to publish" escape="js">'); return false;" 
     33            onclick="doForMarkedInThisWindow(getByID('<$mt:var name="template_type" default="template"$>-listing-form'), '<__trans phrase="template" escape="js">', '<__trans phrase="templates" escape="js">', 'id', 'publish_archive_templates', {}, '<__trans phrase="to publish" escape="js">'); return false;" 
    3434            accesskey="a" 
    3535            title="<__trans phrase="Publish selected templates (a)">" 
     
    3737    </mt:if> 
    3838    <a href="javascript:void(0)" 
    39         onclick="doRemoveItems(getByID('<$mt:var name="template_type"$>-listing-form'), '<__trans phrase="template" escape="js">', '<__trans phrase="templates" escape="js">'); return false;" 
     39        onclick="doRemoveItems(getByID('<$mt:var name="template_type" default="template"$>-listing-form'), '<__trans phrase="template" escape="js">', '<__trans phrase="templates" escape="js">'); return false;" 
    4040        accesskey="x" 
    4141        title="<__trans phrase="Delete selected [_1] (x)" params="<$mt:var name="object_label_plural"$>">" 
     
    7474        <tbody> 
    7575    </mt:if> 
    76             <tr class="<mt:if name="__odd__">odd<mt:else>even</mt:if> template-<$mt:var name="template_type"$>"> 
     76            <tr class="<mt:if name="__odd__">odd<mt:else>even</mt:if> template-<$mt:var name="template_type" default="template"$>"> 
    7777                <td class="cb"><input type="checkbox" name="id" class="select" value="<mt:var name="id">" /></td> 
    7878                <td class="template-name"><a href="<mt:var name="script_url">?__mode=view&amp;_type=template&amp;id=<mt:var name="id">&amp;blog_id=<mt:var name="blog_id">"><mt:var name="name" escape="html"></a></td> 
     
    139139<mt:else> 
    140140    <mt:if name="blog_id"> 
    141     <div id="<$mt:var name="template_type"$>-listing" class="listing zero-state-listing zero-state"> 
     141    <div id="<$mt:var name="template_type" default="template"$>-listing" class="listing zero-state-listing zero-state"> 
    142142        <div class="listing-header"> 
    143143            <$mt:var name="listing_header"$> 
  • trunk/tmpl/cms/list_template.tmpl

    r2622 r3082  
    2121        </mt:if> 
    2222        </ul> 
     23        <$mtapp:ListFilters$> 
    2324    </mtapp:widget> 
    2425    <mtapp:widget 
  • trunk/tmpl/cms/widget/blog_stats_tag_cloud.tmpl

    r1857 r3082  
    55 
    66    <div id="tag-panel" class="<mt:unless name="tab" eq="tag">hidden</mt:unless>" mt:tab-content="tag"> 
     7<mt:Section cache_prefix="tagcloud" period="3600" by_blog="1" by_user="1"> 
    78        <div id="tag-cloud"> 
    89            <ul id="tag-cloud-list"> 
     
    1213            </ul> 
    1314        </div> 
     15</mt:Section> 
    1416        <div id="tag-cloud-recent-entries"></div> 
    1517    </div>