mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
BUGFIX: Updated blog module to support 2.4 API changes
This commit is contained in:
parent
fea6a12472
commit
9545d4f87c
@ -52,7 +52,7 @@ class ArchiveWidget extends Widget {
|
||||
$suffix = (!$stage || $stage == 'Stage') ? "" : "_$stage";
|
||||
|
||||
if($this->DisplayMode == 'month') {
|
||||
if(defined('Database::USE_ANSI_SQL')) {
|
||||
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\"
|
||||
@ -68,7 +68,7 @@ class ArchiveWidget extends Widget {
|
||||
);
|
||||
}
|
||||
} else {
|
||||
if(defined('Database::USE_ANSI_SQL')) {
|
||||
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\"
|
||||
|
@ -13,7 +13,7 @@ class BlogEntry extends Page {
|
||||
static $icon = "blog/images/blogpage";
|
||||
|
||||
static $db = array(
|
||||
"Date" => "SSDatetime",
|
||||
"Date" => "Datetime",
|
||||
"Author" => "Text",
|
||||
"Tags" => "Text"
|
||||
);
|
||||
|
@ -124,7 +124,8 @@ class BlogHolder extends BlogTree implements PermissionProvider {
|
||||
$blog->write();
|
||||
$blog->publish("Stage", "Live");
|
||||
|
||||
Database::alteration_message("Blog page created","created");
|
||||
// 2.3/2.4 dual compatibility
|
||||
if(method_exists('DB', 'alteration_message')) DB::alteration_message("Blog page created","created");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ class BlogTree extends Page {
|
||||
}
|
||||
|
||||
// Try to find a top-level BlogTree
|
||||
if(defined('Database::USE_ANSI_SQL')) {
|
||||
if(defined('DB::USE_ANSI_SQL')) {
|
||||
$top = DataObject::get_one('BlogTree', "\"ParentID\" = '0'");
|
||||
} else {
|
||||
$top = DataObject::get_one('BlogTree', 'ParentID = 0');
|
||||
@ -155,7 +155,7 @@ class BlogTree extends Page {
|
||||
|
||||
if ($tag) {
|
||||
$SQL_tag = Convert::raw2sql($tag);
|
||||
if(defined('Database::USE_ANSI_SQL')) {
|
||||
if(defined('DB::USE_ANSI_SQL')) {
|
||||
$tagCheck = "AND \"BlogEntry\".\"Tags\" LIKE '%$SQL_tag%'";
|
||||
} else {
|
||||
$tagCheck = "AND `BlogEntry`.Tags LIKE '%$SQL_tag%'";
|
||||
@ -168,7 +168,7 @@ class BlogTree extends Page {
|
||||
$month = (int) substr($date, strpos($date, '-') + 1);
|
||||
|
||||
if($year && $month) {
|
||||
if(defined('Database::USE_ANSI_SQL')) {
|
||||
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";
|
||||
@ -177,7 +177,7 @@ class BlogTree extends Page {
|
||||
} else {
|
||||
$year = (int) $date;
|
||||
if($year) {
|
||||
if(defined('Database::USE_ANSI_SQL')) {
|
||||
if(defined('DB::USE_ANSI_SQL')) {
|
||||
$dateCheck = "AND YEAR(\"BlogEntry\".\"Date\") = '$year'";
|
||||
} else {
|
||||
$dateCheck = "AND YEAR(`BlogEntry`.Date) = $year";
|
||||
@ -186,7 +186,7 @@ class BlogTree extends Page {
|
||||
}
|
||||
}
|
||||
elseif ($this->LandingPageFreshness) {
|
||||
if(defined('Database::USE_ANSI_SQL')) {
|
||||
if(defined('DB::USE_ANSI_SQL')) {
|
||||
$dateCheck = "AND \"BlogEntry\".\"Date\" > NOW() - INTERVAL " . $this->LandingPageFreshness;
|
||||
} else {
|
||||
$dateCheck = "AND `BlogEntry`.Date > NOW() - INTERVAL " . $this->LandingPageFreshness;
|
||||
@ -200,13 +200,13 @@ class BlogTree extends Page {
|
||||
if (empty($holderIDs)) return false;
|
||||
|
||||
// Otherwise, do the actual query
|
||||
if(defined('Database::USE_ANSI_SQL')) {
|
||||
if(defined('DB::USE_ANSI_SQL')) {
|
||||
$where = '"ParentID" IN (' . implode(',', $holderIDs) . ") $tagCheck $dateCheck";
|
||||
} else {
|
||||
$where = 'ParentID IN (' . implode(',', $holderIDs) . ") $tagCheck $dateCheck";
|
||||
}
|
||||
|
||||
if(defined('Database::USE_ANSI_SQL')) {
|
||||
if(defined('DB::USE_ANSI_SQL')) {
|
||||
$order = '"BlogEntry"."Date" DESC';
|
||||
} else {
|
||||
$order = '`BlogEntry`.`Date` DESC';
|
||||
|
Loading…
Reference in New Issue
Block a user