Permalink
Browse files

updated for ss3

  • Loading branch information...
1 parent 7606f48 commit b06f8081fab385fd33fba5ef0cbaba2b19c98c7c Shea committed Jul 16, 2012
Showing with 77 additions and 70 deletions.
  1. +1 −1 README.md
  2. +1 −1 SILVERSTRIPE_VERSION
  3. +10 −8 code/pages/NewsArticle.php
  4. +11 −7 code/pages/NewsHolder.php
  5. +10 −15 templates/Layout/NewsArticle.ss
  6. +44 −38 templates/Layout/NewsHolder.ss
View
@@ -8,7 +8,7 @@ Marcus Nyeholt
## Requirements
-SilverStripe 2.4.x
+SilverStripe 3.0.x
## Overview
View
@@ -1 +1 @@
-2.4.x
+3.0.x
View
@@ -31,25 +31,27 @@ class NewsArticle extends Page {
public function getCMSFields() {
$fields = parent::getCMSFields();
- $fields->addFieldToTab('Root.Content.Main', new TextField('Author', _t('NewsArticle.AUTHOR', 'Author')), 'Content');
- $fields->addFieldToTab('Root.Content.Main', $dp = new DateField('OriginalPublishedDate', _t('NewsArticle.PUBLISHED_DATE', 'When was this article first published?')), 'Content');
+ $fields->addFieldToTab('Root.Main', new TextField('Author', _t('NewsArticle.AUTHOR', 'Author')), 'Content');
+ $fields->addFieldToTab('Root.Main', $dp = new DateField('OriginalPublishedDate', _t('NewsArticle.PUBLISHED_DATE', 'When was this article first published?')), 'Content');
$dp->setConfig('showcalendar', true);
- $fields->addFieldToTab('Root.Content.Main', new TextField('ExternalURL', _t('NewsArticle.EXTERNAL_URL', 'External URL to article (will automatically redirect to this URL if no article content set)')), 'Content');
- $fields->addFieldToTab('Root.Content.Main', new TextField('Source', _t('NewsArticle.SOURCE', 'News Source')), 'Content');
+ $fields->addFieldToTab('Root.Main', new TextField('ExternalURL', _t('NewsArticle.EXTERNAL_URL', 'External URL to article (will automatically redirect to this URL if no article content set)')), 'Content');
+ $fields->addFieldToTab('Root.Main', new TextField('Source', _t('NewsArticle.SOURCE', 'News Source')), 'Content');
- $fields->addFieldToTab('Root.Content.Main', $if = new ImageField('Thumbnail', _t('NewsArticle.THUMB', 'Thumbnail')), 'Content');
- $if->setFolderName('news-articles/thumbnails');
+ $fields->addFieldToTab('Root.Main', $if = new UploadField('Thumbnail', _t('NewsArticle.THUMB', 'Thumbnail')), 'Content');
+ $if->setConfig('allowedMaxFileNumber', 1)->setFolderName('news-articles/thumbnails');
+ $if->getValidator()->setAllowedExtensions(array('jpg', 'jpeg', 'png', 'gif'));
if (!$this->OriginalPublishedDate) {
// @TODO Fix this to be correctly localized!!
$this->OriginalPublishedDate = date('Y-m-d');
}
// $fields->addFieldToTab('Root.Content.Main', new TreeDropdownField('InternalPageLinkID', _t('NewsArticle.INTERNAL_PAGE', 'A page on this site for the news')), 'Content');
- $fields->addFieldToTab('Root.Content.Main', new TreeDropdownField('InternalFileID', _t('NewsArticle.INTERNAL_FILE', 'Select a file containing this news article, if any'), 'File'), 'Content');
- $fields->addFieldToTab('Root.Content.Main', new HtmlEditorField('Summary', _t('NewsArticle.SUMMARY', 'Article Summary (displayed in listings)')), 'Content');
+ $fields->addFieldToTab('Root.Main', new TreeDropdownField('InternalFileID', _t('NewsArticle.INTERNAL_FILE', 'Select a file containing this news article, if any'), 'File'), 'Content');
+ $fields->addFieldToTab('Root.Main', $summary = new HtmlEditorField('Summary', _t('NewsArticle.SUMMARY', 'Article Summary (displayed in listings)')), 'Content');
+ $summary->addExtraClass('stacked');
return $fields;
}
View
@@ -25,7 +25,8 @@ class NewsHolder extends Page {
public static $icon = 'news/images/newsholder';
public static $allowed_children = array(
- 'NewsArticle'
+ 'NewsArticle',
+ 'NewsHolder'
);
/**
* Should this news article be automatically filed into a year/month/date
@@ -59,9 +60,9 @@ public function getCMSFields() {
'month' => '/Year/Month',
'year' => '/Year'
);
- $fields->addFieldToTab('Root.Content.Main', new DropdownField('FilingMode', _t('NewsHolder.FILING_MODE', 'File into'), $modes), 'Content');
- $fields->addFieldToTab('Root.Content.Main', new DropdownField('FileBy', _t('NewsHolder.FILE_BY', 'File by'), array('Published' => 'Published', 'Created' => 'Created')), 'Content');
- $fields->addFieldToTab('Root.Content.Main', new CheckboxField('PrimaryNewsSection', _t('NewsHolder.PRIMARY_SECTION', 'Is this a primary news section?'), true), 'Content');
+ $fields->addFieldToTab('Root.Main', new DropdownField('FilingMode', _t('NewsHolder.FILING_MODE', 'File into'), $modes), 'Content');
+ $fields->addFieldToTab('Root.Main', new DropdownField('FileBy', _t('NewsHolder.FILE_BY', 'File by'), array('Published' => 'Published', 'Created' => 'Created')), 'Content');
+ $fields->addFieldToTab('Root.Main', new CheckboxField('PrimaryNewsSection', _t('NewsHolder.PRIMARY_SECTION', 'Is this a primary news section?'), true), 'Content');
return $fields;
}
@@ -99,7 +100,7 @@ public function Articles($number=null) {
if ($subholders) {
$subholders->push($this);
} else {
- $subholders = new DataObjectSet(array($this));
+ $subholders = new DataList($this->class);
}
if ($subholders && $subholders->Count()) {
@@ -112,7 +113,10 @@ public function Articles($number=null) {
$articles = DataObject::get('NewsArticle', $filter, '"OriginalPublishedDate" DESC, "ID" DESC', '', $start . ',' . $number);
- return $articles;
+ $entries = PaginatedList::create($articles);
+ $entries->setPaginationFromQuery($articles->dataQuery()->query());
+
+ return $entries;
}
/**
@@ -125,7 +129,7 @@ public function SubSections($allChildren=true) {
$childHolders = DataObject::get('NewsHolder', singleton('NewsUtils')->dbQuote(array('ParentID =' => $this->ID)));
if ($childHolders && $childHolders->Count()) {
- $subs = new DataObjectSet();
+ $subs = new ArrayList();
foreach ($childHolders as $holder) {
$subs->push($holder);
if ($allChildren === true) {
@@ -1,16 +1,11 @@
-<div class="typography">
- <% if Level(2) %>
- <% include BreadCrumbs %>
- <% end_if %>
- <h2>$Title</h2>
- <div class="newsArticlePublishedDate">$OriginalPublishedDate.Nice</div>
- <div class="newsArticleSummary">
- $Summary
- </div>
- <div class="newsArticleContent">
- $Content
- </div>
-
- $Form
- $PageComments
+<div class="content-container typography">
+ <article>
+ <h1>$Title</h1>
+ <div class="newsArticlePublishedDate">$OriginalPublishedDate.Nice</div>
+ <div class="newsArticleSummary">$Summary</div>
+ <div class="newsArticleContent">$Content</div>
+ $Form
+ $PageComments
+ </article>
</div>
+<% include SideBar %>
@@ -1,38 +1,44 @@
-<div class="typography">
-
- <h2>$Title</h2>
- $Content
- <!-- if there's some subsections, lets use those and list their children -->
- <% if SubSections(false) %>
- <% control SubSections(false) %>
- <h2><a href="$Link">$Title.XML</a></h2>
- <% include NewsListItem %>
- <% end_control %>
- <% else %>
- <!-- otherwise, lets just use the children of the current news holder -->
- <% include NewsListItem %>
- <% if Articles.MoreThanOnePage %>
- <div id="NextPrevLinks">
- <% if Articles.NotLastPage %>
- <div id="NextLink">
- <a class="next" href="$Articles.NextLink" title="View the next page">See older articles</a>
- </div>
- <% end_if %>
- <% if Articles.NotFirstPage %>
- <div id="PrevLink">
- <a class="prev" href="$Articles.PrevLink" title="View the previous page">See newer articles</a>
- </div>
- <% end_if %>
- <span>
- <% if Articles.PaginationSummary %><% control Articles.PaginationSummary %>
- <% if CurrentBool %>
- $PageNum
- <% else %>
- <a href="$Link" title="View page number $PageNum">$PageNum</a>
- <% end_if %>
- <% end_control %><% end_if %>
- </span>
- </div>
- <% end_if %>
- <% end_if %>
-</div>
+<div class="content-container typography">
+ <article>
+ <h1>$Title</h1>
+ <div class="content">
+ $Content
+ <!-- if there's some subsections, lets use those and list their children -->
+ <% if SubSections(false) %>
+ <% control SubSections(false) %>
+ <h2><a href="$Link">$Title.XML</a></h2>
+ <% include NewsListItem %>
+ <% end_control %>
+ <% else %>
+ <!-- otherwise, lets just use the children of the current news holder -->
+ <% include NewsListItem %>
+ <% if Articles.MoreThanOnePage %>
+ <div id="NextPrevLinks">
+ <% if Articles.NotLastPage %>
+ <div id="NextLink">
+ <p><a class="next" href="$Articles.NextLink" title="View the next page">See older articles</a></p>
+ </div>
+ <% end_if %>
+ <% if Articles.NotFirstPage %>
+ <div id="PrevLink">
+ <p><a class="prev" href="$Articles.PrevLink" title="View the previous page">See newer articles</a></p>
+ </div>
+ <% end_if %>
+ <span>
+ <% if Articles.PaginationSummary %><% control Articles.PaginationSummary %>
+ <% if CurrentBool %>
+ $PageNum
+ <% else %>
+ <a href="$Link" title="View page number $PageNum">$PageNum</a>
+ <% end_if %>
+ <% end_control %><% end_if %>
+ </span>
+ </div>
+ <% end_if %>
+ <% end_if %>
+ </div>
+ </article>
+ $Form
+ $PageComments
+</div>
+<% include SideBar %>

0 comments on commit b06f808

Please sign in to comment.