Issues (38)

src/Pages/StaffMember.php (12 issues)

Severity
1
<?php
2
3
namespace Dynamic\Staff\Pages;
4
5
use Dynamic\Staff\Model\StaffDepartment;
6
use SilverStripe\AssetAdmin\Forms\UploadField;
7
use SilverStripe\Assets\Image;
8
use SilverStripe\Forms\DropdownField;
9
use SilverStripe\Forms\EmailField;
10
use SilverStripe\Forms\FieldList;
11
use SilverStripe\Forms\TextField;
12
13
/**
14
 * Class StaffMember
15
 * @package Dynamic\Staff\Pages
16
 */
17
class StaffMember extends \Page
18
{
19
    /**
20
     * @var string
21
     */
22
    private static $singular_name = 'Staff Member';
0 ignored issues
show
The private property $singular_name is not used, and could be removed.
Loading history...
23
24
    /**
25
     * @var string
26
     */
27
    private static $plural_name = 'Staff Members';
0 ignored issues
show
The private property $plural_name is not used, and could be removed.
Loading history...
28
29
    /**
30
     * @var string
31
     */
32
    private static $description = 'Detailed information about a specific staff member';
0 ignored issues
show
The private property $description is not used, and could be removed.
Loading history...
33
34
    /**
35
     * @var array
36
     */
37
    private static $db = array(
0 ignored issues
show
The private property $db is not used, and could be removed.
Loading history...
38
        'Position' => 'Varchar(255)',
39
        'OfficeLocation' => 'Varchar(255)',
40
        'Email' => 'Varchar(255)',
41
        'Phone' => 'Varchar(20)',
42
        'Mobile' => 'Varchar(20)',
43
        'Fax' => 'Varchar(20)',
44
        'Website' => 'Varchar(255)',
45
        'Facebook' => 'Varchar(255)',
46
        'Twitter' => 'Varchar(255)',
47
        'LinkedIn' => 'Varchar(255)',
48
    );
49
50
    /**
51
     * @var array
52
     */
53
    private static $has_one = array(
0 ignored issues
show
The private property $has_one is not used, and could be removed.
Loading history...
54
        'Image' => Image::class,
55
        'Department' => StaffDepartment::class,
56
    );
57
58
    /**
59
     * @var array
60
     */
61
    private static $owns = [
0 ignored issues
show
The private property $owns is not used, and could be removed.
Loading history...
62
        'Image',
63
    ];
64
65
    /**
66
     * @var array
67
     */
68
    private static $summary_fields = array(
0 ignored issues
show
The private property $summary_fields is not used, and could be removed.
Loading history...
69
        'Title',
70
        'JobTitle',
71
        'Email'
72
    );
73
74
    /**
75
     * @var array
76
     */
77
    private static $defaults = array(
0 ignored issues
show
The private property $defaults is not used, and could be removed.
Loading history...
78
        'ShowInMenus' => false,
79
    );
80
81
    /**
82
     * @var bool
83
     */
84
    private static $can_be_root = false;
0 ignored issues
show
The private property $can_be_root is not used, and could be removed.
Loading history...
85
86
    /**
87
     * @var array
88
     */
89
    private static $allowed_children = [];
0 ignored issues
show
The private property $allowed_children is not used, and could be removed.
Loading history...
90
91
    /**
92
     * This will display or hide the current class from the SiteTree. This variable can be
93
     * configured using YAML.
94
     *
95
     * @var bool
96
     */
97
    private static $show_in_sitetree = false;
0 ignored issues
show
The private property $show_in_sitetree is not used, and could be removed.
Loading history...
98
99
    /**
100
     * @var string
101
     */
102
    private static $table_name = 'StaffMember';
0 ignored issues
show
The private property $table_name is not used, and could be removed.
Loading history...
103
104
    /**
105
     * @return FieldList
106 1
     */
107 1
    public function getCMSFields()
108 1
    {
109 1
        $this->beforeUpdateCMSFields(function (FieldList $fields) {
110 1
            $imageField = UploadField::create('Image', 'Image')
111 1
                ->setFolderName('Uploads/StaffMembers')
112
                ->setAllowedFileCategories('image')
113 1
                ->setIsMultiUpload(false);
114 1
            $imageField->getValidator()->allowedExtensions = array('jpg', 'gif', 'png');
115 1
116
            $fields->addFieldsToTab(
117 1
                'Root.Main',
118 1
                [
119 1
                    TextField::create('Position'),
120 1
                    DropdownField::create('DepartmentID', 'Department', StaffDepartment::get()->map())
121 1
                        ->setEmptyString(''),
122 1
                    TextField::create('OfficeLocation'),
123 1
                    $imageField,
124 1
                ],
125 1
                'Content'
126
            );
127
128 1
            $fields->addFieldsToTab('Root.Contact', array(
129 1
                EmailField::create('Email'),
130 1
                TextField::create('Phone'),
131
                TextField::create('Mobile'),
132
                TextField::create('Fax'),
133
                TextField::create('Website'),
134
                TextField::create('Twitter'),
135
                TextField::create('Facebook'),
136
                TextField::create('LinkedIn', 'LinkedIn'),
137
            ));
138
139
            $fields->dataFieldByName('Title')->setTitle('Name');
140
            $fields->dataFieldByName('Content')->setTitle('Biography');
141
        });
142
143
        $fields = parent::getCMSFields();
144
145
        $fields->insertBefore(
146
            'Content',
147
            $fields->dataFieldByName('ParentID')
148
        );
149
150
        return $fields;
151
    }
152
}
153