GalleryPage_Controller   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 24
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A init() 0 18 2
1
<?php
2
3
class GalleryPage extends Page
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...
4
{
5
    /**
6
     * @var string
7
     */
8
    private static $icon = 'flex-images-gallery/images/icons/gallery.png';
0 ignored issues
show
Unused Code introduced by
The property $icon is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
9
10
    /**
11
     * @var string
12
     */
13
    private static $description = 'Gallery page';
0 ignored issues
show
Unused Code introduced by
The property $description is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
14
15
    /**
16
     * @var array
17
     */
18
    private static $db = array(
0 ignored issues
show
Unused Code introduced by
The property $db is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
19
        'Height' => 'int',
20
    );
21
22
    /**
23
     * @var array
24
     */
25
    private static $has_many = array(
0 ignored issues
show
Unused Code introduced by
The property $has_many is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
26
        'GalleryBlocks' => 'ContentBlock_Gallery',
27
    );
28
29
    /**
30
     * @var string
31
     */
32
    private static $many_many = array(
0 ignored issues
show
Unused Code introduced by
The property $many_many is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
33
        'Images' => 'Image',
34
    );
35
36
    /**
37
     * @return FieldList
38
     */
39
    public function getCMSFields()
40
    {
41
        $fields = parent::getCMSFields();
42
43
        // remove the content block
44
        $fields->removeByName('Content');
45
46
        // Add a gallery gridfield for the images.
47
        $fields->addFieldToTab(
48
            'Root.Main',
49
            SortableGalleryField::create('Images'),
50
            'Metadata'
51
        );
52
53
        // add configuration tab for the height
54
        $fields->addFieldsToTab(
55
            'Root.Configuration',
56
            array(
57
                NoticeMessage::create('This value defines the height of an image row (in pixel).'),
58
                TextField::create('Height'),
59
            )
60
        );
61
62
        return $fields;
63
    }
64
}
65
66
class GalleryPage_Controller extends Page_Controller
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
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...
67
{
68
    /**
69
     * add the requirements
70
     */
71
    public function init()
72
    {
73
        parent::init();
74
75
        // add the used libs in.
76
        Requirements::css(FLEX_IMAGES_GALLERY_MODULE_DIR . '/css/styles.css');
77
        Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
78
        Requirements::javascript(FLEX_IMAGES_GALLERY_MODULE_DIR . '/javascript/jquery.flex-images.js');
79
        Requirements::javascript(FLEX_IMAGES_GALLERY_MODULE_DIR . '/javascript/lightbox.js');
80
81
        // add the defined rowHeight to the js file
82
        Requirements::javascriptTemplate(
83
            FLEX_IMAGES_GALLERY_MODULE_DIR . '/javascript/GalleryPage.template.js',
84
            array(
85
                'rowHeight' => ($this->Height) ? $this->Height : 180,
86
            )
87
        );
88
    }
89
}
90