BUGFIX: Updated blog module to support 2.4 API changes

This commit is contained in:
Sam Minnee 2009-10-26 22:03:52 +00:00
parent fea6a12472
commit 9545d4f87c
4 changed files with 12 additions and 11 deletions

View File

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

View File

@ -13,7 +13,7 @@ class BlogEntry extends Page {
static $icon = "blog/images/blogpage";
static $db = array(
"Date" => "SSDatetime",
"Date" => "Datetime",
"Author" => "Text",
"Tags" => "Text"
);

View File

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

View File

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