From b05a3a2cc6ea816c215a9f3266dd6b83d92dbf39 Mon Sep 17 00:00:00 2001 From: Andrew O'Neil Date: Fri, 12 Sep 2008 02:09:13 +0000 Subject: [PATCH] FEATURE: Added receiving of TrackPack pings --- code/BlogEntry.php | 5 ++- code/BlogHolder.php | 2 +- code/TrackBackDecorator.php | 53 ++++++++++++++++++++++++++++++++ code/TrackBackPing.php | 16 ++++++++++ templates/Includes/TrackBacks.ss | 15 +++++++++ templates/Layout/BlogEntry.ss | 3 +- templates/TrackBackPingReturn.ss | 5 +++ templates/TrackBackRdf.ss | 3 ++ 8 files changed, 99 insertions(+), 3 deletions(-) create mode 100644 code/TrackBackDecorator.php create mode 100644 code/TrackBackPing.php create mode 100644 templates/Includes/TrackBacks.ss create mode 100644 templates/TrackBackPingReturn.ss create mode 100644 templates/TrackBackRdf.ss diff --git a/code/BlogEntry.php b/code/BlogEntry.php index a175017..e3fa3de 100644 --- a/code/BlogEntry.php +++ b/code/BlogEntry.php @@ -8,7 +8,6 @@ * An individual blog entry page to show a blog entry in full */ class BlogEntry extends Page { - static $default_parent = array('BlogHolder'); static $can_be_root = false; @@ -28,6 +27,10 @@ class BlogEntry extends Page { static $defaults = array( "ProvideComments" => true ); + + static $extensions = array( + 'TrackBackDecorator' + ); static $allowed_children = "none"; diff --git a/code/BlogHolder.php b/code/BlogHolder.php index 07ef73f..04b04e6 100644 --- a/code/BlogHolder.php +++ b/code/BlogHolder.php @@ -248,7 +248,7 @@ class BlogHolder_Controller extends Page_Controller { } } - return $this->Entries(array('start' => $start, 'limit' => $limit), $tag, $date); + return $this->Entries("$start,$limit", $tag, $date); } /** diff --git a/code/TrackBackDecorator.php b/code/TrackBackDecorator.php new file mode 100644 index 0000000..436a48b --- /dev/null +++ b/code/TrackBackDecorator.php @@ -0,0 +1,53 @@ + array( + 'TrackBacks' => 'TrackBackPing' + ) + ); + } + + function updateMetaTags(&$tags) { + $tags .= $this->owner->renderWith('TrackBackRdf'); + } + + function TrackBackPingLink() { + return $this->owner->AbsoluteLink() . 'trackbackping'; + } + + function trackbackping() { + $error = 0; + $message = ''; + + if(!(isset($_POST['url']) && $_POST['url'])) { + $error = 1; + $message = 'Missing required POST parameter \'url\'.'; + } else { + $trackbackping = new TrackBackPing(); + $trackbackping->Url = $_POST['url']; + if(isset($_POST['title']) && $_POST['title']) { + $trackbackping->Title = $_POST['title']; + } + if(isset($_POST['excerpt']) && $_POST['excerpt']) { + $trackbackping->Excerpt = $_POST['excerpt']; + } + if(isset($_POST['blog_name']) && $_POST['blog_name']) { + $trackbackping->BlogName = $_POST['blog_name']; + } + $trackbackping->PageID = $this->owner->ID; + $trackbackping->write(); + } + + $returnData = new ArrayData(array( + 'Error' => $error, + 'Message' => $message + )); + + return $returnData->renderWith('TrackBackPingReturn'); + } +} + + +?> diff --git a/code/TrackBackPing.php b/code/TrackBackPing.php new file mode 100644 index 0000000..900a50a --- /dev/null +++ b/code/TrackBackPing.php @@ -0,0 +1,16 @@ + 'Varchar', + 'Excerpt' => 'Text', + 'Url' => 'Varchar', + 'BlogName' => 'Varchar' + ); + + static $has_one = array( + 'Page' => 'Page' + ); +} + +?> diff --git a/templates/Includes/TrackBacks.ss b/templates/Includes/TrackBacks.ss new file mode 100644 index 0000000..7ae6e7d --- /dev/null +++ b/templates/Includes/TrackBacks.ss @@ -0,0 +1,15 @@ +<% if TrackBacks %> +
+

TrackBacks

+ + + +
+<% end_if %> diff --git a/templates/Layout/BlogEntry.ss b/templates/Layout/BlogEntry.ss index 97aca53..9551141 100644 --- a/templates/Layout/BlogEntry.ss +++ b/templates/Layout/BlogEntry.ss @@ -18,6 +18,7 @@ <% if CurrentMember %>

<% _t('EDITTHIS', 'Edit this post') %> | <% _t('UNPUBLISHTHIS', 'Unpublish this post') %>

<% end_if %> - + + <% include TrackBacks %> $PageComments diff --git a/templates/TrackBackPingReturn.ss b/templates/TrackBackPingReturn.ss new file mode 100644 index 0000000..b31f395 --- /dev/null +++ b/templates/TrackBackPingReturn.ss @@ -0,0 +1,5 @@ + + + $Error + <% if Message %>$Message<% end_if %> + diff --git a/templates/TrackBackRdf.ss b/templates/TrackBackRdf.ss new file mode 100644 index 0000000..62c73b6 --- /dev/null +++ b/templates/TrackBackRdf.ss @@ -0,0 +1,3 @@ + + +