Source of file FaqHolderPage.php
Size: 3,178 Bytes - Last Modified: 2021-12-23T10:41:37+00:00
/var/www/docs.ssmods.com/process/src/src/FaqHolderPage.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 | <?php namespace Sunnysideup\Faqs; use Page; use SilverStripe\ORM\ArrayList; /** *@author nicolaas[at]sunnysideup.co.nz *@description: holds FAQs and displays them nicely. */ class FaqHolderPage extends Page { /** * The holder page class in use. * You can extends this Class and change this value. * * @var string */ protected $holderPage = FaqHolderPage::class; /** * The item page class in use. * You can extends this Class and change this value. * * @var string */ protected $entryPage = FaqOnePage::class; private static $table_name = 'FaqHolderPage'; private static $icon = 'sunnysideup/faqs: client/images/FaqHolderPage-file.png'; private static $description = 'A list of Frequently Asked Questions'; //private static $default_parent = ''; private static $default_child = FaqOnePage::class; private static $allowed_children = [FaqHolderPage::class, FaqOnePage::class]; /** * Standard SS variable. */ private static $singular_name = 'FAQ Holder Page'; /** * Standard SS variable. */ private static $plural_name = 'FAQ Holder Pages'; public function i18n_singular_name() { return _t('FaqHolderPage.SINGULARNAME', 'FAQ Holder Page'); } public function i18n_plural_name() { return _t('FaqHolderPage.PLURALNAME', 'FAQ Holder Pages'); } /** * Returns children FaqHolderPage pages of this FaqHolderPage. * * @param null|mixed $filter * * @return ArrayList (FaqHolderPages) */ public function ChildGroups(?int $maxRecursiveLevel = 99, ?int $numberOfRecursions = 0, $filter = null): ArrayList { $arrayList = ArrayList::create(); if ($numberOfRecursions < $maxRecursiveLevel) { $className = $this->getHolderPage(); $children = $className::get()->filter(['ParentID' => $this->ID]); if (! empty($filter)) { $children = $children->filter($filter); } if ($children->exists()) { foreach ($children as $child) { $arrayList->push($child); ++$numberOfRecursions; $arrayList->merge($child->ChildGroups($maxRecursiveLevel, $numberOfRecursions, $filter)); } } } return $arrayList; } /** * sets the classname for pages that are holder pages. * * @param string $name */ public function setHolderPage($name) { $this->holderPage = $name; } /** * gets the classname for pages that are holder pages. * * @return string */ public function getHolderPage() { return $this->holderPage; } /** * sets the classname for pages that are individual items. * * @param string $name */ public function setEntryName($name) { $this->entryPage; } /** * gets the classname for pages that are individual items. * * @return string */ public function getEntryName() { return $this->entryPage; } } |