Merge branch '0.5' into 0.6

This commit is contained in:
Daniel Hensby 2018-02-20 13:24:43 +00:00
commit e2cf6421c6
No known key found for this signature in database
GPG Key ID: B00D1E9767F0B06E
4 changed files with 134 additions and 119 deletions

View File

@ -65,7 +65,6 @@ class BlogHolder extends BlogTree implements PermissionProvider {
/**
* Get members who have BLOGMANAGEMENT and ADMIN permission
*/
function blogOwners($sort = array('FirstName'=>'ASC','Surname'=>'ASC'), $direction = null) {
$members = Permission::get_members_by_permission(array('ADMIN','BLOGMANAGEMENT'));
@ -183,6 +182,7 @@ class BlogHolder extends BlogTree implements PermissionProvider {
}
class BlogHolder_Controller extends BlogTree_Controller {
static $allowed_actions = array(
'index',
'tag',
@ -304,6 +304,7 @@ class BlogHolder_Controller extends BlogTree_Controller {
}
$form->saveInto($blogentry);
$blogentry->ParentID = $this->ID;
$blogentry->Content = str_replace("\r\n", "\n", $form->Fields()->fieldByName('BlogPost')->dataValue());

View File

@ -22,6 +22,13 @@ class BlogTree extends Page {
// Default number of blog entries to show
static $default_entries_limit = 10;
/**
* @var bool Include an automatic link to the rss feed for
* the browser. Disabling this will allow you to include your
* own feedburner link
*/
static $include_rss_link = true;
static $db = array(
'LandingPageFreshness' => 'Varchar',
);
@ -144,7 +151,6 @@ class BlogTree extends Page {
* @return DataObjectSet
*/
public function Entries($limit = '', $tag = '', $date = '', $retrieveCallback = null, $filter = '') {
$tagCheck = '';
$dateCheck = '';
@ -185,7 +191,6 @@ class BlogTree extends Page {
}
}
}
// Build a list of all IDs for BlogHolders that are children of us
$holderIDs = $this->BlogHolderIDs();
@ -221,7 +226,9 @@ class BlogTree_Controller extends Page_Controller {
function init() {
parent::init();
$this->IncludeBlogRSS();
if(BlogTree::$include_rss_link) {
$this->IncludeBlogRSS();
}
Requirements::themedCSS("blog","blog");
}
@ -234,7 +241,7 @@ class BlogTree_Controller extends Page_Controller {
// only use freshness if no action is present (might be displaying tags or rss)
if ($this->LandingPageFreshness && !$this->request->param('Action')) {
$d = new Zend_Date(SS_Datetime::now()->getValue());
$d->sub($this->LandingPageFreshness, Zend_Date::MONTH);
$d->sub(intval($this->LandingPageFreshness, Zend_Date::MONTH), Zend_Date::MONTH);
$date = $d->toString('YYYY-MM-dd');
$filter = "\"BlogEntry\".\"Date\" > '$date'";

View File

@ -25,41 +25,40 @@ if(class_exists('Widget')) {
static $title = 'Browse by Date';
static $cmsTitle = 'Blog Archive';
static $cmsTitle = 'Blog Archive';
static $description = 'Show a list of months or years in which there are blog posts, and provide links to them.';
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();
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->merge(
new FieldList(
new OptionsetField(
'DisplayMode',
_t('ArchiveWidget.DispBY', 'Display by'),
array(
'month' => _t('ArchiveWidget.MONTH', 'month'),
'year' => _t('ArchiveWidget.YEAR', 'year')
)
$fields->merge(
new FieldList(
new OptionsetField(
'DisplayMode',
_t('ArchiveWidget.DispBY', 'Display by'),
array(
'month' => _t('ArchiveWidget.MONTH', 'month'),
'year' => _t('ArchiveWidget.YEAR', 'year')
)
)
);
)
);
$this->extend('updateCMSFields', $fields);
$this->extend('updateCMSFields', $fields);
return $fields;
}
return $fields;
}
function getDates() {
Requirements::themedCSS('archivewidget');
function getDates() {
Requirements::themedCSS('archivewidget');
$results = new ArrayList();
$container = BlogTree::current();
$ids = $container->BlogHolderIDs();
$results = new ArrayList();
$container = BlogTree::current();
$ids = $container->BlogHolderIDs();
$stage = Versioned::current_stage();
$suffix = (!$stage || $stage == 'Stage') ? "" : "_$stage";
if(empty($ids)) return $results;$stage = Versioned::current_stage();
$suffix = (!$stage || $stage == 'Stage') ? "" : "_$stage";
$monthclause = method_exists(DB::getConn(), 'formattedDatetimeClause') ? DB::getConn()->formattedDatetimeClause('"Date"', '%m') : 'MONTH("Date")';
$yearclause = method_exists(DB::getConn(), 'formattedDatetimeClause') ? DB::getConn()->formattedDatetimeClause('"Date"', '%Y') : 'YEAR("Date")';

View File

@ -6,9 +6,12 @@
class BlogHolderFunctionalTest extends FunctionalTest {
static $fixture_file = 'blog/tests/BlogHolderFunctionalTest.yml';
static $origlThemes;
function setUp() {
parent::setUp();
self::$origlThemes = SSViewer::current_theme();
SSViewer::set_theme(null);
$blogHolder = $this->objFromFixture('BlogHolder', 'blogholder');
$blogHolder->publish('Stage', 'Live');
@ -16,6 +19,11 @@ class BlogHolderFunctionalTest extends FunctionalTest {
$blogEntry->publish('Stage', 'Live');
}
function tearDown(){
SSViewer::set_theme(self::$origlThemes);
parent::tearDown();
}
function testFrontendBlogPostRequiresPermission() {
// get valid SecurityID (from comments form, would usually be copy/pasted)
$blogEntry = $this->objFromFixture('BlogEntry', 'entry1');