Issues (31)

src/ImageTextElement.php (31 issues)

1
<?php
2
namespace DorsetDigital\Elements;
3
4
use DNADesign\Elemental\Models\BaseElement;
5
use SilverStripe\AssetAdmin\Forms\UploadField;
6
use SilverStripe\Assets\Image;
7
use SilverStripe\Forms\DropdownField;
8
use SilverStripe\Forms\HTMLEditor\HTMLEditorField;
9
use SilverStripe\Forms\TextField;
10
use SilverStripe\ORM\FieldType\DBField;
11
12
13
class ImageTextElement extends BaseElement
14
{
15
16
    private static $singular_name = 'Text & Image Block';
0 ignored issues
show
The private property $singular_name is not used, and could be removed.
Loading history...
17
    private static $plural_name = 'Text & Image Blocks';
0 ignored issues
show
The private property $plural_name is not used, and could be removed.
Loading history...
18
    private static $description = 'Adds a block of text with accompanying image';
0 ignored issues
show
The private property $description is not used, and could be removed.
Loading history...
19
    private static $table_name = 'DorsetDigital_Elements_ImageText';
0 ignored issues
show
The private property $table_name is not used, and could be removed.
Loading history...
20
    private static $db = [
0 ignored issues
show
The private property $db is not used, and could be removed.
Loading history...
21
        'Content' => 'HTMLText',
0 ignored issues
show
This array key does not seem to be aligned correctly; expected 26 spaces, but found 8.
Loading history...
22
        'ImagePosition' => 'Varchar(10)',
0 ignored issues
show
This array key does not seem to be aligned correctly; expected 26 spaces, but found 8.
Loading history...
23
        'ImageAlt' => 'Varchar(255)',
0 ignored issues
show
This array key does not seem to be aligned correctly; expected 26 spaces, but found 8.
Loading history...
24
        'ImageWidth' => 'Varchar(10)'
0 ignored issues
show
This array key does not seem to be aligned correctly; expected 26 spaces, but found 8.
Loading history...
25
    ];
0 ignored issues
show
The closing parenthesis does not seem to be aligned correctly; expected 25 space(s), but found 4.
Loading history...
26
    private static $many_many = [
0 ignored issues
show
The private property $many_many is not used, and could be removed.
Loading history...
27
        'Image' => Image::class
0 ignored issues
show
This array key does not seem to be aligned correctly; expected 33 spaces, but found 8.
Loading history...
28
    ];
0 ignored issues
show
The closing parenthesis does not seem to be aligned correctly; expected 32 space(s), but found 4.
Loading history...
29
    private static $owns = [
0 ignored issues
show
The private property $owns is not used, and could be removed.
Loading history...
Multi-line array contains a single value; use single-line array instead
Loading history...
30
        'Image'
31
    ];
0 ignored issues
show
The closing parenthesis does not seem to be aligned correctly; expected 27 space(s), but found 4.
Loading history...
32
    private static $inline_editable = false;
0 ignored issues
show
The private property $inline_editable is not used, and could be removed.
Loading history...
33
34
    private static $sizes = [
0 ignored issues
show
The private property $sizes is not used, and could be removed.
Loading history...
35
        'half' => '1/2 page width',
0 ignored issues
show
This array key does not seem to be aligned correctly; expected 29 spaces, but found 8.
Loading history...
36
        'third' => '1/3 page width',
0 ignored issues
show
This array key does not seem to be aligned correctly; expected 29 spaces, but found 8.
Loading history...
37
        'quarter' => '1/4 page width',
0 ignored issues
show
This array key does not seem to be aligned correctly; expected 29 spaces, but found 8.
Loading history...
38
        'sixth' => '1/6 page width'
0 ignored issues
show
This array key does not seem to be aligned correctly; expected 29 spaces, but found 8.
Loading history...
39
    ];
0 ignored issues
show
The closing parenthesis does not seem to be aligned correctly; expected 28 space(s), but found 4.
Loading history...
40
41
42
    public function getCMSFields()
0 ignored issues
show
This method is not in camel caps format.

This check looks for method names that are not written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection seeker becomes databaseConnectionSeeker.

Loading history...
43
    {
44
        $fields = parent::getCMSFields();
45
        $fields->addFieldsToTab('Root.Main', [
46
            HTMLEditorField::create('Content'),
0 ignored issues
show
This array value does not seem to be aligned correcty; expected 46 spaces, but found 12.
Loading history...
47
            UploadField::create('Image')
0 ignored issues
show
This array value does not seem to be aligned correcty; expected 46 spaces, but found 12.
Loading history...
48
                ->setAllowedFileCategories('image/supported')
49
                ->setFolderName('pageimages')
50
                ->setAllowedMaxFileNumber(1),
51
            DropdownField::create('ImagePosition')
0 ignored issues
show
This array value does not seem to be aligned correcty; expected 46 spaces, but found 12.
Loading history...
52
                ->setSource([ 'after' => 'After Content', 'before' => 'Before Content' ]),
53
            TextField::create('ImageAlt')->setTitle('Alt text for the image'),
0 ignored issues
show
This array value does not seem to be aligned correcty; expected 46 spaces, but found 12.
Loading history...
54
            DropdownField::create('ImageWidth')
55
                ->setSource($this->config()->get('sizes'))
56
                ->setDescription('Relative image size on larger screens.  On smaller screens the image will flow before or after the text content, instead of sitting next to it.')
0 ignored issues
show
There should be a trailing comma after the last value of an array declaration.
Loading history...
57
        ]);
0 ignored issues
show
The closing parenthesis does not seem to be aligned correctly; expected 45 space(s), but found 8.
Loading history...
58
        return $fields;
59
    }
0 ignored issues
show
Expected 2 blank lines after function; 1 found
Loading history...
60
61
    public function getType()
62
    {
63
        return 'Image & Text';
64
    }
65
66
67
}
68