2018-04-21 06:29:32 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
// vendor/silverstripe/errorpage/src/ErrorPage.php
|
|
|
|
// extends global Page class
|
|
|
|
//namespace Site\Pages;
|
|
|
|
|
|
|
|
use SilverStripe\CMS\Model\SiteTree;
|
2018-08-13 14:13:55 +02:00
|
|
|
use DNADesign\Elemental\Models\ElementContent;
|
2018-04-21 06:29:32 +02:00
|
|
|
|
|
|
|
class Page extends SiteTree
|
|
|
|
{
|
2019-08-19 10:37:24 +02:00
|
|
|
private static $default_container_class = 'container';
|
|
|
|
|
|
|
|
public static function DefaultContainer()
|
|
|
|
{
|
|
|
|
return self::config()->get('default_container_class');
|
|
|
|
}
|
|
|
|
|
2018-08-13 14:13:55 +02:00
|
|
|
/*
|
|
|
|
* Shows custom summary of the post, otherwise
|
|
|
|
* Displays summary of the first content element
|
|
|
|
*/
|
|
|
|
public function Summary($wordsToDisplay = 30)
|
|
|
|
{
|
|
|
|
$summary = $this->getField('Summary');
|
|
|
|
if ($summary) {
|
|
|
|
return $summary;
|
|
|
|
}
|
|
|
|
|
|
|
|
$element = ElementContent::get()->filter([
|
|
|
|
'ParentID' => $this->ElementalArea()->ID,
|
|
|
|
'HTML:not' => [null],
|
|
|
|
])->first();
|
|
|
|
|
|
|
|
if ($element) {
|
|
|
|
return $element->dbObject('HTML')->Summary($wordsToDisplay);
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2019-09-07 03:39:49 +02:00
|
|
|
|
|
|
|
public function CSSClass()
|
|
|
|
{
|
|
|
|
return str_replace(['\\'], '-', $this->getField('ClassName'));
|
|
|
|
}
|
2018-04-21 06:29:32 +02:00
|
|
|
}
|