Version: current

     1 <?php
     2
     3 /**
     4  * Настройки комментирования
     5  *
     6  * @author inxo
     7  */
     8 class CommentsSiteConfig extends DataObjectDecorator {
     9
    10     function extraStatics() {
    11         return array(
    12             'db' => array(
    13                 'CommentsExeptClasses' => 'Text', // список классов для которых выполняется действие по умолчанию
    14                 'CommentsDefaultAction' => "Enum('Allow,Deny')"
    15             ),
    16             'defaults' => array(
    17                 'CommentsExeptClasses' => '',
    18                 'CommentsDefaultAction'=>'Allow'
    19             )
    20         );
    21     }
    22
    23     public function updateCMSFields(FieldSet &$fields) {
    24         if (!Director::isDev()) return;
    25
    26             $classes = SiteTree::page_type_classes();
    27             $result = array();
    28             foreach($classes as $class) {
    29                 $instance = singleton($class);
    30                 if($instance instanceof HiddenClass) continue;
    31                 if(!$instance->canCreate()) continue;
    32                 $name = $instance->i18n_singular_name();
    33                 $result[$class] = $name;
    34             }
    35             $actions = singleton('SiteConfig')->dbObject('CommentsDefaultAction')->enumValues();
    36             foreach ($actions as $actionName => $actionItem) {
    37                 $actions[$actionName] = _t('SiteConfig.CommentsAction' . $actionItem);
    38             }
    39
    40         $tab = WebylonSiteConfig::get_config_tab($fields, 'Comments', _t('SiteConfig.CommentsConfigTitle', 'Comments'));
    41
    42         $tab->push(new HeaderField('Comments', _t('SiteConfig.CommentsConfigTitle', 'Comments')));
    43         $tab->push(new DropdownField('CommentsDefaultAction', _t('SiteConfig.CommentsDefaultAction', 'Comments Default Action'), $actions));
    44         $tab->push(new CheckboxSetField('CommentsExeptClasses', _t('SiteConfig.CommentsExeptClasses', 'Comments Exept Classes'), $result));
    45
    46     }
    47
    48 }
    49

[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -