1 | <?php |
||
9 | use SilverStripe\Forms\LiteralField; |
||
10 | use SilverStripe\Forms\TreeDropdownField; |
||
11 | use SilverStripe\ORM\DataObject; |
||
12 | |||
13 | /** |
||
14 | * |
||
15 | *@author nicolaas[at]sunnysideup.co.nz |
||
16 | *@description: creates a list of places where people can follow you (e.g. twitter, your blog, etc...) |
||
17 | * |
||
18 | */ |
||
19 | class SocialNetworkingLinksDataObject extends DataObject |
||
20 | { |
||
21 | private static $db = array( |
||
22 | 'URL' => 'Varchar(255)', |
||
23 | 'Title' => 'Varchar(255)', |
||
24 | 'Sort' => 'Int' |
||
25 | ); |
||
26 | |||
27 | private static $casting = array( |
||
28 | 'Code' => 'Varchar(255)', |
||
29 | 'Link' => 'Varchar(255)', |
||
30 | 'IconHTML' => 'HTMLText' |
||
31 | ); |
||
32 | |||
33 | private static $has_one = array( |
||
34 | 'Icon' => Image::class, |
||
35 | 'InternalLink' => 'Page' |
||
36 | ); |
||
37 | |||
38 | private static $searchable_fields = array( |
||
39 | 'Title' => 'PartialMatchFilter' |
||
40 | ); |
||
41 | |||
42 | private static $field_labels = array( |
||
43 | 'InternalLink' => 'Internal Link', |
||
44 | 'URL' => 'OR External Link (e.g. http://twitter.com/myname/) - will override internal link', |
||
45 | 'Title' => 'Title', |
||
46 | 'Sort' => 'Sort Index (lower numbers shown first)', |
||
47 | 'IconID' => 'Icon (preferably something like 32pixels by 32pixels)' |
||
48 | ); |
||
49 | |||
50 | private static $summary_fields = array( |
||
51 | 'Title' => 'Title', |
||
52 | 'IconHTML' => 'HTMLText' |
||
53 | ); |
||
54 | |||
55 | private static $default_sort = 'Sort ASC, Title ASC'; |
||
56 | |||
57 | private static $singular_name = 'Join Us link'; |
||
58 | |||
59 | private static $plural_name = 'Join Us links'; |
||
60 | |||
61 | public function canView($member = null) |
||
65 | |||
66 | public function canCreate($member = null, $context = []) |
||
70 | |||
71 | public function canEdit($member = null) |
||
75 | |||
76 | public function canDelete($member = null) |
||
80 | |||
81 | /** |
||
82 | * @return String - returns the title with all non-alphanumeric + spaces removed. |
||
83 | */ |
||
84 | public function Code() |
||
88 | |||
89 | public function IconHTML() |
||
103 | |||
104 | public function Link() |
||
115 | |||
116 | public function getCMSFields() |
||
117 | { |
||
118 | $fields = parent::getCMSFields(); |
||
119 | if ($this->ID) { |
||
129 |
Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a
@return
annotation as described here.