ClickMenu.php 68.8 KB
Newer Older
1
2
3
<?php
namespace TYPO3\CMS\Backend\ClickMenu;

4
/*
5
 * This file is part of the TYPO3 CMS project.
6
 *
7
8
9
 * It is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License, either version 2
 * of the License, or any later version.
10
 *
11
12
 * For the full copyright and license information, please read the
 * LICENSE.txt file that was distributed with this source code.
13
 *
14
15
 * The TYPO3 project - inspiring people to share!
 */
16

17
use TYPO3\CMS\Backend\Clipboard\Clipboard;
18
use TYPO3\CMS\Backend\Utility\BackendUtility;
19
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
20
21
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory;
22
use TYPO3\CMS\Core\Resource\Folder;
Nicole Cordes's avatar
Nicole Cordes committed
23
use TYPO3\CMS\Core\Resource\ResourceFactory;
24
25
use TYPO3\CMS\Core\Type\Bitmask\JsConfirmation;
use TYPO3\CMS\Core\Type\Bitmask\Permission;
Nicole Cordes's avatar
Nicole Cordes committed
26
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
27
use TYPO3\CMS\Core\Utility\GeneralUtility;
28
use TYPO3\CMS\Lang\LanguageService;
29
30
31
32
33

/**
 * Class for generating the click menu
 * @internal
 */
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
class ClickMenu
{
    /**
     * Defines if the click menu is first level or second.
     * Second means the click menu is triggered from another menu.
     *
     * @var int
     */
    public $cmLevel = 0;

    /**
     * Clipboard array (submitted by eg. pressing the paste button)
     *
     * @var bool
     */
    public $CB;

    /**
     * If set, the calling document should be in the listframe of a frameset.
     *
     * @var bool
     */
    public $listFrame = false;

    /**
     * If set, the menu is about database records, not files. (set if part 2 [1] of the item-var is NOT blank)
     *
     * @var bool
     */
    public $isDBmenu = false;

    /**
     * Stores the parts of the input $item string, splitted by "|":
     * [0] = table/file, [1] = uid/blank, [2] = flag: If set, listFrame,
     * If "2" then "content frame" is forced  [3] = ("+" prefix = disable
     * all by default, enable these. Default is to disable) Items key list
     *
     * @var array
     */
73
    public $iParts = [];
74
75
76
77
78
79

    /**
     * Contains list of keywords of items to disable in the menu
     *
     * @var array
     */
80
    public $disabledItems = [];
81
82
83
84
85
86
87

    /**
     * Array of classes to be used for user processing of the menu content.
     * This is for the API of adding items to the menu from outside.
     *
     * @var array
     */
88
    public $extClassArray = [];
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108

    /**
     * Set, when edit icon is drawn.
     *
     * @var bool
     */
    public $editPageIconSet = false;

    /**
     * Set to TRUE, if editing of the element is OK.
     *
     * @var bool
     */
    public $editOK = false;

    /**
     * The current record
     *
     * @var array
     */
109
    public $rec = [];
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155

    /**
     * Clipboard set from the outside
     * Declared as public for now, should become protected
     * soon-ish
     * @var Clipboard;
     */
    public $clipObj;

    /**
     * The current page record
     * @var array
     */
    protected $pageinfo;

    /**
     * Language Service property. Used to access localized labels
     *
     * @var LanguageService
     */
    protected $languageService;

    /**
     * @var BackendUserAuthentication
     */
    protected $backendUser;

    /**
     * @var IconFactory
     */
    protected $iconFactory;

    /**
     * @param LanguageService $languageService Language Service to inject
     * @param BackendUserAuthentication $backendUser
     */
    public function __construct(LanguageService $languageService = null, BackendUserAuthentication $backendUser = null)
    {
        $this->languageService = $languageService ?: $GLOBALS['LANG'];
        $this->backendUser = $backendUser ?: $GLOBALS['BE_USER'];
        $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
    }

    /**
     * Initialize click menu
     *
156
     * @return array the array to be returned as JSON including all click menu items
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
     */
    public function init()
    {
        $CMcontent = '';
        // Setting GPvars:
        $this->cmLevel = (int)GeneralUtility::_GP('cmLevel');
        $this->CB = GeneralUtility::_GP('CB');

        // Deal with Drag&Drop context menus
        if ((string)GeneralUtility::_GP('dragDrop') !== '') {
            return $this->printDragDropClickMenu(GeneralUtility::_GP('dragDrop'), GeneralUtility::_GP('srcId'), GeneralUtility::_GP('dstId'));
        }
        // Can be set differently as well
        $this->iParts[0] = GeneralUtility::_GP('table');
        $this->iParts[1] = GeneralUtility::_GP('uid');
        $this->iParts[2] = GeneralUtility::_GP('listFr');
        $this->iParts[3] = GeneralUtility::_GP('enDisItems');
        // Setting flags:
        if ($this->iParts[2]) {
            $this->listFrame = true;
        }
        if (isset($this->iParts[1]) && $this->iParts[1] !== '') {
            $this->isDBmenu = true;
        }
        $TSkey = ($this->isDBmenu ? 'page' : 'folder') . ($this->listFrame ? 'List' : 'Tree');
        $this->disabledItems = GeneralUtility::trimExplode(',', $this->backendUser->getTSConfigVal('options.contextMenu.' . $TSkey . '.disableItems'), true);
        // &cmLevel flag detected (2nd level menu)
        if (!$this->cmLevel) {
            // Make 1st level clickmenu:
            if ($this->isDBmenu) {
                $CMcontent = $this->printDBClickMenu($this->iParts[0], $this->iParts[1]);
            } else {
                $CMcontent = $this->printFileClickMenu($this->iParts[0]);
            }
        } else {
            // Make 2nd level clickmenu (only for DBmenus)
            if ($this->isDBmenu) {
                $CMcontent = $this->printNewDBLevel($this->iParts[0], $this->iParts[1]);
            }
        }
        // Return clickmenu content:
        return $CMcontent;
    }

    /***************************************
     *
     * DATABASE
     *
     ***************************************/
    /**
     * Make 1st level clickmenu:
     *
     * @param string $table Table name
     * @param int $uid UID for the current record.
211
     * @return array the array to be returned as JSON
212
213
214
215
216
217
     */
    public function printDBClickMenu($table, $uid)
    {
        $uid = (int)$uid;
        // Get record:
        $this->rec = BackendUtility::getRecordWSOL($table, $uid);
218
        $menuItems = [];
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
        $root = 0;
        $DBmount = false;
        // Rootlevel
        if ($table === 'pages' && $uid === 0) {
            $root = 1;
        }
        // DB mount
        if ($table === 'pages' && in_array($uid, $this->backendUser->returnWebmounts())) {
            $DBmount = true;
        }
        // Used to hide cut,copy icons for l10n-records
        $l10nOverlay = false;
        // Should only be performed for overlay-records within the same table
        if (BackendUtility::isTableLocalizable($table) && !isset($GLOBALS['TCA'][$table]['ctrl']['transOrigPointerTable'])) {
            $l10nOverlay = (int)$this->rec[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] != 0;
        }
        // If record found (or root), go ahead and fill the $menuItems array which will contain data for the elements to render.
        if (is_array($this->rec) || $root) {
            // Get permissions
238
            $lCP = $this->backendUser->calcPerms(BackendUtility::getRecord('pages', $table === 'pages' ? (int)$this->rec['uid'] : (int)$this->rec['pid']));
239
240
241
242
243
244
            // View
            if (!in_array('view', $this->disabledItems, true)) {
                if ($table === 'pages') {
                    $menuItems['view'] = $this->DB_view($uid);
                }
                if ($table === 'tt_content') {
245
246
                    $ws_rec = BackendUtility::getRecordWSOL($table, (int)$this->rec['uid']);
                    $menuItems['view'] = $this->DB_view((int)$ws_rec['pid']);
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
                }
            }
            // Edit:
            if (!$root && ($this->backendUser->isPSet($lCP, $table, 'edit') || $this->backendUser->isPSet($lCP, $table, 'editcontent'))) {
                if (!in_array('edit', $this->disabledItems, true)) {
                    $menuItems['edit'] = $this->DB_edit($table, $uid);
                }
                $this->editOK = true;
            }
            // New:
            if (!in_array('new', $this->disabledItems, true) && $this->backendUser->isPSet($lCP, $table, 'new')) {
                $menuItems['new'] = $this->DB_new($table, $uid);
            }
            // Info:
            if (!in_array('info', $this->disabledItems, true) && !$root) {
                $menuItems['info'] = $this->DB_info($table, $uid);
            }
            $menuItems['spacer1'] = 'spacer';
            // Copy:
            if (!in_array('copy', $this->disabledItems, true) && !$root && !$DBmount && !$l10nOverlay) {
                $menuItems['copy'] = $this->DB_copycut($table, $uid, 'copy');
            }
            // Cut:
270
            if (!in_array('cut', $this->disabledItems, true) && !$root && !$DBmount && !$l10nOverlay && $this->editOK) {
271
272
273
274
275
276
                $menuItems['cut'] = $this->DB_copycut($table, $uid, 'cut');
            }
            // Paste:
            $elFromAllTables = count($this->clipObj->elFromTable(''));
            if (!in_array('paste', $this->disabledItems, true) && $elFromAllTables) {
                $selItem = $this->clipObj->getSelectedRecord();
277
                $elInfo = [
278
279
280
                    GeneralUtility::fixed_lgd_cs($selItem['_RECORD_TITLE'], $this->backendUser->uc['titleLen']),
                    $root ? $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] : GeneralUtility::fixed_lgd_cs(BackendUtility::getRecordTitle($table, $this->rec), $this->backendUser->uc['titleLen']),
                    $this->clipObj->currentMode()
281
                ];
282
283
284
285
286
287
288
289
290
291
292
293
                if ($table === 'pages' && $lCP & Permission::PAGE_NEW) {
                    if ($elFromAllTables) {
                        $menuItems['pasteinto'] = $this->DB_paste('', $uid, 'into', $elInfo);
                    }
                }
                $elFromTable = count($this->clipObj->elFromTable($table));
                if (!$root && !$DBmount && $elFromTable && $GLOBALS['TCA'][$table]['ctrl']['sortby']) {
                    $menuItems['pasteafter'] = $this->DB_paste($table, -$uid, 'after', $elInfo);
                }
            }

            // Delete:
294
            $elInfo = [GeneralUtility::fixed_lgd_cs(BackendUtility::getRecordTitle($table, $this->rec), $this->backendUser->uc['titleLen'])];
295
296
297
            $disableDeleteTS = $this->backendUser->getTSConfig('options.disableDelete');
            $disableDelete = (bool) trim(isset($disableDeleteTS['properties'][$table]) ? $disableDeleteTS['properties'][$table] : $disableDeleteTS['value']);
            if (!in_array('delete', $this->disabledItems, true) && !$root && !$DBmount && $this->backendUser->isPSet($lCP, $table, 'delete') && !$disableDelete) {
298
299
300
301
                $menuItems['spacer2'] = 'spacer';
                $menuItems['delete'] = $this->DB_delete($table, $uid, $elInfo);
            }
            if (!in_array('history', $this->disabledItems, true)) {
302
                $menuItems['history'] = $this->DB_history($table, $uid);
303
304
            }

305
            $localItems = [];
306
307
308
309
310
            if (!$this->cmLevel && !in_array('moreoptions', $this->disabledItems, true)) {
                // Creating menu items here:
                if ($this->editOK) {
                    $localItems['spacer3'] = 'spacer';
                    $localItems['moreoptions'] = $this->linkItem(
311
312
                        $this->label('more') . '&nbsp;&nbsp;<span class="fa fa-caret-right"></span>',
                        '<span class="fa fa-fw"></span>',
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
                        'TYPO3.ClickMenu.fetch(' . GeneralUtility::quoteJSvalue(GeneralUtility::linkThisScript() . '&cmLevel=1&subname=moreoptions') . ');return false;',
                        false,
                        true
                    );
                    $menuItemHideUnhideAllowed = false;
                    $hiddenField = '';
                    // Check if column for disabled is defined
                    if (isset($GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled'])) {
                        $hiddenField = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled'];
                        if (
                            $hiddenField !== '' && !empty($GLOBALS['TCA'][$table]['columns'][$hiddenField]['exclude'])
                            && $this->backendUser->check('non_exclude_fields', $table . ':' . $hiddenField)
                        ) {
                            $menuItemHideUnhideAllowed = true;
                        }
                    }
                    if ($menuItemHideUnhideAllowed && !in_array('hide', $this->disabledItems, true)) {
                        $localItems['hide'] = $this->DB_hideUnhide($table, $this->rec, $hiddenField);
                    }
                    $anyEnableColumnsFieldAllowed = false;
                    // Check if columns are defined
                    if (isset($GLOBALS['TCA'][$table]['ctrl']['enablecolumns'])) {
                        $columnsToCheck = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns'];
                        if ($table === 'pages' && !empty($columnsToCheck)) {
                            $columnsToCheck[] = 'extendToSubpages';
                        }
                        foreach ($columnsToCheck as $currentColumn) {
                            if (
                                !empty($GLOBALS['TCA'][$table]['columns'][$currentColumn]['exclude'])
                                && $this->backendUser->check('non_exclude_fields', $table . ':' . $currentColumn)
                            ) {
                                $anyEnableColumnsFieldAllowed = true;
                            }
                        }
                    }
                    if ($anyEnableColumnsFieldAllowed && !in_array('edit_access', $this->disabledItems, true)) {
                        $localItems['edit_access'] = $this->DB_editAccess($table, $uid);
                    }
                }
                // Find delete element among the input menu items and insert the local items just before that:
                $c = 0;
                $deleteFound = false;
                foreach ($menuItems as $key => $value) {
                    $c++;
                    if ($key === 'delete') {
                        $deleteFound = true;
                        break;
                    }
                }
                if ($deleteFound) {
                    // .. subtract two... (delete item + its spacer element...)
                    $c -= 2;
                    // and insert the items just before the delete element.
                    array_splice($menuItems, $c, 0, $localItems);
                } else {
                    $menuItems = array_merge($menuItems, $localItems);
                }
            }
        }
        // Adding external elements to the menuItems array
        $menuItems = $this->processingByExtClassArray($menuItems, $table, $uid);
        // Processing by external functions?
        $menuItems = $this->externalProcessingOfDBMenuItems($menuItems);
        if (!is_array($this->rec)) {
377
            $this->rec = [];
378
379
380
381
382
383
384
385
386
387
388
        }

        // Return the printed elements:
        return $this->printItems($menuItems);
    }

    /**
     * Make 2nd level clickmenu (only for DBmenus)
     *
     * @param string $table Table name
     * @param int $uid UID for the current record.
389
     * @return array the array to be returned as JSON
390
391
392
393
394
395
396
     */
    public function printNewDBLevel($table, $uid)
    {
        $localItems = [];
        $uid = (int)$uid;
        // Setting internal record to the table/uid :
        $this->rec = BackendUtility::getRecordWSOL($table, $uid);
397
        $menuItems = [];
398
399
400
401
402
403
404
        $root = 0;
        // Rootlevel
        if ($table === 'pages' && $uid === 0) {
            $root = 1;
        }
        // If record was found, check permissions and get menu items.
        if (is_array($this->rec) || $root) {
405
            $lCP = $this->backendUser->calcPerms(BackendUtility::getRecord('pages', $table === 'pages' ? (int)$this->rec['uid'] : (int)$this->rec['pid']));
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
            // Edit:
            if (!$root && ($this->backendUser->isPSet($lCP, $table, 'edit') || $this->backendUser->isPSet($lCP, $table, 'editcontent'))) {
                $this->editOK = true;
            }
            $menuItems = $this->processingByExtClassArray($menuItems, $table, $uid);
        }

        $subname = GeneralUtility::_GP('subname');
        if ($subname === 'moreoptions') {
            // If the page can be edited, then show this:
            if ($this->editOK) {
                if (($table === 'pages' || $table === 'tt_content') && !in_array('move_wizard', $this->disabledItems, true)) {
                    $localItems['move_wizard'] = $this->DB_moveWizard($table, $uid, $this->rec);
                }
                if (($table === 'pages' || $table === 'tt_content') && !in_array('new_wizard', $this->disabledItems, true)) {
                    $localItems['new_wizard'] = $this->DB_newWizard($table, $uid, $this->rec);
                }
                if ($table === 'pages' && !in_array('perms', $this->disabledItems, true) && $this->backendUser->check('modules', 'system_BeuserTxPermission')) {
                    $localItems['perms'] = $this->DB_perms($table, $uid, $this->rec);
                }
                if (!in_array('db_list', $this->disabledItems, true) && $this->backendUser->check('modules', 'web_list')) {
                    $localItems['db_list'] = $this->DB_db_list($table, $uid, $this->rec);
                }
            }
            // Temporary mount point item:
            if ($table === 'pages') {
                $localItems['temp_mount_point'] = $this->DB_tempMountPoint($uid);
            }
            // Merge the locally created items into the current menu items passed to this function.
            $menuItems = array_merge($menuItems, $localItems);
        }

        // Return the printed elements:
        if (!is_array($menuItems)) {
440
            $menuItems = [];
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
        }
        return $this->printItems($menuItems);
    }

    /**
     * Processing the $menuItems array (for extension classes) (DATABASE RECORDS)
     *
     * @param array $menuItems Array for manipulation.
     * @return array Processed $menuItems array
     */
    public function externalProcessingOfDBMenuItems($menuItems)
    {
        return $menuItems;
    }

    /**
     * Processing the $menuItems array by external classes (typ. adding items)
     *
     * @param array $menuItems Array for manipulation.
     * @param string $table Table name
     * @param int $uid UID for the current record.
     * @return array Processed $menuItems array
     */
    public function processingByExtClassArray($menuItems, $table, $uid)
    {
        if (is_array($this->extClassArray)) {
            foreach ($this->extClassArray as $conf) {
                $obj = GeneralUtility::makeInstance($conf['name']);
                $menuItems = $obj->main($this, $menuItems, $table, $uid);
            }
        }
        return $menuItems;
    }

    /**
     * Returning JavaScript for the onClick event linking to the input URL.
     *
     * @param string $url The URL relative to TYPO3_mainDir
     * @param string $retUrl The return_url-parameter
     * @param bool $hideCM If set, the "hideCM()" will be called
     * @param string $overrideLoc If set, gives alternative location to load in (for example top frame or somewhere else)
     * @return string JavaScript for an onClick event.
     */
    public function urlRefForCM($url, $retUrl = '', $hideCM = true, $overrideLoc = '')
    {
486
487
        $loc = 'top.list_frame';
        return ($overrideLoc ? 'var docRef=' . $overrideLoc : 'var docRef=(top.list_frame)?top.list_frame:' . $loc)
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
            . '; docRef.location.href=' . GeneralUtility::quoteJSvalue($url) . ($retUrl ? '+' . GeneralUtility::quoteJSvalue('&' . $retUrl . '=') . '+top.rawurlencode('
            . $this->frameLocation('docRef.document') . '.pathname+' . $this->frameLocation('docRef.document') . '.search)' : '')
            . ';';
    }

    /**
     * Adding CM element for Clipboard "copy" and "cut"
     *
     * @param string $table Table name
     * @param int $uid UID for the current record.
     * @param string $type Type: "copy" or "cut
     * @return array Item array, element in $menuItems
     * @internal
     */
    public function DB_copycut($table, $uid, $type)
    {
        $isSel = '';
        if ($this->clipObj->current === 'normal') {
            $isSel = $this->clipObj->isSelected($table, $uid);
        }
508
        $addParam = [];
509
        if ($this->listFrame) {
510
            $addParam['reloadListFrame'] = 1;
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
        }
        $icon = $this->iconFactory->getIcon('actions-edit-' . $type . ($isSel === $type ? '-release' : ''), Icon::SIZE_SMALL)->render();
        return $this->linkItem(
            $this->label($type),
            $icon,
            'TYPO3.ClickMenu.fetch(' . GeneralUtility::quoteJSvalue($this->clipObj->selUrlDB($table, $uid, ($type === 'copy' ? 1 : 0), ($isSel == $type), $addParam)) . ');return false;'
        );
    }

    /**
     * Adding CM element for Clipboard "paste into"/"paste after"
     * NOTICE: $table and $uid should follow the special syntax for paste, see clipboard-class :: pasteUrl();
     *
     * @param string $table Table name
     * @param int $uid UID for the current record. NOTICE: Special syntax!
     * @param string $type Type: "into" or "after
     * @param array $elInfo Contains instructions about whether to copy or cut an element.
     * @return array Item array, element in $menuItems
     * @see \TYPO3\CMS\Backend\Clipboard\Clipboard::pasteUrl()
     * @internal
     */
    public function DB_paste($table, $uid, $type, $elInfo)
    {
534
        $loc = 'top.list_frame';
535
536
537
538
539
        $jsCode = $loc . '.location.href='
            . GeneralUtility::quoteJSvalue($this->clipObj->pasteUrl($table, $uid, 0) . '&redirect=')
            . ' + top.rawurlencode(' . $this->frameLocation($loc . '.document') . '.pathname+'
            . $this->frameLocation($loc . '.document') . '.search);';

540
        if ($this->backendUser->jsConfirmation(JsConfirmation::COPY_MOVE_PASTE)) {
541
            $title = $this->languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_mod_web_list.xlf:clip_paste');
542
543
            $lllKey = ($elInfo[2] === 'copy' ? 'copy' : 'move') . '_' . $type;
            $confirmMessage = sprintf(
544
                $this->languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:mess.' . $lllKey),
545
546
547
548
549
550
551
552
                $elInfo[0],
                $elInfo[1]
            );
            $jsCode = 'top.TYPO3.Modal.confirm(' . GeneralUtility::quoteJSvalue($title) . ', '
                . GeneralUtility::quoteJSvalue($confirmMessage) . ')'
                . '.on(\'button.clicked\', function(e) { if (e.target.name === \'ok\') {'
                . $jsCode
                . '} top.TYPO3.Modal.dismiss(); });';
553
        }
554
        $editOnClick = 'if(' . $loc . ') { ' . $jsCode . ' }';
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
        return $this->linkItem(
            $this->label('paste' . $type),
            $this->iconFactory->getIcon('actions-document-paste-' . $type, Icon::SIZE_SMALL)->render(),
            $editOnClick . 'return false;'
        );
    }

    /**
     * Adding CM element for Info
     *
     * @param string $table Table name
     * @param int $uid UID for the current record.
     * @return array Item array, element in $menuItems
     * @internal
     */
    public function DB_info($table, $uid)
    {
        return $this->linkItem(
            $this->label('info'),
            $this->iconFactory->getIcon('actions-document-info', Icon::SIZE_SMALL)->render(),
            'top.launchView(' . GeneralUtility::quoteJSvalue($table) . ', ' . GeneralUtility::quoteJSvalue($uid) . ');'
        );
    }

    /**
     * Adding CM element for History
     *
     * @param string $table Table name
     * @param int $uid UID for the current record.
     * @return array Item array, element in $menuItems
     * @internal
     */
    public function DB_history($table, $uid)
    {
589
        $url = BackendUtility::getModuleUrl('record_history', ['element' => $table . ':' . $uid]);
590
        return $this->linkItem(
591
            htmlspecialchars($this->languageService->getLL('CM_history')),
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
            $this->iconFactory->getIcon('actions-document-history-open', Icon::SIZE_SMALL)->render(),
            $this->urlRefForCM($url, 'returnUrl')
        );
    }

    /**
     * Adding CM element for Permission setting
     *
     * @param string $table Table name
     * @param int $uid UID for the current record.
     * @param array $rec The "pages" record with "perms_*" fields inside.
     * @return array Item array, element in $menuItems
     * @internal
     */
    public function DB_perms($table, $uid, $rec)
    {
        if (!ExtensionManagementUtility::isLoaded('beuser')) {
            return '';
        }

612
        $parameters = [
613
            'id' => $uid,
614
        ];
615
616
617
618
619
620
621
622

        if ($rec['perms_userid'] == $this->backendUser->user['uid'] || $this->backendUser->isAdmin()) {
            $parameters['return_id'] = $uid;
            $parameters['edit'] = '1';
        }

        $url = BackendUtility::getModuleUrl('system_BeuserTxPermission', $parameters);
        return $this->linkItem(
623
            htmlspecialchars($this->languageService->getLL('CM_perms')),
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
            $this->iconFactory->getIcon('status-status-locked', Icon::SIZE_SMALL)->render(),
            $this->urlRefForCM($url)
        );
    }

    /**
     * Adding CM element for DBlist
     *
     * @param string $table Table name
     * @param int $uid UID for the current record.
     * @param array $rec Record of the element (needs "pid" field if not pages-record)
     * @return array Item array, element in $menuItems
     * @internal
     */
    public function DB_db_list($table, $uid, $rec)
    {
640
        $urlParams = [];
641
642
        $urlParams['id'] = $table === 'pages' ? $uid : $rec['pid'];
        $urlParams['table'] = $table === 'pages' ? '' : $table;
643
        $url = BackendUtility::getModuleUrl('web_list', $urlParams);
644
        return $this->linkItem(
645
            htmlspecialchars($this->languageService->getLL('CM_db_list')),
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
            $this->iconFactory->getIcon('actions-system-list-open', Icon::SIZE_SMALL)->render(),
            'top.nextLoadModuleUrl=' . GeneralUtility::quoteJSvalue($url) . ';top.goToModule(\'web_list\', 1);'
        );
    }

    /**
     * Adding CM element for Moving wizard
     *
     * @param string $table Table name
     * @param int $uid UID for the current record.
     * @param array $rec Record. Needed for tt-content elements which will have the sys_language_uid sent
     * @return array Item array, element in $menuItems
     * @internal
     */
    public function DB_moveWizard($table, $uid, $rec)
    {
        // Hardcoded field for tt_content elements.
        $url = BackendUtility::getModuleUrl('move_element') . '&table=' . $table . '&uid=' . $uid;
        $url .= ($table === 'tt_content' ? '&sys_language_uid=' . (int)$rec['sys_language_uid'] : '');
        return $this->linkItem(
666
            htmlspecialchars($this->languageService->getLL('CM_moveWizard' . ($table === 'pages' ? '_page' : ''))),
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
            $this->iconFactory->getIcon('actions-' . ($table === 'pages' ? 'page' : 'document') . '-move', Icon::SIZE_SMALL)->render(),
            $this->urlRefForCM($url, 'returnUrl')
        );
    }

    /**
     * Adding CM element for Create new wizard (either BackendUtility::getModuleUrl('db_new') or BackendUtility::getModuleUrl('new_content_element') or custom wizard)
     *
     * @param string $table Table name
     * @param int $uid UID for the current record.
     * @param array $rec Record.
     * @return array Item array, element in $menuItems
     * @internal
     */
    public function DB_newWizard($table, $uid, $rec)
    {
683
684
685
686
        if ($table === 'pages') {
            $url = BackendUtility::getModuleUrl('db_new', ['id' => $uid, 'pagesOnly' => 1]);
        } else {
            //  If mod.newContentElementWizard.override is set, use a custom module instead
687
            $tsConfig = BackendUtility::getModTSconfig((int)$this->pageinfo['uid'], 'mod');
688
689
690
            $newContentWizardModuleName = isset($tsConfig['properties']['newContentElementWizard.']['override'])
                ? $tsConfig['properties']['newContentElementWizard.']['override']
                : 'new_content_element';
691
692
            $url = BackendUtility::getModuleUrl($newContentWizardModuleName, ['id' => $rec['pid'], 'sys_language_uid' => (int)$rec['sys_language_uid']]);
        }
693
        return $this->linkItem(
694
            htmlspecialchars($this->languageService->getLL('CM_newWizard')),
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
            $this->iconFactory->getIcon(($table === 'pages' ? 'actions-page-new' : 'actions-document-new'), Icon::SIZE_SMALL)->render(),
            $this->urlRefForCM($url, 'returnUrl')
        );
    }

    /**
     * Adding CM element for Editing of the access related fields of a table (disable, starttime, endtime, fe_groups)
     *
     * @param string $table Table name
     * @param int $uid UID for the current record.
     * @return array Item array, element in $menuItems
     * @internal
     */
    public function DB_editAccess($table, $uid)
    {
710
        $url = BackendUtility::getModuleUrl('record_edit', [
711
            'columnsOnly' => (implode(',', $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']) . ($table === 'pages' ? ',extendToSubpages' : '')),
712
            'edit[' . $table . '][' . $uid . ']' => 'edit'
713
        ]);
714
        return $this->linkItem(
715
            htmlspecialchars($this->languageService->getLL('CM_editAccess')),
716
717
718
719
720
721
722
723
724
725
726
727
            $this->iconFactory->getIcon('actions-document-edit-access', Icon::SIZE_SMALL)->render(),
            $this->urlRefForCM($url, 'returnUrl'),
            1
        );
    }

    /**
     * Adding CM element for edit page properties
     *
     * @param int $uid page uid to edit (PID)
     * @return array Item array, element in $menuItems
     * @internal
728
     * @deprecated since TYPO3 v8, will be removed in TYPO3 v9
729
730
731
     */
    public function DB_editPageProperties($uid)
    {
732
        GeneralUtility::logDeprecatedFunction();
733
        $url = BackendUtility::getModuleUrl('record_edit', [
734
            'edit[pages][' . $uid . ']' => 'edit'
735
        ]);
736
        return $this->linkItem(
737
            htmlspecialchars($this->languageService->getLL('CM_editPageProperties')),
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
            $this->iconFactory->getIcon('actions-page-open', Icon::SIZE_SMALL)->render(),
            $this->urlRefForCM($url, 'returnUrl'),
            1
        );
    }

    /**
     * Adding CM element for regular editing of the element!
     *
     * @param string $table Table name
     * @param int $uid UID for the current record.
     * @return array Item array, element in $menuItems
     * @internal
     */
    public function DB_edit($table, $uid)
    {
        // If another module was specified, replace the default Page module with the new one
        $newPageModule = trim($this->backendUser->getTSConfigVal('options.overridePageModule'));
        $pageModule = BackendUtility::isModuleSetInTBE_MODULES($newPageModule) ? $newPageModule : 'web_layout';
757
        $loc = 'top.list_frame';
758
759
760
761
762
        $iconName = 'actions-open';
        if ($table === 'pages') {
            $iconName = 'actions-page-open';
        }
        $theIcon = $this->iconFactory->getIcon($iconName, Icon::SIZE_SMALL)->render();
763

764
        $link = BackendUtility::getModuleUrl('record_edit', [
765
            'edit[' . $table . '][' . $uid . ']' => 'edit'
766
        ]);
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784

        if ($this->iParts[0] === 'pages' && $this->iParts[1] && $this->backendUser->check('modules', $pageModule)) {
            $this->editPageIconSet = true;
        }
        $editOnClick = 'if(' . $loc . '){' . $loc . '.location.href=' . GeneralUtility::quoteJSvalue($link . '&returnUrl=') . '+top.rawurlencode(' . $this->frameLocation(($loc . '.document')) . '.pathname+' . $this->frameLocation(($loc . '.document')) . '.search);}';
        return $this->linkItem($this->label('edit'), $theIcon, $editOnClick . ';');
    }

    /**
     * Adding CM element for regular Create new element
     *
     * @param string $table Table name
     * @param int $uid UID for the current record.
     * @return array Item array, element in $menuItems
     * @internal
     */
    public function DB_new($table, $uid)
    {
785
        $frame = 'top.list_frame';
786
787
        $location = $this->frameLocation($frame . '.document');
        $module = $this->listFrame
788
789
            ? GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('record_edit', ['edit[' . $table . '][-' . $uid . ']' => 'new']) . '&returnUrl=') . '+top.rawurlencode(' . $location . '.pathname+' . $location . '.search)'
            : GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('db_new', ['id' => (int)$uid]));
790
791
792
793
794
795
796
797
798
799
        $editOnClick = 'if(' . $frame . '){' . $frame . '.location.href=' . $module . ';}';
        $icon = $this->iconFactory->getIcon('actions-' . ($table === 'pages' ? 'page' : 'document') . '-new', Icon::SIZE_SMALL)->render();
        return $this->linkItem($this->label('new'), $icon, $editOnClick);
    }

    /**
     * Adding CM element for Delete
     *
     * @param string $table Table name
     * @param int $uid UID for the current record.
800
     * @param array $elInfo Label for including in the confirmation message, EXT:lang/Resources/Private/Language/locallang_core.xlf:mess.delete
801
802
803
804
805
     * @return array Item array, element in $menuItems
     * @internal
     */
    public function DB_delete($table, $uid, $elInfo)
    {
806
        $loc = 'top.list_frame';
807
808
809
810
811
        $jsCode = $loc . '.location.href='
            . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('tce_db') . '&redirect=')
            . '+top.rawurlencode(' . $this->frameLocation($loc . '.document') . '.pathname+'
            . $this->frameLocation($loc . '.document') . '.search)+'
            . GeneralUtility::quoteJSvalue(
812
                '&cmd[' . $table . '][' . $uid . '][delete]=1&prErr=1&vC=' . $this->backendUser->veriCode()
813
814
            );

815
        if ($table === 'pages') {
816
817
818
819
            $jsCode .= 'top.nav.refresh.defer(500, top.nav);';
        }

