Issues (96)

src/TypographyController.php (4 issues)

1
<?php
2
3
namespace LeKoala\DevToolkit;
4
5
use SilverStripe\Forms\Form;
6
use SilverStripe\Assets\Image;
7
use SilverStripe\Control\Controller;
8
use SilverStripe\Forms\DateField;
9
use SilverStripe\Forms\FieldList;
10
use SilverStripe\Forms\TextField;
11
use SilverStripe\Forms\EmailField;
12
use SilverStripe\Forms\FieldGroup;
13
use SilverStripe\Forms\FormAction;
14
use SilverStripe\Forms\HeaderField;
15
use SilverStripe\Forms\LiteralField;
16
use SilverStripe\Forms\NumericField;
17
use SilverStripe\Control\HTTPRequest;
18
use SilverStripe\Forms\CheckboxField;
19
use SilverStripe\Forms\CurrencyField;
20
use SilverStripe\Forms\DateTimeField;
21
use SilverStripe\Forms\DropdownField;
22
use SilverStripe\Forms\TextareaField;
23
use SilverStripe\Forms\OptionsetField;
24
use SilverStripe\Forms\RequiredFields;
25
use SilverStripe\Forms\CheckboxSetField;
26
27
/**
28
 * A typography test page
29
 *
30
 * @link https://github.com/axllent/silverstripe-typography/blob/master/src/TypographyController.php
31
 * @link https://github.com/sunnysideup/silverstripe-typography
32
 */
33
class TypographyController extends Controller
34
{
35
    public function index(HTTPRequest $request = null)
0 ignored issues
show
The parameter $request is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

35
    public function index(/** @scrutinizer ignore-unused */ HTTPRequest $request = null)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
36
    {
37
        $this->Title = 'Typography test page';
0 ignored issues
show
Bug Best Practice introduced by
The property Title does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
38
        $this->ExtraMeta .= '<meta name="robots" content="noindex, nofollow" />';
0 ignored issues
show
Bug Best Practice introduced by
The property ExtraMeta does not exist on LeKoala\DevToolkit\TypographyController. Since you implemented __get, consider adding a @property annotation.
Loading history...
39
40
        return $this->renderWith(array('Typography', 'Page'));
41
    }
42
    public function RandomImage()
43
    {
44
        return Image::get()->sort('RAND()')->first();
45
    }
46
    public function TypoForm()
47
    {
48
        $array = array('green', 'yellow', 'blue', 'pink', 'orange');
49
        $form = new Form(
50
            $this,
51
            'TestForm',
52
            $fields = FieldList::create(
53
                HeaderField::create('HeaderField1', 'HeaderField Level 1', 1),
54
                LiteralField::create('LiteralField', '<p>All fields up to EmailField are required and should be marked as such</p>'),
55
                TextField::create('TextField1', 'Text Field Example 1'),
56
                TextField::create('TextField2', 'Text Field Example 2'),
57
                TextField::create('TextField3', 'Text Field Example 3'),
58
                TextField::create('TextField4', ''),
59
                HeaderField::create('FieldGroupHdr', 'First/last name FieldGroup'),
60
                FieldGroup::create(
61
                    TextField::create('FirstName1', 'First Name'),
62
                    TextField::create('LastName1', 'Last Name')
63
                ),
64
                HeaderField::create('HeaderField2b', 'Field with right title', 2),
65
                TextareaField::create('TextareaField', 'Textarea Field')
66
                    ->setColumns(45)
67
                    ->setRightTitle('This is the right title'),
68
                EmailField::create('EmailField', 'Email address'),
69
                HeaderField::create('HeaderField2c', 'HeaderField Level 2', 2),
70
                DropdownField::create('DropdownField', 'Dropdown Field', array(0 => '-- please select --', 1 => 'test AAAA', 2 => 'test BBBB')),
71
                OptionsetField::create('OptionSF', 'Optionset Field', $array),
72
                CheckboxSetField::create('CheckboxSF', 'Checkbox Set Field', $array),
73
                CurrencyField::create('CurrencyField', 'Bling bling', '$123.45'),
74
                HeaderField::create('HeaderField3', 'Other Fields', 3),
75
                NumericField::create('NumericField', 'Numeric Field '),
76
                DateField::create('DateField', 'Date Field'),
77
                DateTimeField::create('DateTimeField', 'Date and Time Field'),
78
                CheckboxField::create('CheckboxField', 'Checkbox Field')
79
            ),
80
            $actions = FieldList::create(
81
                FormAction::create('submit', 'Submit Button')
82
            ),
83
            $requiredFields = RequiredFields::create(
84
                'TextField1',
85
                'TextField2',
86
                'TextField3',
87
                'ErrorField1',
88
                'ErrorField2',
89
                'EmailField',
90
                'TextField3',
91
                'RightTitleField',
92
                'CheckboxField',
93
                'CheckboxSetField'
94
            )
95
        );
96
        $form->setMessage('warning message', 'warning');
97
        return $form;
98
    }
99
    public function TestForm($data)
0 ignored issues
show
The parameter $data is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

99
    public function TestForm(/** @scrutinizer ignore-unused */ $data)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
100
    {
101
        $this->redirectBack();
102
    }
103
}
104