Merge branch '0.3' into 0.4

This commit is contained in:
Daniel Hensby 2018-02-20 13:17:23 +00:00
commit dfaa974697
No known key found for this signature in database
GPG Key ID: B00D1E9767F0B06E
3 changed files with 46 additions and 36 deletions

View File

@ -28,7 +28,7 @@ class BlogHolder extends BlogTree implements PermissionProvider {
);
function getCMSFields() {
$blogOwners = $this->blogOwners();
$blogOwners = $this->blogOwners();
SiteTree::disableCMSFieldsExtensions();
$fields = parent::getCMSFields();
@ -42,22 +42,22 @@ class BlogHolder extends BlogTree implements PermissionProvider {
return $fields;
}
/**
* Get members who have BLOGMANAGEMENT and ADMIN permission
*/
*/
function blogOwners($sort = 'Name', $direction = "ASC") {
$adminMembers = Permission::get_members_by_permission('ADMIN');
$adminMembers = Permission::get_members_by_permission('ADMIN');
$blogOwners = Permission::get_members_by_permission('BLOGMANAGEMENT');
if(!$adminMembers) $adminMembers = new DataObjectSet();
if(!$adminMembers) $adminMembers = new DataObjectSet();
if(!$blogOwners) $blogOwners = new DataObjectSet();
$blogOwners->merge($adminMembers);
$blogOwners->sort($sort, $direction);
$this->extend('extendBlogOwners', $blogOwners);
return $blogOwners;
}
@ -152,6 +152,7 @@ class BlogHolder extends BlogTree implements PermissionProvider {
}
class BlogHolder_Controller extends BlogTree_Controller {
static $allowed_actions = array(
'index',
'tag',
@ -161,7 +162,7 @@ class BlogHolder_Controller extends BlogTree_Controller {
'post' => 'BLOGMANAGEMENT',
'BlogEntryForm' => 'BLOGMANAGEMENT',
);
function init() {
parent::init();
Requirements::themedCSS("bbcodehelp");
@ -194,9 +195,9 @@ class BlogHolder_Controller extends BlogTree_Controller {
/**
* A simple form for creating blog entries
*/
function BlogEntryForm() {
function BlogEntryForm() {
if(!Permission::check('BLOGMANAGEMENT')) return Security::permissionFailure();
$id = 0;
if($this->request->latestParam('ID')) {
@ -221,7 +222,7 @@ class BlogHolder_Controller extends BlogTree_Controller {
} else {
$tagfield = new TextField('Tags');
}
$field = 'TextField';
if(!$this->AllowCustomAuthors && !Permission::check('ADMIN')) {
$field = 'ReadonlyField';
@ -235,7 +236,7 @@ class BlogHolder_Controller extends BlogTree_Controller {
new LiteralField("Tagsnote"," <label id='tagsnote'>"._t('BlogHolder.TE', "For example: sport, personal, science fiction")."<br/>" .
_t('BlogHolder.SPUC', "Please separate tags using commas.")."</label>")
);
$submitAction = new FormAction('postblog', _t('BlogHolder.POST', 'Post blog entry'));
$actions = new FieldSet($submitAction);
$validator = new RequiredFields('Title','BlogPost');
@ -273,12 +274,12 @@ class BlogHolder_Controller extends BlogTree_Controller {
}
$form->saveInto($blogentry);
$blogentry->ParentID = $this->ID;
$blogentry->Content = $form->datafieldByName('BlogPost')->dataValue();
if(Object::hasExtension('Translatable')) {
$blogentry->Locale = $this->Locale;
$blogentry->Locale = $this->Locale;
}
$blogentry->Status = "Published";

View File

@ -13,6 +13,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(
'Name' => 'Varchar',
'InheritSideBar' => 'Boolean',
@ -41,7 +48,7 @@ class BlogTree extends Page {
* uses current
*/
static function current($page = null) {
if (!$page) {
$controller = Controller::curr();
if($controller) $page = $controller->data();
@ -152,7 +159,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();
@ -206,7 +211,7 @@ class BlogTree extends Page {
}
class BlogTree_Controller extends Page_Controller {
static $allowed_actions = array(
'index',
'rss',
@ -216,14 +221,16 @@ class BlogTree_Controller extends Page_Controller {
function init() {
parent::init();
$this->IncludeBlogRSS();
if(BlogTree::$include_rss_link) {
$this->IncludeBlogRSS();
}
Requirements::themedCSS("blog");
}
function BlogEntries($limit = null) {
require_once('Zend/Date.php');
if($limit === null) $limit = BlogTree::$default_entries_limit;
// only use freshness if no action is present (might be displaying tags or rss)
@ -231,7 +238,7 @@ class BlogTree_Controller extends Page_Controller {
$d = new Zend_Date(SS_Datetime::now()->getValue());
$d->sub($this->LandingPageFreshness);
$date = $d->toString('YYYY-MM-dd');
$filter = "\"BlogEntry\".\"Date\" > '$date'";
} else {
$filter = '';
@ -241,7 +248,7 @@ class BlogTree_Controller extends Page_Controller {
if(isset($_GET['author']) && isset($_GET['authorID'])) {
$author = Convert::raw2sql($_GET['author']);
$id = Convert::raw2sql($_GET['authorID']);
$filter .= " \"BlogEntry\".\"Author\" LIKE '". $author . "' OR \"BlogEntry\".\"AuthorID\" = '". $id ."'";
}
else if(isset($_GET['author'])) {
@ -252,9 +259,9 @@ class BlogTree_Controller extends Page_Controller {
}
$start = isset($_GET['start']) ? (int) $_GET['start'] : 0;
$date = $this->SelectedDate();
return $this->Entries("$start,$limit", $this->SelectedTag(), ($date) ? $date->Format('Y-m') : '', null, $filter);
}
@ -264,7 +271,7 @@ class BlogTree_Controller extends Page_Controller {
function IncludeBlogRSS() {
RSSFeed::linkToFeed($this->Link() . "rss", _t('BlogHolder.RSSFEED',"RSS feed of these blogs"));
}
/**
* Get the rss feed for this blog holder's entries
*/
@ -281,7 +288,7 @@ class BlogTree_Controller extends Page_Controller {
$rss->outputToBrowser();
}
}
/**
* Protection against infinite loops when an RSS widget pointing to this page is added to this page
*/
@ -290,16 +297,16 @@ class BlogTree_Controller extends Page_Controller {
return parent::defaultAction($action);
}
/**
* Return the currently viewing tag used in the template as $Tag
* Return the currently viewing tag used in the template as $Tag
*
* @return String
*/
function SelectedTag() {
return ($this->request->latestParam('Action') == 'tag') ? Convert::raw2xml($this->request->latestParam('ID')) : '';
return ($this->request->latestParam('Action') == 'tag') ? Convert::raw2xml($this->request->latestParam('ID')) : '';
}
/**
* Return the selected date from the blog tree
*
@ -309,15 +316,15 @@ class BlogTree_Controller extends Page_Controller {
if($this->request->latestParam('Action') == 'date') {
$year = $this->request->latestParam('ID');
$month = $this->request->latestParam('OtherID');
if(is_numeric($year) && is_numeric($month) && $month < 13) {
$date = new Date();
$date->setValue($year .'-'. $month);
return $date;
}
}
return false;
}
}

View File

@ -52,6 +52,8 @@ class ArchiveWidget extends Widget {
$container = BlogTree::current();
$ids = $container->BlogHolderIDs();
if(empty($ids)) return $results;
$stage = Versioned::current_stage();
$suffix = (!$stage || $stage == 'Stage') ? "" : "_$stage";