-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathCompanyEditForm.php
More file actions
100 lines (90 loc) · 4.5 KB
/
Copy pathCompanyEditForm.php
File metadata and controls
100 lines (90 loc) · 4.5 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php
/**
* Copyright 2014 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 CompanyEditForm extends BootstrapForm
{
function __construct($controller, $name, $company)
{
// Define fields //////////////////////////////////////
if ($company->canEditProfile()) {
$fields = new FieldList (
new TextField('Name', 'Company Name'),
new TextField ('URL', 'Company Web Address (URL)'),
new LiteralField('Break', '<p></p>'),
new LiteralField('Break', '<hr/>'),
$big_logo = FileAttachmentField::create('BigLogo', 'Large Company Logo'),
$small_logo = FileAttachmentField::create('Logo', 'Small Company Logo'),
new LiteralField('Break', '<p></p>'),
new LiteralField('Break', '<hr/>'),
new TextField('Industry', 'Industry (less than 4 Words)'),
$desc = new HtmlEditorField('Description', 'Company Description'),
new LiteralField('Break', '<p></p>'),
$contrib = new HtmlEditorField('Contributions', 'How you are contributing to OpenStack (less than 150 words)'),
new LiteralField('Break', '<p></p>'),
$products = new HtmlEditorField('Products', 'Products/Services Related to OpenStack (less than 100 words)'),
new LiteralField('Break', '<p></p>'),
new LiteralField('Break', '<p></p>'),
new ColorField("Color","Company Color"),
new LiteralField('Break', '<p></p>'),
new LiteralField('Break', '<hr/>'),
new TextField('ContactEmail', 'Best Contact email address (optional)'),
new LiteralField('Break', '<p>This email address will be displayed on your profile and may be different than your own address.')
);
$desc->addExtraClass("company-description");
$contrib->addExtraClass("company-contributions");
$products->addExtraClass("company-products");
$big_logo_validator = new Upload_Image_Validator();
$big_logo_validator->setAllowedExtensions(array('jpg','png','jpeg'));
$big_logo_validator->setAllowedMaxImageWidth(500);
$big_logo->setAcceptedFiles(array('jpg','png','jpeg'));
$big_logo->setView('grid');
$big_logo->setFolderName('companies/main_logo');
$big_logo->setValidator($big_logo_validator);
$small_logo_validator = new Upload_Image_Validator();
$small_logo_validator->setAllowedExtensions(array('jpg','png','jpeg'));
$small_logo_validator->setAllowedMaxImageWidth(200);
$small_logo->setAcceptedFiles(array('jpg','png','jpeg'));
$small_logo->setView('grid');
$small_logo->setFolderName('companies/main_logo');
$small_logo->setValidator($small_logo_validator);
} else if ($company->canEditLogo()) {
$fields = new FieldList (
new ReadonlyField('Name', 'Company Name'),
new ReadonlyField ('URL', 'Company Web Address (URL)'),
new LiteralField('Break', '<p></p>'),
new LiteralField('Break', '<hr/>'),
new CustomUploadField('BigLogo', 'Large Company Logo'),
new CustomUploadField('Logo', 'Small Company Logo')
);
}
$actionButton = new FormAction('save', 'Save Changes');
//$actionButton->addExtraClass('btn green-btn');
$actions = new FieldList(
$actionButton
);
parent::__construct($controller, $name, $fields, $actions);
// tiny MCE Config
$tinyMCE = HtmlEditorConfig::get('cms');
$tinyMCE->setOption('resize', 'false');
$tinyMCE->setOption('menubar', 'false');
$tinyMCE->setOption('statusbar', 'false');
$tinyMCE->setOption('setup', 'OnSetupTinyCompanyEditForm');
}
function forTemplate()
{
return $this->renderWith(array(
$this->class,
'Form'
));
}
}