Completed
Push — master ( c238bb...d3c2be )
by Julito
53:04 queued 30:32
created

PlatformSettingsSchema   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 149
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 149
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A buildSettings() 0 60 1
B buildForm() 0 79 1
1
<?php
2
/* For licensing terms, see /license.txt */
3
4
namespace Chamilo\CoreBundle\Settings;
5
6
use Chamilo\CoreBundle\Form\Type\YesNoType;
7
use Chamilo\SettingsBundle\Transformer\ArrayToIdentifierTransformer;
8
use Sylius\Bundle\SettingsBundle\Schema\SchemaInterface;
9
use Sylius\Bundle\SettingsBundle\Schema\SettingsBuilderInterface;
10
use Symfony\Component\Form\FormBuilderInterface;
11
12
/**
13
 * Class PlatformSettingsSchema
14
 * @package Chamilo\CoreBundle\Settings
15
 */
16
class PlatformSettingsSchema extends AbstractSettingsSchema
17
{
18
    /**
19
     * {@inheritdoc}
20
     */
21
    public function buildSettings(SettingsBuilderInterface $builder)
22
    {
23
        $builder
24
            ->setDefaults(
25
                [
26
                    'institution' => 'Chamilo.org',
27
                    'institution_url' => 'http://www.chamilo.org',
28
                    'institution_address' => '',
29
                    'site_name' => 'Chamilo site',
30
//                    'administrator_email' => '[email protected]',
31
//                    'administrator_name' => 'Jane',
32
//                    'administrator_surname' => 'Doe',
33
//                    'administrator_phone' => '123456',
34
                    'timezone' => 'Europe/Paris',
35
                    'theme' => 'chamilo',
36
                    'gravatar_enabled' => 'false',
37
                    'gravatar_type' => 'mm',
38
                    'gamification_mode' => ' ',
39
                    'order_user_list_by_official_code' => 'false',
40
                    'cookie_warning' => 'false',
41
                    'donotlistcampus' => 'false',
42
                    'catalog_show_courses_sessions' => '0',
43
                    'course_catalog_hide_private' => 'false',
44
                    'use_custom_pages' => 'false',
45
                    'pdf_logo_header' => '',
46
                    'allow_my_files' => 'true',
47
                    'chamilo_database_version' => '2.0.0',
48
                    'registered' => 'false',
49
                    'load_term_conditions_section' => 'login',
50
                    'server_type' => 'false',
51
                    'show_full_skill_name_on_skill_wheel' => 'false',
52
                    'show_official_code_whoisonline' => 'false',
53
                    'show_tabs' => []
54
                    //
55
//('catalog_show_courses_sessions', '0', 'CatalogueShowOnlyCourses'),
56
//('catalog_show_courses_sessions', '1', 'CatalogueShowOnlySessions'),
57
//('catalog_show_courses_sessions', '2', 'CatalogueShowCoursesAndSessions'),
58
                ]
59
            )
60
            ->setTransformer(
61
                'show_tabs',
62
                new ArrayToIdentifierTransformer()
63
            )
64
        ;
65
        $allowedTypes = [
66
            'institution' => ['string'],
67
            'institution_url' => ['string'],
68
            'site_name' => ['string'],
69
//                    'administrator_email' => array('string'),
70
//                    'administrator_name' => array('string'),
71
//                    'administrator_surname' => array('string'),
72
//                    'administrator_phone' => array('string'),
73
            'timezone' => ['string'],
74
            'gravatar_enabled' => ['string'],
75
            'gravatar_type' => ['string'],
76
            'show_tabs' => ['array']
77
            //'gamification_mode' => array('string'),
78
        ];
79
80
        $this->setMultipleAllowedTypes($allowedTypes, $builder);
81
    }
82
83
    /**
84
     * {@inheritdoc}
85
     */
86
    public function buildForm(FormBuilderInterface $builder)
87
    {
88
        $tabs = [
89
            'TabsCampusHomepage' => 'campus_homepage',
90
            'TabsMyCourses' => 'my_courses',
91
            'TabsReporting' => 'reporting',
92
            'TabsPlatformAdministration' => 'platform_administration',
93
            'mypersonalopenarea' => 'my_agenda',
94
            'TabsMyAgenda' => 'my_profile',
95
            'TabsMyGradebook' => 'my_gradebook',
96
            'TabsSocial' => 'social',
97
            'TabsDashboard' => 'dashboard'
98
        ];
99
100
        $builder
101
            ->add('institution')
102
            ->add('institution_url', 'url')
103
            ->add('institution_address')
104
            ->add('site_name')
105
//            ->add('administrator_email', 'email')
106
//            ->add('administrator_name')
107
//            ->add('administrator_surname')
108
//            ->add('administrator_phone')
109
            ->add('timezone', 'timezone')
110
            ->add('theme')
111
            ->add('gravatar_enabled', YesNoType::class)
112
            ->add(
113
                'gravatar_type',
114
                'choice',
115
                [
116
                    'choices' => [
117
                        'mm' => 'mistery-man',
118
                        'identicon' => 'identicon',
119
                        'monsterid' => 'monsterid',
120
                        'wavatar' => 'wavatar',
121
                    ],
122
                ]
123
            )
124
            ->add('gamification_mode')
125
            ->add('order_user_list_by_official_code', YesNoType::class)
126
            ->add('cookie_warning', YesNoType::class)
127
            ->add('donotlistcampus', YesNoType::class)
128
            ->add('course_catalog_hide_private', YesNoType::class)
129
            ->add(
130
                'catalog_show_courses_sessions',
131
                'choice',
132
                ['choices' => [
133
                    '0' => 'CatalogueShowOnlyCourses',
134
                    '1' => 'CatalogueShowOnlySessions',
135
                    '2' => 'CatalogueShowCoursesAndSessions',
136
                ]]
137
            )
138
            ->add('use_custom_pages', YesNoType::class)
139
            ->add('pdf_logo_header')
140
            ->add('allow_my_files', YesNoType::class)
141
            // old settings with no category
142
            ->add('chamilo_database_version')
143
            ->add('registered', YesNoType::class)
144
            ->add(
145
                'load_term_conditions_section',
146
                'choice',
147
                [
148
                    'choices' => [
149
                        '0' => 'Login',
150
                        '1' => 'Course',
151
                    ],
152
                ]
153
            )
154
            ->add('server_type', YesNoType::class)
155
            ->add('show_full_skill_name_on_skill_wheel', YesNoType::class)
156
            ->add('show_official_code_whoisonline', YesNoType::class)
157
            ->add(
158
                'show_tabs',
159
                'choice',
160
                [
161
                    'multiple' => true,
162
                    'choices' => $tabs,
163
                    'label' => 'ShowTabsTitle',
164
                    'help_block' => 'ShowTabsComment'
165
                ]
166
            )
167
        ;
168
    }
169
}
170