FlashObjectDOD::set_classes_with_flash()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
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
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
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())) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

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.

Loading history...
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())) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

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.

Loading history...
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