Permalink
Browse files

Added standard module layout info

  • Loading branch information...
0 parents commit 958f8531718c29f79de1cee8ad409b8e7f3d5318 @nyeholt committed Feb 24, 2010
@@ -0,0 +1,3 @@
+Version 0.1.0 RC1
+2009-11-16
+
17 LICENSE
@@ -0,0 +1,17 @@
+Copyright (c) 2009, SilverStripe Australia PTY LTD - www.silverstripe.com.au
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of SilverStripe nor the names of its contributors may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+OF SUCH DAMAGE.
26 README
@@ -0,0 +1,26 @@
+###############################################
+Module
+###############################################
+
+Maintainer Contact
+-----------------------------------------------
+Marcus Nyeholt
+
+<marcus (at) silverstripe (dot) com (dot) au>
+
+Requirements
+-----------------------------------------------
+SilverStripe 2.4.x
+
+Documentation
+-----------------------------------------------
+
+Quick Usage Overview
+-----------------------------------------------
+
+API
+-----------------------------------------------
+
+Troubleshooting
+-----------------------------------------------
+
@@ -0,0 +1 @@
+2.4.0
0 TODO
No changes.
@@ -0,0 +1 @@
+0.1.0-rc1
@@ -0,0 +1,23 @@
+<?php
+/*
+ *
+Copyright (c) 2009, SilverStripe Australia PTY LTD - www.silverstripe.com.au
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of SilverStripe nor the names of its contributors may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+OF SUCH DAMAGE.
+ */
+
+?>
@@ -0,0 +1,108 @@
+<?php
+/*
+
+Copyright (c) 2009, SilverStripe Australia PTY LTD - www.silverstripe.com.au
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of SilverStripe nor the names of its contributors may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+OF SUCH DAMAGE.
+*/
+
+/**
+ *
+ *
+ * @author Marcus Nyeholt <marcus@silverstripe.com.au>
+ */
+class NewsArticle extends Page
+{
+ public static $icon = 'news/images/newspaper';
+
+ public static $db = array(
+ 'Summary' => 'HTMLText',
+ 'Author' => 'Varchar(128)',
+ 'PublishedDate' => 'Date',
+ 'ExternalURL' => 'Varchar(255)',
+ 'Source' => 'Varchar(128)',
+ );
+
+ /**
+ * The InternalFile is used when the news article is mostly contained in another item -
+ * if this is set, then the URL to the item is returned in the call to "Link" for this asset.
+ *
+ * @var array
+ */
+ public static $has_one = array(
+ 'InternalFile' => 'File',
+ );
+
+ public function getCMSFields()
+ {
+ $fields = parent::getCMSFields();
+
+ $fields->addFieldToTab('Root.Content.Main', new TextField('Author', _t('NewsArticle.AUTHOR', 'Author')), 'Content');
+ $fields->addFieldToTab('Root.Content.Main', new CalendarDateField('PublishedDate', _t('NewsArticle.PUBLISHED_DATE', 'When was this article first published?')), 'Content');
+
+ $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');
+ if (!$this->PublishedDate) {
+ // @TODO Fix this to be correctly localized!!
+ $this->PublishedDate = 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');
+
+ return $fields;
+ }
+
+ public function onBeforeWrite()
+ {
+ parent::onBeforeWrite();
+
+ if (!$this->PublishedDate) {
+ // @TODO Fix this to be correctly localized!!
+ $this->PublishedDate = date('Y-m-d 12:00:00');
+ }
+ }
+
+ /**
+ * Link to the news article. If it has an external URL set, or a file, link to that instead.
+ *
+ * @param String $action
+ * @return String
+ */
+ public function Link($action='')
+ {
+ if (strlen($this->ExternalURL) && !strlen($this->Content)) {
+ // redirect away
+ return $this->ExternalURL;
+ }
+
+ if ($this->InternalFile()->ID) {
+ $file = $this->InternalFile();
+ return $file->Link($action);
+ }
+
+ return parent::Link($action);
+ }
+}
+
+class NewsArticle_Controller extends Page_Controller
+{
+
+}
+?>
@@ -0,0 +1,97 @@
+<?php
+/*
+
+Copyright (c) 2009, SilverStripe Australia PTY LTD - www.silverstripe.com.au
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of SilverStripe nor the names of its contributors may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+OF SUCH DAMAGE.
+*/
+
+/**
+ *
+ *
+ * @author Marcus Nyeholt <marcus@silverstripe.com.au>
+ */
+class NewsHolder extends Page
+{
+ public static $icon = 'news/images/newsholder';
+
+ /**
+ * A bit of a cheat way of letting the template determine how many articles to display.
+ *
+ * We need to do this because using something like <% if Articles(2).HasMore %> doesn't work, as
+ * the .HasMore isn't parsed correctly...
+ *
+ * @var int
+ */
+ protected $numberToDisplay = 10;
+
+
+ /**
+ * Returns a list of articles within this news holder.
+ *
+ * If there are sub-newsholders, it will return all the articles from there also
+ *
+ * @return DataObjectSet
+ */
+ public function Articles($number=null)
+ {
+ if (!$number) {
+ $number = $this->numberToDisplay;
+ }
+
+ $start = isset($_REQUEST['start']) ? (int) $_REQUEST['start'] : 0;
+
+ $subholders = DataObject::get('NewsHolder', db_quote(array('ParentID =' => $this->ID)));
+ $articles = null;
+ if ($subholders && $subholders->Count()) {
+ $ids = $subholders->column('ID');
+ $articles = DataObject::get('NewsArticle', db_quote(array('ParentID IN' => $ids)), 'PublishedDate DESC', '', $start.','.$number);
+ } else {
+ $articles = DataObject::get('NewsArticle', db_quote(array('ParentID = ' => $this->ID)), 'PublishedDate DESC', '', $start.','.$number);
+ }
+
+ return $articles;
+ }
+
+ /**
+ *
+ * Set the number of articles to be displayed in a listing
+ *
+ * @param int $num
+ */
+ public function SetArticleNumber($num)
+ {
+ $this->numberToDisplay = $num;
+ }
+
+ /**
+ * Returns a list of sub news sections, if available
+ *
+ * @return DataObjectSet
+ */
+ public function SubSections()
+ {
+ $subholders = DataObject::get('NewsHolder', db_quote(array('ParentID =' => $this->ID)));
+ return $subholders;
+ }
+}
+
+class NewsHolder_Controller extends Page_Controller
+{
+
+}
+?>
@@ -0,0 +1,74 @@
+<?php
+/**
+
+Copyright (c) 2009, SilverStripe Australia PTY LTD - www.silverstripe.com.au
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of SilverStripe nor the names of its contributors may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+OF SUCH DAMAGE.
+
+*/
+
+/**
+ * A simple helper function to deal with DB quoting.
+ */
+if (!defined('SSAU_QUOTE_CHAR')) {
+
+ define('SSAU_QUOTE_CHAR', defined('DB::USE_ANSI_SQL') ? '"' : '');
+
+ /**
+ * Quote up a filter of the form
+ *
+ * array ("ParentID =" => 1)
+ *
+ *
+ *
+ * @param unknown_type $filter
+ * @return unknown_type
+ */
+ function db_quote($filter = array(), $join = " AND ")
+ {
+ $string = '';
+ $sep = '';
+
+ foreach ($filter as $field => $value) {
+ // first break the field up into its two components
+ list($field, $operator) = explode(' ', trim($field));
+ if (is_array($value)) {
+ // quote each individual one into a string
+ $ins = '';
+ $insep = '';
+ foreach ($value as $v) {
+ $ins .= $insep . Convert::raw2sql($v);
+ $insep = ',';
+ }
+ $value = '('.$ins.')';
+ } else {
+ $value = "'" . Convert::raw2sql($value) . "'";
+ }
+
+ if (strpos($field, '.')) {
+ list($tb, $fl) = explode('.', $field);
+ $string .= $sep . SSAU_QUOTE_CHAR . $tb . SSAU_QUOTE_CHAR . '.' . SSAU_QUOTE_CHAR . $fl . SSAU_QUOTE_CHAR . " $operator " . $value;
+ } else {
+ $string .= $sep . SSAU_QUOTE_CHAR . $field . SSAU_QUOTE_CHAR . " $operator " . $value;
+ }
+ $sep = $join;
+ }
+
+ return $string;
+ }
+}
+?>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,12 @@
+<ul class="newsArticles">
+ <% if Articles %><% control Articles %>
+ <li>
+ <a href="$Link"><h3>$Title</h3></a>
+ <% if Thumbnail %>
+ $Thumbnail.SetRatioSize(50,50)
+ <% end_if %>
+ <p>$Content.Summary(50)</p>
+ <p><a href="$Link">Read the full article... </a></p>
+ </li>
+ <% end_control %><% end_if %>
+</ul>
@@ -0,0 +1,16 @@
+<div class="typography">
+ <% if Level(2) %>
+ <% include BreadCrumbs %>
+ <% end_if %>
+ <h2>$Title</h2>
+ <div class="newsArticlePublishedDate">$PublishedDate.Nice</div>
+ <div class="newsArticleSummary">
+ $Summary
+ </div>
+ <div class="newsArticleContent">
+ $Content
+ </div>
+
+ $Form
+ $PageComments
+</div>
Oops, something went wrong.

0 comments on commit 958f853

Please sign in to comment.