NEW Making widgets dependency optional

This commit is contained in:
Ingo Schommer 2013-04-11 12:35:22 +02:00
parent 966d168119
commit ee532292d2
6 changed files with 265 additions and 268 deletions

View File

@ -14,7 +14,7 @@ The blog module allows you to post blogs on your SilverStripe. It includes the a
## Requirements ## Requirements
* Silverstripe 3.0 * Silverstripe 3.0
* silverstripe-widgets module * (Optional) silverstripe-widgets module
## Feature Overview ## Feature Overview
@ -76,10 +76,6 @@ or: mysite/blog/2007 would show blog entries for 2007
See [:pagecomment](/pagecomment) for creating Askimet-protected comments for every page. See [:pagecomment](/pagecomment) for creating Askimet-protected comments for every page.
## Widgets
See [widgets](/widgets)
## Working with the theme ## Working with the theme

View File

@ -1,11 +1,12 @@
<?php <?php
/** if(class_exists('Widget')) {
/**
* Shows a widget with viewing blog entries * Shows a widget with viewing blog entries
* by months or years. * by months or years.
* *
* @package blog * @package blog
*/ */
class ArchiveWidget extends Widget { class ArchiveWidget extends Widget {
static $db = array( static $db = array(
'DisplayMode' => 'Varchar' 'DisplayMode' => 'Varchar'
); );
@ -106,6 +107,6 @@ class ArchiveWidget extends Widget {
return $results; return $results;
} }
} }
?> }

View File

@ -1,9 +1,11 @@
<?php <?php
/** if(class_exists('Widget')) {
/**
* Blog Management Widget * Blog Management Widget
* @package blog * @package blog
*/ */
class BlogManagementWidget extends Widget implements PermissionProvider { class BlogManagementWidget extends Widget {
static $db = array(); static $db = array();
static $has_one = array(); static $has_one = array();
@ -45,13 +47,9 @@ class BlogManagementWidget extends Widget implements PermissionProvider {
} }
} }
function providePermissions() {
return array("BLOGMANAGEMENT" => "Blog management");
} }
} class BlogManagementWidget_Controller extends Widget_Controller {
class BlogManagementWidget_Controller extends Widget_Controller {
function WidgetHolder() { function WidgetHolder() {
if(Permission::check("BLOGMANAGEMENT")) { if(Permission::check("BLOGMANAGEMENT")) {
@ -63,5 +61,6 @@ class BlogManagementWidget_Controller extends Widget_Controller {
$container = BlogTree::current(); $container = BlogTree::current();
return ($container && $container->ClassName != "BlogTree") ? $container->Link('post') : false; return ($container && $container->ClassName != "BlogTree") ? $container->Link('post') : false;
} }
}
} }
?>

View File

@ -1,6 +1,6 @@
<?php <?php
if(class_exists('Widget')) {
class RSSWidget extends Widget { class RSSWidget extends Widget {
static $db = array( static $db = array(
"RSSTitle" => "Text", "RSSTitle" => "Text",
"RssUrl" => "Text", "RssUrl" => "Text",
@ -91,6 +91,6 @@ class RSSWidget extends Widget {
return $output; return $output;
} }
} }
} }
?> }

View File

@ -1,13 +1,13 @@
<?php <?php
if(class_exists('Widget')) {
/** /**
* A simple widget that just shows a link * A simple widget that just shows a link
* to this website's blog RSS, with an RSS * to this website's blog RSS, with an RSS
* icon. * icon.
* *
* @package blog * @package blog
*/ */
class SubscribeRSSWidget extends Widget { class SubscribeRSSWidget extends Widget {
static $title = 'Subscribe via RSS'; static $title = 'Subscribe via RSS';
@ -26,6 +26,6 @@ class SubscribeRSSWidget extends Widget {
$container = BlogTree::current(); $container = BlogTree::current();
if ($container) return $container->Link('rss'); if ($container) return $container->Link('rss');
} }
} }
?> }

View File

@ -14,9 +14,10 @@
} }
], ],
"require": "require": {
{ "silverstripe/cms": "3.0.*"
"silverstripe/cms": "3.0.*", },
"suggests": {
"silverstripe/widgets": "0.1.*" "silverstripe/widgets": "0.1.*"
} }
} }