📄 entry.pm
字号:
next if $url =~ /^$archive_url/; if (my $item = discover_tb($url)) { $to_ping{ $item->{ping_url} } = 1 unless $pinged{$item->{ping_url}}; } } $entry->to_ping_urls(join "\n", keys %to_ping); } $entry->SUPER::save(@_) or return; ## If pings are allowed on this entry, create or update ## the corresponding TrackBack object for this entry. require MT::Trackback; if ($entry->allow_pings) { my $tb; unless ($tb = MT::Trackback->load({ entry_id => $entry->id })) { $tb = MT::Trackback->new; $tb->blog_id($entry->blog_id); $tb->entry_id($entry->id); $tb->category_id(0); ## category_id can't be NULL } $tb->title($entry->title); $tb->description($entry->get_excerpt); $tb->url($entry->permalink); $tb->is_disabled(0); $tb->save or return $entry->error($tb->errstr); } else { ## If there is a TrackBack item for this entry, but ## pings are now disabled, make sure that we mark the ## object as disabled. if (my $tb = MT::Trackback->load({ entry_id => $entry->id })) { $tb->is_disabled(1); $tb->save or return $entry->error($tb->errstr); } } 1;}sub remove { my $entry = shift; my $comments = $entry->comments; for my $comment (@$comments) { $comment->remove; } require MT::Placement; my @place = MT::Placement->load({ entry_id => $entry->id }); for my $place (@place) { $place->remove; } require MT::Trackback; my @tb = MT::Trackback->load({ entry_id => $entry->id }); for my $tb (@tb) { $tb->remove; } $entry->SUPER::remove; # Archive types other than Individual may refer to this entry, but # not essentially. only the individual A.T. needs to be blottoed. require MT::FileInfo; my @finfos = MT::FileInfo->load({ entry_id => $entry->id, archive_type => 'Individual', }); for my $finfo (@finfos) { $finfo->remove(); }}sub blog { my ($entry) = @_; my $blog = $entry->{__blog}; unless ($blog) { my $blog_id = $entry->blog_id; require MT::Blog; $blog = MT::Blog->load($blog_id) or return $entry->error(MT->translate( "Load of blog '[_1]' failed: [_2]", $blog_id, MT::Blog->errstr)); $entry->{__blog} = $blog; } return $blog;}1;__END__=head1 NAMEMT::Entry - Movable Type entry record=head1 SYNOPSIS use MT::Entry; my $entry = MT::Entry->new; $entry->blog_id($blog->id); $entry->status(MT::Entry::RELEASE()); $entry->author_id($author->id); $entry->title('My title'); $entry->text('Some text'); $entry->save or die $entry->errstr;=head1 DESCRIPTIONAn I<MT::Entry> object represents an entry in the Movable Type system. Itcontains all of the metadata about the entry (author, status, category, etc.),as well as the actual body (and extended body) of the entry.=head1 USAGEAs a subclass of I<MT::Object>, I<MT::Entry> inherits all of thedata-management and -storage methods from that class; thus you should lookat the I<MT::Object> documentation for details about creating a new object,loading an existing object, saving an object, etc.The following methods are unique to the I<MT::Entry> interface:=head2 $entry->nextLoads and returns the next entry, where "next" is defined as the next recordin ascending chronological order (the entry posted after the current entry).entry I<$entry>).Returns an I<MT::Entry> object representing this next entry; if there is nota next entry, returns C<undef>.Caches the return value internally so that subsequent calls will not have tore-query the database.=head2 $entry->previousLoads and returns the previous entry, where "previous" is defined as theprevious record in ascending chronological order (the entry posted before thecurrent entry I<$entry>).Returns an I<MT::Entry> object representing this previous entry; if there isnot a next entry, returns C<undef>.Caches the return value internally so that subsequent calls will not have tore-query the database.=head2 $entry->authorReturns an I<MT::Author> object representing the author of the entryI<$entry>. If the author record has been removed, returns C<undef>.Caches the return value internally so that subsequent calls will not have tore-query the database.=head2 $entry->categoryReturns an I<MT::Category> object representing the primary category of theentry I<$entry>. If a primary category has not been assigned, returnsC<undef>.Caches the return value internally so that subsequent calls will not have tore-query the database.=head2 $entry->categoriesReturns a reference to an array of I<MT::Category> objects representing thecategories to which the entry I<$entry> has been assigned (both primary andsecondary categories). If the entry has not been assigned to any categories,returns a reference to an empty array.Caches the return value internally so that subsequent calls will not have tore-query the database.=head2 $entry->is_in_category($cat)Returns true if the entry I<$entry> has been assigned to entry I<$cat>, falseotherwise.=head2 $entry->commentsReturns a reference to an array of I<MT::Comment> objects representing thecomments made on the entry I<$entry>. If no comments have been made on theentry, returns a reference to an empty array.Caches the return value internally so that subsequent calls will not have tore-query the database.=head2 $entry->comment_countReturns the number of comments made on this entry.Caches the return value internally so that subsequent calls will not have tore-query the database.=head2 $entry->ping_countReturns the number of TrackBack pings made on this entry.Caches the return value internally so that subsequent calls will not have tore-query the database.=head2 $entry->archive_file([ $archive_type ])Returns the name of/path to the archive file for the entry I<$entry>. IfI<$archive_type> is not specified, and you are using multiple archive typesfor your blog, the path is created from the preferred archive type that youhave selected. If I<$archive_type> is specified, it should be one of thefollowing values: C<Individual>, C<Daily>, C<Weekly>, C<Monthly>, andC<Category>.=head2 $entry->archive_url([ $archive_type ])Returns the absolute URL to the archive page for the entry I<$entry>. Thiscalls I<archive_file> internally, so if I<$archive_type> is specified, itis merely passed through to that method. In other words, this is theblog Archive URL plus the results of I<archive_file>.=head2 $entry->permalink([ $archive_type ])Returns the (smart) permalink for the entry I<$entry>. Internally this callsI<archive_url>, which calls I<archive_file>, so I<$archive_type> (ifspecified) is merely passed through to that method. The result of thismethod is the same as I<archive_url> plus the URI fragment(C<#entry_id>), unless the preferred archive type is Individual, in whichcase the two methods give exactly the same results.=head2 $entry->text_filtersReturns a reference to an array of text filter keynames (the short namesthat are the first argument to I<MT::add_text_filter>. This list can bepassed directly in as the second argument to I<MT::apply_text_filters>.=head1 DATA ACCESS METHODSThe I<MT::Entry> object holds the following pieces of data. These fields canbe accessed and set using the standard data access methods described in theI<MT::Object> documentation.=over 4=item * idThe numeric ID of the entry.=item * blog_idThe numeric ID of the blog in which this entry has been posted.=item * author_idThe numeric ID of the author who posted this entry.=item * statusThe status of the entry, either Publish (C<2>) or Draft (C<1>).=item * allow_commentsAn integer flag specifying whether comments are allowed on this entry. Thissetting determines whether C<E<lt>MTEntryIfAllowCommentsE<gt>> containers aredisplayed for this entry. Possible values are 0 for no comments, 1 for opencomments and 2 for closed comments (that is, display the comments on thisentry but do not allow new comments to be added).=item * convert_breaksA boolean flag specifying whether line and paragraph breaks should be convertedwhen rebuilding this entry.=item * titleThe title of the entry.=item * excerptThe excerpt of the entry.=item * textThe main body text of the entry.=item * text_moreThe extended body text of the entry.=item * created_onThe timestamp denoting when the entry record was created, in the formatC<YYYYMMDDHHMMSS>. Note that the timestamp has already been adjusted for theselected timezone.=item * modified_onThe timestamp denoting when the entry record was last modified, in theformat C<YYYYMMDDHHMMSS>. Note that the timestamp has already been adjustedfor the selected timezone.=back=head1 DATA LOOKUPIn addition to numeric ID lookup, you can look up or sort records by anycombination of the following fields. See the I<load> documentation inI<MT::Object> for more information.=over 4=item * blog_id=item * status=item * author_id=item * created_on=item * modified_on=back=head1 NOTES=over 4=item *When you remove an entry using I<MT::Entry::remove>, in addition to removingthe entry record, all of the comments and placements (I<MT::Comment> andI<MT::Placement> records, respectively) for this entry will also be removed.=back=head1 AUTHOR & COPYRIGHTSPlease see the I<MT> manpage for author, copyright, and license information.=cut
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -