Source of file Page.php
Size: 2,742 Bytes - Last Modified: 2022-02-21T10:00:20+00:00
/var/www/docs.ssmods.com/process/src/app/src/Pages/Page.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 | <?php // vendor/silverstripe/errorpage/src/ErrorPage.php // extends global Page class //namespace App\Pages; use DNADesign\Elemental\Models\ElementContent; use SilverStripe\CMS\Model\SiteTree; use SilverStripe\FontAwesome\FontAwesomeField; use TractorCow\Fluent\Extension\FluentSiteTreeExtension; class Page extends SiteTree { protected $_cached = []; private static $default_container_class = 'container'; private static $db = [ 'BlockIcon' => 'Varchar(255)', ]; private static $field_include = [ 'ElementalAreaID', ]; public static function DefaultContainer() { return self::config()->get('default_container_class'); } public function getSettingsFields() { $fields = parent::getSettingsFields(); $fields->addFieldsToTab('Root.Icon', [ FontAwesomeField::create('BlockIcon', 'Page link Icon'), ]); return $fields; } /* * Shows custom summary of the post, otherwise * Displays summary of the first content element */ public function Summary($wordsToDisplay = 30) { if (isset($this->_cached['summary' . $wordsToDisplay])) { return $this->_cached['summary' . $wordsToDisplay]; } $summary = $this->getField('Summary'); if ($summary) { $this->_cached['summary' . $wordsToDisplay] = $summary; return $this->_cached['summary' . $wordsToDisplay]; } $element = ElementContent::get()->filter([ 'ParentID' => $this->ElementalArea()->ID, 'HTML:not' => [null], ])->first(); if ($element) { $this->_cached['summary' . $wordsToDisplay] = $element->dbObject('HTML')->Summary($wordsToDisplay); return $this->_cached['summary' . $wordsToDisplay]; } $content = $this->getField('Content'); if ($content) { $this->_cached['summary' . $wordsToDisplay] = $this->dbObject('Content')->Summary($wordsToDisplay); return $this->_cached['summary' . $wordsToDisplay]; } $this->_cached['summary' . $wordsToDisplay] = false; return $this->_cached['summary' . $wordsToDisplay]; } public function CSSClass() { return str_replace(['\\'], '-', $this->getField('ClassName')); } protected function onBeforeWrite() { parent::onBeforeWrite(); if (class_exists(FluentSiteTreeExtension::class) && ! $this->isDraftedInLocale() && $this->isInDB()) { $elementalArea = $this->ElementalArea(); $elementalAreaNew = $elementalArea->duplicate(); $this->setField('ElementalAreaID', $elementalAreaNew->ID); } } } |