mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
Commenting blog
This commit is contained in:
parent
acd6e1a6c5
commit
408cf5c8bb
@ -1,5 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @package blog
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An individual blog entry page to show a blog entry in full
|
||||||
|
*/
|
||||||
class BlogEntry extends Page {
|
class BlogEntry extends Page {
|
||||||
|
|
||||||
static $default_parent = array('BlogHolder');
|
static $default_parent = array('BlogHolder');
|
||||||
@ -62,6 +69,9 @@ class BlogEntry extends Page {
|
|||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the tags added to this blog entry
|
||||||
|
*/
|
||||||
function Tags() {
|
function Tags() {
|
||||||
$theseTags = split(" *, *", trim($this->Tags));
|
$theseTags = split(" *, *", trim($this->Tags));
|
||||||
|
|
||||||
@ -77,11 +87,16 @@ class BlogEntry extends Page {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the sidebar
|
||||||
|
*/
|
||||||
function SideBar() {
|
function SideBar() {
|
||||||
return $this->getParent()->SideBar();
|
return $this->getParent()->SideBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a bbcode parsed summary of the blog entry
|
||||||
|
*/
|
||||||
function ParagraphSummary(){
|
function ParagraphSummary(){
|
||||||
$content = new Text('Content');
|
$content = new Text('Content');
|
||||||
$content->value = Convert::raw2xml($this->Content);
|
$content->value = Convert::raw2xml($this->Content);
|
||||||
@ -89,6 +104,9 @@ class BlogEntry extends Page {
|
|||||||
return $parser->parse();
|
return $parser->parse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the bbcode parsed content
|
||||||
|
*/
|
||||||
function ParsedContent() {
|
function ParsedContent() {
|
||||||
$parser = new BBCodeParser($this->Content);
|
$parser = new BBCodeParser($this->Content);
|
||||||
$content = new Text('Content');
|
$content = new Text('Content');
|
||||||
@ -96,6 +114,9 @@ class BlogEntry extends Page {
|
|||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Link for editing this blog entry
|
||||||
|
*/
|
||||||
function EditURL(){
|
function EditURL(){
|
||||||
return $this->getParent()->Link('post')."/".$this->ID."/";
|
return $this->getParent()->Link('post')."/".$this->ID."/";
|
||||||
}
|
}
|
||||||
@ -108,6 +129,9 @@ class BlogEntry_Controller extends Page_Controller {
|
|||||||
Requirements::themedCSS("blog");
|
Requirements::themedCSS("blog");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a link to unpublish the blog entry
|
||||||
|
*/
|
||||||
function unpublishPost(){
|
function unpublishPost(){
|
||||||
if(!Permission::check('ADMIN')){
|
if(!Permission::check('ADMIN')){
|
||||||
Security::permissionFailure($this,
|
Security::permissionFailure($this,
|
||||||
|
@ -1,5 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @package blog
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Blog holder to display summarised blog entries
|
||||||
|
*/
|
||||||
|
|
||||||
class BlogHolder extends Page {
|
class BlogHolder extends Page {
|
||||||
|
|
||||||
static $icon = "blog/images/blogholder";
|
static $icon = "blog/images/blogholder";
|
||||||
@ -23,6 +31,9 @@ class BlogHolder extends Page {
|
|||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The DataObject of blog entries
|
||||||
|
*/
|
||||||
public function BlogEntries($limit = 10) {
|
public function BlogEntries($limit = 10) {
|
||||||
$start = isset($_GET['start']) ? (int)$_GET['start'] : 0;
|
$start = isset($_GET['start']) ? (int)$_GET['start'] : 0;
|
||||||
$tagCheck = '';
|
$tagCheck = '';
|
||||||
@ -51,10 +62,16 @@ class BlogHolder extends Page {
|
|||||||
return DataObject::get("Page","`ParentID` = $this->ID AND ShowInMenus = 1 $tagCheck $dateCheck","`BlogEntry`.Date DESC",'',"$start, $limit");
|
return DataObject::get("Page","`ParentID` = $this->ID AND ShowInMenus = 1 $tagCheck $dateCheck","`BlogEntry`.Date DESC",'',"$start, $limit");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Only display the blog entries that have the specified tag
|
||||||
|
*/
|
||||||
function Tag() {
|
function Tag() {
|
||||||
return isset($_GET['tag']) ? $_GET['tag'] : false;
|
return isset($_GET['tag']) ? $_GET['tag'] : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A simple form for creating blog entries
|
||||||
|
*/
|
||||||
function BlogEntryForm(){
|
function BlogEntryForm(){
|
||||||
Requirements::javascript('jsparty/behaviour.js');
|
Requirements::javascript('jsparty/behaviour.js');
|
||||||
Requirements::javascript('jsparty/prototype.js');
|
Requirements::javascript('jsparty/prototype.js');
|
||||||
@ -101,14 +118,23 @@ class BlogHolder extends Page {
|
|||||||
return $form;
|
return $form;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if url has "/post"
|
||||||
|
*/
|
||||||
function isPost(){
|
function isPost(){
|
||||||
return Director::urlParam('Action') == 'post';
|
return Director::urlParam('Action') == 'post';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Link for creating a new blog entry
|
||||||
|
*/
|
||||||
function postURL(){
|
function postURL(){
|
||||||
return $this->Link('post');
|
return $this->Link('post');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create default blog setup
|
||||||
|
*/
|
||||||
function requireDefaultRecords() {
|
function requireDefaultRecords() {
|
||||||
parent::requireDefaultRecords();
|
parent::requireDefaultRecords();
|
||||||
|
|
||||||
@ -158,7 +184,6 @@ class BlogHolder extends Page {
|
|||||||
class BlogHolder_Controller extends Page_Controller {
|
class BlogHolder_Controller extends Page_Controller {
|
||||||
function init() {
|
function init() {
|
||||||
parent::init();
|
parent::init();
|
||||||
|
|
||||||
// This will create a <link> tag point to the RSS feed
|
// This will create a <link> tag point to the RSS feed
|
||||||
RSSFeed::linkToFeed($this->Link() . "rss", "RSS feed of this blog");
|
RSSFeed::linkToFeed($this->Link() . "rss", "RSS feed of this blog");
|
||||||
Requirements::themedCSS("blog");
|
Requirements::themedCSS("blog");
|
||||||
@ -166,6 +191,9 @@ class BlogHolder_Controller extends Page_Controller {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the archived blogs for a particular month or year, in the format /year/month/ eg: /2008/10/
|
||||||
|
*/
|
||||||
function showarchive() {
|
function showarchive() {
|
||||||
$month = addslashes($this->urlParams['ID']);
|
$month = addslashes($this->urlParams['ID']);
|
||||||
return array(
|
return array(
|
||||||
@ -183,16 +211,25 @@ class BlogHolder_Controller extends Page_Controller {
|
|||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the rss fee for this blog holder's entries
|
||||||
|
*/
|
||||||
function rss() {
|
function rss() {
|
||||||
global $project;
|
global $project;
|
||||||
$rss = new RSSFeed($this->Children(), $this->Link(), $project . " blog", "", "Title", "ParsedContent");
|
$rss = new RSSFeed($this->Children(), $this->Link(), $project . " blog", "", "Title", "ParsedContent");
|
||||||
$rss->outputToBrowser();
|
$rss->outputToBrowser();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return list of usable tags for help
|
||||||
|
*/
|
||||||
function BBTags() {
|
function BBTags() {
|
||||||
return BBCodeParser::usable_tags();
|
return BBCodeParser::usable_tags();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Post a new blog entry
|
||||||
|
*/
|
||||||
function post(){
|
function post(){
|
||||||
if(!Permission::check('ADMIN')){
|
if(!Permission::check('ADMIN')){
|
||||||
Security::permissionFailure($this,
|
Security::permissionFailure($this,
|
||||||
@ -212,7 +249,9 @@ class BlogHolder_Controller extends Page_Controller {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Blog entry form
|
||||||
|
*/
|
||||||
class BlogEntry_Form extends Form {
|
class BlogEntry_Form extends Form {
|
||||||
function postblog($data) {
|
function postblog($data) {
|
||||||
Cookie::set("BlogHolder_Name", $data['Author']);
|
Cookie::set("BlogHolder_Name", $data['Author']);
|
||||||
|
Loading…
Reference in New Issue
Block a user