Completed
Push — master ( d88a7b...8a426a )
by Daniel
16s
created

InternalLinkFormFactory::getFormFields()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 23
rs 9.0856
c 0
b 0
f 0
cc 1
eloc 16
nc 1
nop 3
1
<?php
2
3
namespace SilverStripe\CMS\Forms;
4
5
use SilverStripe\Admin\Forms\LinkFormFactory;
6
use SilverStripe\CMS\Model\SiteTree;
7
use SilverStripe\Forms\CheckboxField;
8
use SilverStripe\Forms\FieldList;
9
use SilverStripe\Forms\TextField;
10
use SilverStripe\Forms\TreeDropdownField;
11
12
/**
13
 * Provides a form factory for inserting internal page links in a HTML editor
14
 */
15
class InternalLinkFormFactory extends LinkFormFactory
16
{
17
    protected function getFormFields($controller, $name, $context)
18
    {
19
        $fields = FieldList::create([
20
            TreeDropdownField::create(
21
                'PageID',
22
                _t(__CLASS__.'.SELECT_PAGE', 'Select a page'),
23
                SiteTree::class,
24
                'ID',
25
                'TreeTitle'
26
            ),
27
            TextField::create(
28
                'Description',
29
                _t(__CLASS__.'.LINKDESCR', 'Link description')
30
            ),
31
            TextField::create('Anchor', _t(__CLASS__.'.ANCHORVALUE', 'Anchor')),
32
            CheckboxField::create(
33
                'TargetBlank',
34
                _t(__CLASS__.'.LINKOPENNEWWIN', 'Open in new window/tab')
35
            ),
36
        ]);
37
38
        return $fields;
39
    }
40
}
41