APICHANGE: Drop 2.3 support - 0.3 will be 2.4 only
This commit is contained in:
parent
a2b9e2f00c
commit
10d15e1ddd
|
@ -6,10 +6,10 @@
|
|||
* @package blog
|
||||
*/
|
||||
class ArchiveWidget extends Widget {
|
||||
|
||||
static $db = array(
|
||||
'DisplayMode' => 'Varchar'
|
||||
);
|
||||
|
||||
static $has_one = array();
|
||||
|
||||
static $has_many = array();
|
||||
|
@ -52,7 +52,6 @@ class ArchiveWidget extends Widget {
|
|||
$suffix = (!$stage || $stage == 'Stage') ? "" : "_$stage";
|
||||
|
||||
if($this->DisplayMode == 'month') {
|
||||
if(defined('DB::USE_ANSI_SQL')) {
|
||||
$sqlResults = DB::query("
|
||||
SELECT DISTINCT MONTH(\"Date\") AS \"Month\", YEAR(\"Date\") AS \"Year\"
|
||||
FROM \"SiteTree$suffix\" INNER JOIN \"BlogEntry$suffix\" ON \"SiteTree$suffix\".\"ID\" = \"BlogEntry$suffix\".\"ID\"
|
||||
|
@ -60,29 +59,12 @@ class ArchiveWidget extends Widget {
|
|||
ORDER BY \"Year\" DESC, \"Month\" DESC;"
|
||||
);
|
||||
} else {
|
||||
$sqlResults = DB::query("
|
||||
SELECT DISTINCT MONTH(`Date`) AS `Month`, YEAR(`Date`) AS `Year`
|
||||
FROM `SiteTree$suffix` NATURAL JOIN `BlogEntry$suffix`
|
||||
WHERE `ParentID` IN (" . implode(', ', $ids) . ")
|
||||
ORDER BY `Year` DESC, `Month` DESC;"
|
||||
);
|
||||
}
|
||||
} else {
|
||||
if(defined('DB::USE_ANSI_SQL')) {
|
||||
$sqlResults = DB::query("
|
||||
SELECT DISTINCT YEAR(\"Date\") AS \"Year\"
|
||||
FROM \"SiteTree$suffix\" INNER JOIN \"BlogEntry$suffix\" ON \"SiteTree$suffix\".\"ID\" = \"BlogEntry$suffix\".\"ID\"
|
||||
WHERE \"ParentID\" IN (" . implode(', ', $ids) . ")
|
||||
ORDER BY \"Year\" DESC"
|
||||
);
|
||||
} else {
|
||||
$sqlResults = DB::query("
|
||||
SELECT DISTINCT YEAR(`Date`) AS `Year`
|
||||
FROM `SiteTree$suffix` NATURAL JOIN `BlogEntry$suffix`
|
||||
WHERE `ParentID` in (".implode(', ',$ids).")
|
||||
ORDER BY `Year` DESC"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if($sqlResults) foreach($sqlResults as $sqlResult) {
|
||||
|
@ -112,5 +94,6 @@ class ArchiveWidget extends Widget {
|
|||
|
||||
return $results;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -5,6 +5,11 @@
|
|||
* @package blog
|
||||
*/
|
||||
class BlogEntry extends Page {
|
||||
static $db = array(
|
||||
"Date" => "Datetime",
|
||||
"Author" => "Text",
|
||||
"Tags" => "Text"
|
||||
);
|
||||
|
||||
static $default_parent = 'BlogHolder';
|
||||
|
||||
|
@ -12,12 +17,6 @@ class BlogEntry extends Page {
|
|||
|
||||
static $icon = "blog/images/blogpage";
|
||||
|
||||
static $db = array(
|
||||
"Date" => "Datetime",
|
||||
"Author" => "Text",
|
||||
"Tags" => "Text"
|
||||
);
|
||||
|
||||
static $has_one = array();
|
||||
|
||||
static $has_many = array();
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
* BlogHolders have a form on them for easy posting, and an owner that can post to them, BlogTrees don't
|
||||
*/
|
||||
class BlogHolder extends BlogTree implements PermissionProvider {
|
||||
|
||||
static $icon = "blog/images/blogholder";
|
||||
|
||||
static $db = array(
|
||||
|
@ -76,7 +75,6 @@ class BlogHolder extends BlogTree implements PermissionProvider {
|
|||
*/
|
||||
function IsOwner() {
|
||||
return (Permission::check('BLOGMANAGEMENT') || Permission::check('ADMIN'));
|
||||
//return Permission::check('ADMIN') || (Member::currentUserID() == $this->OwnerID);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -118,20 +116,18 @@ class BlogHolder extends BlogTree implements PermissionProvider {
|
|||
$blog->Title = _t('BlogHolder.SUCTITLE', "SilverStripe blog module successfully installed");
|
||||
$blog->URLSegment = 'sample-blog-entry';
|
||||
$blog->Tags = _t('BlogHolder.SUCTAGS',"silverstripe, blog");
|
||||
$blog->Content = _t('BlogHolder.SUCCONTENT',"Congratulations, the SilverStripe blog module has been successfully installed. This blog entry can be safely deleted. You can configure aspects of your blog (such as the widgets displayed in the sidebar) in [url=admin]the CMS[/url].");
|
||||
$blog->Content = _t('BlogHolder.SUCCONTENT',"<p>Congratulations, the SilverStripe blog module has been successfully installed. This blog entry can be safely deleted. You can configure aspects of your blog (such as the widgets displayed in the sidebar) in <a href=\"admin\">the CMS</a>.</p>");
|
||||
$blog->Status = "Published";
|
||||
$blog->ParentID = $blogholder->ID;
|
||||
$blog->write();
|
||||
$blog->publish("Stage", "Live");
|
||||
|
||||
// 2.3/2.4 dual compatibility
|
||||
if(method_exists('DB', 'alteration_message')) DB::alteration_message("Blog page created","created");
|
||||
DB::alteration_message("Blog page created","created");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class BlogHolder_Controller extends BlogTree_Controller {
|
||||
|
||||
static $allowed_actions = array(
|
||||
'index',
|
||||
'tag',
|
||||
|
@ -149,10 +145,10 @@ class BlogHolder_Controller extends BlogTree_Controller {
|
|||
* TODO: this is an urgent fix to work with archive link (e.g. page_url/2009/04). Replace this with something better.
|
||||
*/
|
||||
function checkAccessAction($action) {
|
||||
if (preg_match('/[0-9]{4}/', $action))
|
||||
{
|
||||
if(preg_match('/[0-9]{4}/', $action)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return parent::checkAccessAction($action);
|
||||
}
|
||||
|
||||
|
@ -217,6 +213,7 @@ class BlogHolder_Controller extends BlogTree_Controller {
|
|||
} else {
|
||||
$tagfield = new TextField('Tags');
|
||||
}
|
||||
|
||||
$field = 'TextField';
|
||||
if(!$this->AllowCustomAuthors && !Permission::check('ADMIN')) {
|
||||
$field = 'ReadonlyField';
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
* @package blog
|
||||
*/
|
||||
class BlogManagementWidget extends Widget implements PermissionProvider {
|
||||
|
||||
static $db = array();
|
||||
|
||||
static $has_one = array();
|
||||
|
|
|
@ -52,12 +52,7 @@ class BlogTree extends Page {
|
|||
}
|
||||
|
||||
// Try to find a top-level BlogTree
|
||||
if(defined('DB::USE_ANSI_SQL')) {
|
||||
$top = DataObject::get_one('BlogTree', "\"ParentID\" = '0'");
|
||||
} else {
|
||||
$top = DataObject::get_one('BlogTree', 'ParentID = 0');
|
||||
}
|
||||
|
||||
if($top) return $top;
|
||||
|
||||
// Try to find any BlogTree that is not inside another BlogTree
|
||||
|
@ -128,8 +123,7 @@ class BlogTree extends Page {
|
|||
|
||||
if($child instanceof BlogHolder) {
|
||||
$idList[] = $child->ID;
|
||||
}
|
||||
else if ($child instanceof BlogTree) {
|
||||
} elseif($child instanceof BlogTree) {
|
||||
$child->loadDescendantBlogHolderIDListInto($idList);
|
||||
}
|
||||
}
|
||||
|
@ -157,11 +151,7 @@ class BlogTree extends Page {
|
|||
|
||||
if($tag) {
|
||||
$SQL_tag = Convert::raw2sql($tag);
|
||||
if(defined('DB::USE_ANSI_SQL')) {
|
||||
$tagCheck = "AND \"BlogEntry\".\"Tags\" LIKE '%$SQL_tag%'";
|
||||
} else {
|
||||
$tagCheck = "AND `BlogEntry`.Tags LIKE '%$SQL_tag%'";
|
||||
}
|
||||
}
|
||||
|
||||
if($date) {
|
||||
|
@ -170,29 +160,16 @@ class BlogTree extends Page {
|
|||
$month = (int) substr($date, strpos($date, '-') + 1);
|
||||
|
||||
if($year && $month) {
|
||||
if(defined('DB::USE_ANSI_SQL')) {
|
||||
$dateCheck = "AND MONTH(\"BlogEntry\".\"Date\") = '$month' AND YEAR(\"BlogEntry\".\"Date\") = '$year'";
|
||||
} else {
|
||||
$dateCheck = "AND MONTH(`BlogEntry`.Date) = $month AND YEAR(`BlogEntry`.Date) = $year";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$year = (int) $date;
|
||||
if($year) {
|
||||
if(defined('DB::USE_ANSI_SQL')) {
|
||||
$dateCheck = "AND YEAR(\"BlogEntry\".\"Date\") = '$year'";
|
||||
} else {
|
||||
$dateCheck = "AND YEAR(`BlogEntry`.Date) = $year";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif ($this->LandingPageFreshness) {
|
||||
if(defined('DB::USE_ANSI_SQL')) {
|
||||
} elseif ($this->LandingPageFreshness) {
|
||||
$dateCheck = "AND \"BlogEntry\".\"Date\" > NOW() - INTERVAL " . $this->LandingPageFreshness;
|
||||
} else {
|
||||
$dateCheck = "AND `BlogEntry`.Date > NOW() - INTERVAL " . $this->LandingPageFreshness;
|
||||
}
|
||||
}
|
||||
|
||||
// Build a list of all IDs for BlogHolders that are children of us
|
||||
|
@ -202,17 +179,9 @@ class BlogTree extends Page {
|
|||
if(empty($holderIDs)) return false;
|
||||
|
||||
// Otherwise, do the actual query
|
||||
if(defined('DB::USE_ANSI_SQL')) {
|
||||
$where = '"ParentID" IN (' . implode(',', $holderIDs) . ") $tagCheck $dateCheck";
|
||||
} else {
|
||||
$where = 'ParentID IN (' . implode(',', $holderIDs) . ") $tagCheck $dateCheck";
|
||||
}
|
||||
|
||||
if(defined('DB::USE_ANSI_SQL')) {
|
||||
$order = '"BlogEntry"."Date" DESC';
|
||||
} else {
|
||||
$order = '`BlogEntry`.`Date` DESC';
|
||||
}
|
||||
|
||||
// By specifying a callback, you can alter the SQL, or sort on something other than date.
|
||||
if($retrieveCallback) return call_user_func($retrieveCallback, 'BlogEntry', $where, $limit, $order);
|
||||
|
@ -220,7 +189,7 @@ class BlogTree extends Page {
|
|||
}
|
||||
}
|
||||
|
||||
class BlogURL {
|
||||
class BlogTree_URL {
|
||||
static function tag() {
|
||||
if (Director::urlParam('Action') == 'tag') return Director::urlParam('ID');
|
||||
return '';
|
||||
|
@ -232,8 +201,7 @@ class BlogURL {
|
|||
|
||||
if($month && is_numeric($month) && $month >= 1 && $month <= 12 && is_numeric($year)) {
|
||||
return "$year-$month";
|
||||
}
|
||||
elseif (is_numeric($year)) {
|
||||
} elseif (is_numeric($year)) {
|
||||
return $year;
|
||||
}
|
||||
|
||||
|
@ -259,7 +227,7 @@ class BlogTree_Controller extends Page_Controller {
|
|||
if($limit === null) $limit = BlogTree::$default_entries_limit;
|
||||
|
||||
$start = isset($_GET['start']) ? (int) $_GET['start'] : 0;
|
||||
return $this->Entries("$start,$limit", BlogURL::tag(), BlogURL::date());
|
||||
return $this->Entries("$start,$limit", BlogTree_URL::tag(), BlogTree_URL::date());
|
||||
}
|
||||
|
||||
function IncludeBlogRSS() {
|
||||
|
@ -267,40 +235,6 @@ class BlogTree_Controller extends Page_Controller {
|
|||
RSSFeed::linkToFeed($this->Link() . "rss", _t('BlogHolder.RSSFEED',"RSS feed of these blogs"));
|
||||
}
|
||||
|
||||
/*
|
||||
* @todo: It doesn't look like these are used. Remove if no-one complains - Hamish
|
||||
|
||||
/**
|
||||
* Gets the archived blogs for a particular month or year, in the format /year/month/ eg: /2008/10/
|
||||
* /
|
||||
function showarchive() {
|
||||
$month = addslashes($this->urlParams['ID']);
|
||||
return array(
|
||||
"Children" => DataObject::get('SiteTree', "ParentID = $this->ID AND DATE_FORMAT(`BlogEntry`.`Date`, '%Y-%M') = '$month'"),
|
||||
);
|
||||
}
|
||||
|
||||
function ArchiveMonths() {
|
||||
$months = DB::query("SELECT DISTINCT DATE_FORMAT(`BlogEntry`.`Date`, '%M') AS `Month`, DATE_FORMAT(`BlogEntry`.`Date`, '%Y') AS `Year` FROM `BlogEntry` ORDER BY `BlogEntry`.`Date` DESC");
|
||||
$output = new DataObjectSet();
|
||||
foreach($months as $month) {
|
||||
$month['Link'] = $this->Link() . "showarchive/$month[Year]-$month[Month]";
|
||||
$output->push(new ArrayData($month));
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
function tag() {
|
||||
if (Director::urlParam('Action') == 'tag') {
|
||||
return array(
|
||||
'Tag' => Convert::raw2xml(Director::urlParam('ID'))
|
||||
);
|
||||
}
|
||||
return array();
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get the rss feed for this blog holder's entries
|
||||
*/
|
||||
|
@ -325,3 +259,5 @@ class BlogTree_Controller extends Page_Controller {
|
|||
return parent::defaultAction($action);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -6,6 +6,7 @@ class RSSWidget extends Widget {
|
|||
"RssUrl" => "Text",
|
||||
"NumberToShow" => "Int"
|
||||
);
|
||||
|
||||
static $has_one = array();
|
||||
|
||||
static $has_many = array();
|
||||
|
|
|
@ -26,7 +26,6 @@ class SubscribeRSSWidget extends Widget {
|
|||
$container = BlogTree::current();
|
||||
if ($container) return $container->Link() . 'rss';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -101,6 +101,7 @@ class TagCloudWidget extends Widget {
|
|||
foreach($allTags as $tag => $fields) {
|
||||
$output->push(new ArrayData($fields));
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
@ -137,5 +138,4 @@ class TagCloudWidget extends Widget {
|
|||
}
|
||||
|
||||
|
||||
|
||||
?>
|
||||
|
|
|
@ -49,5 +49,4 @@ class TrackBackDecorator extends DataObjectDecorator {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue