-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathMascot.php
More file actions
103 lines (89 loc) · 2.71 KB
/
Copy pathMascot.php
File metadata and controls
103 lines (89 loc) · 2.71 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
101
102
103
<?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 Mascot
*/
class Mascot extends DataObject implements IMascot
{
private static $create_table_options = array('MySQLDatabase' => 'ENGINE=InnoDB');
private static $db = array
(
'Name' => 'Varchar(255)',
'CodeName' => 'Varchar(255)',
'Hide' => 'Boolean',
);
private static $belongs_to = array
(
"OpenStackComponent" => "OpenStackComponent.Mascot"
);
private static $summary_fields = array
(
'Name' => 'Name',
'CodeName' => 'Code Name',
'OpenStackComponent.CodeName' => 'Component',
'Hide' => 'Hide',
);
static $mascots_folder = 'project-mascots';
static $mascots_dir = "images/project-mascots";
/**
* @return int
*/
public function getIdentifier()
{
return (int)$this->getField('ID');
}
/**
* @param FieldList $fields
* @return FieldList|void
*/
public function updateCMSFields(FieldList $fields)
{
$oldFields = $fields->toArray();
foreach ($oldFields as $field) {
$fields->remove($field);
}
$fields->push(new LiteralField("Title", "<h2>OpenStack Component Mascot</h2>"));
$fields->push(new TextField("Name", "Name"));
$fields->push(new TextField("CodeName", "Code Name"));
$fields->push(new CheckboxField('Hide', 'Hide Mascot?'));
return $fields;
}
public function getCodeName()
{
if ($this->OpenStackComponent()->Exists())
return $this->OpenStackComponent()->CodeName;
else if ($this->getField('CodeName'))
return $this->getField('CodeName');
else
return null;
}
/**
* @return null|string
*/
public function getImageDir()
{
if ($this->getCodeName())
return CloudAssetTemplateHelpers::cloud_url(self::$mascots_dir).'/'. $this->getCodeName();
return null;
}
/**
* @return null|string
*/
public function getRelativeImageDir()
{
if ($this->getCodeName())
return self::$mascots_dir.'/'. $this->getCodeName();
return null;
}
}