API Updated blog module to adhere to new rules around configuration. Static configurable properties (db, has_one, etc) are now private.

Also removed trailing ?>(newline) from various files, and cleaned up some redundant code (empty has_ones, etc).
Also noted in the code are places where various static properties should be refactored out in favour of using the Silverstripe configuration system instead. For now the bare mimimum work has been done in order to make the module work in 3.1
This commit is contained in:
Damian Mooyman 2013-04-02 11:38:09 +13:00
parent b8c6bfd3ee
commit 477f857acf
20 changed files with 85 additions and 149 deletions

3
_config/trackback.yml Normal file
View File

@ -0,0 +1,3 @@
BlogEntry:
extensions:
- 'TrackBackDecorator'

View File

@ -5,43 +5,33 @@
* @package blog
*/
class BlogEntry extends Page {
static $db = array(
private static $db = array(
"Date" => "SS_Datetime",
"Author" => "Text",
"Tags" => "Text"
);
static $default_parent = 'BlogHolder';
private static $default_parent = 'BlogHolder';
static $can_be_root = false;
private static $can_be_root = false;
static $icon = "blog/images/blogpage-file.png";
private static $icon = "blog/images/blogpage-file.png";
static $description = "An individual blog entry";
private static $description = "An individual blog entry";
static $singular_name = 'Blog Entry Page';
private static $singular_name = 'Blog Entry Page';
static $plural_name = 'Blog Entry Pages';
static $has_one = array();
private static $plural_name = 'Blog Entry Pages';
static $has_many = array();
static $many_many = array();
static $belongs_many_many = array();
static $defaults = array(
private static $defaults = array(
"ProvideComments" => true,
'ShowInMenus' => false
);
static $extensions = array(
'TrackBackDecorator'
);
/**
* Is WYSIWYG editing allowed?
*
* @todo Update to use SS3 Config
* @var boolean
*/
static $allow_wysiwyg_editing = true;
@ -248,7 +238,7 @@ class BlogEntry extends Page {
class BlogEntry_Controller extends Page_Controller {
static $allowed_actions = array(
private static $allowed_actions = array(
'index',
'trackbackping',
'unpublishPost',

View File

@ -12,25 +12,25 @@
* 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-file.png";
private static $icon = "blog/images/blogholder-file.png";
static $description = "Displays listings of blog entries";
private static $description = "Displays listings of blog entries";
static $singular_name = 'Blog Holder Page';
private static $singular_name = 'Blog Holder Page';
static $plural_name = 'Blog Holder Pages';
private static $plural_name = 'Blog Holder Pages';
static $db = array(
private static $db = array(
'TrackBacksEnabled' => 'Boolean',
'AllowCustomAuthors' => 'Boolean',
'ShowFullEntry' => 'Boolean',
);
static $has_one = array(
private static $has_one = array(
'Owner' => 'Member',
);
static $allowed_children = array(
private static $allowed_children = array(
'BlogEntry'
);
@ -167,7 +167,7 @@ class BlogHolder extends BlogTree implements PermissionProvider {
}
class BlogHolder_Controller extends BlogTree_Controller {
static $allowed_actions = array(
private static $allowed_actions = array(
'index',
'tag',
'date',
@ -304,7 +304,4 @@ class BlogHolder_Controller extends BlogTree_Controller {
$this->redirect($this->Link());
}
}
?>
}

View File

@ -11,33 +11,35 @@
class BlogTree extends Page {
static $icon = "blog/images/blogtree-file.png";
private static $icon = "blog/images/blogtree-file.png";
static $description = "A grouping of blogs";
private static $description = "A grouping of blogs";
static $singular_name = 'Blog Tree Page';
private static $singular_name = 'Blog Tree Page';
static $plural_name = 'Blog Tree Pages';
private static $plural_name = 'Blog Tree Pages';
// Default number of blog entries to show
/**
* Default number of blog entries to show
*
* @todo Update to use SS Config
* @var integer
*/
static $default_entries_limit = 10;
static $db = array(
private static $db = array(
'Name' => 'Varchar(255)',
'InheritSideBar' => 'Boolean',
'LandingPageFreshness' => 'Varchar',
);
static $defaults = array(
private static $defaults = array(
'InheritSideBar' => True
);
static $has_one = array();
static $has_many = array();
static $allowed_children = array(
'BlogTree', 'BlogHolder'
private static $allowed_children = array(
'BlogTree',
'BlogHolder'
);
@ -233,7 +235,7 @@ class BlogTree extends Page {
class BlogTree_Controller extends Page_Controller {
static $allowed_actions = array(
private static $allowed_actions = array(
'index',
'rss',
'tag',

View File

@ -100,6 +100,4 @@ class MetaWeblogController extends Controller {
//TODO dummy function
return array();
}
}
?>
}

View File

@ -1,10 +1,14 @@
<?php
/**
* Add trackback (receive and send) feature blog entry
*/
*/
class TrackBackDecorator extends DataExtension {
/**
* @todo Update to use SS Config and/or Injector definition
* @var string
*/
static $trackback_server_class = 'TrackbackHTTPServer';
// function extraStatics() {
@ -16,7 +20,7 @@ class TrackBackDecorator extends DataExtension {
// );
// }
static $has_many = array(
private static $has_many = array(
'TrackBackURLs' => 'TrackBackURL',
'TrackBacks' => 'TrackBackPing'
);
@ -156,6 +160,4 @@ class TrackbackHTTPServer {
return new SS_HTTPResponse($response, $statusCode);
}
}
?>
}

View File

@ -1,7 +1,7 @@
<?php
class TrackBackPing extends DataObject {
static $db = array(
private static $db = array(
'Title' => 'Varchar',
'Excerpt' => 'Text',
// 2083 is URL-length limit for IE, AFAIK.
@ -10,15 +10,7 @@ class TrackBackPing extends DataObject {
'BlogName' => 'Varchar'
);
static $has_one = array(
private static $has_one = array(
'Page' => 'Page'
);
static $has_many = array();
static $many_many = array();
static $belongs_many_many = array();
}
?>
}

View File

@ -1,12 +1,13 @@
<?php
class TrackBackURL extends DataObject {
static $db = array(
private static $db = array(
'URL' => 'Varchar(2048)',
'Pung' => 'Boolean(0)'
);
static $has_one = array(
private static $has_one = array(
'BlogEntry' => 'BlogEntry'
);

View File

@ -149,4 +149,3 @@ class TypoImport extends Controller {
} // end function
} // end class
?>

View File

@ -6,27 +6,19 @@
* @package blog
*/
class ArchiveWidget extends Widget {
static $db = array(
private static $db = array(
'DisplayMode' => 'Varchar'
);
static $has_one = array();
static $has_many = array();
static $many_many = array();
static $belongs_many_many = array();
static $defaults = array(
private static $defaults = array(
'DisplayMode' => 'month'
);
static $title = 'Browse by Date';
private static $title = 'Browse by Date';
static $cmsTitle = 'Blog Archive';
private static $cmsTitle = 'Blog Archive';
static $description = 'Show a list of months or years in which there are blog posts, and provide links to them.';
private static $description = 'Show a list of months or years in which there are blog posts, and provide links to them.';
function getCMSFields() {
$fields = parent::getCMSFields();
@ -106,6 +98,4 @@ class ArchiveWidget extends Widget {
return $results;
}
}
?>
}

View File

@ -4,21 +4,11 @@
* @package blog
*/
class BlogManagementWidget extends Widget implements PermissionProvider {
static $db = array();
static $has_one = array();
static $has_many = array();
static $many_many = array();
static $belongs_many_many = array();
static $defaults = array();
static $title = "Blog Management";
static $cmsTitle = "Blog Management";
static $description = "Provide a number of links useful for administering a blog. Only shown if the user is an admin.";
private static $title = "Blog Management";
private static $cmsTitle = "Blog Management";
private static $description = "Provide a number of links useful for administering a blog. Only shown if the user is an admin.";
function CommentText() {
@ -63,5 +53,4 @@ class BlogManagementWidget_Controller extends Widget_Controller {
$container = BlogTree::current();
return ($container && $container->ClassName != "BlogTree") ? $container->Link('post') : false;
}
}
?>
}

View File

@ -2,6 +2,6 @@
class BlogTreeExtension extends DataExtension {
static $has_one = array("SideBar" => "WidgetArea");
private static $has_one = array("SideBar" => "WidgetArea");
}

View File

@ -1,26 +1,20 @@
<?php
class RSSWidget extends Widget {
static $db = array(
private static $db = array(
"RSSTitle" => "Text",
"RssUrl" => "Text",
"NumberToShow" => "Int"
);
static $has_one = array();
static $has_many = array();
static $many_many = array();
static $belongs_many_many = array();
static $defaults = array(
private static $defaults = array(
"NumberToShow" => 10,
"RSSTitle" => 'RSS Feed'
);
static $cmsTitle = "RSS Feed";
static $description = "Downloads another page's RSS feed and displays items in a list.";
private static $cmsTitle = "RSS Feed";
private static $description = "Downloads another page's RSS feed and displays items in a list.";
/**
* If the RssUrl is relative, convert it to absolute with the
@ -91,6 +85,4 @@ class RSSWidget extends Widget {
return $output;
}
}
}
?>
}

View File

@ -9,11 +9,11 @@
*/
class SubscribeRSSWidget extends Widget {
static $title = 'Subscribe via RSS';
private static $title = 'Subscribe via RSS';
static $cmsTitle = 'Subscribe via RSS widget';
private static $cmsTitle = 'Subscribe via RSS widget';
static $description = 'Shows a link allowing a user to subscribe to this blog via RSS.';
private static $description = 'Shows a link allowing a user to subscribe to this blog via RSS.';
/**
* Return an absolute URL based on the BlogHolder
@ -26,6 +26,4 @@ class SubscribeRSSWidget extends Widget {
$container = BlogTree::current();
if ($container) return $container->Link('rss');
}
}
?>
}

View File

@ -1,28 +1,22 @@
<?php
class TagCloudWidget extends Widget {
static $db = array(
private static $db = array(
"Title" => "Varchar",
"Limit" => "Int",
"Sortby" => "Varchar"
);
static $has_one = array();
static $has_many = array();
static $many_many = array();
static $belongs_many_many = array();
static $defaults = array(
private static $defaults = array(
"Title" => "Tag Cloud",
"Limit" => "0",
"Sortby" => "alphabet"
);
static $cmsTitle = "Tag Cloud";
static $description = "Shows a tag cloud of tags on your blog.";
private static $cmsTitle = "Tag Cloud";
private static $description = "Shows a tag cloud of tags on your blog.";
static $popularities = array( 'not-popular', 'not-very-popular', 'somewhat-popular', 'popular', 'very-popular', 'ultra-popular' );
@ -144,7 +138,4 @@ class TagCloudWidget extends Widget {
return true;
}
}
?>
}

View File

@ -73,5 +73,3 @@ class BlogHolderTest extends SapphireTest {
}
}
?>

View File

@ -104,5 +104,3 @@ class BlogTreeTest extends SapphireTest {
}
}
?>

View File

@ -3773,5 +3773,3 @@ xmlrpc_encode_entitites($this->errstr, $GLOBALS['xmlrpc_internalencoding'], $cha
return false;
}
}
?>

View File

@ -952,4 +952,3 @@
//$code .= "\$client->setDebug(\$debug);\n";
return $code;
}
?>

View File

@ -1243,4 +1243,3 @@
print $r->serialize();
}
}
?>