1 | <?php |
||
2 | |||
3 | namespace SilverStripe\DocumentConverter; |
||
4 | |||
5 | use InvalidArgumentException; |
||
6 | use SilverStripe\Assets\Folder; |
||
7 | use SilverStripe\Forms\CheckboxField; |
||
8 | use SilverStripe\Forms\CompositeField; |
||
9 | use SilverStripe\Forms\DropdownField; |
||
10 | use SilverStripe\Forms\FieldList; |
||
11 | use SilverStripe\Forms\HeaderField; |
||
12 | use SilverStripe\Forms\LiteralField; |
||
13 | use SilverStripe\Forms\TreeDropdownField; |
||
14 | use SilverStripe\View\Requirements; |
||
15 | |||
16 | /** |
||
17 | * Provides a document import capability through the use of an external service. |
||
18 | * Includes several options fields, which are bundled together with an UploadField |
||
19 | * into a CompositeField. |
||
20 | */ |
||
21 | class SettingsField extends CompositeField |
||
22 | { |
||
23 | /** |
||
24 | * Reference to the inner upload field (ImportField). |
||
25 | */ |
||
26 | private $innerField = null; |
||
27 | |||
28 | /** |
||
29 | * Augments a simple CompositeField with uploader and import options. |
||
30 | * |
||
31 | * @param $children FieldSet/array Any additional children. |
||
32 | */ |
||
33 | public function __construct($children = null) |
||
34 | { |
||
35 | if ($children) { |
||
36 | $class = get_class(); |
||
37 | throw new InvalidArgumentException( |
||
38 | "${class}::__construct does not accept extra parameters." |
||
39 | ); |
||
40 | } |
||
41 | |||
42 | // Add JS specific to this field. |
||
43 | Requirements::javascript('silverstripe/documentconverter: javascript/DocumentConversionField.js'); |
||
44 | |||
45 | $fields = FieldList::create([ |
||
46 | LiteralField::create( |
||
47 | 'FileWarningHeader', |
||
48 | '<div class="alert alert-warning">' . _t( |
||
49 | __CLASS__ . '.FileWarningHeader', |
||
50 | 'Warning: import will remove all content and subpages of this page.' |
||
51 | ) . '</div>', |
||
52 | 4 |
||
53 | ), |
||
54 | $splitHeader = DropdownField::create( |
||
55 | 'DocumentConversionSettings-SplitHeader', |
||
56 | _t( |
||
57 | __CLASS__ . '.SplitHeader', |
||
58 | 'Split document into pages' |
||
59 | ), |
||
60 | [ |
||
61 | 0 => _t(__CLASS__ . '.No', 'no'), |
||
62 | 1 => _t(__CLASS__ . '.EachH1', 'for each heading 1'), |
||
63 | 2 => _t(__CLASS__ . '.EachH2', 'for each heading 2') |
||
64 | ] |
||
65 | ), |
||
66 | $keepSource = CheckboxField::create( |
||
67 | 'DocumentConversionSettings-KeepSource', |
||
68 | _t( |
||
69 | __CLASS__ . '.KeepSource', |
||
70 | 'Keep the original document. Adds a link to it on TOC, if enabled.' |
||
71 | ) |
||
72 | ), |
||
73 | $chosenFolderID = TreeDropdownField::create( |
||
74 | 'DocumentConversionSettings-ChosenFolderID', |
||
75 | _t(__CLASS__ . '.ChooseFolder', 'Choose a folder to save this file'), |
||
76 | Folder::class |
||
77 | ), |
||
78 | $includeTOC = CheckboxField::create( |
||
79 | 'DocumentConversionSettings-IncludeTOC', |
||
80 | _t(__CLASS__ . '.IncludeTOC', 'Replace this page with a Table of Contents.') |
||
81 | ), |
||
82 | $publishPages = CheckboxField::create( |
||
83 | 'DocumentConversionSettings-PublishPages', |
||
84 | _t( |
||
85 | __CLASS__ . '.publishPages', |
||
86 | 'Publish modified pages (not recommended unless you are sure about the conversion outcome)' |
||
87 | ) |
||
88 | ), |
||
89 | $this->innerField = ImportField::create( |
||
90 | 'ImportedFromFile', |
||
91 | _t(__CLASS__ . '.ImportedFromFile', 'Import content from a word document') |
||
92 | ) |
||
93 | ]); |
||
94 | |||
95 | // Prevent the warning popup that appears when navigating away from the page. |
||
96 | $splitHeader->addExtraClass('no-change-track'); |
||
97 | $keepSource->addExtraClass('no-change-track'); |
||
98 | $chosenFolderID->addExtraClass('no-change-track'); |
||
99 | $includeTOC->addExtraClass('no-change-track'); |
||
100 | $publishPages->addExtraClass('no-change-track'); |
||
101 | |||
102 | return parent::__construct($fields); |
||
0 ignored issues
–
show
|
|||
103 | } |
||
104 | |||
105 | public function getInnerField() |
||
106 | { |
||
107 | return $this->innerField; |
||
108 | } |
||
109 | } |
||
110 |
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.