Skip to content

Commit

Permalink
Merge branch '3.0' into 3
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli committed Sep 1, 2024
2 parents 4ca778a + 6057ce5 commit def3eaf
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 20 deletions.
6 changes: 3 additions & 3 deletions _config.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
. "|class],-strong/-b[class],-em/-i[class],-strike[class],-u[class],#p[id|dir|class|align|style]"
. ",-ol[class],"
. "-ul[class],"
. "-li[class],br,img[id|dir|longdesc|usemap|class|src|border|alt=|title|width|height|align|data*],"
. "-li[class],br,"
. "img[id|dir|longdesc|usemap|class|src|border|alt=|title|width|height|align|hspace|vspace|name|data*],"
. "-sub[class],-sup[class],-blockquote[dir|class],"
. "-table[cellspacing|cellpadding|width|height|class|align|dir|id|style],"
. "-tr[id|dir|class|rowspan|width|height|align|valign|bgcolor|background|bordercolor|style],"
Expand All @@ -40,8 +41,7 @@
. "-h4[id|dir|class|align|style],-h5[id|dir|class|align|style],-h6[id|dir|class|align|style],hr[class],"
. "dd[id|class|title|dir],dl[id|class|title|dir],dt[id|class|title|dir],@[id,style,class]",
'extended_valid_elements' =>
'img[class|src|alt|title|hspace|vspace|width|height|align|name|usemap|data*],'
. 'object[classid|codebase|width|height|data|type],'
'object[classid|codebase|width|height|data|type],'
. 'embed[width|height|name|flashvars|src|bgcolor|align|play|loop|quality|'
. 'allowscriptaccess|type|pluginspage|autoplay],'
. 'param[name|value],'
Expand Down
1 change: 1 addition & 0 deletions src/Extensions/TaxonomyTermExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use SilverStripe\Taxonomy\TaxonomyTerm;

/**
* @method SilverStripe\ORM\ManyManyList<BasePage> Pages()
* @extends DataExtension<TaxonomyTerm>
*/
class TaxonomyTermExtension extends DataExtension
Expand Down
2 changes: 1 addition & 1 deletion src/Model/Quicklink.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
use SilverStripe\ORM\DataObject;

/**
* @method BaseHomePage Parent()
* @method SiteTree InternalLink()
* @method BaseHomePage Parent()
*/
class Quicklink extends DataObject
{
Expand Down
4 changes: 4 additions & 0 deletions src/Model/RelatedPageLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
use SilverStripe\ORM\DataObject;
use SilverStripe\Versioned\Versioned;

/**
* @method BasePage BasePage()
* @method BasePage Child()
*/
class RelatedPageLink extends DataObject
{
private static $table_name = 'BasePage_RelatedPages';
Expand Down
4 changes: 4 additions & 0 deletions src/PageTypes/BaseHomePage.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
* **BaseHomePage** is the basic home page.
* By default it is hidden from the CMS - we rely on developers creating their own
* `HomePage` class in the `mysite/code` which will extend from the **BaseHomePage**.
* @method SiteTree FeatureOneLink()
* @method SiteTree FeatureTwoLink()
* @method SiteTree LearnMorePage()
* @method SilverStripe\ORM\HasManyList<Quicklink> Quicklinks()
*/
class BaseHomePage extends Page
{
Expand Down
29 changes: 20 additions & 9 deletions src/PageTypes/BasePage.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Symbiote\GridFieldExtensions\GridFieldOrderableRows;
use TractorCow\Fluent\Model\Locale;
use TractorCow\Fluent\State\FluentState;
use SilverStripe\Forms\FormField;

/**
* `BasePage` is a foundation page class which can be used for constructing your own page types. By default it is
Expand All @@ -26,6 +27,9 @@
* Please note: you should generally always extend `Page` with your custom page types. Refrain from subclassing
* `BasePage` directly. Doing so will omit `Page` from your custom class's hierarchy, and this can have unintended
* side effects where modules rely on modifying things on the `Page` class, as well as with templates and themes.
* @method SilverStripe\ORM\ManyManyThroughList<BasePage> RelatedPagesThrough()
* @method SilverStripe\ORM\ManyManyList<BasePage> SimilarPages()
* @method SilverStripe\ORM\ManyManyList<TaxonomyTerm> Terms()
*/

class BasePage extends SiteTree
Expand Down Expand Up @@ -124,15 +128,22 @@ public function getCMSFields()
'Root.RelatedPages',
_t(__CLASS__ . '.RelatedPages', 'Related pages')
);
$fields->addFieldToTab(
'Root.RelatedPages',
GridField::create(
'RelatedPages',
_t(__CLASS__ . '.RelatedPages', 'Related pages'),
$this->RelatedPagesThrough(),
$components
)
);
$args = [
'RelatedPages',
_t(__CLASS__ . '.RelatedPages', 'Related pages'),
$this->RelatedPagesThrough(),
$components
];
$gridField = GridField::create(...$args);
// If GridField has been replaced by Injector, use that
// Otherwise use anonymous class so that versioned-admin behat tests pass
// when running in kitchen-sink
if (get_class($gridField) === GridField::class) {
$gridField = new class (...$args) extends GridField {
protected $schemaDataType = FormField::SCHEMA_DATA_TYPE_STRUCTURAL;
};
}
$fields->addFieldToTab('Root.RelatedPages', $gridField);

// Taxonomies - Unless they have their own 'Tags' field (such as in Blog, etc)
$hasMany = $this->hasMany();
Expand Down
4 changes: 2 additions & 2 deletions src/PageTypes/DatedUpdateHolder.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public static function AllUpdates(
// Try running query inside try/catch block to handle any invalid date format
$items->dataQuery()->execute();
} catch (DatabaseException $e) {
self::handleInvalidDateFormat($e);
DatedUpdateHolder::handleInvalidDateFormat($e);
// Ensure invalid SQL does not get run again
$items = $className::get()->limit(null);
}
Expand Down Expand Up @@ -213,7 +213,7 @@ public static function ExtractMonths(
])
->execute();
} catch (DatabaseException $e) {
self::handleInvalidDateFormat($e);
DatedUpdateHolder::handleInvalidDateFormat($e);
}

