[MTOS-dev] [movabletype] takayama, r1618: Fixed BugId:70976 BugId:70966, BugId:698...

Hirotaka Ogawa hirotaka.ogawa at gmail.com
Fri Mar 28 19:34:08 PDT 2008


Probably, we need to add:

        $entry = $is_prev ? $arctype->previous_archive_entry($param) :
$arctype->next_archive_entry($param);

line 5630 at MT/Temlate/ContextHandlers.pm.

Thanks,

On Sat, Mar 29, 2008 at 3:32 AM,  <commits at code.sixapart.com> wrote:
> Fixed BugId:70976 BugId:70966, BugId:69874
>  * Applied ogawa-san's patch.
>
>
>  U   branches/release-32/lib/MT/ArchiveType/Author.pm
>  U   branches/release-32/lib/MT/ArchiveType/Category.pm
>  U   branches/release-32/lib/MT/ArchiveType/Date.pm
>  U   branches/release-32/lib/MT/ArchiveType.pm
>  U   branches/release-32/lib/MT/Entry.pm
>  U   branches/release-32/lib/MT/Template/ContextHandlers.pm
>  U   branches/release-32/lib/MT/WeblogPublisher.pm
>
>
>  Modified: branches/release-32/lib/MT/ArchiveType/Author.pm
>  ===================================================================
>  --- branches/release-32/lib/MT/ArchiveType/Author.pm    2008-03-28 15:26:32 UTC (rev 1617)
>  +++ branches/release-32/lib/MT/ArchiveType/Author.pm    2008-03-28 18:32:46 UTC (rev 1618)
>  @@ -209,30 +209,4 @@
>      \@entries;
>   }
>
>  -sub get_adjacent_author_entry {
>  -    my $self = shift;
>  -    my ( $ts, $blog_id, $author, $order ) = @_;
>  -    if ( $order eq 'previous' ) {
>  -        $order = 'descend';
>  -    }
>  -    else {
>  -        $order = 'ascend';
>  -    }
>  -    require MT::Entry;
>  -    my $entry = MT::Entry->load(
>  -        {
>  -            status    => MT::Entry::RELEASE(),
>  -            author_id => $author->id,
>  -            blog_id   => $blog_id
>  -        },
>  -        {
>  -            limit     => 1,
>  -            'sort'    => 'authored_on',
>  -            direction => $order,
>  -            start_val => $ts
>  -        }
>  -    );
>  -    $entry;
>  -}
>  -
>   1;
>
>  Modified: branches/release-32/lib/MT/ArchiveType/Category.pm
>  ===================================================================
>  --- branches/release-32/lib/MT/ArchiveType/Category.pm  2008-03-28 15:26:32 UTC (rev 1617)
>  +++ branches/release-32/lib/MT/ArchiveType/Category.pm  2008-03-28 18:32:46 UTC (rev 1618)
>  @@ -176,29 +176,4 @@
>      return 1;
>   }
>
>  -sub get_adjacent_category_entry {
>  -    my $self = shift;
>  -    my ( $ts, $cat, $order ) = @_;
>  -    if ( $order eq 'previous' ) {
>  -        $order = 'descend';
>  -    }
>  -    else {
>  -        $order = 'ascend';
>  -    }
>  -    require MT::Entry;
>  -    require MT::Placement;
>  -    my $entry = MT::Entry->load(
>  -        { status => MT::Entry::RELEASE() },
>  -        {
>  -            limit     => 1,
>  -            'sort'    => 'authored_on',
>  -            direction => $order,
>  -            start_val => $ts,
>  -            'join' =>
>  -              [ 'MT::Placement', 'entry_id', { category_id => $cat->id } ]
>  -        }
>  -    );
>  -    $entry;
>  -}
>  -
>   1;
>
>  Modified: branches/release-32/lib/MT/ArchiveType/Date.pm
>  ===================================================================
>  --- branches/release-32/lib/MT/ArchiveType/Date.pm      2008-03-28 15:26:32 UTC (rev 1617)
>  +++ branches/release-32/lib/MT/ArchiveType/Date.pm      2008-03-28 18:32:46 UTC (rev 1618)
>  @@ -79,7 +79,7 @@
>      my $archiver = MT->publisher->archiver($at);
>      my ( $start, $end );
>      if ($ts) {
>  -        ( $start, $end ) = $archiver->date_range->($ts);
>  +        ( $start, $end ) = $archiver->date_range($ts);
>      }
>      else {
>          $start = $ctx->{current_timestamp};
>  @@ -129,4 +129,43 @@
>      $entry;
>   }
>
>  +# get an entry in the next or previous archive for dated-based ArchiveType
>  +sub next_archive_entry     { $_[0]->adjacent_archive_entry({ %{$_[1]}, order => 'next'     }) }
>  +sub previous_archive_entry { $_[0]->adjacent_archive_entry({ %{$_[1]}, order => 'previous' }) }
>  +
>  +sub adjacent_archive_entry {
>  +    my $obj = shift;
>  +    my ( $param ) = @_;
>  +
>  +    my $order   = ( $param->{order} eq 'previous' ) ? 'descend' : 'ascend';
>  +    my $cat     = $param->{category} if $obj->category_based;
>  +    my $author  = $param->{author}   if $obj->author_based;
>  +
>  +    my $ts      = $param->{ts};
>  +    my $blog_id = $param->{blog_id} || ($param->{blog} ? $param->{blog}->id : undef);
>  +
>  +    # if $param->{entry} given, override $ts and $blog_id.
>  +    if (my $e = $param->{entry}) {
>  +        $ts      = $e->authored_on;
>  +        $blog_id = $e->blog_id;
>  +    }
>  +    my ( $start, $end ) = $obj->date_range($ts);
>  +    $ts = ( $order eq 'descend' ) ? $start : $end;
>  +
>  +    require MT::Entry;
>  +    require MT::Placement;
>  +    my $entry = MT::Entry->load({
>  +        status  => MT::Entry::RELEASE(),
>  +        $blog_id ? ( blog_id   => $blog_id    ) : (),
>  +        $author  ? ( author_id => $author->id ) : (),
>  +    }, {
>  +        limit     => 1,
>  +        'sort'    => 'authored_on',
>  +        direction => $order,
>  +        start_val => $ts,
>  +        $cat     ? ( 'join'    => [ 'MT::Placement', 'entry_id', { category_id => $cat->id } ] ) : (),
>  +    });
>  +    $entry;
>  +}
>  +
>   1;
>
>  Modified: branches/release-32/lib/MT/ArchiveType.pm
>  ===================================================================
>  --- branches/release-32/lib/MT/ArchiveType.pm   2008-03-28 15:26:32 UTC (rev 1617)
>  +++ branches/release-32/lib/MT/ArchiveType.pm   2008-03-28 18:32:46 UTC (rev 1618)
>  @@ -9,11 +9,6 @@
>   use strict;
>   use MT::WeblogPublisher;
>
>  -our %ArchiveTypes;
>  -BEGIN {
>  -    *ArchiveTypes = *MT::WeblogPublisher::ArchiveTypes;
>  -}
>  -
>   sub new {
>      my $pkg  = shift;
>      my $self = {@_};
>  @@ -138,8 +133,7 @@
>      my $auth     = $params->{Author};
>      my ( $start, $end );
>      if ($ts) {
>  -        MT::WeblogPublisher::init_archive_types() unless %ArchiveTypes;
>  -        my $archiver = $ArchiveTypes{$at};
>  +        my $archiver = MT->publisher->archiver($at);
>          ( $start, $end ) = $archiver->date_range($ts) if $archiver;
>      }
>
>
>  Modified: branches/release-32/lib/MT/Entry.pm
>  ===================================================================
>  --- branches/release-32/lib/MT/Entry.pm 2008-03-28 15:26:32 UTC (rev 1617)
>  +++ branches/release-32/lib/MT/Entry.pm 2008-03-28 18:32:46 UTC (rev 1618)
>  @@ -224,7 +224,7 @@
>          args      => $args,
>          by        => 'authored_on',
>      );
>  -    weaken($o->{$label} = $o) if $o;
>  +    weaken($obj->{$label} = $o) if $o;
>      return $o;
>   }
>
>
>  Modified: branches/release-32/lib/MT/Template/ContextHandlers.pm
>  ===================================================================
>  --- branches/release-32/lib/MT/Template/ContextHandlers.pm      2008-03-28 15:26:32 UTC (rev 1617)
>  +++ branches/release-32/lib/MT/Template/ContextHandlers.pm      2008-03-28 18:32:46 UTC (rev 1618)
>  @@ -5614,26 +5614,20 @@
>      my $arctype = MT->publisher->archiver($at);
>      return '' unless $arctype;
>
>  -    my ($start, $end, $entry);
>  +    my $entry;
>      if ($arctype->date_based && $arctype->category_based) {
>  -        my $cat = $ctx->stash('archive_category');
>  -        $start = $ctx->{current_timestamp};
>  -        $end = $ctx->{current_timestamp_end};
>  -        if ($is_prev) {
>  -            $entry = $arctype->get_adjacent_category_entry( $start, $cat, 'previous' );
>  -        } else {
>  -            $entry = $arctype->get_adjacent_category_entry( $end, $cat, 'next' );
>  -        }
>  +        my $param = {
>  +            ts       => $ctx->{current_timestamp},
>  +            blog_id  => $ctx->stash('blog_id'),
>  +            category => $ctx->stash('archive_category'),
>  +        };
>  +        $entry = $is_prev ? $arctype->previous_archive_entry($param) : $arctype->next_archive_entry($param);
>      } elsif ($arctype->date_based && $arctype->author_based) {
>  -        my $author = $ctx->stash('author');
>  -        my $blog = $ctx->stash('blog');
>  -        $start = $ctx->{current_timestamp};
>  -        $end = $ctx->{current_timestamp_end};
>  -        if ($is_prev) {
>  -            $entry = $arctype->get_adjacent_author_entry( $start, $blog->id, $author, 'previous' );
>  -        } else {
>  -            $entry = $arctype->get_adjacent_author_entry( $end, $blog->id, $author, 'next' );
>  -        }
>  +        my $param = {
>  +            ts       => $ctx->{current_timestamp},
>  +            blog_id  => $ctx->stash('blog_id'),
>  +            author   => $ctx->stash('author'),
>  +        };
>      } elsif ($arctype->category_based) {
>          return _hdlr_category_prevnext(@_);
>      } elsif ($arctype->author_based) {
>  @@ -5658,9 +5652,11 @@
>              "[_1] can be used only with Daily, Weekly, or Monthly archives.",
>              "<MT$tag>" ))
>              unless $arctype->date_based;
>  -        my @arg = ($ts, $ctx->stash('blog_id'), $at);
>  -        push @arg, $is_prev ? 'previous' : 'next';
>  -        $entry = get_entry(@arg);
>  +        my $param = {
>  +            ts => $ctx->{current_timestamp},
>  +            blog_id => $ctx->stash('blog_id'),
>  +        };
>  +        $entry = $is_prev ? $arctype->previous_archive_entry($param) : $arctype->next_archive_entry($param);
>      }
>      if ($entry) {
>          my $builder = $ctx->stash('builder');
>
>  Modified: branches/release-32/lib/MT/WeblogPublisher.pm
>  ===================================================================
>  --- branches/release-32/lib/MT/WeblogPublisher.pm       2008-03-28 15:26:32 UTC (rev 1617)
>  +++ branches/release-32/lib/MT/WeblogPublisher.pm       2008-03-28 18:32:46 UTC (rev 1618)
>  @@ -377,7 +377,7 @@
>      }
>      return 1 if $blog->is_dynamic;
>
>  -    my $at = $blog->archive_type;
>  +    my $at = $param{PreferredArchiveOnly} ? $blog->archive_type_preferred : $blog->archive_type;
>      if ( $at && $at ne 'None' ) {
>          my @at = split /,/, $at;
>          for my $at (@at) {
>  @@ -430,22 +430,23 @@
>      if ( $param{BuildDependencies} ) {
>          ## Rebuild previous and next entry archive pages.
>          if ( my $prev = $entry->previous(1) ) {
>  -            $mt->rebuild_entry( Entry => $prev ) or return;
>  -
>  +            $mt->rebuild_entry( Entry => $prev, PreferredArchiveOnly => 1 ) or return;
>              ## Rebuild the old previous and next entries, if we have some.
>              if ( $param{OldPrevious}
>  +                && ( $param{OldPrevious} != $prev->id )
>                  && ( my $old_prev = MT::Entry->load( $param{OldPrevious} ) ) )
>              {
>  -                $mt->rebuild_entry( Entry => $old_prev ) or return;
>  +                $mt->rebuild_entry( Entry => $old_prev, PreferredArchiveOnly => 1 ) or return;
>              }
>          }
>          if ( my $next = $entry->next(1) ) {
>  -            $mt->rebuild_entry( Entry => $next ) or return;
>  +            $mt->rebuild_entry( Entry => $next, PreferredArchiveOnly => 1 ) or return;
>
>              if ( $param{OldNext}
>  +                && ( $param{OldNext} != $next->id )
>                  && ( my $old_next = MT::Entry->load( $param{OldNext} ) ) )
>              {
>  -                $mt->rebuild_entry( Entry => $old_next ) or return;
>  +                $mt->rebuild_entry( Entry => $old_next, PreferredArchiveOnly => 1 ) or return;
>              }
>          }
>      }
>  @@ -465,12 +466,14 @@
>          my @db_at = grep { my $archiver = $mt->archiver($_); $archiver && $archiver->date_based } $mt->archive_types;
>          for my $at (@db_at) {
>              if ( $at{$at} ) {
>  -                my @arg = ( $entry->authored_on, $entry->blog_id );
>                  my $archiver = $mt->archiver($at);
>  -                if ( my $prev_arch = $archiver->get_entry( @arg, 'previous' ) ) {
>  -                    if ( $archiver->category_based ) {
>  -                        my $cats = $prev_arch->categories;
>  -                        for my $cat (@$cats) {
>  +                if ( $archiver->category_based ) {
>  +                    my $cats = $entry->categories;
>  +                    for my $cat (@$cats) {
>  +                        if ( my $prev_arch = $archiver->previous_archive_entry({
>  +                            entry    => $entry,
>  +                            category => $cat,
>  +                        }) ) {
>                              $mt->_rebuild_entry_archive_type(
>                                  NoStatic => $param{NoStatic},
>                                  Entry    => $prev_arch,
>  @@ -482,24 +485,10 @@
>                                  ArchiveType => $at
>                              ) or return;
>                          }
>  -                    }
>  -                    else {
>  -                        $mt->_rebuild_entry_archive_type(
>  -                            NoStatic    => $param{NoStatic},
>  -                            Entry       => $prev_arch,
>  -                            Blog        => $blog,
>  -                            ArchiveType => $at,
>  -                            $param{TemplateMap}
>  -                            ? ( TemplateMap => $param{TemplateMap} )
>  -                            : (),
>  -                            Author => $prev_arch->author
>  -                        ) or return;
>  -                    }
>  -                }
>  -                if ( my $next_arch = $archiver->get_entry( @arg, 'next' ) ) {
>  -                    if ( $archiver->category_based ) {
>  -                        my $cats = $next_arch->categories;
>  -                        for my $cat (@$cats) {
>  +                        if ( my $next_arch = $archiver->next_archive_entry({
>  +                            entry    => $entry,
>  +                            category => $cat,
>  +                        }) ) {
>                              $mt->_rebuild_entry_archive_type(
>                                  NoStatic => $param{NoStatic},
>                                  Entry    => $next_arch,
>  @@ -512,16 +501,35 @@
>                              ) or return;
>                          }
>                      }
>  -                    else {
>  +                } else {
>  +                    if ( my $prev_arch = $archiver->previous_archive_entry({
>  +                        entry => $entry,
>  +                        $archiver->author_based ? (author => $entry->author) : (),
>  +                    }) ) {
>                          $mt->_rebuild_entry_archive_type(
>                              NoStatic    => $param{NoStatic},
>  +                            Entry       => $prev_arch,
>  +                            Blog        => $blog,
>  +                            ArchiveType => $at,
>  +                            $param{TemplateMap}
>  +                            ? ( TemplateMap => $param{TemplateMap} )
>  +                            : (),
>  +                            $archiver->author_based ? (Author => $entry->author) : (),
>  +                        ) or return;
>  +                    }
>  +                    if ( my $next_arch = $archiver->next_archive_entry({
>  +                        entry => $entry,
>  +                        $archiver->author_based ? (author => $entry->author) : (),
>  +                    }) ) {
>  +                        $mt->_rebuild_entry_archive_type(
>  +                            NoStatic    => $param{NoStatic},
>                              Entry       => $next_arch,
>                              Blog        => $blog,
>                              ArchiveType => $at,
>                              $param{TemplateMap}
>                              ? ( TemplateMap => $param{TemplateMap} )
>                              : (),
>  -                            Author => $next_arch->author
>  +                            $archiver->author_based ? (Author => $entry->author) : (),
>                          ) or return;
>                      }
>                  }
>  @@ -740,8 +748,6 @@
>      my $archiver = $mt->archiver($at);
>      return unless $archiver;
>
>  -    my $fmgr = $blog->file_mgr;
>  -
>      # Special handling for pages-- they are always published to the
>      # 'site' path instead of the 'archive' path, which is reserved for blog
>      # content.
>
>
>  _______________________________________________
>  MTOS-commits mailing list
>  MTOS-commits at sixapart.com
>  http://www.sixapart.com/mailman/listinfo/mtos-commits
>



-- 
Hirotaka Ogawa makes no sense.
http://as-is.net/blog/


More information about the MTOS-dev mailing list