mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
FEATURE: Added receiving of TrackPack pings
This commit is contained in:
parent
f9aa8d9ab2
commit
b05a3a2cc6
@ -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";
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
53
code/TrackBackDecorator.php
Normal file
53
code/TrackBackDecorator.php
Normal 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
16
code/TrackBackPing.php
Normal 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'
|
||||
);
|
||||
}
|
||||
|
||||
?>
|
15
templates/Includes/TrackBacks.ss
Normal file
15
templates/Includes/TrackBacks.ss
Normal 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 %>
|
@ -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>
|
||||
|
5
templates/TrackBackPingReturn.ss
Normal file
5
templates/TrackBackPingReturn.ss
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<response>
|
||||
<error>$Error</error>
|
||||
<% if Message %><message>$Message</message><% end_if %>
|
||||
</response>
|
3
templates/TrackBackRdf.ss
Normal file
3
templates/TrackBackRdf.ss
Normal 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>
|
Loading…
Reference in New Issue
Block a user