1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
@ see http://code.google.com/p/swfobject/wiki/documentation |
4
|
|
|
@ see http://www.swffix.org/swfobject/generator/ |
5
|
|
|
*/ |
6
|
|
|
|
7
|
|
|
class FlashObjectDOD extends SiteTreeDecorator |
8
|
|
|
{ |
9
|
|
|
public function extraStatics() |
10
|
|
|
{ |
11
|
|
|
return array( |
12
|
|
|
'db' => array( |
13
|
|
|
"Title" => "Varchar(255)" |
14
|
|
|
), |
15
|
|
|
'has_one' => array( |
16
|
|
|
"FlashFile" => "File" |
17
|
|
|
), |
18
|
|
|
); |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
protected static $classes_with_flash = array(); |
22
|
|
|
public static function set_classes_with_flash($v) |
23
|
|
|
{ |
24
|
|
|
self::$classes_with_flash = $v; |
25
|
|
|
} |
26
|
|
|
public static function get_classes_with_flash() |
27
|
|
|
{ |
28
|
|
|
return self::$classes_with_flash; |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
protected static $classes_without_flash = array(); |
32
|
|
|
public static function set_classes_without_flash($v) |
33
|
|
|
{ |
34
|
|
|
self::$classes_without_flash = $v; |
35
|
|
|
} |
36
|
|
|
public static function get_classes_without_flash() |
37
|
|
|
{ |
38
|
|
|
return self::$classes_without_flash; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function updateCMSFields(FieldSet &$fields) |
42
|
|
|
{ |
43
|
|
|
if (! FlashObject::has_external_flash_file()) { |
44
|
|
|
$show = true; |
45
|
|
View Code Duplication |
if (is_array(self::get_classes_with_flash()) && count(self::get_classes_with_flash())) { |
|
|
|
|
46
|
|
|
if (!in_array($this->owner->ClassName, self::get_classes_with_flash())) { |
47
|
|
|
$show = false; |
48
|
|
|
} |
49
|
|
|
} |
50
|
|
View Code Duplication |
if (is_array(self::get_classes_without_flash()) && count(self::get_classes_without_flash())) { |
|
|
|
|
51
|
|
|
if (in_array($this->owner->ClassName, self::get_classes_without_flash())) { |
52
|
|
|
$show = false; |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
if ($show) { |
56
|
|
|
$fields->addFieldToTab("Root.Content.FlashObject", new FileIFrameField('FlashFile', 'File')); |
57
|
|
|
$fields->addFieldToTab("Root.Content.FlashObject", new TextField('Title', 'Title')); |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
return $fields; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
public function CreateFlashObject() |
64
|
|
|
{ |
65
|
|
|
if ($this->owner->FlashFileID) { |
66
|
|
|
$obj = new FlashObject(); |
67
|
|
|
$flashFile = $this->owner->FlashFile(); |
68
|
|
|
return $obj->CreateFlashObject($this->owner->Title, null, $flashFile->Filename); |
69
|
|
|
} else { |
70
|
|
|
return new DataObjectSet(); |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/* |
75
|
|
|
legacy function |
76
|
|
|
*/ |
77
|
|
|
|
78
|
|
|
public function FlashObjectData() |
79
|
|
|
{ |
80
|
|
|
return $this->CreateFlashObject(); |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.