1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
class Affiliation extends DataObject |
|
|
|
|
4
|
|
|
{ |
5
|
|
|
public static $db = array( |
6
|
|
|
"Title" => "Varchar(100)", |
7
|
|
|
"Code" => "Varchar(100)", |
8
|
|
|
"Link" => "Varchar(100)", |
9
|
|
|
"Sort" => "Int" |
10
|
|
|
); |
11
|
|
|
|
12
|
|
|
public static $has_one = array( |
13
|
|
|
"Parent" => "SiteTree", |
14
|
|
|
"Logo" => "Image" |
15
|
|
|
); |
16
|
|
|
|
17
|
|
|
public static function get_has_many_complex_table_field($controller, $name) |
18
|
|
|
{ |
19
|
|
|
return new HasManyComplexTableField( |
20
|
|
|
$controller, |
21
|
|
|
$name, |
22
|
|
|
"Affiliation", |
23
|
|
|
$fieldList = self::$summary_fields, |
24
|
|
|
$detailFormFields = null, |
25
|
|
|
$sourceFilter = "ParentID = ".$controller->ID, |
26
|
|
|
$sourceSort = "Sort ASC, Title ASC", |
27
|
|
|
$sourceJoin = "" |
28
|
|
|
); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
public function getCode() |
32
|
|
|
{ |
33
|
|
|
if (!$this->getField("Code")) { |
34
|
|
|
return _t('Affiliation.GETCMSAFFLIATIONIDPREFIX', 'Affiliation').$this->ID; |
|
|
|
|
35
|
|
|
} |
36
|
|
|
return $this->getField("Code"); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public static $searchable_fields = array( |
40
|
|
|
"Title" => "PartialMatchFilter", |
41
|
|
|
"Code" => "PartialMatchFilter", |
42
|
|
|
"Link" => "PartialMatchFilter" |
43
|
|
|
); |
44
|
|
|
|
45
|
|
|
public static $summary_fields = array( |
46
|
|
|
"Title" => "Title", |
47
|
|
|
"Code" => "Code", |
48
|
|
|
"Link" => "Link" |
49
|
|
|
); |
50
|
|
|
|
51
|
|
|
public static $field_labels = array( |
52
|
|
|
"Sort" => "Sorting Index Number (lower numbers show first)" |
53
|
|
|
); |
54
|
|
|
|
55
|
|
|
public static $singular_name = "Affiliation"; |
56
|
|
|
|
57
|
|
|
public static $plural_name = "Affiliations"; |
58
|
|
|
//CRUD settings |
59
|
|
|
|
60
|
|
|
public static $default_sort = "Sort ASC, Title ASC"; |
61
|
|
|
|
62
|
|
|
public static $defaults = array( |
63
|
|
|
"Sort" => 100 |
64
|
|
|
); |
65
|
|
|
|
66
|
|
|
public function populateDefaults() |
67
|
|
|
{ |
68
|
|
|
$this->Sort = 100; |
|
|
|
|
69
|
|
|
parent::populateDefaults(); |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.