Commit b254897f authored by Robbie Averill's avatar Robbie Averill

API Remove carousel, deprecate BasePage methods for default theme. Carousel...

API Remove carousel, deprecate BasePage methods for default theme. Carousel has moved to agency-extensions.
parent a70d1833
<?php
class CarouselItem extends DataObject {
private static $db = array(
'Title' => 'Varchar(255)',
'Caption' => 'Text',
'Archived' => 'Boolean',
'SortOrder' => 'Int'
);
private static $has_one = array(
'Parent' => 'HomePage',
'Image' => 'Image',
'Link' => 'SiteTree'
);
private static $summary_fields = array(
'ImageThumb' => 'Image',
'Title' => 'Title',
'Caption' => 'Text',
'Link.Title' => 'Link',
'ArchivedReadable' => 'Current Status'
);
private static $searchable_fields = array(
'Title',
'Caption'
);
public function getCMSFields() {
$fields = new FieldList(
// Set title
TextField::create('Title', 'Title', null, 255),
// Caption
TextareaField::create('Caption', 'Caption'),
// Image
UploadField::create('Image', 'Image')
->setAllowedFileCategories('image'),
// Linked page id
TreeDropdownField::create('LinkID', _t('CwpCarousel.LinkField', 'Link'), 'SiteTree'),
// Can archive option
CompositeField::create(
LabelField::create(
"LabelArchive",
_t('CwpCarousel.ArchivedField',"Archive this carousel item?")
)->addExtraClass("left"),
CheckboxField::create('Archived', '')
)->addExtraClass("field special")
);
$this->extend('updateCMSFields', $fields);
return $fields;
}
public function canCreate($member = null) {
return $this->Parent()->canCreate($member);
}
public function canEdit($member = null) {
return $this->Parent()->canEdit($member);
}
public function canDelete($member = null) {
return $this->Parent()->canDelete($member);
}
public function canView($member = null) {
return $this->Parent()->canView($member);
}
public function ImageThumb(){
return $this->Image()->SetWidth(50);
}
public function ArchivedReadable(){
if($this->Archived == 1) return _t('GridField.Archived', 'Archived');
return _t('GridField.Live', 'Live');
}
}
......@@ -33,16 +33,11 @@ class BaseHomePage extends Page {
);
private static $has_many = array(
'CarouselItems' => 'CarouselItem',
'Quicklinks' => 'Quicklink.Parent'
);
public $pageIcon = 'images/icons/sitetree_images/home.png';
public function CarouselItems() {
return $this->getComponents('CarouselItems')->sort('SortOrder');
}
public function Quicklinks() {
return $this->getComponents('Quicklinks')->sort('SortOrder');
}
......@@ -52,34 +47,14 @@ class BaseHomePage extends Page {
// Main Content tab
$fields->addFieldToTab(
'Root.Main',
'Root.Main',
TreeDropdownField::create(
'LearnMorePageID',
_t('BaseHomePage.LearnMoreLink','Page to link the "Learn More" button to:'),
'LearnMorePageID',
_t('BaseHomePage.LearnMoreLink','Page to link the "Learn More" button to:'),
'SiteTree'
),
),
'Metadata'
);
// Carousel tab
$gridField = GridField::create(
'CarouselItems',
'Carousel',
$this->CarouselItems(),
GridFieldConfig_RelationEditor::create()
);
$gridConfig = $gridField->getConfig();
$gridConfig->getComponentByType('GridFieldAddNewButton')->setButtonName(
_t('BaseHomePage.AddNewButton','Add new')
);
$gridConfig->removeComponentsByType('GridFieldAddExistingAutocompleter');
$gridConfig->removeComponentsByType('GridFieldDeleteAction');
$gridConfig->addComponent(new GridFieldDeleteAction());
$gridConfig->addComponent(new GridFieldSortableRows('SortOrder'));
$gridConfig->removeComponentsByType('GridFieldSortableHeader');
$gridField->setModelClass('CarouselItem');
$fields->addFieldToTab('Root.Carousel', $gridField);
$gridField = GridField::create(
'Quicklinks',
......@@ -102,7 +77,7 @@ class BaseHomePage extends Page {
$fields->removeByName('Import');
$fields->addFieldToTab(
'Root.Features',
'Root.Features',
ToggleCompositeField::create('FeatureOne', _t('SiteTree.FeatureOne', 'Feature One'),
array(
TextField::create('FeatureOneTitle', _t('BaseHomePage.Title','Title')),
......@@ -133,12 +108,12 @@ class BaseHomePage extends Page {
array(
TextField::create('FeatureTwoTitle', _t('BaseHomePage.Title','Title')),
$dropdownField = DropdownField::create(
'FeatureTwoCategory',
'FeatureTwoCategory',
_t('BaseHomePage.FeatureCategoryDropdown','Category icon'),
singleton('BaseHomePage')->dbObject('FeatureTwoCategory')->enumValues()
),
HTMLEditorField::create(
'FeatureTwoContent',
'FeatureTwoContent',
_t('BaseHomePage.FeatureContentFieldLabel','Content')
),
TextField::create(
......@@ -157,10 +132,6 @@ class BaseHomePage extends Page {
return $fields;
}
public function getVisibleCarouselItems() {
return $this->CarouselItems()->filter('Archived', false);
}
}
class BaseHomePage_Controller extends Page_Controller {
......
......@@ -13,7 +13,7 @@ class BasePage extends SiteTree {
private static $hide_ancestor = 'BasePage';
private static $pdf_export = false;
/*
*Domain to generate PDF's from, DOES not include protocol
*i.e. google.com not http://google.com
......@@ -267,7 +267,7 @@ class BasePage_Controller extends ContentController {
public static $results_per_page = 10;
public static $search_index_class = 'SolrSearchIndex';
/**
* If spelling suggestions for searches are given, enable
* suggested searches to be followed immediately
......@@ -366,7 +366,7 @@ class BasePage_Controller extends ContentController {
// make sure the work directory exists
if(!file_exists(dirname($pdfFile))) Filesystem::makeFolder(dirname($pdfFile));
//decide the domain to use in generation
$pdf_base_url = $this->getPDFBaseURL();
......@@ -454,7 +454,7 @@ class BasePage_Controller extends ContentController {
$suggestions = isset($data['suggestions'])
? $data['suggestions']
: $this->config()->search_follow_suggestions;
// Perform search
$searchIndex = singleton(self::$search_index_class);
$results = CwpSearchEngine::create()
......@@ -476,15 +476,15 @@ class BasePage_Controller extends ContentController {
if($results) {
$response = $response->customise($results);
}
// Render
$templates = $this->getResultsTemplate($request);
return $response->renderWith($templates);
}
/**
* Select the template to render search results with
*
*
* @param SS_HTTPRequest $request
* @return array
*/
......@@ -502,63 +502,25 @@ class BasePage_Controller extends ContentController {
/**
* Provide scripts as needed by the *default* theme.
* Override this function if you are using a custom theme based on the *default*.
*
* @deprecated 1.6..2.0 Use "starter" theme instead
*/
protected function getBaseScripts() {
$themeDir = SSViewer::get_theme_folder();
return array(
THIRDPARTY_DIR .'/jquery/jquery.js',
THIRDPARTY_DIR .'/jquery-ui/jquery-ui.js',
"$themeDir/js/lib/modernizr.js",
"$themeDir/js/bootstrap-transition.2.3.1.js",
'themes/module_bootstrap/js/bootstrap-collapse.js',
"$themeDir/js/bootstrap-carousel.2.3.1.js",
"$themeDir/js/general.js",
"$themeDir/js/express.js",
);
public function getBaseScripts() {
$scripts = array();
$this->extend('updateBaseScripts', $scripts);
return $scripts;
}
/**
* Provide stylesheets, as needed by the *default* theme assumed by this recipe.
* Override this function if you are using a custom theme based on the *default*.
*
* @deprecated 1.6..2.0 Use "starter" theme instead
*/
protected function getBaseStyles() {
$themeDir = SSViewer::get_theme_folder();
return array(
'all' => array(
"$themeDir/css/layout.css",
"$themeDir/css/typography.css"
),
'screen' => array(
"$themeDir/css/responsive.css"
),
'print' => array(
"$themeDir/css/print.css"
)
);
}
public function init() {
parent::init();
// Ensure we only include styles when theme is enabled (except when running certain tests)
$theme = Config::inst()->get('SSViewer', 'theme');
if($theme) {
// Include base scripts that are needed on all pages
Requirements::combine_files('scripts.js', $this->getBaseScripts());
// Include base styles that are needed on all pages
$styles = $this->getBaseStyles();
// Combine by media type.
Requirements::combine_files('styles.css', $styles['all']);
Requirements::combine_files('screen.css', $styles['screen'], 'screen');
Requirements::combine_files('print.css', $styles['print'], 'print');
// Extra folder to keep the relative paths consistent when combining.
Requirements::set_combined_files_folder(ASSETS_DIR . '/_combinedfiles/cwp-' . $theme);
}
public function getBaseStyles() {
$styles = array();
$this->extend('updateBaseStyles', $styles);
return $styles;
}
/**
......
......@@ -141,12 +141,9 @@ container that can contain 12 columns. Elements define the number of columns the
`/themes/default/templates/Layout/Page.ss` and see how the sidenav and content sit beside each other.
The basic page layout uses a `.span3` on the left for the navigation and a `.span9` for the main content area. There is
a slightly more complex layout in the homepage - the hero unit/carousel is built with a `.span4`/`.span8` and the
a slightly more complex layout in the homepage - the
quicklinks/features/news snippets have a `.span3`/`.span4`/`.span5` structure.
The carousel on the homepage is built with the
[Bootstrap carousel](http://getbootstrap.com/2.3.2/javascript.html#carousel).
The sitemap uses the [Bootstrap collapse](http://getbootstrap.com/2.3.2/javascript.html#collapse) module.
## SCSS/SASS
......
......@@ -26,16 +26,9 @@ en:
Term: Term
Terms: Terms
TermsDescription: 'Click to search for additional terms'
CarouselItem:
PLURALNAME: 'Carousel Items'
SINGULARNAME: 'Carousel Item'
CustomSiteConfig:
LogosIconsTab: Logos/Icons
SocialMediaTab: 'Social Media'
CwpCarousel:
ArchivedField: 'Archive this carousel item?'
LinkField: Link
NoteField: 'Note: You will need to create the carousel item before you can add an image'
CwpConfig:
AddThisField: 'AddThis Profile ID'
AddThisFieldDesc: 'Profile ID to be used all across the site (in the format <strong>ra-XXXXXXXXXXXXXXXX</strong>)'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment