1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Extends the original toolbar with document picking capability - modified lines are commented. |
4
|
|
|
*/ |
5
|
|
|
class DocumentHtmlEditorFieldToolbar extends Extension |
6
|
|
|
{ |
7
|
|
|
public function updateLinkForm(Form $form) |
8
|
|
|
{ |
9
|
|
|
$linkType = null; |
10
|
|
|
$fieldList = null; |
11
|
|
|
$fields = $form->Fields();//->fieldByName('Heading'); |
12
|
|
|
foreach ($fields as $field) { |
|
|
|
|
13
|
|
|
$linkType = ($field->fieldByName('LinkType')); |
14
|
|
|
$fieldList = $field; |
15
|
|
|
if ($linkType) { |
16
|
|
|
break; |
17
|
|
|
} //break once we have the object |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
$source = $linkType->getSource(); |
21
|
|
|
$source['document'] = 'Download a document'; |
22
|
|
|
$linkType->setSource($source); |
23
|
|
|
|
24
|
|
|
$addExistingField = new DMSDocumentAddExistingField('AddExisting', 'Add Existing'); |
25
|
|
|
$addExistingField->setForm($form); |
26
|
|
|
$addExistingField->setUseFieldClass(false); |
27
|
|
|
$fieldList->insertAfter($addExistingField, 'Description'); |
28
|
|
|
|
29
|
|
|
$fieldList->push(HiddenField::create('DMSShortcodeHandlerKey', false, DMS::inst()->getShortcodeHandlerKey())); |
30
|
|
|
|
31
|
|
|
// Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/behaviour/behaviour.js"); |
32
|
|
|
// Requirements::javascript(SAPPHIRE_DIR . "/javascript/tiny_mce_improvements.js"); |
33
|
|
|
// |
34
|
|
|
// // create additional field, rebase to 'documents' directory |
35
|
|
|
// $documents = new TreeDropdownField('document', 'Document', 'File', 'ID', 'DocumentDropdownTitle', true); |
36
|
|
|
// $documents->setSearchFunction(array($this, 'documentSearchCallback')); |
37
|
|
|
// $baseFolder = Folder::find_or_make(Document::$directory); |
38
|
|
|
// $documents->setTreeBaseID($baseFolder->ID); |
39
|
|
|
|
40
|
|
|
|
41
|
|
|
//return $form; |
42
|
|
|
} |
43
|
|
|
} |
44
|
|
|
|
There are different options of fixing this problem.
If you want to be on the safe side, you can add an additional type-check:
If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:
Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.