$years = [];
Expand Down
10 changes: 5 additions & 5 deletions src/PageTypes/DatedUpdateHolderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public function parseParams($produceErrorMessages = true)
}
} catch (InvalidArgumentException $e) {
if ($produceErrorMessages) {
$this->getRequest()->getSession()->set(self::TEMP_FORM_MESSAGE, _t(
$this->getRequest()->getSession()->set(DatedUpdateHolderController::TEMP_FORM_MESSAGE, _t(
__CLASS__ . '.InvalidDateFormat',
'Dates must be in "y-MM-dd" format.'
));
Expand All @@ -203,7 +203,7 @@ public function parseParams($produceErrorMessages = true)
list($to, $from) = [$from, $to];

if ($produceErrorMessages) {
$this->getRequest()->getSession()->set(self::TEMP_FORM_MESSAGE, _t(
$this->getRequest()->getSession()->set(DatedUpdateHolderController::TEMP_FORM_MESSAGE, _t(
__CLASS__ . '.FilterAppliedMessage',
'Filter has been applied with the dates reversed.'
));
Expand All @@ -213,7 +213,7 @@ public function parseParams($produceErrorMessages = true)
// Notify the user that filtering by single date is taking place.
if (isset($from) && !isset($to)) {
if ($produceErrorMessages) {
$this->getRequest()->getSession()->set(self::TEMP_FORM_MESSAGE, _t(
$this->getRequest()->getSession()->set(DatedUpdateHolderController::TEMP_FORM_MESSAGE, _t(
__CLASS__ . '.DateRangeFilterMessage',
'Filtered by a single date.'
));
Expand Down Expand Up @@ -350,9 +350,9 @@ public function DateRangeForm()
$form->setFormMethod('get');

// Add any locally stored form messages before returning
if ($formMessage = $this->getRequest()->getSession()->get(self::TEMP_FORM_MESSAGE)) {
if ($formMessage = $this->getRequest()->getSession()->get(DatedUpdateHolderController::TEMP_FORM_MESSAGE)) {
$form->setMessage($formMessage, ValidationResult::TYPE_WARNING);
$this->getRequest()->getSession()->clear(self::TEMP_FORM_MESSAGE);
$this->getRequest()->getSession()->clear(DatedUpdateHolderController::TEMP_FORM_MESSAGE);
}

return $form;
Expand Down
3 changes: 3 additions & 0 deletions src/PageTypes/NewsPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
use SilverStripe\Forms\TextField;
use SilverStripe\ORM\FieldType\DBField;

/**
* @method Image FeaturedImage()
*/
class NewsPage extends DatedUpdatePage
{
private static $description = 'Describes an item of news';
Expand Down

0 comments on commit def3eaf

Please sign in to comment.