-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 1b75122
Showing
15 changed files
with
519 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 Robert van Lienden | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Robert van Lienden - SilverStripe Addons | ||
This module adds several features to silverstripe. Suggested and fully compatible with `robertvanlienden/silverstripe-bulma-portfolio-theme`. | ||
|
||
But you can also use this module stand-alone! | ||
|
||
## Requirements | ||
- SilverStripe 4 | ||
|
||
## Installation | ||
`composer require robertvanlienden/silverstripe-addons` | ||
|
||
If you want some example how to implement features in your own template; View `robertvanlienden/silverstripe-bulma-portfolio-theme`. | ||
|
||
## All features | ||
* Upload logo for website header | ||
* Page header (you can disable this for the whole site in the Settings) | ||
* Footer text left/right | ||
* Portfolio overview and detail page | ||
* Slideshow images | ||
|
||
## License | ||
This theme is published under MIT License. | ||
|
||
If you use this theme commercial and make money with this theme, please be kind and do a donation with PayPal (see Donations below). | ||
|
||
## Issue/PR | ||
Feel free to make some issue/PR if you find issues/bugs/improvements. | ||
|
||
If you want to create some new feature or do big changes, please first provide an issue. | ||
T his to avoid that you put lots of work in some feature that will never gets merged. | ||
|
||
## Donations | ||
Do you want to thank me for making this SilverStripe module? | ||
|
||
Please donate to me with PayPal! You can donate on [https://paypal.me/robertvanlienden/](http://paypal.me/robertvanlienden). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
Name: silverstripeaddons | ||
--- | ||
Page: | ||
extensions: | ||
- RobertVanLienden\SilverStripeAddons\Extensions\PageExtension | ||
PageController: | ||
extensions: | ||
- RobertVanLienden\SilverStripeAddons\Extensions\PageControllerExtension | ||
Silverstripe\SiteConfig\SiteConfig: | ||
extensions: | ||
- RobertVanLienden\SilverStripeAddons\Extensions\SiteConfigExtension |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"name": "robertvanlienden/silverstripe-addons", | ||
"description": "A addon to add ", | ||
"type": "silverstripe-vendormodule", | ||
"keywords": [ | ||
"silverstripe", | ||
"addon" | ||
], | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Robert van Lienden", | ||
"email": "mail@robertvanlienden.nl" | ||
} | ||
], | ||
"minimum-stability": "dev", | ||
"prefer-stable": true, | ||
"require": { | ||
"php": ">=8.0", | ||
"silverstripe/admin": "^1.7@stable", | ||
"silverstripe/cms": "^4.8@stable", | ||
"silverstripe/vendor-plugin": "^1.0", | ||
"gorriecoe/silverstripe-linkfield": "^1.0", | ||
"silverstripe/lumberjack": "^2.2" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"RobertVanLienden\\SilverStripeAddons\\": "src/" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
namespace RobertVanLienden\SilverStripeAddons\Controllers; | ||
|
||
class PortfolioDetailPageController extends \PageController { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
namespace RobertVanLienden\SilverStripeAddons\Controllers; | ||
|
||
class PortfolioOverviewPageController extends \PageController { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
namespace RobertVanLienden\SilverStripeAddons\Extensions; | ||
|
||
use SilverStripe\ORM\DataExtension; | ||
|
||
class PageControllerExtension extends DataExtension { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
namespace RobertVanLienden\SilverStripeAddons\Extensions; | ||
|
||
use gorriecoe\Link\Models\Link; | ||
use gorriecoe\LinkField\LinkField; | ||
use SilverStripe\AssetAdmin\Forms\UploadField; | ||
use SilverStripe\Assets\Image; | ||
use SilverStripe\Forms\CheckboxField; | ||
use SilverStripe\Forms\FieldList; | ||
use SilverStripe\Forms\HTMLEditor\HTMLEditorField; | ||
use SilverStripe\Forms\TextField; | ||
use SilverStripe\ORM\DataExtension; | ||
use SilverStripe\SiteConfig\SiteConfig; | ||
|
||
class PageExtension extends DataExtension { | ||
|
||
private static array $db = [ | ||
'HeaderTitle' => 'Varchar(225)', | ||
'HeaderContent' => 'HTMLText', | ||
'HeaderDisabled' => 'Boolean', | ||
'DarkContent' => 'Boolean', | ||
]; | ||
|
||
private static array $has_one = [ | ||
'HeaderImage' => Image::class, | ||
'HeaderButtonLink' => Link::class, | ||
]; | ||
|
||
private static array $owns = [ | ||
'HeaderImage' | ||
]; | ||
|
||
|
||
public function updateCMSFields(FieldList $fields) | ||
{ | ||
parent::updateCMSFields($fields); | ||
|
||
$siteConfig = SiteConfig::current_site_config(); | ||
|
||
if($siteConfig->AddonsHeaderFeatureFlag) { | ||
$fields->addFieldsToTab('Root.Header', [ | ||
CheckboxField::create('HeaderDisabled', 'Disable the header on this page'), | ||
CheckboxField::create('DarkContent', 'Content in black'), | ||
UploadField::create('HeaderImage') | ||
->setFolderName('header-images'), | ||
TextField::create('HeaderTitle', 'Header title'), | ||
HTMLEditorField::create('HeaderContent', 'Header content'), | ||
LinkField::create('HeaderButtonLink', 'Header button link', $this->owner) | ||
->setDescription('The title will be used on the button as content'), | ||
]); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
namespace RobertVanLienden\SilverStripeAddons\Extensions; | ||
|
||
use SilverStripe\AssetAdmin\Forms\UploadField; | ||
use SilverStripe\Assets\Image; | ||
use SilverStripe\Forms\CheckboxField; | ||
use SilverStripe\Forms\CompositeField; | ||
use SilverStripe\Forms\FieldList; | ||
use SilverStripe\Forms\HTMLEditor\HTMLEditorField; | ||
use SilverStripe\Forms\LiteralField; | ||
use SilverStripe\ORM\DataExtension; | ||
|
||
class SiteConfigExtension extends DataExtension | ||
{ | ||
private static array $db = [ | ||
'AddonsHeaderFeatureFlag' => 'Boolean', | ||
'FooterLeft' => 'HTMLText', | ||
'FooterRight' => 'HTMLText', | ||
]; | ||
|
||
private static array $has_one = [ | ||
'HeaderLogo' => Image::class, | ||
]; | ||
private static array $owns = [ | ||
'HeaderLogo', | ||
]; | ||
|
||
private static array $defaults = [ | ||
'AddonsHeaderFeatureFlag' => true, | ||
]; | ||
|
||
public function updateCMSFields(FieldList $fields) | ||
{ | ||
parent::updateCMSFields($fields); | ||
|
||
$fields->addFieldsToTab('Root.SilverstripeAddonsSettings.Features', [ | ||
LiteralField::create('AddonsDescritpion', ' | ||
<h3>SilverStripe Addons Features</h3> | ||
<p>Here you can turn on/off features for SilverStripe addons</p> | ||
'), | ||
CompositeField::create([ | ||
CheckboxField::create('AddonsHeaderFeatureFlag', 'Turn on header visual images with content on all pages') | ||
->setDescription('This feature flag adds a header visual to all pages. | ||
The header needs to get configured in the SilverStripe template. | ||
You can also use <a href="https://github.com/robertvanlienden/silverstripe-bulma-portfolio-theme" target="_blank"> | ||
robertvanlienden/silverstripe-bulma-portfolio-theme</a>.') | ||
]) | ||
]); | ||
|
||
$fields->addFieldsToTab('Root.SilverstripeAddonsSettings.Header', [ | ||
UploadField::create('HeaderLogo', 'Header logo') | ||
->setFolderName('header-logo') | ||
]); | ||
|
||
$fields->addFieldsToTab('Root.SilverstripeAddonsSettings.Footer', [ | ||
HTMLEditorField::create('FooterLeft', 'Footer left'), | ||
HTMLEditorField::create('FooterRight', 'Footer right'), | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
namespace RobertVanLienden\SilverStripeAddons\Models; | ||
|
||
use Page; | ||
use SilverStripe\AssetAdmin\Forms\UploadField; | ||
use SilverStripe\Assets\Image; | ||
use SilverStripe\ORM\DataObject; | ||
|
||
class SlideShowImage extends DataObject | ||
{ | ||
private static string $table_name = 'SSAddonsSlideShowImage'; | ||
|
||
private static array $db = [ | ||
'Title' => 'Varchar', | ||
]; | ||
|
||
private static array $has_one = [ | ||
'Image' => Image::class, | ||
'Page' => Page::class, | ||
]; | ||
|
||
private static array $owns = [ | ||
'Image' | ||
]; | ||
|
||
public function getCMSFields() | ||
{ | ||
$fields = parent::getCMSFields(); | ||
|
||
$fields->removeByName(['PageID', 'Image']); | ||
|
||
$fields->addFieldsToTab('Root.Main', [ | ||
UploadField::create('Image', 'Image') | ||
->setFolderName('slideshow-images') | ||
]); | ||
|
||
return $fields; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php | ||
|
||
namespace RobertVanLienden\SilverStripeAddons\Pages; | ||
|
||
use RobertVanLienden\SilverStripeAddons\Models\SlideShowImage; | ||
use SilverStripe\AssetAdmin\Forms\UploadField; | ||
use SilverStripe\Assets\Image; | ||
use SilverStripe\Forms\GridField\GridField; | ||
use SilverStripe\Forms\GridField\GridFieldConfig_RecordEditor; | ||
use SilverStripe\Forms\HTMLEditor\HTMLEditorField; | ||
use SilverStripe\Forms\TextField; | ||
|
||
class ItemDetailPage extends \Page | ||
{ | ||
private static string $table_name = 'SSAddonsItemDetailPage'; | ||
private static string $icon_class = 'font-icon-p-article'; | ||
private static string $description = 'A portfolio item page'; | ||
|
||
private static bool $can_be_root = false; | ||
|
||
private static array $db = [ | ||
'ProjectSummary' => 'HTMLText', | ||
'ButtonText' => 'Varchar(225)', | ||
]; | ||
|
||
private static array $has_one = [ | ||
'OverviewImage' => Image::class, | ||
]; | ||
|
||
private static array $has_many = [ | ||
'SlideShowImages' => SlideShowImage::class, | ||
]; | ||
|
||
private static array $owns = [ | ||
'OverviewImage', | ||
'SlideShowImages' | ||
]; | ||
|
||
public function getCMSFields() | ||
{ | ||
$fields = parent::getCMSFields(); | ||
|
||
$fields->addFieldsToTab('Root.Project', [ | ||
UploadField::create('OverviewImage') | ||
->setFolderName('portfolio'), | ||
HTMLEditorField::create('ProjectSummary') | ||
->setDescription('A summary for the portfolio detail page. | ||
Without summary the first 50 characters of the content will get used.'), | ||
TextField::create('ButtonText') | ||
->setDescription('The text that will get shown on the link on the project summary'), | ||
]); | ||
|
||
$slideShowImagesConfig = GridFieldConfig_RecordEditor::create(); | ||
|
||
$fields->addFieldsToTab('Root.SlideShowImages', [ | ||
GridField::create('Images', | ||
'Slideshow images', | ||
$this->SlideShowImages(), | ||
$slideShowImagesConfig) | ||
]); | ||
|
||
return $fields; | ||
} | ||
|
||
public function getShortContent(string $content = null): string | ||
{ | ||
if (!$content) { | ||
$content = ''; | ||
} | ||
|
||
$content = strip_tags($content); | ||
|
||
return substr($content, 0, 500) . ' ...'; | ||
} | ||
} |
Oops, something went wrong.