        if ($this->backendUser->jsConfirmation(JsConfirmation::DELETE)) {
820
            $title = $this->languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_mod_web_list.xlf:delete');
821
            $confirmMessage = sprintf(
822
                $this->languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:mess.delete'),
823
824
825
826
827
                $elInfo[0]
            );
            $confirmMessage .= BackendUtility::referenceCount(
                $table,
                $uid,
828
                ' ' . $this->languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.referencesToRecord')
829
830
831
832
            );
            $confirmMessage .= BackendUtility::translationCount(
                $table,
                $uid,
833
                ' ' . $this->languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.translationsOfRecord')
834
835
836
837
838
839
            );
            $jsCode = 'top.TYPO3.Modal.confirm(' . GeneralUtility::quoteJSvalue($title) . ', '
                . GeneralUtility::quoteJSvalue($confirmMessage) . ')'
                . '.on(\'button.clicked\', function(e) { if (e.target.name === \'ok\') {'
                . $jsCode
                . '} top.TYPO3.Modal.dismiss(); });';
840
        }
841
        $editOnClick = 'if(' . $loc . ') { ' . $jsCode . ' }';
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
        return $this->linkItem(
            $this->label('delete'),
            $this->iconFactory->getIcon('actions-edit-delete', Icon::SIZE_SMALL)->render(),
            $editOnClick . 'return false;'
        );
    }

    /**
     * Adding CM element for View Page
     *
     * @param int $id Page uid (PID)
     * @param string $anchor Anchor, if any
     * @return array Item array, element in $menuItems
     * @internal
     */
    public function DB_view($id, $anchor = '')
    {
        $icon = $this->iconFactory->getIcon('actions-document-view', Icon::SIZE_SMALL)->render();
        return $this->linkItem($this->label('view'), $icon, BackendUtility::viewOnClick($id, '', null, $anchor) . ';');
    }

    /**
     * Adding element for setting temporary mount point.
     *
     * @param int $page_id Page uid (PID)
     * @return array Item array, element in $menuItems
     * @internal
     */
    public function DB_tempMountPoint($page_id)
    {
        return $this->linkItem(
            $this->label('tempMountPoint'),
874
            $this->iconFactory->getIcon('actions-pagetree-mountroot', Icon::SIZE_SMALL)->render(),
875
            'if (top.nav_frame) {
876
877
878
879
880
881
882
883
				var node = top.TYPO3.Backend.NavigationContainer.PageTree.getSelected();
				if (node === null) {
					return false;
				}

				var useNode = {
					attributes: {
						nodeData: {
884
							id: ' . (int)$page_id . '
885
886
887
888
889
890
891
						}
					}
				};

				node.ownerTree.commandProvider.mountAsTreeRoot(useNode, node.ownerTree);
			}
			');
892
893
894
895
896
897
898
899
900
901
902
903
904
    }

    /**
     * Adding CM element for hide/unhide of the input record
     *
     * @param string $table Table name
     * @param array $rec Record array
     * @param string $hideField Name of the hide field
     * @return array Item array, element in $menuItems
     * @internal
     */
    public function DB_hideUnhide($table, $rec, $hideField)
    {
905
        return $this->DB_changeFlag($table, $rec, $hideField, $this->label(($rec[$hideField] ? 'un' : '') . 'hide'));
906
907
908
909
910
911
912
913
914
915
916
917
918
919
    }

    /**
     * Adding CM element for a flag field of the input record
     *
     * @param string $table Table name
     * @param array $rec Record array
     * @param string $flagField Name of the flag field
     * @param string $title Menu item Title
     * @return array Item array, element in $menuItems
     */
    public function DB_changeFlag($table, $rec, $flagField, $title)
    {
        $uid = $rec['_ORIG_uid'] ?: $rec['uid'];
920
        $loc = 'top.list_frame';
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
        $editOnClick = 'if(' . $loc . '){' . $loc . '.location.href=' .
            GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('tce_db') . '&redirect=') . '+top.rawurlencode(' .
            $this->frameLocation($loc . '.document') . '.pathname+' . $this->frameLocation(($loc . '.document')) . '.search)+' .
            GeneralUtility::quoteJSvalue(
                '&data[' . $table . '][' . $uid . '][' . $flagField . ']=' . ($rec[$flagField] ? 0 : 1) . '&prErr=1&vC=' . $this->backendUser->veriCode()
            ) . ';};';
        if ($table === 'pages') {
            $editOnClick .= 'top.nav.refresh.defer(500, top.nav);';
        }
        return $this->linkItem(
            $title,
            $this->iconFactory->getIcon('actions-edit-' . ($rec[$flagField] ? 'un' : '') . 'hide', Icon::SIZE_SMALL)->render(),
            $editOnClick . 'return false;',
            1
        );
    }

    /***************************************
     *
     * FILE
     *
     ***************************************/
    /**
     * Make 1st level clickmenu:
     *
     * @param string $combinedIdentifier The combined identifier
     * @return string HTML content
     * @see \TYPO3\CMS\Core\Resource\ResourceFactory::retrieveFileOrFolderObject()
     */
    public function printFileClickMenu($combinedIdentifier)
    {
        $identifier = '';
953
        $menuItems = [];
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
        $combinedIdentifier = rawurldecode($combinedIdentifier);
        $fileObject = ResourceFactory::getInstance()
                ->retrieveFileOrFolderObject($combinedIdentifier);
        if ($fileObject) {
            $folder = false;
            $isStorageRoot = false;
            $isOnline = true;
            $userMayViewStorage = false;
            $userMayEditStorage = false;
            $identifier = $fileObject->getCombinedIdentifier();
            if ($fileObject instanceof Folder) {
                $folder = true;
                if ($fileObject->getIdentifier() === $fileObject->getStorage()->getRootLevelFolder()->getIdentifier()) {
                    $isStorageRoot = true;
                    if ($this->backendUser->check('tables_select', 'sys_file_storage')) {
                        $userMayViewStorage = true;
                    }
                    if ($this->backendUser->check('tables_modify', 'sys_file_storage')) {
                        $userMayEditStorage = true;
                    }
                }
                if (!$fileObject->getStorage()->isOnline()) {
                    $isOnline = false;
                }
            }
            // Hide
            if (!in_array('hide', $this->disabledItems, true) && $isStorageRoot && $userMayEditStorage) {
                $record = BackendUtility::getRecord('sys_file_storage', $fileObject->getStorage()->getUid());
                $menuItems['hide'] = $this->DB_changeFlag(
                    'sys_file_storage',
                    $record,
                    'is_online',
986
                    $this->label($record['is_online'] ? 'offline' : 'online')
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
                );
            }
            // Edit
            if (!in_array('edit', $this->disabledItems, true) && $fileObject->checkActionPermission('write')) {
                if (!$folder && !$isStorageRoot && $fileObject->isIndexed() && $this->backendUser->check('tables_modify', 'sys_file_metadata')) {
                    $metaData = $fileObject->_getMetaData();
                    $menuItems['edit2'] = $this->DB_edit('sys_file_metadata', $metaData['uid']);
                }
                if (!$folder && GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['SYS']['textfile_ext'], $fileObject->getExtension()) && $fileObject->checkActionPermission('write')) {
                    $menuItems['edit'] = $this->FILE_launch($identifier, 'file_edit', 'editcontent', 'actions-page-open');
                } elseif ($isStorageRoot && $userMayEditStorage) {
                    $menuItems['edit'] = $this->DB_edit('sys_file_storage', $fileObject->getStorage()->getUid());
                }
            }
            // Rename
            if (!in_array('rename', $this->disabledItems, true) && !$isStorageRoot && $fileObject->checkActionPermission('rename')) {
                $menuItems['rename'] = $this->FILE_launch($identifier, 'file_rename', 'rename', 'actions-edit-rename');
            }
            // Upload
            if (!in_array('upload', $this->disabledItems, true) && $folder && $isOnline && $fileObject->checkActionPermission('write')) {
                $menuItems['upload'] = $this->FILE_launch($identifier, 'file_upload', 'upload', 'actions-edit-upload');
            }
            // New
            if (!in_array('new', $this->disabledItems, true) && $folder && $isOnline && $fileObject->checkActionPermission('write')) {
                $menuItems['new'] = $this->FILE_launch($identifier, 'file_newfolder', 'new', 'actions-document-new');
            }
            // Info
            if (!in_array('info', $this->disabledItems, true) && $fileObject->checkActionPermission('read')) {
                if ($isStorageRoot && $userMayViewStorage) {
                    $menuItems['info'] = $this->DB_info('sys_file_storage', $fileObject->getStorage()->getUid());
                } elseif (!$folder) {
                    $menuItems['info'] = $this->fileInfo($identifier);
                }
            }
            $menuItems[] = 'spacer';
            // Copy:
            if (!in_array('copy', $this->disabledItems, true) && !$isStorageRoot && $fileObject->checkActionPermission('read')) {
                $menuItems['copy'] = $this->FILE_copycut($identifier, 'copy');
            }
            // Cut:
            if (!in_array('cut', $this->disabledItems, true) && !$isStorageRoot && $fileObject->checkActionPermission('move')) {
                $menuItems['cut'] = $this->FILE_copycut($identifier, 'cut');
            }
            // Paste:
            $elFromAllTables = count($this->clipObj->elFromTable('_FILE'));
            if (!in_array('paste', $this->disabledItems, true) && $elFromAllTables && $folder && $fileObject->checkActionPermission('write')) {
                $elArr = $this->clipObj->elFromTable('_FILE');
                $selItem = reset($elArr);
                $clickedFileOrFolder = ResourceFactory::getInstance()->retrieveFileOrFolderObject($combinedIdentifier);
                $fileOrFolderInClipBoard = ResourceFactory::getInstance()->retrieveFileOrFolderObject($selItem);
1037
                $elInfo = [
1038
1039
1040
                    $fileOrFolderInClipBoard->getName(),
                    $clickedFileOrFolder->getName(),
                    $this->clipObj->currentMode()
1041
                ];
1042
1043
1044
1045
1046
1047
1048
1049
                if (!$fileOrFolderInClipBoard instanceof Folder || !$fileOrFolderInClipBoard->getStorage()->isWithinFolder($fileOrFolderInClipBoard, $clickedFileOrFolder)) {
                    $menuItems['pasteinto'] = $this->FILE_paste($identifier, $selItem, $elInfo);
                }
            }
            $menuItems[] = 'spacer';
            // Delete:
            if (!in_array('delete', $this->disabledItems, true) && $fileObject->checkActionPermission('delete')) {
                if ($isStorageRoot && $userMayEditStorage) {
1050
                    $elInfo = [GeneralUtility::fixed_lgd_cs($fileObject->getStorage()->getName(), $this->backendUser->uc['titleLen'])];
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
                    $menuItems['delete'] = $this->DB_delete('sys_file_storage', $fileObject->getStorage()->getUid(), $elInfo);
                } elseif (!$isStorageRoot) {
                    $menuItems['delete'] = $this->FILE_delete($identifier);
                }
            }
        }
        // Adding external elements to the menuItems array
        $menuItems = $this->processingByExtClassArray($menuItems, $identifier, 0);
        // Processing by external functions?
        $menuItems = $this->externalProcessingOfFileMenuItems($menuItems);
        // Return the printed elements:
        return $this->printItems($menuItems);
    }

    /**
     * Processing the $menuItems array (for extension classes) (FILES)
     *
     * @param array $menuItems Array for manipulation.
     * @return array Processed $menuItems array
     */
    public function externalProcessingOfFileMenuItems($menuItems)
    {
        return $menuItems;
    }

    /**
     * Multi-function for adding an entry to the $menuItems array
     *
     * @param string $path Path to the file/directory (target)
     * @param string $moduleName Script (deprecated) or module name (e.g. file_edit) to pass &target= to
     * @param string $type "type" is the code which fetches the correct label for the element from "cm.
     * @param string $iconName
     * @param bool $noReturnUrl If set, the return URL parameter will not be set in the link
     * @return array Item array, element in $menuItems
     * @internal
     */
    public function FILE_launch($path, $moduleName, $type, $iconName, $noReturnUrl = false)
    {
1089
        $loc = 'top.list_frame';
1090
        $scriptUrl = BackendUtility::getModuleUrl($moduleName);
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112

        $editOnClick = 'if(' . $loc . '){' . $loc . '.location.href=' . GeneralUtility::quoteJSvalue($scriptUrl . '&target=' . rawurlencode($path)) . ($noReturnUrl ? '' : '+\'&returnUrl=\'+top.rawurlencode(' . $this->frameLocation($loc . '.document') . '.pathname+' . $this->frameLocation($loc . '.document') . '.search)') . ';}';
        return $this->linkItem(
            $this->label($type),
            $this->iconFactory->getIcon($iconName, Icon::SIZE_SMALL)->render(),
            $editOnClick . 'top.nav.refresh();'
        );
    }

    /**
     * Returns element for copy or cut of files.
     *
     * @param string $path Path to the file/directory (target)
     * @param string $type Type: "copy" or "cut
     * @return array Item array, element in $menuItems
     * @internal
     */
    public function FILE_copycut($path, $type)
    {
        $isSel = '';
        // Pseudo table name for use in the clipboard.
        $table = '_FILE';
1113
        $uid = GeneralUtility::shortMD5($path);
1114
1115
1116
        if ($this->clipObj->current === 'normal') {
            $isSel = $this->clipObj->isSelected($table, $uid);
        }
1117
        $addParam = [];
1118
        if ($this->listFrame) {
1119
            $addParam['reloadListFrame'] = 1;
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
        }
        return $this->linkItem(
            $this->label($type),
            $this->iconFactory->getIcon('actions-edit-' . $type . ($isSel === $type ? '-release' : ''), Icon::SIZE_SMALL)->render(),
            'TYPO3.ClickMenu.fetch(' . GeneralUtility::quoteJSvalue($this->clipObj->selUrlFile($path, ($type === 'copy' ? 1 : 0), ($isSel == $type), $addParam)) . ');return false;'
        );
    }

    /**
     * Creates element for deleting of target
     *
     * @param string $path Path to the file/directory (target)
     * @return array Item array, element in $menuItems
     * @internal
     */
    public function FILE_delete($path)
    {
1137
        $loc = 'top.list_frame';
1138
1139
1140
1141
        $jsCode = $loc . '.location.href='
            . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('tce_file') . '&redirect=')
            . '+top.rawurlencode(' . $this->frameLocation(($loc . '.document'))
            . '.pathname+' . $this->frameLocation(($loc . '.document')) . '.search)+' .
