Changeset 27 for recently-pinged-on
- Timestamp:
- 04/06/05 22:06:12 (4 years ago)
- Files:
-
- 1 modified
-
recently-pinged-on/trunk/recently-pinged-on.pl (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
recently-pinged-on/trunk/recently-pinged-on.pl
r25 r27 1 1 # A plugin for adding 'recently_pinged_on' option to MTEntries container 2 # by Hirotaka Ogawa (http://as-is.net/blog/)3 2 # 4 # Release 0.1 1 (Jan 29, 2005)3 # Release 0.12 (Feb 06, 2005) 5 4 # 6 5 # This software is provided as-is. You may use it for commercial or … … 15 14 require MT::Plugin; 16 15 my $plugin = new MT::Plugin(); 17 $plugin->name("recently_pinged_on Plugin 0.1 1");16 $plugin->name("recently_pinged_on Plugin 0.12"); 18 17 $plugin->description("Add 'recently_ping_on' option to MTEntries container"); 19 18 $plugin->doc_link("http://as-is.net/hacks/2005/01/recently_pinged_on_plugin.html"); … … 29 28 sub hdlr_entries { 30 29 my ($ctx, $args, $cond) = @_; 30 my $recently_pinged_on = $args->{recently_pinged_on} or 31 return &$mt_hdlr_entries(@_); 31 32 32 my $recently_pinged_on = $args->{recently_pinged_on}; 33 return &$mt_hdlr_entries($ctx, $args, $cond) unless $recently_pinged_on; 33 my $blog_id = $ctx->stash('blog_id'); 34 34 35 35 require MT::TBPing; 36 my $iter = MT::TBPing->load_iter({ blog_id => $ ctx->stash('blog_id')},36 my $iter = MT::TBPing->load_iter({ blog_id => $blog_id }, 37 37 { sort => 'created_on', 38 38 direction => 'descend' }); … … 45 45 46 46 require MT::Trackback; 47 my $trackback = MT::Trackback->load($tb_id);48 my $entry_id = $trackback->entry_id or next;49 50 47 require MT::Entry; 51 my $entry = MT::Entry->load($entry_id);52 next if $entry->status != MT::Entry::RELEASE();53 48 my @args = ({ status => MT::Entry::RELEASE() }, 49 { join => ['MT::Trackback', 'entry_id', { id => $tb_id }] }); 50 my $entry = MT::Entry->load(@args) or next; 54 51 push(@entries, $entry); 55 52 last if ++$count == $recently_pinged_on; … … 57 54 } 58 55 56 my $res = ''; 59 57 my $tokens = $ctx->stash('tokens'); 60 58 my $builder = $ctx->stash('builder'); 61 my $res = ''; 62 my $saved_entry = $ctx->stash('entry'); 59 my $i = 0; 63 60 for my $e (@entries) { 64 $ctx->stash('entry', $e); 65 defined(my $out = $builder->build($ctx, $tokens)) 66 or return $ctx->error($ctx->errstr); 61 local $ctx->{__stash}{entry} = $e; 62 local $ctx->{current_timestamp} = $e->created_on; 63 local $ctx->{modification_timestamp} = $e->modified_on; 64 my $out = $builder->build($ctx, $tokens, { 65 %$cond, 66 EntryIfExtended => $e->text_more ? 1 : 0, 67 EntryIfAllowComments => $e->allow_comments, 68 EntryIfCommentsOpen => $e->allow_comments && $e->allow_comments eq '1', 69 EntryIfAllowPings => $e->allow_pings, 70 EntriesHeader => !$i, 71 EntriesFooter => !defined $entries[$i+1] 72 }); 73 return $ctx->error($ctx->errstr) unless defined $out; 67 74 $res .= $out; 75 $i++; 68 76 } 69 $ctx->stash('entry', $saved_entry);70 77 $res; 71 78 }
![(please configure the [header_logo] section in trac.ini)](/public/chrome/common/trac_banner.png)