################################################################################ # MTPingedEntry - A Plugin for Moveable Type # ** This is Masahiko Isshiki's kung fu! ** # http://www.masahiko.info/blog/ # # Release 1.0 # October 20, 2003 # --------------------------------------------------------------------------- # This software is provided as-is. # You may use it for commercial or personal use. # If you distribute it, please keep this notice intact. # # Copyright (c) 2003 Masahiko Isshiki. # --------------------------------------------------------------------------- ################################################################################ package MT::Plugins::PingedEntry; use strict; use MT::Template::Context; use vars qw($VERSION); $VERSION = 1.0; my $cleanbuild = 0; # turning on cleanbuild will silently put error messages in your blog MT::Template::Context->add_container_tag(PingedEntry => \&PingedEntry); MT::Template::Context->add_tag(PingedEntryLink => \&PingedEntryLink); MT::Template::Context->add_tag(PingedEntryTitle => \&PingedEntryTitle); sub PingedEntry { my ($ctx, $args) = @_; my $content = ""; if (exists $args->{"cleanbuild"}) { $cleanbuild = $args->{"cleanbuild"}; } my $ping = $ctx->stash('ping'); if (!$ping) { $content = "MTPingedEntry"; if (! $cleanbuild) { return $ctx->_no_ping_error($content); } return $content; } require MT::Trackback; my $tbid = $ping->tb_id; my $tb = MT::Trackback->load($tbid); if (!$tb) { $content = "Error in MTPingedEntry, while loading Trackback ID = $tbid"; if (! $cleanbuild) { return $ctx->error($content); } return $content; } require MT::Entry; my $entryid = $tb->entry_id; my $entry = MT::Entry->load($entryid); if (!$entry) { $content = "Error in MTPingedEntry, while loading Entry ID = $entryid"; if (! $cleanbuild) { return $ctx->error($content); } return $content; } my $title = $entry->title; my $permalink = $entry->permalink; my $builder = $ctx->stash('builder'); my $tokens = $ctx->stash('tokens'); $ctx->stash('pingedentry_permalink', $permalink); $ctx->stash('pingedentry_title', $title); $content = $builder->build($ctx,$tokens); return $content; } sub PingedEntryLink { my $ctx = shift; return $ctx->stash('pingedentry_permalink'); } sub PingedEntryTitle { my $ctx = shift; return $ctx->stash('pingedentry_title'); } 1;