1142
1143
            GeneralUtility::quoteJSvalue(
                '&file[delete][0][data]=' . rawurlencode($path) . '&vC=' . $this->backendUser->veriCode()
1144
1145
            );
        if ($this->backendUser->jsConfirmation(JsConfirmation::DELETE)) {
1146
            $fileOrFolderObject = ResourceFactory::getInstance()->retrieveFileOrFolderObject($path);
1147
            $title = $this->languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_mod_web_list.xlf:delete');
1148
            $confirmMessage = sprintf(
1149
                $this->languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:mess.delete'),
1150
                $fileOrFolderObject->getName()
1151
            );
1152
            if ($fileOrFolderObject instanceof Folder) {
1153
                $confirmMessage .= BackendUtility::referenceCount('_FILE', $fileOrFolderObject->getIdentifier(), ' ' . $this->languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.referencesToFolder'));
1154
            } else {
1155
                $confirmMessage .= BackendUtility::referenceCount('sys_file', $fileOrFolderObject->getUid(), ' ' . $this->languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.referencesToFile'));
1156
            }
1157
1158
1159
1160
1161
1162
1163
            $jsCode = 'top.TYPO3.Modal.confirm(' . GeneralUtility::quoteJSvalue($title) . ', '
                . GeneralUtility::quoteJSvalue($confirmMessage) . ')'
                . '.on(\'button.clicked\', function(e) { if (e.target.name === \'ok\') {'
                . $jsCode
                . '} top.TYPO3.Modal.dismiss(); });';
        }
        $editOnClick = 'if(' . $loc . ') { ' . $jsCode . ' }';
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
        return $this->linkItem(
            $this->label('delete'),
            $this->iconFactory->getIcon('actions-edit-delete', Icon::SIZE_SMALL)->render(),
            $editOnClick . 'return false;'
        );
    }

    /**
     * Creates element for pasting files.
     *
     * @param string $path Path to the file/directory (target)
     * @param string $target target - NOT USED.
     * @param array $elInfo Various values for the labels.
     * @return array Item array, element in $menuItems
     * @internal
     */
    public function FILE_paste($path, $target, $elInfo)
    {
1182
        $loc = 'top.list_frame';
1183
1184
1185
1186
1187
1188

        $jsCode = $loc . '.location.href='
            . GeneralUtility::quoteJSvalue($this->clipObj->pasteUrl('_FILE', $path, 0) . '&redirect=')
            . '+top.rawurlencode(' . $this->frameLocation($loc . '.document')
            . '.pathname+' . $this->frameLocation($loc . '.document') . '.search); top.nav.refresh();';

1189
        if ($this->backendUser->jsConfirmation(JsConfirmation::COPY_MOVE_PASTE)) {
1190
            $title = $this->languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_mod_web_list.xlf:clip_paste');
1191
1192

            $confirmMessage = sprintf(
1193
                $this->languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:mess.'
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
                    . ($elInfo[2] === 'copy' ? 'copy' : 'move') . '_into'),
                $elInfo[0],
                $elInfo[1]
            );

            $jsCode = 'top.TYPO3.Modal.confirm(' . GeneralUtility::quoteJSvalue($title) . ', '
                . GeneralUtility::quoteJSvalue($confirmMessage) . ')'
                . '.on(\'button.clicked\', function(e) { if (e.target.name === \'ok\') {'
                . $jsCode
                . '} top.TYPO3.Modal.dismiss(); });';
1204
        }
1205
        $editOnClick = 'if(' . $loc . ') { ' . $jsCode . ' }';
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
        return $this->linkItem(
            $this->label('pasteinto'),
            $this->iconFactory->getIcon('actions-document-paste-into', Icon::SIZE_SMALL)->render(),
            $editOnClick . 'return false;'
        );
    }

    /**
     * Adding ClickMenu element for file info
     *
     * @param string $identifier The combined identifier of the file.
     * @return array Item array, element in $menuItems
     */
    protected function fileInfo($identifier)
    {
        return $this->DB_info('_FILE', $identifier);
    }

    /***************************************
     *
     * DRAG AND DROP
     *
     ***************************************/
    /**
     * Make 1st level clickmenu:
     *
     * @param string $table The absolute path
     * @param int $srcId UID for the current record.
     * @param int $dstId Destination ID
1235
     * @return array the array to be returned as JSON
1236
1237
1238
     */
    public function printDragDropClickMenu($table, $srcId, $dstId)
    {
1239
        $menuItems = [];
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
        // If the drag and drop menu should apply to PAGES use this set of menu items
        if ($table === 'pages') {
            // Move Into:
            $menuItems['movePage_into'] = $this->dragDrop_copymovepage($srcId, $dstId, 'move', 'into');
            // Move After:
            $menuItems['movePage_after'] = $this->dragDrop_copymovepage($srcId, $dstId, 'move', 'after');
            // Copy Into:
            $menuItems['copyPage_into'] = $this->dragDrop_copymovepage($srcId, $dstId, 'copy', 'into');
            // Copy After:
            $menuItems['copyPage_after'] = $this->dragDrop_copymovepage($srcId, $dstId, 'copy', 'after');
        }
        // If the drag and drop menu should apply to FOLDERS use this set of menu items
        if ($table === 'folders') {
            // Move Into:
            $menuItems['moveFolder_into'] = $this->dragDrop_copymovefolder($srcId, $dstId, 'move');
            // Copy Into:
            $menuItems['copyFolder_into'] = $this->dragDrop_copymovefolder($srcId, $dstId, 'copy');
        }
        // Adding external elements to the menuItems array
        $menuItems = $this->processingByExtClassArray($menuItems, 'dragDrop_' . $table, $srcId);
        // to extend this, you need to apply a Context Menu to a "virtual" table called "dragDrop_pages" or similar
        // Processing by external functions?
        $menuItems = $this->externalProcessingOfDBMenuItems($menuItems);
        // Return the printed elements:
        return $this->printItems($menuItems);
    }

    /**
     * Processing the $menuItems array (for extension classes) (DRAG'N DROP)
     *
     * @param array $menuItems Array for manipulation.
     * @return array Processed $menuItems array
     */
    public function externalProcessingOfDragDropMenuItems($menuItems)
    {
        return $menuItems;
    }

    /**
     * Adding CM element for Copying/Moving a Page Into/After from a drag & drop action
     *
     * @param int $srcUid source UID code for the record to modify
     * @param int $dstUid destination UID code for the record to modify
     * @param string $action Action code: either "move" or "copy
     * @param string $into Parameter code: either "into" or "after
     * @return array Item array, element in $menuItems
     * @internal
     */
    public function dragDrop_copymovepage($srcUid, $dstUid, $action, $into)
    {
        $negativeSign = $into === 'into' ? '' : '-';
1291
        $loc = 'top.list_frame';
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
        $editOnClick = 'if(' . $loc . '){' . $loc . '.document.location=' .
            GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('tce_db') . '&redirect=') . '+top.rawurlencode(' .
            $this->frameLocation(($loc . '.document')) . '.pathname+' . $this->frameLocation(($loc . '.document')) . '.search)+' .
            GeneralUtility::quoteJSvalue(
                '&cmd[pages][' . $srcUid . '][' . $action . ']=' . $negativeSign . $dstUid . '&prErr=1&vC=' .
                $this->backendUser->veriCode()
            ) . ';};top.nav.refresh();';
        return $this->linkItem(
            $this->label($action . 'Page_' . $into),
            $this->iconFactory->getIcon('actions-document-paste-' . $into, Icon::SIZE_SMALL)->render(),
            $editOnClick . 'return false;'
        );
    }

    /**
     * Adding CM element for Copying/Moving a Folder Into from a drag & drop action
     *
     * @param string $srcPath source path for the record to modify
     * @param string $dstPath destination path for the records to modify
     * @param string $action Action code: either "move" or "copy
     * @return array Item array, element in $menuItems
     * @internal
     */
    public function dragDrop_copymovefolder($srcPath, $dstPath, $action)
    {
1317
        $loc = 'top.list_frame';
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
        $editOnClick = 'if(' . $loc . '){' . $loc . '.document.location=' .
            GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('tce_file') . '&redirect=') . '+top.rawurlencode(' .
            $this->frameLocation(($loc . '.document')) . '.pathname+' . $this->frameLocation(($loc . '.document')) . '.search)+' .
            GeneralUtility::quoteJSvalue(
                '&file[' . $action . '][0][data]=' . $srcPath . '&file[' . $action . '][0][target]=' . $dstPath . '&prErr=1&vC=' .
                $this->backendUser->veriCode()
            ) . ';};top.nav.refresh();';
        return $this->linkItem(
            $this->label($action . 'Folder_into'),
            $this->iconFactory->getIcon('apps-pagetree-drag-move-into', Icon::SIZE_SMALL)->render(),
            $editOnClick . 'return false;'
        );
    }

    /***************************************
     *
     * COMMON
     *
     **************************************/
    /**
     * Prints the items from input $menuItems array - as JS section for writing to the div-layers.
     *
     * @param array $menuItems Array
1341
     * @return array the array to be returned via JSON
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
     */
    public function printItems($menuItems)
    {
        // Enable/Disable items
        $menuItems = $this->enableDisableItems($menuItems);
        // Clean up spacers
        $menuItems = $this->cleanUpSpacers($menuItems);
        // Adding JS part and return the content
        return $this->printLayerJScode($menuItems);
    }

    /**
     * Create the JavaScript section
     *
     * @param array $menuItems The $menuItems array to print
1357
     * @return array|null the items to print, and The JavaScript section which will print the content of the CM to the div-layer in the target frame.
1358
1359
1360
1361
1362
1363
1364
     */
    public function printLayerJScode($menuItems)
    {
        // Clipboard must not be submitted - then it's probably a copy/cut situation.
        if ($this->isCMlayers()) {
            // Create the table displayed in the clickmenu layer:
            // Wrap the inner table in another table to create outer border:
1365
1366
1367
1368
            return [
                'items' => $this->menuItemsForClickMenu($menuItems),
                'level' => $this->cmLevel
            ];
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
        }
    }

    /**
     * Traverses the menuItems and generates an output array for implosion in the CM div-layers table.
     *
     * @param array $menuItems Array
     * @return array array for implosion in the CM div-layers table.
     */
    public function menuItemsForClickMenu($menuItems)
    {
1380
        $out = [];
1381
1382
1383
        foreach ($menuItems as $cc => $i) {
            // MAKE horizontal spacer
            if (is_string($i) && $i === 'spacer') {
1384
                $out[] = '<span class="list-group-item list-group-item-divider"></span>';
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
            } else {
                // Just make normal element:
                $onClick = $i[3];
                $onClick = preg_replace('/return[[:space:]]+hideCM\\(\\)[[:space:]]*;/i', '', $onClick);
                $onClick = preg_replace('/return[[:space:]]+false[[:space:]]*;/i', '', $onClick);
                $onClick = preg_replace('/hideCM\\(\\);/i', '', $onClick);
                if (!$i[5]) {
                    $onClick .= 'TYPO3.ClickMenu.hideAll();';
                }
                $out[] = '
1395
					<a href="javascript:;" class="list-group-item" onclick="' . htmlspecialchars($onClick) . '">
1396
1397
						<span class="list-group-item-icon">' . $i[2] . '</span> ' . $i[1] . '
					</a>';
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
            }
        }
        return $out;
    }

    /**
     * Adds or inserts a menu item
     * Can be used to set the position of new menu entries within the list of existing menu entries. Has this syntax: [cmd]:[menu entry key],[cmd].... cmd can be "after", "before" or "top" (or blank/"bottom" which is default). If "after"/"before" then menu items will be inserted after/before the existing entry with [menu entry key] if found. "after-spacer" and "before-spacer" do the same, but inserts before or after an item and a spacer. If not found, the bottom of list. If "top" the items are inserted in the top of the list.
     *
     * @param array $menuItems Menu items array
     * @param array $newMenuItems Menu items array to insert
     * @param string $position Position command string. Has this syntax: [cmd]:[menu entry key],[cmd].... cmd can be "after", "before" or "top" (or blank/"bottom" which is default). If "after"/"before" then menu items will be inserted after/before the existing entry with [menu entry key] if found. "after-spacer" and "before-spacer" do the same, but inserts before or after an item and a spacer. If not found, the bottom of list. If "top" the items are inserted in the top of the list.
     * @return array Menu items array, processed.
     */
    public function addMenuItems($menuItems, $newMenuItems, $position = '')
    {
        if (is_array($newMenuItems)) {
1415
            $pointer = 0;
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
            if ($position) {
                $posArr = GeneralUtility::trimExplode(',', $position, true);
                foreach ($posArr as $pos) {
                    list($place, $menuEntry) = GeneralUtility::trimExplode(':', $pos, true);
                    list($place, $placeExtra) = GeneralUtility::trimExplode('-', $place, true);
                    // Bottom
                    $pointer = count($menuItems);
                    $found = false;
                    if ($place) {
                        switch (strtolower($place)) {
                            case 'after':
                            case 'before':
                                if ($menuEntry) {
                                    $p = 1;
                                    reset($menuItems);
                                    while (true) {
                                        if ((string)key($menuItems) === $menuEntry) {
                                            $pointer = $p;
                                            $found = true;
                                            break;
                                        }
                                        if (!next($menuItems)) {
                                            break;
                                        }
                                        $p++;
                                    }
                                    if (!$found) {
                                        break;
                                    }
                                    if ($place === 'before') {
                                        $pointer--;
                                        if ($placeExtra === 'spacer' and prev($menuItems) === 'spacer') {
                                            $pointer--;
                                        }
                                    } elseif ($place === 'after') {
                                        if ($placeExtra === 'spacer' and next($menuItems) === 'spacer') {
                                            $pointer++;
                                        }
                                    }
                                }
                                break;
                            default:
                                if (strtolower($place) === 'top') {
                                    $pointer = 0;
                                } else {
                                    $pointer = count($menuItems);
                                }
                                $found = true;
                        }
                    }
                    if ($found) {
                        break;
                    }
                }
            }
            $pointer = max(0, $pointer);
            $menuItemsBefore = array_slice($menuItems, 0, $pointer ?: 0);
            $menuItemsAfter = array_slice($menuItems, $pointer);
            $menuItems = $menuItemsBefore + $newMenuItems + $menuItemsAfter;
        }
        return $menuItems;
    }

    /**
     * Creating an array with various elements for the clickmenu entry
     *
     * @param string $str The label, htmlspecialchar'ed already
     * @param string $icon <img>-tag for the icon
     * @param string $onClick JavaScript onclick event for label/icon
     * @param int $onlyCM ==1 and the element will NOT appear in clickmenus in the topframe (unless clickmenu is totally unavailable)! ==2 and the item will NEVER appear in top frame. (This is mostly for "less important" options since the top frame is not capable of holding so many elements horizontally)
1486
     * @param int $dontHide If set, the clickmenu layer will not hide itself onclick - used for secondary menus to appear...
1487
1488
1489
1490
     * @return array $menuItem entry with 6 numerical entries: [0] is the HTML for display of the element with link and icon an mouseover etc., [1]-[5] is simply the input params passed through!
     */
    public function linkItem($str, $icon, $onClick, $onlyCM = 0, $dontHide = 0)
    {
1491
        return [
1492
            '<a href="javascript:;" onclick="' . htmlspecialchars($onClick) . '">' . $str . $icon . '</a>',
1493
1494
1495
1496
1497
            $str,
            $icon,
            $onClick,
            $onlyCM,
            $dontHide
1498
        ];
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
    }

    /**
     * Enabling / Disabling items based on list provided from GET var ($this->iParts[3])
     *
     * @param array $menuItems Menu items array
     * @return array Menu items array, processed.
     */
    public function enableDisableItems($menuItems)
    {
        if ($this->iParts[3]) {
            // Detect "only" mode: (only showing listed items)
            if ($this->iParts[3][0] === '+') {
                $this->iParts[3] = substr($this->iParts[3], 1);
                $only = true;
            } else {
                $only = false;
            }
            // Do filtering:
            // Transfer ONLY elements which are mentioned (or are spacers)
            if ($only) {
1520
                $newMenuArray = [];
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
                foreach ($menuItems as $key => $value) {
                    if (GeneralUtility::inList($this->iParts[3], $key) || is_string($value) && $value === 'spacer') {
                        $newMenuArray[$key] = $value;
                    }
                }
                $menuItems = $newMenuArray;
            } else {
                // Traverse all elements except those listed (just unsetting them):
                $elements = GeneralUtility::trimExplode(',', $this->iParts[3], true);
                foreach ($elements as $value) {
                    unset($menuItems[$value]);
                }
            }
        }
        // Return processed menu items:
        return $menuItems;
    }

    /**
     * Clean up spacers; Will remove any spacers in the start/end of menu items array plus any duplicates.
     *
     * @param array $menuItems Menu items array
     * @return array Menu items array, processed.
     */
    public function cleanUpSpacers($menuItems)
    {
        // Remove doubles:
        $prevItemWasSpacer = false;
        foreach ($menuItems as $key => $value) {
            if (is_string($value) && $value === 'spacer') {
                if ($prevItemWasSpacer) {
                    unset($menuItems[$key]);
                }
                $prevItemWasSpacer = true;
            } else {
                $prevItemWasSpacer = false;
            }
        }
        // Remove first:
        reset($menuItems);
        $key = key($menuItems);
        $value = current($menuItems);
        if (is_string($value) && $value === 'spacer') {
            unset($menuItems[$key]);
        }
        // Remove last:
        end($menuItems);
        $key = key($menuItems);
        $value = current($menuItems);
        if (is_string($value) && $value === 'spacer') {
            unset($menuItems[$key]);
        }
        // Return processed menu items:
        return $menuItems;
    }

    /**
     * Get label from locallang_core.xlf:cm.*
     *
     * @param string $label The "cm."-suffix to get.
     * @return string
     */
    public function label($label)
    {
1585
        return htmlspecialchars($this->languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:cm.' . $label));
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
    }

    /**
     * Returns TRUE if there should be writing to the div-layers (commands sent to clipboard MUST NOT write to div-layers)
     *
     * @return bool
     */
    public function isCMlayers()
    {
        return !$this->CB;
    }

    /**
     * Appends ".location" to input string
     *
     * @param string $str Input string, probably a JavaScript document reference
     * @return string
     */
    public function frameLocation($str)
    {
        return $str . '.location';
    }
1608
}