Merge branch '0.6' into 1.0

This commit is contained in:
Daniel Hensby 2018-02-20 13:31:31 +00:00
commit bdea98a875
No known key found for this signature in database
GPG Key ID: B00D1E9767F0B06E
5 changed files with 123 additions and 117 deletions

View File

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

View File

@ -1,11 +1,11 @@
<?php <?php
/** /**
* @package blog * @package blog
*/ */
/** /**
* Blog tree is a way to group Blogs. It allows a tree of "Blog Holders". * Blog tree is a way to group Blogs. It allows a tree of "Blog Holders".
* Viewing branch nodes shows all blog entries from all blog holder children * Viewing branch nodes shows all blog entries from all blog holder children
*/ */
@ -14,26 +14,26 @@ class BlogTree extends Page {
private static $icon = "blog/images/blogtree-file.png"; private static $icon = "blog/images/blogtree-file.png";
private static $description = "A grouping of blogs"; private static $description = "A grouping of blogs";
private static $singular_name = 'Blog Tree Page'; private static $singular_name = 'Blog Tree Page';
private 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
static $default_entries_limit = 10; static $default_entries_limit = 10;
private static $db = array( private static $db = array(
'Name' => 'Varchar(255)', 'Name' => 'Varchar(255)',
'LandingPageFreshness' => 'Varchar', 'LandingPageFreshness' => 'Varchar',
); );
private static $defaults = array( private static $defaults = array(
); );
private static $has_one = array(); private static $has_one = array();
private static $has_many = array(); private static $has_many = array();
private static $allowed_children = array( private static $allowed_children = array(
'BlogTree', 'BlogHolder' 'BlogTree', 'BlogHolder'
); );
@ -49,43 +49,43 @@ class BlogTree extends Page {
* @return BlogTree * @return BlogTree
*/ */
static function current($page = null) { static function current($page = null) {
if (!$page && Controller::has_curr()) { if (!$page && Controller::has_curr()) {
$controller = Controller::curr(); $controller = Controller::curr();
if ($controller->hasMethod('data')) { if ($controller->hasMethod('data')) {
$page = $controller->data(); $page = $controller->data();
} }
} }
if ($page) { if ($page) {
// If we _are_ a BlogTree, use us // If we _are_ a BlogTree, use us
if ($page instanceof BlogTree) return $page; if ($page instanceof BlogTree) return $page;
// If page is a virtual page use that // If page is a virtual page use that
if($page instanceof VirtualPage && $page->CopyContentFrom() instanceof BlogTree) return $page; if($page instanceof VirtualPage && $page->CopyContentFrom() instanceof BlogTree) return $page;
// Or, if we a a BlogEntry underneath a BlogTree, use our parent // Or, if we a a BlogEntry underneath a BlogTree, use our parent
if($page->is_a("BlogEntry")) { if($page->is_a("BlogEntry")) {
$parent = $page->getParent(); $parent = $page->getParent();
if($parent instanceof BlogTree) return $parent; if($parent instanceof BlogTree) return $parent;
} }
} }
// Try to find a top-level BlogTree // Try to find a top-level BlogTree
$top = DataObject::get_one('BlogTree', "\"ParentID\" = '0'"); $top = DataObject::get_one('BlogTree', "\"ParentID\" = '0'");
if($top) return $top; if($top) return $top;
// Try to find any BlogTree that is not inside another BlogTree // Try to find any BlogTree that is not inside another BlogTree
if($blogTrees=DataObject::get('BlogTree')) foreach($blogTrees as $tree) { if($blogTrees=DataObject::get('BlogTree')) foreach($blogTrees as $tree) {
if(!($tree->getParent() instanceof BlogTree)) return $tree; if(!($tree->getParent() instanceof BlogTree)) return $tree;
} }
// This shouldn't be possible, but assuming the above fails, just return anything you can get // This shouldn't be possible, but assuming the above fails, just return anything you can get
return $blogTrees->first(); return $blogTrees->first();
} }
/* ----------- ACCESSOR OVERRIDES -------------- */ /* ----------- ACCESSOR OVERRIDES -------------- */
public function getLandingPageFreshness() { public function getLandingPageFreshness() {
$freshness = $this->getField('LandingPageFreshness'); $freshness = $this->getField('LandingPageFreshness');
// If we want to inherit freshness, try that first // If we want to inherit freshness, try that first
@ -94,65 +94,65 @@ class BlogTree extends Page {
if ($freshness == "INHERIT") $freshness = ''; if ($freshness == "INHERIT") $freshness = '';
return $freshness; return $freshness;
} }
/* ----------- CMS CONTROL -------------- */ /* ----------- CMS CONTROL -------------- */
function getSettingsFields() { function getSettingsFields() {
$fields = parent::getSettingsFields(); $fields = parent::getSettingsFields();
$fields->addFieldToTab( $fields->addFieldToTab(
'Root.Settings', 'Root.Settings',
new DropdownField( new DropdownField(
'LandingPageFreshness', 'LandingPageFreshness',
'When you first open the blog, how many entries should I show', 'When you first open the blog, how many entries should I show',
array( array(
"" => "All entries", "" => "All entries",
"1" => "Last month's entries", "1" => "Last month's entries",
"2" => "Last 2 months' entries", "2" => "Last 2 months' entries",
"3" => "Last 3 months' entries", "3" => "Last 3 months' entries",
"4" => "Last 4 months' entries", "4" => "Last 4 months' entries",
"5" => "Last 5 months' entries", "5" => "Last 5 months' entries",
"6" => "Last 6 months' entries", "6" => "Last 6 months' entries",
"7" => "Last 7 months' entries", "7" => "Last 7 months' entries",
"8" => "Last 8 months' entries", "8" => "Last 8 months' entries",
"9" => "Last 9 months' entries", "9" => "Last 9 months' entries",
"10" => "Last 10 months' entries", "10" => "Last 10 months' entries",
"11" => "Last 11 months' entries", "11" => "Last 11 months' entries",
"12" => "Last year's entries", "12" => "Last year's entries",
"INHERIT" => "Take value from parent Blog Tree" "INHERIT" => "Take value from parent Blog Tree"
) )
) )
); );
return $fields; return $fields;
} }
/* ----------- New accessors -------------- */ /* ----------- New accessors -------------- */
public function loadDescendantBlogHolderIDListInto(&$idList) { public function loadDescendantBlogHolderIDListInto(&$idList) {
if ($children = $this->AllChildren()) { if ($children = $this->AllChildren()) {
foreach($children as $child) { foreach($children as $child) {
if(in_array($child->ID, $idList)) continue; if(in_array($child->ID, $idList)) continue;
if($child instanceof BlogHolder) { if($child instanceof BlogHolder) {
$idList[] = $child->ID; $idList[] = $child->ID;
} elseif($child instanceof BlogTree) { } elseif($child instanceof BlogTree) {
$child->loadDescendantBlogHolderIDListInto($idList); $child->loadDescendantBlogHolderIDListInto($idList);
} }
} }
} }
} }
// Build a list of all IDs for BlogHolders that are children of us // Build a list of all IDs for BlogHolders that are children of us
public function BlogHolderIDs() { public function BlogHolderIDs() {
$holderIDs = array(); $holderIDs = array();
$this->loadDescendantBlogHolderIDListInto($holderIDs); $this->loadDescendantBlogHolderIDListInto($holderIDs);
return $holderIDs; return $holderIDs;
} }
/** /**
* Get entries in this blog. * Get entries in this blog.
* *
* @param string $limit A clause to insert into the limit clause. * @param string $limit A clause to insert into the limit clause.
* @param string $tag Only get blog entries with this tag * @param string $tag Only get blog entries with this tag
* @param string $date Only get blog entries on this date - either a year, or a year-month eg '2008' or '2008-02' * @param string $date Only get blog entries on this date - either a year, or a year-month eg '2008' or '2008-02'
@ -162,10 +162,9 @@ class BlogTree extends Page {
* @return PaginatedList The list of entries in a paginated list * @return PaginatedList The list of entries in a paginated list
*/ */
public function Entries($limit = '', $tag = '', $date = '', $retrieveCallback = null, $filter = '') { public function Entries($limit = '', $tag = '', $date = '', $retrieveCallback = null, $filter = '') {
$tagCheck = ''; $tagCheck = '';
$dateCheck = ''; $dateCheck = '';
if($tag) { if($tag) {
$SQL_tag = Convert::raw2sql($tag); $SQL_tag = Convert::raw2sql($tag);
$tagCheck = "AND \"BlogEntry\".\"Tags\" LIKE '%$SQL_tag%'"; $tagCheck = "AND \"BlogEntry\".\"Tags\" LIKE '%$SQL_tag%'";
@ -175,12 +174,12 @@ class BlogTree extends Page {
// Some systems still use the / seperator for date presentation // Some systems still use the / seperator for date presentation
if( strpos($date, '-') ) $seperator = '-'; if( strpos($date, '-') ) $seperator = '-';
elseif( strpos($date, '/') ) $seperator = '/'; elseif( strpos($date, '/') ) $seperator = '/';
if(isset($seperator) && !empty($seperator)) { if(isset($seperator) && !empty($seperator)) {
// The 2 in the explode argument will tell it to only create 2 elements // The 2 in the explode argument will tell it to only create 2 elements
// i.e. in this instance the $year and $month fields respectively // i.e. in this instance the $year and $month fields respectively
list($year,$month) = explode( $seperator, $date, 2); list($year,$month) = explode( $seperator, $date, 2);
$year = (int)$year; $year = (int)$year;
$month = (int)$month; $month = (int)$month;
@ -203,13 +202,12 @@ class BlogTree extends Page {
} }
} }
} }
// Build a list of all IDs for BlogHolders that are children of us // Build a list of all IDs for BlogHolders that are children of us
$holderIDs = $this->BlogHolderIDs(); $holderIDs = $this->BlogHolderIDs();
// If no BlogHolders, no BlogEntries. So return false // If no BlogHolders, no BlogEntries. So return false
if(empty($holderIDs)) return false; if(empty($holderIDs)) return false;
// Otherwise, do the actual query // Otherwise, do the actual query
if($filter) $filter .= ' AND '; if($filter) $filter .= ' AND ';
$filter .= '"SiteTree"."ParentID" IN (' . implode(',', $holderIDs) . ") $tagCheck $dateCheck"; $filter .= '"SiteTree"."ParentID" IN (' . implode(',', $holderIDs) . ") $tagCheck $dateCheck";
@ -228,44 +226,44 @@ class BlogTree extends Page {
} }
class BlogTree_Controller extends Page_Controller { class BlogTree_Controller extends Page_Controller {
private static $allowed_actions = array( private static $allowed_actions = array(
'index', 'index',
'rss', 'rss',
'tag', 'tag',
'date' 'date'
); );
private static $casting = array( private static $casting = array(
'SelectedTag' => 'Text', 'SelectedTag' => 'Text',
'SelectedAuthor' => 'Text' 'SelectedAuthor' => 'Text'
); );
function init() { function init() {
parent::init(); parent::init();
$this->IncludeBlogRSS(); $this->IncludeBlogRSS();
Requirements::themedCSS("blog","blog"); Requirements::themedCSS("blog","blog");
} }
/** /**
* Determine selected BlogEntry items to show on this page * Determine selected BlogEntry items to show on this page
* *
* @param int $limit * @param int $limit
* @return PaginatedList * @return PaginatedList
*/ */
public function BlogEntries($limit = null) { public function BlogEntries($limit = null) {
require_once('Zend/Date.php'); require_once('Zend/Date.php');
if($limit === null) $limit = BlogTree::$default_entries_limit; if($limit === null) $limit = BlogTree::$default_entries_limit;
// only use freshness if no action is present (might be displaying tags or rss) // only use freshness if no action is present (might be displaying tags or rss)
if ($this->LandingPageFreshness && !$this->request->param('Action')) { if ($this->LandingPageFreshness && !$this->request->param('Action')) {
$d = new Zend_Date(SS_Datetime::now()->getValue()); $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'); $date = $d->toString('YYYY-MM-dd');
$filter = "\"BlogEntry\".\"Date\" > '$date'"; $filter = "\"BlogEntry\".\"Date\" > '$date'";
} else { } else {
$filter = ''; $filter = '';
@ -275,7 +273,7 @@ class BlogTree_Controller extends Page_Controller {
if(isset($_GET['author']) && isset($_GET['authorID'])) { if(isset($_GET['author']) && isset($_GET['authorID'])) {
$author = Convert::raw2sql($_GET['author']); $author = Convert::raw2sql($_GET['author']);
$id = Convert::raw2sql($_GET['authorID']); $id = Convert::raw2sql($_GET['authorID']);
$filter .= " \"BlogEntry\".\"Author\" LIKE '". $author . "' OR \"BlogEntry\".\"AuthorID\" = '". $id ."'"; $filter .= " \"BlogEntry\".\"Author\" LIKE '". $author . "' OR \"BlogEntry\".\"AuthorID\" = '". $id ."'";
} }
else if(isset($_GET['author'])) { else if(isset($_GET['author'])) {
@ -286,7 +284,7 @@ class BlogTree_Controller extends Page_Controller {
} }
$date = $this->SelectedDate(); $date = $this->SelectedDate();
return $this->Entries($limit, $this->SelectedTag(), ($date) ? $date : '', null, $filter); return $this->Entries($limit, $this->SelectedTag(), ($date) ? $date : '', null, $filter);
} }
@ -296,7 +294,7 @@ class BlogTree_Controller extends Page_Controller {
public function IncludeBlogRSS() { public function IncludeBlogRSS() {
RSSFeed::linkToFeed($this->Link('rss'), _t('BlogHolder.RSSFEED',"RSS feed of these blogs")); RSSFeed::linkToFeed($this->Link('rss'), _t('BlogHolder.RSSFEED',"RSS feed of these blogs"));
} }
/** /**
* Get the rss feed for this blog holder's entries * Get the rss feed for this blog holder's entries
*/ */
@ -305,7 +303,7 @@ class BlogTree_Controller extends Page_Controller {
$blogName = $this->Title; $blogName = $this->Title;
$altBlogName = $project_name . ' blog'; $altBlogName = $project_name . ' blog';
$entries = $this->Entries(20); $entries = $this->Entries(20);
if($entries) { if($entries) {
@ -313,18 +311,18 @@ class BlogTree_Controller extends Page_Controller {
return $rss->outputToBrowser(); return $rss->outputToBrowser();
} }
} }
/** /**
* Protection against infinite loops when an RSS widget pointing to this page is added to this page * Protection against infinite loops when an RSS widget pointing to this page is added to this page
*/ */
public function defaultAction($action) { public function defaultAction($action) {
if(stristr($_SERVER['HTTP_USER_AGENT'], 'SimplePie')) return $this->rss(); if(stristr($_SERVER['HTTP_USER_AGENT'], 'SimplePie')) return $this->rss();
return parent::defaultAction($action); 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 * @return string
*/ */
@ -335,7 +333,7 @@ class BlogTree_Controller extends Page_Controller {
} }
return ''; return '';
} }
/** /**
* Return the selected date from the blog tree * Return the selected date from the blog tree
* *
@ -345,18 +343,18 @@ class BlogTree_Controller extends Page_Controller {
if($this->request->latestParam('Action') == 'date') { if($this->request->latestParam('Action') == 'date') {
$year = $this->request->latestParam('ID'); $year = $this->request->latestParam('ID');
$month = $this->request->latestParam('OtherID'); $month = $this->request->latestParam('OtherID');
if(is_numeric($year) && is_numeric($month) && $month < 13) { if(is_numeric($year) && is_numeric($month) && $month < 13) {
$date = $year .'-'. $month; $date = $year .'-'. $month;
return $date; return $date;
} else { } else {
if(is_numeric($year)) return $year; if(is_numeric($year)) return $year;
} }
} }
return false; return false;
} }
@ -385,18 +383,17 @@ class BlogTree_Controller extends Page_Controller {
} }
} }
} }
/** /**
*
* @return string * @return string
*/ */
public function SelectedNiceDate(){ public function SelectedNiceDate(){
$date = $this->SelectedDate(); $date = $this->SelectedDate();
if(strpos($date, '-')) { if(strpos($date, '-')) {
$date = explode("-",$date); $date = explode("-",$date);
return date("F", mktime(0, 0, 0, $date[1], 1, date('Y'))). " " .date("Y", mktime(0, 0, 0, date('m'), 1, $date[0])); return date("F", mktime(0, 0, 0, $date[1], 1, date('Y'))). " " .date("Y", mktime(0, 0, 0, date('m'), 1, $date[0]));
} else { } else {
return date("Y", mktime(0, 0, 0, date('m'), 1, $date)); return date("Y", mktime(0, 0, 0, date('m'), 1, $date));
} }

View File

@ -1,34 +1,34 @@
<?php <?php
if(class_exists('Widget')) { 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 {
private static $db = array( private static $db = array(
'DisplayMode' => 'Varchar' 'DisplayMode' => 'Varchar'
); );
private static $defaults = array( private static $defaults = array(
'DisplayMode' => 'month' 'DisplayMode' => 'month'
); );
private static $title = 'Browse by Date'; private static $title = 'Browse by Date';
private static $cmsTitle = 'Blog Archive'; private static $cmsTitle = 'Blog Archive';
private static $description = private static $description =
'Show a list of months or years in which there are blog posts, and provide links to them.'; 'Show a list of months or years in which there are blog posts, and provide links to them.';
function getCMSFields() { function getCMSFields() {
$fields = parent::getCMSFields(); $fields = parent::getCMSFields();
$fields->merge( $fields->merge(
new FieldList( new FieldList(
new OptionsetField( new OptionsetField(
@ -39,21 +39,21 @@ if(class_exists('Widget')) {
'year' => _t('ArchiveWidget.YEAR', 'year') 'year' => _t('ArchiveWidget.YEAR', 'year')
) )
) )
) )
); );
$this->extend('updateCMSFields', $fields); $this->extend('updateCMSFields', $fields);
return $fields; return $fields;
} }
function getDates() { function getDates() {
Requirements::themedCSS('archivewidget'); Requirements::themedCSS('archivewidget');
$results = new ArrayList(); $results = new ArrayList();
$container = BlogTree::current(); $container = BlogTree::current();
$ids = $container->BlogHolderIDs(); $ids = $container->BlogHolderIDs();
$stage = Versioned::current_stage(); $stage = Versioned::current_stage();
$suffix = (!$stage || $stage == 'Stage') ? "" : "_$stage"; $suffix = (!$stage || $stage == 'Stage') ? "" : "_$stage";
@ -64,9 +64,9 @@ if(class_exists('Widget')) {
$monthclause = 'MONTH("Date")'; $monthclause = 'MONTH("Date")';
$yearclause = 'YEAR("Date")'; $yearclause = 'YEAR("Date")';
} }
// Changed the WHERE clause from where ParentID to WHERE SiteTree$suffix.ParentID as it was ambiguous. // Changed the WHERE clause from where ParentID to WHERE SiteTree$suffix.ParentID as it was ambiguous.
if($this->DisplayMode == 'month') { if($this->DisplayMode == 'month') {
$sqlResults = DB::query(" $sqlResults = DB::query("
SELECT DISTINCT CAST($monthclause AS " . DB::getConn()->dbDataType('unsigned integer') . ") SELECT DISTINCT CAST($monthclause AS " . DB::getConn()->dbDataType('unsigned integer') . ")
@ -86,33 +86,34 @@ if(class_exists('Widget')) {
ORDER BY \"Year\" DESC" ORDER BY \"Year\" DESC"
); );
} }
if($sqlResults) foreach($sqlResults as $sqlResult) { if($sqlResults) foreach($sqlResults as $sqlResult) {
$isMonthDisplay = $this->DisplayMode == 'month'; $isMonthDisplay = $this->DisplayMode == 'month';
$monthVal = (isset($sqlResult['Month'])) ? (int) $sqlResult['Month'] : 1; $monthVal = (isset($sqlResult['Month'])) ? (int) $sqlResult['Month'] : 1;
$month = ($isMonthDisplay) ? $monthVal : 1; $month = ($isMonthDisplay) ? $monthVal : 1;
$year = ($sqlResult['Year']) ? (int) $sqlResult['Year'] : date('Y'); $year = ($sqlResult['Year']) ? (int) $sqlResult['Year'] : date('Y');
$date = DBField::create_field('Date', array( $date = DBField::create_field('Date', array(
'Day' => 1, 'Day' => 1,
'Month' => $month, 'Month' => $month,
'Year' => $year 'Year' => $year
)); ));
if($isMonthDisplay) { if($isMonthDisplay) {
$link = $container->Link('date') . '/' . $sqlResult['Year'] . '/' . sprintf("%'02d", $monthVal); $link = $container->Link('date') . '/' . $sqlResult['Year'] . '/' . sprintf("%'02d", $monthVal);
} else { } else {
$link = $container->Link('date') . '/' . $sqlResult['Year']; $link = $container->Link('date') . '/' . $sqlResult['Year'];
} }
$results->push(new ArrayData(array( $results->push(new ArrayData(array(
'Date' => $date, 'Date' => $date,
'Link' => $link 'Link' => $link
))); )));
} }
return $results; return $results;
} }
} }
} }

View File

@ -1,14 +1,14 @@
<?php <?php
if(class_exists('Widget')) { if(class_exists('Widget')) {
/** /**
* A list of tags associated with blog posts * A list of tags associated with blog posts
* *
* @package blog * @package blog
*/ */
class TagCloudWidget extends Widget { class TagCloudWidget extends Widget {
private static $db = array( private static $db = array(
"Title" => "Varchar", "Title" => "Varchar",
"Limit" => "Int", "Limit" => "Int",
@ -22,7 +22,7 @@ if(class_exists('Widget')) {
); );
private static $cmsTitle = "Tag Cloud"; private static $cmsTitle = "Tag Cloud";
private static $description = "Shows a tag cloud of tags on your blog."; private static $description = "Shows a tag cloud of tags on your blog.";
/** /**
@ -41,7 +41,7 @@ if(class_exists('Widget')) {
); );
public function getCMSFields() { public function getCMSFields() {
$this->beforeUpdateCMSFields(function($fields) { $this->beforeUpdateCMSFields(function($fields) {
$fields->merge( $fields->merge(
new FieldList( new FieldList(
@ -65,18 +65,18 @@ if(class_exists('Widget')) {
function Title() { function Title() {
return $this->Title ? $this->Title : _t('TagCloudWidget.DEFAULTTITLE', 'Tag Cloud'); return $this->Title ? $this->Title : _t('TagCloudWidget.DEFAULTTITLE', 'Tag Cloud');
} }
/** /**
* Current BlogTree used as the container for this tagcloud. * Current BlogTree used as the container for this tagcloud.
* Used by {@link TagCloudWidgetTest} for testing * Used by {@link TagCloudWidgetTest} for testing
* *
* @var BlogTree * @var BlogTree
*/ */
public static $container = null; public static $container = null;
/** /**
* Return all sorted tags in the system * Return all sorted tags in the system
* *
* @return ArrayList * @return ArrayList
*/ */
function getTagsCollection() { function getTagsCollection() {
@ -114,7 +114,7 @@ if(class_exists('Widget')) {
return $b - $a; return $b - $a;
}); });
} }
// Apply limiting // Apply limiting
if($this->Limit > 0) $tagCounts = array_slice($tagCounts, 0, $this->Limit, true); if($this->Limit > 0) $tagCounts = array_slice($tagCounts, 0, $this->Limit, true);
@ -125,13 +125,13 @@ if(class_exists('Widget')) {
// If there are more frequencies than buckets, divide frequencies into buckets // If there are more frequencies than buckets, divide frequencies into buckets
if ($numsizes > $buckets) $numsizes = $buckets; if ($numsizes > $buckets) $numsizes = $buckets;
// Adjust offset to use central buckets (if using a subset of available buckets) // Adjust offset to use central buckets (if using a subset of available buckets)
$offset = round(($buckets - $numsizes)/2); $offset = round(($buckets - $numsizes)/2);
$output = new ArrayList(); $output = new ArrayList();
foreach($tagCounts as $tag => $count) { foreach($tagCounts as $tag => $count) {
// Find position of $count in the selected range, adjusted for bucket range used // Find position of $count in the selected range, adjusted for bucket range used
if($maxCount == $minCount) { if($maxCount == $minCount) {
$popularity = $offset; $popularity = $offset;

View File

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