Fixed compatibility issues for SilverStripe 3.0

This commit is contained in:
Ed 2012-03-24 16:33:36 -03:00
parent b91fdd0443
commit a9c0b3dd76
10 changed files with 37 additions and 37 deletions

View File

@ -61,22 +61,22 @@ class BlogEntry extends Page {
SiteTree::enableCMSFieldsExtensions();
if(!self::$allow_wysiwyg_editing) {
$fields->removeFieldFromTab("Root.Content.Main","Content");
$fields->addFieldToTab("Root.Content.Main", new TextareaField("Content", _t("BlogEntry.CN", "Content"), 20));
$fields->removeFieldFromTab("Root.Main","Content");
$fields->addFieldToTab("Root.Main", new TextareaField("Content", _t("BlogEntry.CN", "Content"), 20));
}
$fields->addFieldToTab("Root.Content.Main", $dateField = new DatetimeField("Date", _t("BlogEntry.DT", "Date")),"Content");
$fields->addFieldToTab("Root.Main", $dateField = new DatetimeField("Date", _t("BlogEntry.DT", "Date")),"Content");
$dateField->getDateField()->setConfig('showcalendar', true);
$dateField->getTimeField()->setConfig('showdropdown', true);
$fields->addFieldToTab("Root.Content.Main", new TextField("Author", _t("BlogEntry.AU", "Author"), $firstName),"Content");
$fields->addFieldToTab("Root.Main", new TextField("Author", _t("BlogEntry.AU", "Author"), $firstName),"Content");
if(!self::$allow_wysiwyg_editing) {
$fields->addFieldToTab("Root.Content.Main", new LiteralField("BBCodeHelper", "<div id='BBCode' class='field'>" .
$fields->addFieldToTab("Root.Main", new LiteralField("BBCodeHelper", "<div id='BBCode' class='field'>" .
"<a id=\"BBCodeHint\" target='new'>" . _t("BlogEntry.BBH", "BBCode help") . "</a>" .
"<div id='BBTagsHolder' style='display:none;'>".$codeparser->useable_tagsHTML()."</div></div>"));
}
$fields->addFieldToTab("Root.Content.Main", new TextField("Tags", _t("BlogEntry.TS", "Tags (comma sep.)")),"Content");
$fields->addFieldToTab("Root.Main", new TextField("Tags", _t("BlogEntry.TS", "Tags (comma sep.)")),"Content");
$this->extend('updateCMSFields', $fields);
@ -88,7 +88,7 @@ class BlogEntry extends Page {
*/
function TagsCollection() {
$tags = split(" *, *", trim($this->Tags));
$output = new DataObjectSet();
$output = new ArrayList();
$link = $this->getParent() ? $this->getParent()->Link('tag') : '';

View File

@ -34,9 +34,9 @@ class BlogHolder extends BlogTree implements PermissionProvider {
$fields = parent::getCMSFields();
SiteTree::enableCMSFieldsExtensions();
$fields->addFieldToTab('Root.Content.Main', new CheckboxField('TrackBacksEnabled', 'Enable TrackBacks'));
$fields->addFieldToTab('Root.Content.Main', new DropdownField('OwnerID', 'Blog owner', $blogOwners->toDropDownMap('ID', 'Name', 'None')));
$fields->addFieldToTab('Root.Content.Main', new CheckboxField('AllowCustomAuthors', 'Allow non-admins to have a custom author field'));
$fields->addFieldToTab('Root.Main', new CheckboxField('TrackBacksEnabled', 'Enable TrackBacks'));
$fields->addFieldToTab('Root.Main', new DropdownField('OwnerID', 'Blog owner', $blogOwners->map('ID', 'Name')));
$fields->addFieldToTab('Root.Main', new CheckboxField('AllowCustomAuthors', 'Allow non-admins to have a custom author field'));
$this->extend('updateCMSFields', $fields);
@ -50,8 +50,8 @@ class BlogHolder extends BlogTree implements PermissionProvider {
$adminMembers = Permission::get_members_by_permission('ADMIN');
$blogOwners = Permission::get_members_by_permission('BLOGMANAGEMENT');
if(!$adminMembers) $adminMembers = new DataObjectSet();
if(!$blogOwners) $blogOwners = new DataObjectSet();
if(!$adminMembers) $adminMembers = new ArrayList();
if(!$blogOwners) $blogOwners = new ArrayList();
$blogOwners->merge($adminMembers);
$blogOwners->sort($sort, $direction);

View File

@ -95,8 +95,8 @@ class BlogTree extends Page {
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.Content.Main", new TextField("Name", "Name of blog"));
$fields->addFieldToTab('Root.Content.Main', new DropdownField('LandingPageFreshness', 'When you first open the blog, how many entries should I show', array(
$fields->addFieldToTab("Root.Main", new TextField("Name", "Name of blog"));
$fields->addFieldToTab('Root.Main', new DropdownField('LandingPageFreshness', 'When you first open the blog, how many entries should I show', array(
"" => "All entries",
"1 MONTH" => "Last month's entries",
"2 MONTH" => "Last 2 months' entries",
@ -113,8 +113,8 @@ class BlogTree extends Page {
"INHERIT" => "Take value from parent Blog Tree"
)));
$fields->addFieldToTab("Root.Content.Widgets", new CheckboxField("InheritSideBar", 'Inherit Sidebar From Parent'));
$fields->addFieldToTab("Root.Content.Widgets", new WidgetAreaEditor("SideBar"));
$fields->addFieldToTab("Root.Widgets", new CheckboxField("InheritSideBar", 'Inherit Sidebar From Parent'));
$fields->addFieldToTab("Root.Widgets", new WidgetAreaEditor("SideBar"));
return $fields;
}
@ -149,7 +149,7 @@ class BlogTree extends Page {
* @param string date Only get blog entries on this date - either a year, or a year-month eg '2008' or '2008-02'
* @param callback retrieveCallback A function to call with pagetype, filter and limit for custom blog sorting or filtering
* @param string $where
* @return DataObjectSet
* @return DataList
*/
public function Entries($limit = '', $tag = '', $date = '', $retrieveCallback = null, $filter = '') {

View File

@ -30,10 +30,10 @@ class TrackBackDecorator extends DataObjectDecorator {
'',
'ID'
);
$fields->addFieldToTab("Root.Content.Main", $trackbackURLTable);
$fields->addFieldToTab("Root.Main", $trackbackURLTable);
}
else {
$fields->addFieldToTab("Root.Content.Main", new ReadonlyField("TrackBackURLsReadOnly", _t("BlogEntry.TrackbackURLs", "Trackback URLs"), _t("BlogEntry.TrackbackURLs_DISABLED", "To use this feature, please check 'Enable TrackBacks' check box on the blog holder.")));
$fields->addFieldToTab("Root.Main", new ReadonlyField("TrackBackURLsReadOnly", _t("BlogEntry.TrackbackURLs", "Trackback URLs"), _t("BlogEntry.TrackbackURLs_DISABLED", "To use this feature, please check 'Enable TrackBacks' check box on the blog holder.")));
}
}

View File

@ -99,7 +99,7 @@ class TypoImport extends Controller {
$Ccreated_at = $row2[8];
// put the typo blog comment in the SS database
$newCEntry = new PageComment();
$newCEntry = new Comment();
$newCEntry->Name = $Cauthor;
$newCEntry->Comment = $comment;
$newCEntry->Created = $created_at;
@ -129,17 +129,17 @@ class TypoImport extends Controller {
pg_query($dbconn, "UPDATE SiteTree SET Content = REPLACE(Content, \"&#8482;\", \"&trade;\")");
pg_query($dbconn, "UPDATE SiteTree SET Content = REPLACE(Content, \"&#38;\", \"&amp;\")");
pg_query($dbconn, "UPDATE PageComment SET Comment = REPLACE(Comment, \"&#215;\", \"x\")");
pg_query($dbconn, "UPDATE PageComment SET Comment = REPLACE(Comment, \"&#8217;\", \"&rsquo;\")");
pg_query($dbconn, "UPDATE PageComment SET Comment = REPLACE(Comment, \"&#8216;\", \"&lsquo;\")");
pg_query($dbconn, "UPDATE PageComment SET Comment = REPLACE(Comment, \"&#151;\", \"&mdash;\")");
pg_query($dbconn, "UPDATE PageComment SET Comment = REPLACE(Comment, \"&#8220;\", \"&ldquo;\")");
pg_query($dbconn, "UPDATE PageComment SET Comment = REPLACE(Comment, \"&#8221;\", \"&rdquo;\")");
pg_query($dbconn, "UPDATE PageComment SET Comment = REPLACE(Comment, \"&#8211;\", \"&ndash;\")");
pg_query($dbconn, "UPDATE PageComment SET Comment = REPLACE(Comment, \"&#8212;\", \"&mdash;\")");
pg_query($dbconn, "UPDATE PageComment SET Comment = REPLACE(Comment, \"&#8230;\", \"&hellip;\")");
pg_query($dbconn, "UPDATE PageComment SET Comment = REPLACE(Comment, \"&#8482;\", \"&trade;\")");
pg_query($dbconn, "UPDATE PageComment SET Comment = REPLACE(Comment, \"&#38;\", \"&amp;\")");
pg_query($dbconn, "UPDATE Comment SET Comment = REPLACE(Comment, \"&#215;\", \"x\")");
pg_query($dbconn, "UPDATE Comment SET Comment = REPLACE(Comment, \"&#8217;\", \"&rsquo;\")");
pg_query($dbconn, "UPDATE Comment SET Comment = REPLACE(Comment, \"&#8216;\", \"&lsquo;\")");
pg_query($dbconn, "UPDATE Comment SET Comment = REPLACE(Comment, \"&#151;\", \"&mdash;\")");
pg_query($dbconn, "UPDATE Comment SET Comment = REPLACE(Comment, \"&#8220;\", \"&ldquo;\")");
pg_query($dbconn, "UPDATE Comment SET Comment = REPLACE(Comment, \"&#8221;\", \"&rdquo;\")");
pg_query($dbconn, "UPDATE Comment SET Comment = REPLACE(Comment, \"&#8211;\", \"&ndash;\")");
pg_query($dbconn, "UPDATE Comment SET Comment = REPLACE(Comment, \"&#8212;\", \"&mdash;\")");
pg_query($dbconn, "UPDATE Comment SET Comment = REPLACE(Comment, \"&#8230;\", \"&hellip;\")");
pg_query($dbconn, "UPDATE Comment SET Comment = REPLACE(Comment, \"&#8482;\", \"&trade;\")");
pg_query($dbconn, "UPDATE Comment SET Comment = REPLACE(Comment, \"&#38;\", \"&amp;\")");
}

View File

@ -52,7 +52,7 @@ class ArchiveWidget extends Widget {
function Dates() {
Requirements::themedCSS('archivewidget');
$results = new DataObjectSet();
$results = new ArrayList();
$container = BlogTree::current();
$ids = $container->BlogHolderIDs();

View File

@ -21,7 +21,7 @@ class BlogManagementWidget extends Widget implements PermissionProvider {
static $description = "Provide a number of links useful for administering a blog. Only shown if the user is an admin.";
function CommentText() {
$unmoderatedcount = DB::query("SELECT COUNT(*) FROM \"PageComment\" WHERE \"NeedsModeration\"=1")->value();
$unmoderatedcount = DB::query("SELECT COUNT(*) FROM \"Comment\" WHERE \"NeedsModeration\"=1")->value();
if($unmoderatedcount == 1) {
return _t("BlogManagementWidget.UNM1", "You have 1 unmoderated comment");
} else if($unmoderatedcount > 1) {
@ -35,7 +35,7 @@ class BlogManagementWidget extends Widget implements PermissionProvider {
if(!Permission::check('BLOGMANAGEMENT')) {
return false;
}
$unmoderatedcount = DB::query("SELECT COUNT(*) FROM \"PageComment\" WHERE \"NeedsModeration\"=1")->value();
$unmoderatedcount = DB::query("SELECT COUNT(*) FROM \"Comment\" WHERE \"NeedsModeration\"=1")->value();
if($unmoderatedcount > 0) {
return "admin/comments/unmoderated";

View File

@ -59,7 +59,7 @@ class RSSWidget extends Widget {
}
function FeedItems() {
$output = new DataObjectSet();
$output = new ArrayList();
// Protection against infinite loops when an RSS widget pointing to this page is added to this page
if(stristr($_SERVER['HTTP_USER_AGENT'], 'SimplePie')) {

View File

@ -105,7 +105,7 @@ class TagCloudWidget extends Widget {
}
}
$output = new DataObjectSet();
$output = new ArrayList();
foreach($allTags as $tag => $fields) {
$output->push(new ArrayData($fields));
}

View File

@ -56,7 +56,7 @@ class BlogHolderTest extends SapphireTest {
function testBlogOwners() {
$mainblog = $this->objFromFixture('BlogHolder', 'mainblog');
$actualMembers = array_values($mainblog->blogOwners()->toDropDownMap('ID', 'Name'));
$actualMembers = array_values($mainblog->blogOwners()->map('ID', 'Name'));
$expectedMembers = array(
'ADMIN User', // test default admin
'Admin One',