FEATURE: Added receiving of TrackPack pings

This commit is contained in:
Andrew O'Neil 2008-09-12 02:09:13 +00:00
parent f9aa8d9ab2
commit b05a3a2cc6
8 changed files with 99 additions and 3 deletions

View File

@ -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";

View File

@ -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);
}
/**

View File

@ -0,0 +1,53 @@
<?php
class TrackBackDecorator extends DataObjectDecorator {
function extraDBFields() {
return array(
'has_many' => 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');
}
}
?>

16
code/TrackBackPing.php Normal file
View File

@ -0,0 +1,16 @@
<?php
class TrackBackPing extends DataObject {
static $db = array(
'Title' => 'Varchar',
'Excerpt' => 'Text',
'Url' => 'Varchar',
'BlogName' => 'Varchar'
);
static $has_one = array(
'Page' => 'Page'
);
}
?>

View File

@ -0,0 +1,15 @@
<% if TrackBacks %>
<div id="TrackBacks_holder" class="typography">
<h4>TrackBacks</h4>
<ul id="TrackBacks">
<% control TrackBacks %>
<li>
<a href="$Url"><% if Title %>$Title<% else %>$Url<% end_if %></a> <span class="date">on $Created.Nice</span>
<% if Excerpt %><p class="excerpt">$Excerpt</p><% end_if %>
</li>
<% end_control %>
</ul>
</div>
<% end_if %>

View File

@ -18,6 +18,7 @@
</div>
<% if CurrentMember %><p><a href="$EditURL" id="editpost" title="<% _t('EDITTHIS', 'Edit this post') %>"><% _t('EDITTHIS', 'Edit this post') %></a> | <a href="$Link(unpublishPost)" id="unpublishpost"><% _t('UNPUBLISHTHIS', 'Unpublish this post') %></a></p><% end_if %>
<% include TrackBacks %>
$PageComments
</div>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<response>
<error>$Error</error>
<% if Message %><message>$Message</message><% end_if %>
</response>

View File

@ -0,0 +1,3 @@
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:dc="http://purl.org/dc/elements/1.1/" >
<rdf:Description rdf:about="$AbsoluteLink" trackback:ping="$TrackBackPingLink" dc:identifier="$AbsoluteLink" dc:title="$Title" />
</rdf:RDF>