diff --git a/code/ArchiveWidget.php b/code/ArchiveWidget.php index 0746d11..a423a49 100644 --- a/code/ArchiveWidget.php +++ b/code/ArchiveWidget.php @@ -6,10 +6,10 @@ * @package blog */ class ArchiveWidget extends Widget { - static $db = array( 'DisplayMode' => 'Varchar' ); + static $has_one = array(); static $has_many = array(); @@ -52,37 +52,19 @@ 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\" - WHERE \"ParentID\" IN (" . implode(', ', $ids) . ") - 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;" - ); - } + $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\" + 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" - ); - } + $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" + ); } if($sqlResults) foreach($sqlResults as $sqlResult) { @@ -111,6 +93,7 @@ class ArchiveWidget extends Widget { } return $results; - } - + } } + +?> diff --git a/code/BlogEntry.php b/code/BlogEntry.php index 07a685a..6688932 100644 --- a/code/BlogEntry.php +++ b/code/BlogEntry.php @@ -5,19 +5,18 @@ * @package blog */ class BlogEntry extends Page { - - static $default_parent = 'BlogHolder'; - - static $can_be_root = false; - - static $icon = "blog/images/blogpage"; - static $db = array( "Date" => "Datetime", "Author" => "Text", "Tags" => "Text" ); + static $default_parent = 'BlogHolder'; + + static $can_be_root = false; + + static $icon = "blog/images/blogpage"; + static $has_one = array(); static $has_many = array(); diff --git a/code/BlogHolder.php b/code/BlogHolder.php index b6a4512..f08a76b 100644 --- a/code/BlogHolder.php +++ b/code/BlogHolder.php @@ -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',"

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 the CMS.

"); $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,14 +213,15 @@ class BlogHolder_Controller extends BlogTree_Controller { } else { $tagfield = new TextField('Tags'); } + $field = 'TextField'; if(!$this->AllowCustomAuthors && !Permission::check('ADMIN')) { $field = 'ReadonlyField'; } $fields = new FieldSet( new HiddenField("ID", "ID"), - new TextField("Title",_t('BlogHolder.SJ', "Subject")), - new $field("Author",_t('BlogEntry.AU'),$membername), + new TextField("Title", _t('BlogHolder.SJ', "Subject")), + new $field("Author", _t('BlogEntry.AU'), $membername), $contentfield, $tagfield, new LiteralField("Tagsnote","