Source of file PageListWidget.php
Size: 3,805 Bytes - Last Modified: 2021-12-23T10:21:36+00:00
/var/www/docs.ssmods.com/process/src/src/Model/Widgets/PageListWidget.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 | <?php namespace SilverCart\Model\Widgets; use SilverCart\Model\Pages\Page; use SilverCart\Model\Translation\TranslationTools; use SilverCart\Model\Widgets\Widget; use SilverCart\Model\Widgets\WidgetTools; use SilverCart\Model\Widgets\PageListWidgetTranslation; use SilverStripe\Forms\TreeMultiselectField; /** * Provides a view for pages. * * @package SilverCart * @subpackage Model_Widgets * @author Sebastian Diel <sdiel@pixeltricks.de> * @since 09.10.2017 * @copyright 2017 pixeltricks GmbH * @license see license file in modules root directory */ class PageListWidget extends Widget { /** * Has-many relations * * @var array */ private static $has_many = array( 'PageListWidgetTranslations' => PageListWidgetTranslation::class, ); /** * Many-many relations * * @var array */ private static $many_many = array( 'Pages' => Page::class, ); /** * DB table name * * @var string */ private static $table_name = 'SilvercartPageListWidget'; /** * Casting * * @var array */ private static $casting = array( 'FrontTitle' => 'Varchar(255)', 'FrontContent' => 'Text', ); /** * Getter for the front title depending on the set language * * @return string */ public function getFrontTitle() { return $this->getTranslationFieldValue('FrontTitle'); } /** * Getter for the FrontContent depending on the set language * * @return string The HTML front content * * @author Sascha Koehler <skoehler@pixeltricks.de> * @since 06.12.2012 */ public function getFrontContent() { return $this->getTranslationFieldValue('FrontContent'); } /** * Field labels for display in tables. * * @param boolean $includerelations A boolean value to indicate if the labels returned include relation fields * * @return array * * @author Sascha Koehler <skoehler@pixeltricks.de> * @since 06.12.2012 */ public function fieldLabels($includerelations = true) { $fieldLabels = array_merge( parent::fieldLabels($includerelations), WidgetTools::fieldLabelsForProductSliderWidget($this), array( 'Pages' => _t(PageListWidget::class . '.PAGES', 'Attributed pages'), 'PageListWidgetTranslations' => _t(TranslationTools::class . '.TRANSLATIONS', 'Translations'), ) ); $this->extend('updateFieldLabels', $fieldLabels); return $fieldLabels; } /** * Returns an array of field/relation names (db, has_one, has_many, * many_many, belongs_many_many) to exclude from form scaffolding in * backend. * This is a performance friendly way to exclude fields. * * @return array * * @author Roland Lehmann <rlehmann@pixeltricks.de> * @since 14.03.2013 */ public function excludeFromScaffolding() { $excludeFromScaffolding = array_merge( parent::excludeFromScaffolding(), array( 'Pages' ) ); $this->extend('updateExcludeFromScaffolding', $excludeFromScaffolding); return $excludeFromScaffolding; } /** * GUI fields * * @return FieldList */ public function getCMSFields() { $fields = parent::getCMSFields(); $pagesField = new TreeMultiselectField( 'Pages', $this->fieldLabel('Pages'), Page::class, 'ID', 'Title' ); $fields->insertAfter($pagesField, 'FrontContent'); return $fields; } } |