-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathPaperAdminUI.php
More file actions
78 lines (67 loc) · 2.99 KB
/
Copy pathPaperAdminUI.php
File metadata and controls
78 lines (67 loc) · 2.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
/**
* Copyright 2018 OpenStack Foundation
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
/**
* Class PaperAdminUI
*/
final class PaperAdminUI extends DataExtension
{
/**
* @var array
*/
private static $summary_fields = [
'Title' => 'Title',
'Creator.Email' => 'Creator',
];
public function updateCMSFields(FieldList $f)
{
//clear all fields
$oldFields = $f->toArray();
foreach ($oldFields as $field) {
$f->remove($field);
}
$f->add($rootTab = new TabSet("Root", $tabMain = new Tab('Main')));
$logo_field = UploadField::create('BackgroundImage', 'Header Background Image');
$logo_field->setAllowedMaxFileNumber(1);
$logo_field->setAllowedFileCategories('image');
$logo_field->setFolderName('papers/headers');
$logo_field->getValidator()->setAllowedMaxFileSize(1024*1024*1);
$f->addFieldToTab('Root.Main', $logo_field);
$f->addFieldToTab('Root.Main', new TextField('Title', 'Title'));
$f->addFieldToTab('Root.Main', new TextField('Subtitle', 'Subtitle'));
$f->addFieldToTab('Root.Main', new HtmlEditorField('Abstract', 'Abstract'));
$f->addFieldToTab('Root.Main', new HtmlEditorField('Footer', 'Footer'));
if ($this->owner->ID > 0) {
// sections
$config = GridFieldConfig_RecordEditor::create(50);
$config->removeComponentsByType('GridFieldAddNewButton');
$multi_class_selector = new GridFieldAddNewMultiClass();
$multi_class_selector->setClasses
(
[
'PaperSection' => 'Regular Section',
'CaseOfStudySection' => 'Case Of Study Section',
'IndexSection' => 'Index Section',
]
);
$config->addComponent($multi_class_selector);
$config->addComponent($sort = new GridFieldSortableRows('Order'));
$gridField = new GridField('Sections', 'Sections', $this->owner->Sections()->where('ParentSectionID = 0 OR ParentSectionID IS NULL')->sort('Order'), $config);
$f->addFieldToTab('Root.Sections', $gridField);
// translators
$config = GridFieldConfig_RecordEditor::create(50);
$translators = new GridField('Translators', 'Translators', $this->owner->Translators(), $config);
$f->addFieldToTab('Root.Translators', $translators);
}
}
}