[TASK] Reduce CGL violations DoubleQuoteUsageNotRequired in /typo3/
[Packages/TYPO3.CMS.git] / typo3 / alt_clickmenu.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * Context menu
29 *
30 * The script is called in the top frame of the backend typically by a click on an icon for which a context menu should appear.
31 * Either this script displays the context menu horizontally in the top frame or alternatively (default in MSIE, Mozilla) it writes the output to a <div>-layer in the calling document (which then appears as a layer/context sensitive menu)
32 * Writing content back into a <div>-layer is necessary if we want individualized context menus with any specific content for any specific element.
33 * Context menus can appear for either database elements or files
34 * The input to this script is basically the "&init" var which is divided by "|" - each part is a reference to table|uid|listframe-flag.
35 *
36 * If you want to integrate a context menu in your scripts, please see template::getContextMenuCode()
37 *
38 * Revised for TYPO3 3.6 2/2003 by Kasper Skårhøj
39 * XHTML compliant
40 *
41 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
42 */
43
44
45 require ('init.php');
46 require ('template.php');
47 $LANG->includeLLFile('EXT:lang/locallang_misc.xml');
48
49
50
51
52 /**
53 * Class for generating the click menu
54 *
55 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
56 * @package TYPO3
57 * @subpackage core
58 * @internal
59 */
60 class clickMenu {
61
62 // Internal, static: GPvar:
63 var $cmLevel=0; // Defines if the click menu is first level or second. Second means the click menu is triggered from another menu.
64 var $CB; // Clipboard array (submitted by eg. pressing the paste button)
65
66 // Internal, static:
67 var $backPath=''; // Backpath for scripts/images.
68 var $PH_backPath='###BACK_PATH###'; // BackPath place holder: We need different backPath set whether the clickmenu is written back to a frame which is not in typo3/ dir or if the clickmenu is shown in the top frame (no backpath)
69 var $listFrame=0; // If set, the calling document should be in the listframe of a frameset.
70 var $isDBmenu=0; // If set, the menu is about database records, not files. (set if part 2 [1] of the item-var is NOT blank)
71 var $alwaysContentFrame=0; // If TRUE, the "content" frame is always used for reference (when condensed mode is enabled)
72 var $iParts=array(); // 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
73 var $disabledItems=array(); // Contains list of keywords of items to disable in the menu
74 var $dontDisplayTopFrameCM=0; // If TRUE, the context sensitive menu will not appear in the top frame, only as a layer.
75 var $leftIcons=0; // If TRUE, Show icons on the left.
76 var $extClassArray=array(); // 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.
77 var $ajax=0; // enable/disable ajax behavior
78
79 // Internal, dynamic:
80 var $elCount=0; // Counter for elements in the menu. Used to number the name / id of the mouse-over icon.
81 var $editPageIconSet=0; // Set, when edit icon is drawn.
82 var $editOK=0; // Set to TRUE, if editing of the element is OK.
83 var $rec=array();
84
85
86
87 /**
88 * Initialize click menu
89 *
90 * @return string The clickmenu HTML content
91 */
92 function init() {
93 // Setting GPvars:
94 $this->cmLevel = intval(t3lib_div::_GP('cmLevel'));
95 $this->CB = t3lib_div::_GP('CB');
96 if(t3lib_div::_GP('ajax')) {
97 $this->ajax = 1;
98 // XML has to be parsed, no parse errors allowed
99 @ini_set('display_errors', 0);
100 }
101
102 // Deal with Drag&Drop context menus
103 if (strcmp(t3lib_div::_GP('dragDrop'), '')) {
104 $CMcontent = $this->printDragDropClickMenu(t3lib_div::_GP('dragDrop'), t3lib_div::_GP('srcId'), t3lib_div::_GP('dstId'));
105 return $CMcontent;
106 }
107
108 // can be set differently as well
109 $this->iParts[0] = t3lib_div::_GP('table');
110 $this->iParts[1] = t3lib_div::_GP('uid');
111 $this->iParts[2] = t3lib_div::_GP('listFr');
112 $this->iParts[3] = t3lib_div::_GP('enDisItems');
113
114 // Setting flags:
115 if ($this->iParts[2]) $this->listFrame=1;
116 if ($GLOBALS['BE_USER']->uc['condensedMode'] || $this->iParts[2]==2) $this->alwaysContentFrame=1;
117 if (strcmp($this->iParts[1], '')) $this->isDBmenu=1;
118
119 $TSkey = ($this->isDBmenu? 'page' : 'folder' ) . ($this->listFrame ? 'List' : 'Tree');
120 $this->disabledItems = t3lib_div::trimExplode(',', $GLOBALS['BE_USER']->getTSConfigVal('options.contextMenu.'.$TSkey.'.disableItems'), 1);
121 $this->leftIcons = $GLOBALS['BE_USER']->getTSConfigVal('options.contextMenu.options.leftIcons');
122
123 // &cmLevel flag detected (2nd level menu)
124 if (!$this->cmLevel) {
125 // Make 1st level clickmenu:
126 if ($this->isDBmenu) {
127 $CMcontent = $this->printDBClickMenu($this->iParts[0], $this->iParts[1]);
128 } else {
129 $CMcontent = $this->printFileClickMenu($this->iParts[0]);
130 }
131 } else {
132 // Make 2nd level clickmenu (only for DBmenus)
133 if ($this->isDBmenu) {
134 $CMcontent = $this->printNewDBLevel($this->iParts[0], $this->iParts[1]);
135 }
136 }
137
138 // Return clickmenu content:
139 return $CMcontent;
140 }
141
142 /**
143 * Returns TRUE if the menu should (also?) be displayed in topframe, not just <div>-layers
144 *
145 * @return boolean
146 */
147 function doDisplayTopFrameCM() {
148 if ($this->ajax) {
149 return FALSE;
150 } else {
151 return !$GLOBALS['SOBE']->doc->isCMlayers() || !$this->dontDisplayTopFrameCM;
152 }
153 }
154
155
156
157
158
159
160
161
162
163
164
165
166 /***************************************
167 *
168 * DATABASE
169 *
170 ***************************************/
171
172 /**
173 * Make 1st level clickmenu:
174 *
175 * @param string Table name
176 * @param integer UID for the current record.
177 * @return string HTML content
178 */
179 function printDBClickMenu($table, $uid) {
180
181 // Get record:
182 $this->rec = t3lib_BEfunc::getRecordWSOL($table, $uid);
183 $menuItems=array();
184
185 $root=0;
186 $DBmount = FALSE;
187 if ($table=='pages' && !strcmp($uid, '0')) { // Rootlevel
188 $root=1;
189 }
190
191 if ($table=='pages' && in_array($uid, $GLOBALS['BE_USER']->returnWebmounts())) { // DB mount
192 $DBmount = TRUE;
193 }
194 // used to hide cut,copy icons for l10n-records
195 $l10nOverlay = FALSE;
196 // should only be performed for overlay-records within the same table
197 if (t3lib_BEfunc::isTableLocalizable($table) && !isset($GLOBALS['TCA'][$table]['ctrl']['transOrigPointerTable'])) {
198 $l10nOverlay = intval($this->rec[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']]) != 0;
199 }
200
201 // If record found (or root), go ahead and fill the $menuItems array which will contain data for the elements to render.
202 if (is_array($this->rec) || $root) {
203
204 // Get permissions
205 $lCP = $GLOBALS['BE_USER']->calcPerms(t3lib_BEfunc::getRecord('pages', ($table=='pages'?$this->rec['uid']:$this->rec['pid'])));
206
207 // View
208 if (!in_array('view', $this->disabledItems)) {
209 if ($table=='pages') $menuItems['view']=$this->DB_view($uid);
210 if ($table==$GLOBALS['TYPO3_CONF_VARS']['SYS']['contentTable']) {
211 $ws_rec = t3lib_BEfunc::getRecordWSOL($table, $this->rec['uid']);
212 $menuItems['view']=$this->DB_view($ws_rec['pid']);
213 }
214 }
215
216 // Edit:
217 if(!$root && ($GLOBALS['BE_USER']->isPSet($lCP, $table, 'edit') || $GLOBALS['BE_USER']->isPSet($lCP, $table, 'editcontent'))) {
218 if (!in_array('edit', $this->disabledItems)) $menuItems['edit']=$this->DB_edit($table, $uid);
219 $this->editOK=1;
220 }
221
222 // New:
223 if (!in_array('new', $this->disabledItems) && $GLOBALS['BE_USER']->isPSet($lCP, $table, 'new')) {
224 $menuItems['new'] = $this->DB_new($table, $uid);
225 }
226
227 // Info:
228 if(!in_array('info', $this->disabledItems) && !$root) $menuItems['info']=$this->DB_info($table, $uid);
229
230 $menuItems['spacer1']='spacer';
231
232 // Copy:
233 if (!in_array('copy', $this->disabledItems) && !$root && !$DBmount && !$l10nOverlay) $menuItems['copy'] = $this->DB_copycut($table, $uid, 'copy');
234 // Cut:
235 if (!in_array('cut', $this->disabledItems) && !$root && !$DBmount && !$l10nOverlay) $menuItems['cut'] = $this->DB_copycut($table, $uid, 'cut');
236
237 // Paste:
238 $elFromAllTables = count($this->clipObj->elFromTable(''));
239 if (!in_array('paste', $this->disabledItems) && $elFromAllTables) {
240 $selItem = $this->clipObj->getSelectedRecord();
241 $elInfo=array(
242 t3lib_div::fixed_lgd_cs($selItem['_RECORD_TITLE'],
243 $GLOBALS['BE_USER']->uc['titleLen']),
244 ($root
245 ? $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']
246 : t3lib_div::fixed_lgd_cs(t3lib_BEfunc::getRecordTitle($table, $this->rec), $GLOBALS['BE_USER']->uc['titleLen'])
247 ),
248 $this->clipObj->currentMode()
249 );
250 if ($table=='pages' && ($lCP & 8)) {
251 if ($elFromAllTables) $menuItems['pasteinto']=$this->DB_paste('', $uid, 'into', $elInfo);
252 }
253
254 $elFromTable = count($this->clipObj->elFromTable($table));
255 if (!$root && !$DBmount && $elFromTable && $GLOBALS['TCA'][$table]['ctrl']['sortby']) $menuItems['pasteafter']=$this->DB_paste($table, -$uid, 'after', $elInfo);
256 }
257
258 // Delete:
259 $elInfo=array(t3lib_div::fixed_lgd_cs(t3lib_BEfunc::getRecordTitle($table, $this->rec), $GLOBALS['BE_USER']->uc['titleLen']));
260 if(!in_array('delete', $this->disabledItems) && !$root && !$DBmount && $GLOBALS['BE_USER']->isPSet($lCP, $table, 'delete')) {
261 $menuItems['spacer2']='spacer';
262 $menuItems['delete']=$this->DB_delete($table, $uid, $elInfo);
263 }
264
265 if(!in_array('history', $this->disabledItems)) {
266 $menuItems['history']=$this->DB_history($table, $uid, $elInfo);
267 }
268 }
269
270 // Adding external elements to the menuItems array
271 $menuItems = $this->processingByExtClassArray($menuItems, $table, $uid);
272
273 // Processing by external functions?
274 $menuItems = $this->externalProcessingOfDBMenuItems($menuItems);
275
276 if (!is_array($this->rec)) {
277 $this->rec = array();
278 }
279
280 // Return the printed elements:
281 return $this->printItems($menuItems,
282 $root?
283 t3lib_iconWorks::getSpriteIcon('apps-pagetree-root') . htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']) :
284 t3lib_iconWorks::getSpriteIconForRecord($table, $this->rec, array('title'=> htmlspecialchars(t3lib_BEfunc::getRecordIconAltText($this->rec, $table)))) . t3lib_BEfunc::getRecordTitle($table, $this->rec, TRUE)
285 );
286 }
287
288 /**
289 * Make 2nd level clickmenu (only for DBmenus)
290 *
291 * @param string Table name
292 * @param integer UID for the current record.
293 * @return string HTML content
294 */
295 function printNewDBLevel($table, $uid) {
296
297 // Setting internal record to the table/uid :
298 $this->rec = t3lib_BEfunc::getRecordWSOL($table, $uid);
299 $menuItems=array();
300 $root=0;
301 if ($table=='pages' && !strcmp($uid, '0')) { // Rootlevel
302 $root=1;
303 }
304
305 // If record was found, check permissions and get menu items.
306 if (is_array($this->rec) || $root) {
307 $lCP = $GLOBALS['BE_USER']->calcPerms(t3lib_BEfunc::getRecord(
308 'pages',
309 ($table=='pages' ? $this->rec['uid'] : $this->rec['pid']))
310 );
311 // Edit:
312 if (!$root && ($GLOBALS['BE_USER']->isPSet($lCP, $table, 'edit') || $GLOBALS['BE_USER']->isPSet($lCP, $table, 'editcontent'))) {
313 $this->editOK=1;
314 }
315
316 $menuItems = $this->processingByExtClassArray($menuItems, $table, $uid);
317 }
318
319 // Return the printed elements:
320 if (!is_array($menuItems)) $menuItems=array();
321 return $this->printItems($menuItems,
322 $root?
323 t3lib_iconWorks::getSpriteIcon('apps-pagetree-root') . htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']):
324 t3lib_iconWorks::getSpriteIconForRecord($table, $this->rec,
325 array('title' => htmlspecialchars(t3lib_BEfunc::getRecordIconAltText($this->rec, $table)))) .
326 t3lib_BEfunc::getRecordTitle($table, $this->rec, TRUE)
327 );
328 }
329
330 /**
331 * Processing the $menuItems array (for extension classes) (DATABASE RECORDS)
332 *
333 * @param array $menuItems array for manipulation.
334 * @return array Processed $menuItems array
335 */
336 function externalProcessingOfDBMenuItems($menuItems) {
337 return $menuItems;
338 }
339
340 /**
341 * Processing the $menuItems array by external classes (typ. adding items)
342 *
343 * @param array $menuItems array for manipulation.
344 * @param string Table name
345 * @param integer UID for the current record.
346 * @return array Processed $menuItems array
347 */
348 function processingByExtClassArray($menuItems, $table, $uid) {
349 if (is_array($this->extClassArray)) {
350 foreach ($this->extClassArray as $conf) {
351 $obj=t3lib_div::makeInstance($conf['name']);
352 $menuItems = $obj->main($this, $menuItems, $table, $uid);
353 }
354 }
355 return $menuItems;
356 }
357
358 /**
359 * Returning JavaScript for the onClick event linking to the input URL.
360 *
361 * @param string The URL relative to TYPO3_mainDir
362 * @param string The return_url-parameter
363 * @param boolean If set, the "hideCM()" will be called
364 * @param string If set, gives alternative location to load in (for example top frame or somewhere else)
365 * @return string JavaScript for an onClick event.
366 */
367 function urlRefForCM($url, $retUrl='', $hideCM=1, $overrideLoc='') {
368 $loc = 'top.content.list_frame';
369 $editOnClick= ($overrideLoc ? 'var docRef='.$overrideLoc : 'var docRef=(top.content.list_frame)?top.content.list_frame:'.$loc).'; docRef.location.href=top.TS.PATH_typo3+\''.$url.'\''.
370 ($retUrl ? "+'&" . $retUrl . "='+top.rawurlencode(" . $this->frameLocation('docRef.document') . '.pathname+' . $this->frameLocation('docRef.document') . '.search)' : '') . ';' .
371 ($hideCM ? 'return hideCM();' : '');
372 return $editOnClick;
373 }
374
375 /**
376 * Adding CM element for Clipboard "copy" and "cut"
377 *
378 * @param string Table name
379 * @param integer UID for the current record.
380 * @param string Type: "copy" or "cut"
381 * @return array Item array, element in $menuItems
382 * @internal
383 */
384 function DB_copycut($table, $uid, $type) {
385 if ($this->clipObj->current=='normal') {
386 $isSel = $this->clipObj->isSelected($table, $uid);
387 }
388
389 $addParam = array();
390 if ($this->listFrame) {
391 $addParam['reloadListFrame'] = ($this->alwaysContentFrame ? 2 : 1);
392 }
393
394 return $this->linkItem(
395 $this->label($type),
396 $this->excludeIcon(t3lib_iconWorks::getSpriteIcon('actions-edit-' . $type . ($isSel === $type ? '-release' : ''))),
397 "top.loadTopMenu('" . $this->clipObj->selUrlDB($table, $uid, ($type == 'copy' ? 1: 0), ($isSel==$type), $addParam) . "');return false;"
398 );
399 }
400
401 /**
402 * Adding CM element for Clipboard "paste into"/"paste after"
403 * NOTICE: $table and $uid should follow the special syntax for paste, see clipboard-class :: pasteUrl();
404 *
405 * @param string Table name
406 * @param integer UID for the current record. NOTICE: Special syntax!
407 * @param string Type: "into" or "after"
408 * @param array Contains instructions about whether to copy or cut an element.
409 * @return array Item array, element in $menuItems
410 * @see t3lib_clipboard::pasteUrl()
411 * @internal
412 */
413 function DB_paste($table, $uid, $type, $elInfo) {
414 $editOnClick = '';
415 $loc = 'top.content.list_frame';
416 if($GLOBALS['BE_USER']->jsConfirmation(2)) {
417 $conf = $loc.' && confirm('.$GLOBALS['LANG']->JScharCode(sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:mess.'.($elInfo[2]=='copy'?'copy':'move').'_'.$type), $elInfo[0], $elInfo[1])).')';
418 } else {
419 $conf = $loc;
420 }
421 $editOnClick = 'if(' . $conf . '){' . $loc . '.location.href=top.TS.PATH_typo3+\'' . $this->clipObj->pasteUrl($table, $uid, 0) . '&redirect=\'+top.rawurlencode(' . $this->frameLocation($loc . '.document') . '.pathname+' . $this->frameLocation($loc . '.document') . '.search); hideCM();}';
422
423 return $this->linkItem(
424 $this->label('paste'.$type),
425 $this->excludeIcon(t3lib_iconWorks::getSpriteIcon('actions-document-paste-' . $type)),
426 $editOnClick.'return false;'
427 );
428 }
429
430 /**
431 * Adding CM element for Info
432 *
433 * @param string Table name
434 * @param integer UID for the current record.
435 * @return array Item array, element in $menuItems
436 * @internal
437 */
438 function DB_info($table, $uid) {
439 return $this->linkItem(
440 $this->label('info'),
441 $this->excludeIcon(t3lib_iconWorks::getSpriteIcon('actions-document-info')),
442 "top.launchView('".$table."', '".$uid."'); return hideCM();"
443 );
444 }
445
446 /**
447 * Adding CM element for History
448 *
449 * @param string Table name
450 * @param integer UID for the current record.
451 * @return array Item array, element in $menuItems
452 * @internal
453 */
454 function DB_history($table, $uid) {
455 $url = 'show_rechis.php?element='.rawurlencode($table.':'.$uid);
456 return $this->linkItem(
457 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_history')),
458 $this->excludeIcon(t3lib_iconWorks::getSpriteIcon('actions-document-history-open')),
459 $this->urlRefForCM($url, 'returnUrl'),
460 0
461 );
462 }
463
464 /**
465 * Adding CM element for Permission setting
466 *
467 * @param string Table name
468 * @param integer UID for the current record.
469 * @param array The "pages" record with "perms_*" fields inside.
470 * @return array Item array, element in $menuItems
471 * @internal
472 */
473 function DB_perms($table, $uid, $rec) {
474 if (!t3lib_extMgm::isLoaded('perm')) {
475 return '';
476 }
477 $url = t3lib_extMgm::extRelPath('perm') . 'mod1/index.php?id=' . $uid . ($rec['perms_userid'] == $GLOBALS['BE_USER']->user['uid'] || $GLOBALS['BE_USER']->isAdmin() ? '&return_id=' . $uid . '&edit=1' : '');
478 return $this->linkItem(
479 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_perms')),
480 $this->excludeIcon(t3lib_iconWorks::getSpriteIcon('status-status-locked')),
481 $this->urlRefForCM($url),
482 0
483 );
484 }
485
486 /**
487 * Adding CM element for DBlist
488 *
489 * @param string Table name
490 * @param integer UID for the current record.
491 * @param array Record of the element (needs "pid" field if not pages-record)
492 * @return array Item array, element in $menuItems
493 * @internal
494 */
495 function DB_db_list($table, $uid, $rec) {
496 $urlParams = array();
497 $urlParams['id'] = ($table == 'pages') ? $uid : $rec['pid'];
498 $urlParams['table'] = $table == 'pages' ? '' : $table;
499 $url = t3lib_BEfunc::getModuleUrl('web_list', $urlParams, '', TRUE);
500 return $this->linkItem(
501 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_db_list')),
502 $this->excludeIcon(t3lib_iconWorks::getSpriteIcon('actions-system-list-open')),
503 "top.nextLoadModuleUrl='".$url."';top.goToModule('web_list', 1);",
504 0
505 );
506 }
507
508 /**
509 * Adding CM element for Moving wizard
510 *
511 * @param string Table name
512 * @param integer UID for the current record.
513 * @param array Record. Needed for tt-content elements which will have the sys_language_uid sent
514 * @return array Item array, element in $menuItems
515 * @internal
516 */
517 function DB_moveWizard($table, $uid, $rec) {
518 $url = 'move_el.php?table=' . $table . '&uid=' . $uid .
519 ($table=='tt_content' ? '&sys_language_uid=' . intval($rec['sys_language_uid']) : ''); // Hardcoded field for tt_content elements.
520
521 return $this->linkItem(
522 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_moveWizard' . ($table=='pages' ? '_page' : ''))),
523 $this->excludeIcon(t3lib_iconWorks::getSpriteIcon('actions-' . ($table === 'pages' ? 'page' : 'document' ) . '-move')),
524 $this->urlRefForCM($url, 'returnUrl'),
525 0
526 );
527 }
528
529 /**
530 * Adding CM element for Create new wizard (either db_new.php or sysext/cms/layout/db_new_content_el.php or custom wizard)
531 *
532 * @param string Table name
533 * @param integer UID for the current record.
534 * @param array Record.
535 * @return array Item array, element in $menuItems
536 * @internal
537 */
538 function DB_newWizard($table, $uid, $rec) {
539 // If mod.web_list.newContentWiz.overrideWithExtension is set, use that extension's create new content wizard instead:
540 $tmpTSc = t3lib_BEfunc::getModTSconfig($this->pageinfo['uid'], 'mod.web_list');
541 $tmpTSc = $tmpTSc['properties']['newContentWiz.']['overrideWithExtension'];
542 $newContentWizScriptPath = t3lib_extMgm::isLoaded($tmpTSc) ? (t3lib_extMgm::extRelPath($tmpTSc).'mod1/db_new_content_el.php') : 'sysext/cms/layout/db_new_content_el.php';
543
544 $url = ($table=='pages' || !t3lib_extMgm::isLoaded('cms')) ? 'db_new.php?id='.$uid.'&pagesOnly=1' : $newContentWizScriptPath.'?id='.$rec['pid'].'&sys_language_uid='.intval($rec['sys_language_uid']);
545 return $this->linkItem(
546 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_newWizard')),
547 $this->excludeIcon(t3lib_iconWorks::getSpriteIcon('actions-' . ($table === 'pages' ? 'page' : 'document' ) . '-new')),
548 $this->urlRefForCM($url, 'returnUrl'),
549 0
550 );
551 }
552
553 /**
554 * Adding CM element for Editing of the access related fields of a table (disable, starttime, endtime, fe_groups)
555 *
556 * @param string Table name
557 * @param integer UID for the current record.
558 * @return array Item array, element in $menuItems
559 * @internal
560 */
561 function DB_editAccess($table, $uid) {
562 $addParam='&columnsOnly='.rawurlencode(implode(',', $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']).($table=='pages' ? ',extendToSubpages' :''));
563 $url = 'alt_doc.php?edit['.$table.']['.$uid.']=edit'.$addParam;
564 return $this->linkItem(
565 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_editAccess')),
566 $this->excludeIcon(t3lib_iconWorks::getSpriteIcon('actions-document-edit-access')),
567 $this->urlRefForCM($url, 'returnUrl'),
568 1 // no top frame CM!
569 );
570 }
571
572 /**
573 * Adding CM element for edit page properties
574 *
575 * @param integer page uid to edit (PID)
576 * @return array Item array, element in $menuItems
577 * @internal
578 */
579 function DB_editPageProperties($uid) {
580 $url = 'alt_doc.php?edit[pages]['.$uid.']=edit';
581 return $this->linkItem(
582 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_editPageProperties')),
583 $this->excludeIcon(t3lib_iconWorks::getSpriteIcon('actions-page-open')),
584 $this->urlRefForCM($url, 'returnUrl'),
585 1 // no top frame CM!
586 );
587 }
588
589 /**
590 * Adding CM element for regular editing of the element!
591 *
592 * @param string Table name
593 * @param integer UID for the current record.
594 * @return array Item array, element in $menuItems
595 * @internal
596 */
597 function DB_edit($table, $uid) {
598
599 // If another module was specified, replace the default Page module with the new one
600 $newPageModule = trim($GLOBALS['BE_USER']->getTSConfigVal('options.overridePageModule'));
601 $pageModule = t3lib_BEfunc::isModuleSetInTBE_MODULES($newPageModule) ? $newPageModule : 'web_layout';
602
603 $editOnClick='';
604 $loc = 'top.content.list_frame';
605 $addParam='';
606 $theIcon = 'actions-document-open';
607 if (
608 $this->iParts[0]=='pages' &&
609 $this->iParts[1] &&
610 $GLOBALS['BE_USER']->check('modules', $pageModule)
611 ) {
612 $theIcon = 'actions-page-open';
613 $this->editPageIconSet=1;
614 if ($GLOBALS['BE_USER']->uc['classicPageEditMode'] || !t3lib_extMgm::isLoaded('cms')) {
615 $addParam='&editRegularContentFromId='.intval($this->iParts[1]);
616 } else {
617 $editOnClick = 'if(' . $loc . '){' . $loc . ".location.href=top.TS.PATH_typo3+'alt_doc.php?returnUrl='+top.rawurlencode(" . $this->frameLocation($loc . '.document') . '.pathname+' . $this->frameLocation($loc . '.document') . ".search)+'&edit[" . $table . '][' . $uid . ']=edit' . $addParam . "';}";
618 }
619 }
620 if (!$editOnClick) {
621 $editOnClick = 'if(' . $loc . '){' . $loc . ".location.href=top.TS.PATH_typo3+'alt_doc.php?returnUrl='+top.rawurlencode(" . $this->frameLocation($loc . '.document') . '.pathname+' . $this->frameLocation($loc . '.document') . ".search)+'&edit[" . $table . '][' . $uid . ']=edit' . $addParam . "';}";
622 }
623
624 return $this->linkItem(
625 $this->label('edit'),
626 $this->excludeIcon(t3lib_iconWorks::getSpriteIcon($theIcon)),
627 $editOnClick.'return hideCM();'
628 );
629 }
630
631 /**
632 * Adding CM element for regular Create new element
633 *
634 * @param string Table name
635 * @param integer UID for the current record.
636 * @return array Item array, element in $menuItems
637 * @internal
638 */
639 function DB_new($table, $uid) {
640 $editOnClick='';
641 $loc = 'top.content.list_frame';
642 $editOnClick='if('.$loc.'){'.$loc.".location.href=top.TS.PATH_typo3+'".
643 ($this->listFrame?
644 "alt_doc.php?returnUrl='+top.rawurlencode(" . $this->frameLocation($loc . '.document') . '.pathname+' . $this->frameLocation($loc . '.document') . ".search)+'&edit[" . $table . '][-' . $uid . "]=new'":
645 'db_new.php?id='.intval($uid)."'").
646 ';}';
647
648 return $this->linkItem(
649 $this->label('new'),
650 $this->excludeIcon(t3lib_iconWorks::getSpriteIcon('actions-' . ($table === 'pages' ? 'page' : 'document' ) . '-new')),
651 $editOnClick.'return hideCM();'
652 );
653 }
654
655 /**
656 * Adding CM element for Delete
657 *
658 * @param string Table name
659 * @param integer UID for the current record.
660 * @param array Label for including in the confirmation message, EXT:lang/locallang_core.php:mess.delete
661 * @return array Item array, element in $menuItems
662 * @internal
663 */
664 function DB_delete($table, $uid, $elInfo) {
665 $editOnClick='';
666 $loc = 'top.content.list_frame';
667 if($GLOBALS['BE_USER']->jsConfirmation(4)) {
668 $conf = 'confirm(' . $GLOBALS['LANG']->JScharCode(sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:mess.delete'), $elInfo[0]) .
669 t3lib_BEfunc::referenceCount($table, $uid, ' (There are %s reference(s) to this record!)') .
670 t3lib_BEfunc::translationCount($table, $uid, ' ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.translationsOfRecord'))
671 ) . ')';
672 } else {
673 $conf = '1==1';
674 }
675 $editOnClick = 'if(' . $loc . ' && ' . $conf . ' ){' . $loc . ".location.href=top.TS.PATH_typo3+'tce_db.php?redirect='+top.rawurlencode(" . $this->frameLocation($loc . '.document') . '.pathname+' . $this->frameLocation($loc . '.document') . ".search)+'" .
676 '&cmd[' . $table . '][' . $uid . '][delete]=1&prErr=1&vC=' . $GLOBALS['BE_USER']->veriCode() . t3lib_BEfunc::getUrlToken('tceAction') . "';}hideCM();top.nav.refresh.defer(500, top.nav);";
677
678 return $this->linkItem(
679 $this->label('delete'),
680 $this->excludeIcon(t3lib_iconWorks::getSpriteIcon('actions-edit-delete')),
681 $editOnClick.'return false;'
682 );
683 }
684
685 /**
686 * Adding CM element for View Page
687 *
688 * @param integer Page uid (PID)
689 * @param string Anchor, if any
690 * @return array Item array, element in $menuItems
691 * @internal
692 */
693 function DB_view($id, $anchor='') {
694 return $this->linkItem(
695 $this->label('view'),
696 $this->excludeIcon(t3lib_iconWorks::getSpriteIcon('actions-document-view')),
697 t3lib_BEfunc::viewOnClick($id, $this->PH_backPath, t3lib_BEfunc::BEgetRootLine($id), $anchor).'return hideCM();'
698 );
699 }
700
701 /**
702 * Adding element for setting temporary mount point.
703 *
704 * @param integer Page uid (PID)
705 * @return array Item array, element in $menuItems
706 * @internal
707 */
708 function DB_tempMountPoint($page_id) {
709 return $this->linkItem(
710 $this->label('tempMountPoint'),
711 $this->excludeIcon(t3lib_iconWorks::getSpriteIcon('apps-pagetree-page-mountpoint')),
712 'if (top.content.nav_frame) {
713 var node = top.TYPO3.Backend.NavigationContainer.PageTree.getSelected();
714 if (node === null) {
715 return false;
716 }
717
718 var useNode = {
719 attributes: {
720 nodeData: {
721 id: ' . intval($page_id) . '
722 }
723 }
724 };
725
726 node.ownerTree.commandProvider.mountAsTreeRoot(useNode, node.ownerTree);
727 }
728 return hideCM();
729 '
730 );
731 }
732
733 /**
734 * Adding CM element for hide/unhide of the input record
735 *
736 * @param string Table name
737 * @param array Record array
738 * @param string Name of the hide field
739 * @return array Item array, element in $menuItems
740 * @internal
741 */
742 function DB_hideUnhide($table, $rec, $hideField) {
743 return $this->DB_changeFlag($table, $rec, $hideField, $this->label(($rec[$hideField]?'un':'').'hide'), 'hide');
744 }
745
746 /**
747 * Adding CM element for a flag field of the input record
748 *
749 * @param string Table name
750 * @param array Record array
751 * @param string Name of the flag field
752 * @param string Menu item Title
753 * @param string Name of the item used for icons and labels
754 * @param string Icon path relative to typo3/ folder
755 * @return array Item array, element in $menuItems
756 */
757 function DB_changeFlag($table, $rec, $flagField, $title, $name, $iconRelPath='gfx/') {
758 $uid = $rec['_ORIG_uid'] ? $rec['_ORIG_uid'] : $rec['uid'];
759 $editOnClick='';
760 $loc = 'top.content.list_frame';
761 $editOnClick = 'if(' . $loc . '){' . $loc . ".location.href=top.TS.PATH_typo3+'tce_db.php?redirect='" .
762 '+top.rawurlencode(' . $this->frameLocation($loc . '.document') . '.pathname+' . $this->frameLocation($loc . '.document') . ".search)+'" .
763 '&data[' . $table . '][' . $uid . '][' . $flagField . ']=' .
764 ($rec[$flagField] ? 0 : 1) . '&prErr=1&vC=' . $GLOBALS['BE_USER']->veriCode() . t3lib_BEfunc::getUrlToken('tceAction') . "';}hideCM();top.nav.refresh.defer(500, top.nav);";
765
766 return $this->linkItem(
767 $title,
768 $this->excludeIcon(t3lib_iconWorks::getSpriteIcon('actions-edit-' . ( $rec[$flagField] ? 'un' : '') . 'hide')),
769 $editOnClick.'return false;',
770 1
771 );
772 }
773
774
775
776
777
778
779
780
781 /***************************************
782 *
783 * FILE
784 *
785 ***************************************/
786
787 /**
788 * Make 1st level clickmenu:
789 *
790 * @param string $combinedIdentifier The combined identifier
791 * @return string HTML content
792 * @see t3lib_file_Factory::retrieveFileOrFolderObject()
793 */
794 function printFileClickMenu($combinedIdentifier) {
795 $menuItems=array();
796 $combinedIdentifier = rawurldecode($combinedIdentifier);
797
798 $fileObject = t3lib_file_Factory::getInstance()->retrieveFileOrFolderObject($combinedIdentifier);
799
800 if ($fileObject) {
801 $folder = FALSE;
802 $identifier = $fileObject->getCombinedIdentifier();
803 if ($fileObject instanceof t3lib_file_Folder) {
804 $icon = t3lib_iconWorks::getSpriteIconForFile(
805 'folder',
806 array(
807 'class'=>'absmiddle',
808 'title' => htmlspecialchars($fileObject->getName())
809 )
810 );
811 $folder = TRUE;
812 } else {
813 $icon = t3lib_iconWorks::getSpriteIconForFile(
814 $fileObject->getExtension(),
815 array(
816 'class'=>'absmiddle',
817 'title' => htmlspecialchars(
818 $fileObject->getName() .
819 ' (' . t3lib_div::formatSize($fileObject->getSize()) . ')'
820 )
821 )
822 );
823 }
824 // edit
825 if (!in_array('edit', $this->disabledItems) && !$folder
826 && t3lib_div::inList($GLOBALS['TYPO3_CONF_VARS']['SYS']['textfile_ext'], $fileObject->getExtension())) {
827 $menuItems['edit'] = $this->FILE_launch($identifier, 'file_edit.php', 'edit', 'edit_file.gif');
828 }
829 // rename
830 if (!in_array('rename', $this->disabledItems)) {
831 $menuItems['rename'] = $this->FILE_launch($identifier, 'file_rename.php', 'rename', 'rename.gif');
832 }
833 // upload
834 if (!in_array('upload', $this->disabledItems) && $folder) {
835 $menuItems['upload'] = $this->FILE_upload($identifier);
836 }
837
838 // new
839 if (!in_array('new', $this->disabledItems) && $folder) {
840 $menuItems['new'] = $this->FILE_launch($identifier, 'file_newfolder.php', 'new', 'new_file.gif');
841 }
842 // info
843 if (!in_array('info', $this->disabledItems)) {
844 $menuItems['info'] = $this->DB_info($identifier, '');
845 }
846
847 $menuItems[] = 'spacer';
848
849 // copy:
850 if (!in_array('copy', $this->disabledItems)) {
851 $menuItems['copy'] = $this->FILE_copycut($identifier, 'copy');
852 }
853 // cut:
854 if (!in_array('cut', $this->disabledItems)) {
855 $menuItems['cut'] = $this->FILE_copycut($identifier, 'cut');
856 }
857
858 // Paste:
859 $elFromAllTables = count($this->clipObj->elFromTable('_FILE'));
860 if (!in_array('paste', $this->disabledItems) && $elFromAllTables && $folder) {
861 $elArr = $this->clipObj->elFromTable('_FILE');
862 $selItem = reset($elArr);
863 $elInfo=array(
864 basename($selItem),
865 basename($path),
866 $this->clipObj->currentMode()
867 );
868 $menuItems['pasteinto'] = $this->FILE_paste($identifier, $selItem, $elInfo);
869 }
870
871 $menuItems[]='spacer';
872
873 // delete:
874 if (!in_array('delete', $this->disabledItems)) {
875 $menuItems['delete']=$this->FILE_delete($identifier);
876 }
877 }
878
879 // Adding external elements to the menuItems array
880 $menuItems = $this->processingByExtClassArray($menuItems, $identifier, 0);
881
882 // Processing by external functions?
883 $menuItems = $this->externalProcessingOfFileMenuItems($menuItems);
884
885 // Return the printed elements:
886 return $this->printItems($menuItems, $icon . $fileObject->getName());
887 }
888
889
890 /**
891 * Processing the $menuItems array (for extension classes) (FILES)
892 *
893 * @param array $menuItems array for manipulation.
894 * @return array Processed $menuItems array
895 */
896 function externalProcessingOfFileMenuItems($menuItems) {
897 return $menuItems;
898 }
899
900 /**
901 * Multi-function for adding an entry to the $menuItems array
902 *
903 * @param string Path to the file/directory (target)
904 * @param string Script (eg. file_edit.php) to pass &target= to
905 * @param string "type" is the code which fetches the correct label for the element from "cm."
906 * @param string icon image-filename from "gfx/" (12x12 icon)
907 * @param boolean If set, the return URL parameter will not be set in the link
908 * @return array Item array, element in $menuItems
909 * @internal
910 */
911 function FILE_launch($path, $script, $type, $image, $noReturnUrl=FALSE) {
912 $loc = 'top.content.list_frame';
913
914 $editOnClick = 'if(' . $loc . '){' . $loc . ".location.href=top.TS.PATH_typo3+'".$script.'?target=' . rawurlencode($path) . ($noReturnUrl ? "'" : "&returnUrl='+top.rawurlencode(" . $this->frameLocation($loc . '.document') . '.pathname+' . $this->frameLocation($loc . '.document') . '.search)') . ';}';
915 return $this->linkItem(
916 $this->label($type),
917 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/'.$image, 'width="12" height="12"').' alt="" />'),
918 $editOnClick . 'top.nav.refresh();return hideCM();'
919 );
920 }
921
922 /**
923 * function for adding an upload entry to the $menuItems array
924 *
925 * @param string Path to the file/directory (target)
926 * @return array Item array, element in $menuItems
927 * @internal
928 */
929 function FILE_upload($path) {
930 $script = 'file_upload.php';
931 $type = 'upload';
932 $image = 'upload.gif';
933 if ($GLOBALS['BE_USER']->uc['enableFlashUploader']) {
934 $loc = 'top.content.list_frame';
935
936 $editOnClick = 'if (top.TYPO3.FileUploadWindow.isFlashAvailable()) { initFlashUploader("' . rawurlencode($path) . '"); } else if(' . $loc . '){' . $loc . ".location.href=top.TS.PATH_typo3+'".$script.'?target=' . rawurlencode($path) . "';}";
937
938 return $this->linkItem(
939 $this->label($type),
940 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/'.$image, 'width="12" height="12"').' alt="" />'),
941 $editOnClick . 'return hideCM();'
942 );
943 } else {
944 return $this->FILE_launch($path, $script, $type, $image, TRUE);
945 }
946 }
947
948 /**
949 * Returns element for copy or cut of files.
950 *
951 * @param string Path to the file/directory (target)
952 * @param string Type: "copy" or "cut"
953 * @return array Item array, element in $menuItems
954 * @internal
955 */
956 function FILE_copycut($path, $type) {
957 $table = '_FILE'; // Pseudo table name for use in the clipboard.
958 $uid = t3lib_div::shortmd5($path);
959 if ($this->clipObj->current=='normal') {
960 $isSel = $this->clipObj->isSelected($table, $uid);
961 }
962
963 $addParam = array();
964 if ($this->listFrame) {
965 $addParam['reloadListFrame'] = ($this->alwaysContentFrame ? 2 : 1);
966 }
967
968 return $this->linkItem(
969 $this->label($type),
970 $this->excludeIcon(t3lib_iconWorks::getSpriteIcon('actions-edit-' . $type . ($isSel === $type ? '-release' : ''))),
971 "top.loadTopMenu('".$this->clipObj->selUrlFile($path, ($type=='copy'?1:0), ($isSel==$type), $addParam)."');return false;"
972 );
973 }
974
975 /**
976 * Creates element for deleting of target
977 *
978 * @param string Path to the file/directory (target)
979 * @return array Item array, element in $menuItems
980 * @internal
981 */
982 function FILE_delete($path) {
983 $editOnClick='';
984 $loc = 'top.content.list_frame';
985 if($GLOBALS['BE_USER']->jsConfirmation(4)) {
986 $conf = 'confirm(' . $GLOBALS['LANG']->JScharCode(sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:mess.delete'), basename($path)).t3lib_BEfunc::referenceCount('_FILE', $path, ' (There are %s reference(s) to this file!)')) . ')';
987 } else {
988 $conf = '1==1';
989 }
990 $editOnClick = 'if(' . $loc . ' && ' . $conf . ' ){' . $loc . ".location.href=top.TS.PATH_typo3+'tce_file.php?redirect='+top.rawurlencode(" . $this->frameLocation($loc . '.document') . '.pathname+' . $this->frameLocation($loc . '.document') . ".search)+'" .
991 '&file[delete][0][data]=' . rawurlencode($path) . '&vC=' . $GLOBALS['BE_USER']->veriCode() . "';}hideCM();";
992
993 return $this->linkItem(
994 $this->label('delete'),
995 $this->excludeIcon(t3lib_iconWorks::getSpriteIcon('actions-edit-delete')),
996 $editOnClick.'return false;'
997 );
998 }
999
1000 /**
1001 * Creates element for pasting files.
1002 *
1003 * @param string Path to the file/directory (target)
1004 * @param string target - NOT USED.
1005 * @param array Various values for the labels.
1006 * @return array Item array, element in $menuItems
1007 * @internal
1008 */
1009 function FILE_paste($path, $target, $elInfo) {
1010 $editOnClick='';
1011 $loc = 'top.content.list_frame';
1012 if($GLOBALS['BE_USER']->jsConfirmation(2)) {
1013 $conf = $loc . ' && confirm(' . $GLOBALS['LANG']->JScharCode(sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:mess.' . ($elInfo[2]=='copy'?'copy':'move') . '_into'), $elInfo[0], $elInfo[1])). ')';
1014 } else {
1015 $conf=$loc;
1016 }
1017
1018 $editOnClick='if('.$conf.'){'.$loc.".location.href=top.TS.PATH_typo3+'".$this->clipObj->pasteUrl('_FILE', $path, 0).
1019 "&redirect='+top.rawurlencode(" . $this->frameLocation($loc . '.document') . '.pathname+' . $this->frameLocation($loc . '.document') . '.search); }hideCM();top.nav.refresh();';
1020
1021 return $this->linkItem(
1022 $this->label('pasteinto'),
1023 $this->excludeIcon(t3lib_iconWorks::getSpriteIcon('actions-document-paste-into')),
1024 $editOnClick.'return false;'
1025 );
1026 }
1027
1028
1029
1030
1031
1032 /***************************************
1033 *
1034 * DRAG AND DROP
1035 *
1036 ***************************************/
1037
1038 /**
1039 * Make 1st level clickmenu:
1040 *
1041 * @param string The absolute path
1042 * @param integer UID for the current record.
1043 * @param integer Destination ID
1044 * @return string HTML content
1045 */
1046 function printDragDropClickMenu($table, $srcId, $dstId) {
1047 $menuItems=array();
1048
1049 // If the drag and drop menu should apply to PAGES use this set of menu items
1050 if ($table == 'pages') {
1051 // Move Into:
1052 $menuItems['movePage_into']=$this->dragDrop_copymovepage($srcId, $dstId, 'move', 'into');
1053 // Move After:
1054 $menuItems['movePage_after']=$this->dragDrop_copymovepage($srcId, $dstId, 'move', 'after');
1055 // Copy Into:
1056 $menuItems['copyPage_into']=$this->dragDrop_copymovepage($srcId, $dstId, 'copy', 'into');
1057 // Copy After:
1058 $menuItems['copyPage_after']=$this->dragDrop_copymovepage($srcId, $dstId, 'copy', 'after');
1059 }
1060
1061 // If the drag and drop menu should apply to FOLDERS use this set of menu items
1062 if ($table == 'folders') {
1063 // Move Into:
1064 $menuItems['moveFolder_into']=$this->dragDrop_copymovefolder($srcId, $dstId, 'move');
1065 // Copy Into:
1066 $menuItems['copyFolder_into']=$this->dragDrop_copymovefolder($srcId, $dstId, 'copy');
1067 }
1068
1069 // Adding external elements to the menuItems array
1070 $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
1071
1072 // Processing by external functions?
1073 $menuItems = $this->externalProcessingOfDBMenuItems($menuItems);
1074
1075 // Return the printed elements:
1076 return $this->printItems($menuItems,
1077 t3lib_iconWorks::getSpriteIconForRecord($table, $this->rec, array('title'=> t3lib_BEfunc::getRecordTitle($table, $this->rec, TRUE)))
1078 );
1079 }
1080
1081
1082 /**
1083 * Processing the $menuItems array (for extension classes) (DRAG'N DROP)
1084 *
1085 * @param array $menuItems array for manipulation.
1086 * @return array Processed $menuItems array
1087 */
1088 function externalProcessingOfDragDropMenuItems($menuItems) {
1089 return $menuItems;
1090 }
1091
1092
1093 /**
1094 * Adding CM element for Copying/Moving a Page Into/After from a drag & drop action
1095 *
1096 * @param integer source UID code for the record to modify
1097 * @param integer destination UID code for the record to modify
1098 * @param string Action code: either "move" or "copy"
1099 * @param string Parameter code: either "into" or "after"
1100 * @return array Item array, element in $menuItems
1101 * @internal
1102 */
1103 function dragDrop_copymovepage($srcUid, $dstUid, $action, $into) {
1104 $negativeSign = ($into == 'into') ? '' : '-';
1105 $editOnClick='';
1106 $loc = 'top.content.list_frame';
1107 $editOnClick = 'if(' . $loc . '){' . $loc . '.document.location=top.TS.PATH_typo3+"tce_db.php?redirect="+top.rawurlencode(' . $this->frameLocation($loc . '.document') . '.pathname+' . $this->frameLocation($loc . '.document') . '.search)+"' .
1108 '&cmd[pages][' . $srcUid . '][' . $action . ']=' . $negativeSign . $dstUid . '&prErr=1&vC=' . $GLOBALS['BE_USER']->veriCode() . t3lib_BEfunc::getUrlToken('tceAction') . '";}hideCM();top.nav.refresh();';
1109
1110 return $this->linkItem(
1111 $this->label($action.'Page_'.$into),
1112 $this->excludeIcon(t3lib_iconWorks::getSpriteIcon('actions-document-paste-' . $into)),
1113 $editOnClick.'return false;',
1114 0
1115 );
1116 }
1117
1118
1119 /**
1120 * Adding CM element for Copying/Moving a Folder Into from a drag & drop action
1121 *
1122 * @param string source path for the record to modify
1123 * @param string destination path for the records to modify
1124 * @param string Action code: either "move" or "copy"
1125 * @return array Item array, element in $menuItems
1126 * @internal
1127 */
1128 function dragDrop_copymovefolder($srcPath, $dstPath, $action) {
1129 $editOnClick='';
1130 $loc = 'top.content.list_frame';
1131 $editOnClick = 'if(' . $loc . '){' . $loc . '.document.location=top.TS.PATH_typo3+"tce_file.php?redirect="+top.rawurlencode(' . $this->frameLocation($loc . '.document') . '.pathname+' . $this->frameLocation($loc . '.document') . '.search)+"' .
1132 '&file['.$action.'][0][data]='.$srcPath.'&file['.$action.'][0][target]='.$dstPath.'&prErr=1&vC='.$GLOBALS['BE_USER']->veriCode().'";}hideCM();top.nav.refresh();';
1133
1134 return $this->linkItem(
1135 $this->label($action.'Folder_into'),
1136 $this->excludeIcon(t3lib_iconWorks::getSpriteIcon('apps-pagetree-drag-move-into')),
1137 $editOnClick.'return false;',
1138 0
1139 );
1140 }
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150 /***************************************
1151 *
1152 * COMMON
1153 *
1154 **************************************/
1155
1156 /**
1157 * Prints the items from input $menuItems array - both as topframe menu AND the JS section for writing to the div-layers.
1158 * Of course the topframe menu will appear only if $this->doDisplayTopFrameCM() returns TRUE
1159 *
1160 * @param array $menuItems array
1161 * @param string HTML code for the element which was clicked - shown in the end of the horizontal menu in topframe after the close-button.
1162 * @return string HTML code
1163 */
1164 function printItems($menuItems, $item) {
1165
1166 $out='';
1167
1168 // Enable/Disable items:
1169 $menuItems = $this->enableDisableItems($menuItems);
1170
1171 // Clean up spacers:
1172 $menuItems = $this->cleanUpSpacers($menuItems);
1173
1174 // Adding topframe part (horizontal clickmenu)
1175 if ($this->doDisplayTopFrameCM()) {
1176 $out.= '
1177
1178 <!--
1179 Table, which contains the click menu when shown in the top frame of the backend:
1180 -->
1181 <table border="0" cellpadding="0" cellspacing="0" id="typo3-CSM-top">
1182 <tr>
1183
1184 <!-- Items: -->
1185 <td class="c-item">'.
1186 implode('</td>
1187 <td><img'.t3lib_iconWorks::skinImg($this->PH_backPath, 'gfx/acm_spacer2.gif', 'width="8" height="12"').' alt="" /></td>
1188 <td class="c-item">',$this->menuItemsForTopFrame($menuItems)).
1189 '</td>
1190
1191 <!-- Close button: -->
1192 <td class="c-closebutton"><a href="#" onclick="hideCM();return false;">' .
1193 t3lib_iconWorks::getSpriteIcon('actions-document-close', array(
1194 'title'=> $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.close', 1)
1195 )) . '</a></td>
1196
1197 <!-- The item of the clickmenu: -->
1198 <td class="c-itemicon">'.$item.'</td>
1199 </tr>
1200 </table>
1201 ';
1202
1203 // Set remaining BACK_PATH to blank (if any)
1204 $out = str_replace($this->PH_backPath, '', $out);
1205 }
1206 // Adding JS part:
1207 $out.=$this->printLayerJScode($menuItems);
1208
1209 // Return the content
1210 return $out;
1211 }
1212
1213 /**
1214 * Create the JavaScript section
1215 *
1216 * @param array The $menuItems array to print
1217 * @return string The JavaScript section which will print the content of the CM to the div-layer in the target frame.
1218 */
1219 function printLayerJScode($menuItems) {
1220 $script='';
1221 if ($this->isCMlayers()) { // Clipboard must not be submitted - then it's probably a copy/cut situation.
1222 $frameName = '.'.($this->listFrame ? 'list_frame' : 'nav_frame');
1223 if ($this->alwaysContentFrame) $frameName='';
1224
1225 // Create the table displayed in the clickmenu layer:
1226 $CMtable = '
1227 <table border="0" cellpadding="0" cellspacing="0" class="typo3-CSM">
1228 '.implode('', $this->menuItemsForClickMenu($menuItems)).'
1229 </table>';
1230
1231 // Wrap the inner table in another table to create outer border:
1232 $CMtable = $this->wrapColorTableCM($CMtable);
1233
1234 // Set back path place holder to real back path
1235 $CMtable = str_replace($this->PH_backPath, $this->backPath, $CMtable);
1236 if ($this->ajax) {
1237 $innerXML = '<data><clickmenu><htmltable><![CDATA['.$CMtable.']]></htmltable><cmlevel>'.$this->cmLevel.'</cmlevel></clickmenu></data>';
1238 return $innerXML;
1239 } else {
1240 // Create JavaScript section:
1241 $script=$GLOBALS['TBE_TEMPLATE']->wrapScriptTags('
1242
1243 if (top.content && top.content'.$frameName.' && top.content'.$frameName.'.Clickmenu) {
1244 top.content'.$frameName.'.Clickmenu.populateData(unescape("'.t3lib_div::rawurlencodeJS($CMtable).'"),'.$this->cmLevel.');
1245 }
1246 '.(!$this->doDisplayTopFrameCM()?'hideCM();':'')
1247 );
1248 return $script;
1249 }
1250 }
1251 }
1252
1253 /**
1254 * Wrapping the input string in a table with background color 4 and a black border style.
1255 * For the pop-up menu
1256 *
1257 * @param string HTML content to wrap in table.
1258 * @return string
1259 */
1260 function wrapColorTableCM($str) {
1261
1262 return '<div class="typo3-CSM-wrapperCM">
1263 ' . $str . '
1264 </div>';
1265 }
1266
1267 /**
1268 * Traverses the menuItems and generates an output array for implosion in the topframe horizontal menu
1269 *
1270 * @param array $menuItem array
1271 * @param array Array with HTML content to be imploded between <td>-tags
1272 * @return array Array of menu items for top frame.
1273 */
1274 function menuItemsForTopFrame($menuItems) {
1275 $out=array();
1276 foreach ($menuItems as $i) {
1277 if ($i[4]==1 && !$GLOBALS['SOBE']->doc->isCMlayers()) $i[4]=0; // IF the topbar is the ONLY means of the click menu, then items normally disabled from the top menu will appear anyways IF they are disabled with a "1" (2+ will still disallow them in the topbar)
1278 if (is_array($i) && !$i[4]) $out[]=$i[0];
1279 }
1280 return $out;
1281 }
1282
1283 /**
1284 * Traverses the menuItems and generates an output array for implosion in the CM div-layers table.
1285 *
1286 * @param array $menuItem array
1287 * @param array Array with HTML content to be imploded between <td>-tags
1288 * @return array array for implosion in the CM div-layers table.
1289 */
1290 function menuItemsForClickMenu($menuItems) {
1291 $out=array();
1292 foreach ($menuItems as $cc => $i) {
1293 if (is_string($i) && $i=='spacer') { // MAKE horizontal spacer
1294 $out[]='
1295 <tr class="bgColor2">
1296 <td colspan="2"><img src="clear.gif" width="1" height="1" alt="" /></td>
1297 </tr>';
1298 } else { // Just make normal element:
1299 $onClick=$i[3];
1300 $onClick=preg_replace('/return[[:space:]]+hideCM\(\)[[:space:]]*;/i', '', $onClick);
1301 $onClick=preg_replace('/return[[:space:]]+false[[:space:]]*;/i', '', $onClick);
1302 $onClick=preg_replace('/hideCM\(\);/i', '', $onClick);
1303 if (!$i[5]) $onClick.='Clickmenu.hideAll();';
1304
1305 $CSM = ' oncontextmenu="'.htmlspecialchars($onClick).';return false;"';
1306
1307 $out[]='
1308 <tr class="typo3-CSM-itemRow" onclick="'.htmlspecialchars($onClick).'" onmouseover="this.bgColor=\''.$GLOBALS['TBE_TEMPLATE']->bgColor5.'\';" onmouseout="this.bgColor=\'\';"'.$CSM.'>
1309 '.(!$this->leftIcons?'<td class="typo3-CSM-item">'.$i[1].'</td><td align="center">'.$i[2].'</td>' : '<td align="center">'.$i[2].'</td><td class="typo3-CSM-item">'.$i[1].'</td>').'
1310 </tr>';
1311 }
1312 }
1313 return $out;
1314 }
1315
1316 /**
1317 * Adds or inserts a menu item
1318 * 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.
1319 *
1320 * @param array Menu items array
1321 * @param array Menu items array to insert
1322 * @param string 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.
1323 * @return array Menu items array, processed.
1324 */
1325 function addMenuItems($menuItems, $newMenuItems, $position='') {
1326 if (is_array($newMenuItems)) {
1327
1328 if($position) {
1329
1330 $posArr = t3lib_div::trimExplode(',', $position, 1);
1331 foreach($posArr as $pos) {
1332 list($place, $menuEntry) = t3lib_div::trimExplode(':', $pos, 1);
1333 list($place, $placeExtra) = t3lib_div::trimExplode('-', $place, 1);
1334
1335 // bottom
1336 $pointer = count($menuItems);
1337
1338 $found=FALSE;
1339
1340 if ($place) {
1341 switch(strtolower($place)) {
1342 case 'after':
1343 case 'before':
1344 if ($menuEntry) {
1345 $p=1;
1346 reset ($menuItems);
1347 while (TRUE) {
1348 if (!strcmp(key($menuItems), $menuEntry)) {
1349 $pointer = $p;
1350 $found=TRUE;
1351 break;
1352 }
1353 if (!next($menuItems)) break;
1354 $p++;
1355 }
1356 if (!$found) break;
1357
1358 if ($place=='before') {
1359 $pointer--;
1360 if ($placeExtra=='spacer' AND prev($menuItems)=='spacer') {
1361 $pointer--;
1362 }
1363 } elseif ($place=='after') {
1364 if ($placeExtra=='spacer' AND next($menuItems)=='spacer') {
1365 $pointer++;
1366 }
1367 }
1368 }
1369 break;
1370 default:
1371 if (strtolower($place)=='top') {
1372 $pointer = 0;
1373 } else {
1374 $pointer = count($menuItems);
1375 }
1376 $found=TRUE;
1377 break;
1378 }
1379 }
1380 if($found) break;
1381 }
1382 }
1383 $pointer=max(0, $pointer);
1384 $menuItemsBefore = array_slice($menuItems, 0, ($pointer?$pointer:0));
1385 $menuItemsAfter = array_slice($menuItems, $pointer);
1386 $menuItems = $menuItemsBefore + $newMenuItems + $menuItemsAfter;
1387 }
1388 return $menuItems;
1389 }
1390
1391 /**
1392 * Creating an array with various elements for the clickmenu entry
1393 *
1394 * @param string The label, htmlspecialchar'ed already
1395 * @param string <img>-tag for the icon
1396 * @param string JavaScript onclick event for label/icon
1397 * @param boolean ==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)
1398 * @param boolean If set, the clickmenu layer will not hide itself onclick - used for secondary menus to appear...
1399 * @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!
1400 */
1401 function linkItem($str, $icon, $onClick, $onlyCM=0, $dontHide=0) {
1402 $this->elCount++;
1403 if($this->ajax) {
1404 $onClick = str_replace('top.loadTopMenu', 'showClickmenu_raw', $onClick);
1405 }
1406
1407
1408 return array(
1409 t3lib_iconWorks::getSpriteIcon('empty-empty', array(
1410 'class' => 'c-roimg',
1411 'id'=> 'roimg_' . $this->elCount
1412 )) .
1413 '<a href="#" onclick="'.htmlspecialchars($onClick).'" onmouseover="mo('.$this->elCount.');" onmouseout="mout('.$this->elCount.');">'.
1414 $str.$icon.
1415 '</a>',
1416 $str,
1417 $icon,
1418 $onClick,
1419 $onlyCM,
1420 $dontHide
1421 );
1422 }
1423
1424 /**
1425 * Returns the input string IF not a user setting has disabled display of icons.
1426 *
1427 * @param string The icon-image tag
1428 * @return string The icon-image tag prefixed with space char IF the icon should be printed at all due to user settings
1429 */
1430 function excludeIcon($iconCode) {
1431 return ($GLOBALS['BE_USER']->uc['noMenuMode'] && strcmp($GLOBALS['BE_USER']->uc['noMenuMode'], 'icons')) ? '' : ' '.$iconCode;
1432 }
1433
1434 /**
1435 * Enabling / Disabling items based on list provided from GET var ($this->iParts[3])
1436 *
1437 * @param array Menu items array
1438 * @return array Menu items array, processed.
1439 */
1440 function enableDisableItems($menuItems) {
1441 if ($this->iParts[3]) {
1442
1443 // Detect "only" mode: (only showing listed items)
1444 if (substr($this->iParts[3], 0, 1)=='+') {
1445 $this->iParts[3] = substr($this->iParts[3], 1);
1446 $only = TRUE;
1447 } else {
1448 $only = FALSE;
1449 }
1450
1451 // Do filtering:
1452 if ($only) { // Transfer ONLY elements which are mentioned (or are spacers)
1453 $newMenuArray = array();
1454 foreach($menuItems as $key => $value) {
1455 if (t3lib_div::inList($this->iParts[3], $key) || (is_string($value) && $value=='spacer')) {
1456 $newMenuArray[$key] = $value;
1457 }
1458 }
1459 $menuItems = $newMenuArray;
1460 } else { // Traverse all elements except those listed (just unsetting them):
1461 $elements = t3lib_div::trimExplode(',', $this->iParts[3], 1);
1462 foreach($elements as $value) {
1463 unset($menuItems[$value]);
1464 }
1465 }
1466 }
1467
1468 // Return processed menu items:
1469 return $menuItems;
1470 }
1471
1472 /**
1473 * Clean up spacers; Will remove any spacers in the start/end of menu items array plus any duplicates.
1474 *
1475 * @param array Menu items array
1476 * @return array Menu items array, processed.
1477 */
1478 function cleanUpSpacers($menuItems) {
1479
1480 // Remove doubles:
1481 $prevItemWasSpacer = FALSE;
1482 foreach($menuItems as $key => $value) {
1483 if (is_string($value) && $value=='spacer') {
1484 if ($prevItemWasSpacer) {
1485 unset($menuItems[$key]);
1486 }
1487 $prevItemWasSpacer = TRUE;
1488 } else {
1489 $prevItemWasSpacer = FALSE;
1490 }
1491 }
1492
1493 // Remove first:
1494 reset($menuItems);
1495 $key = key($menuItems);
1496 $value = current($menuItems);
1497 if (is_string($value) && $value=='spacer') {
1498 unset($menuItems[$key]);
1499 }
1500
1501
1502 // Remove last:
1503 end($menuItems);
1504 $key = key($menuItems);
1505 $value = current($menuItems);
1506 if (is_string($value) && $value=='spacer') {
1507 unset($menuItems[$key]);
1508 }
1509
1510 // Return processed menu items:
1511 return $menuItems;
1512 }
1513
1514 /**
1515 * Get label from locallang_core.php:cm.*
1516 *
1517 * @param string The "cm."-suffix to get.
1518 * @return string
1519 */
1520 function label($label) {
1521 return $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:cm.'.$label, 1));
1522 }
1523
1524 /**
1525 * Returns TRUE if there should be writing to the div-layers (commands sent to clipboard MUST NOT write to div-layers)
1526 *
1527 * @return boolean
1528 */
1529 function isCMlayers() {
1530 if($this->ajax) {
1531 return !$this->CB;
1532 } else {
1533 return $GLOBALS['SOBE']->doc->isCMlayers() && !$this->CB;
1534 }
1535 }
1536
1537 /**
1538 * Appends ".location" to input string
1539 *
1540 * @param string Input string, probably a JavaScript document reference
1541 * @return string
1542 */
1543 function frameLocation($str) {
1544 return $str.'.location';
1545 }
1546 }
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560 /**
1561 * Script Class for the Context Sensitive Menu in TYPO3 (rendered in top frame, normally writing content dynamically to list frames).
1562 *
1563 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
1564 * @package TYPO3
1565 * @subpackage core
1566 * @see template::getContextMenuCode()
1567 */
1568 class SC_alt_clickmenu {
1569
1570 // Internal, static: GPvar:
1571 var $backPath; // Back path.
1572 var $item; // Definition of which item the click menu should be made for.
1573 var $reloadListFrame; // Defines the name of the document object for which to reload the URL.
1574
1575 // Internal:
1576 var $content=''; // Content accumulation
1577 var $doc; // Template object
1578 var $include_once=array(); // Files to include_once() - set in init() function
1579 var $extClassArray=array(); // Internal array of classes for extending the clickmenu
1580 var $dontDisplayTopFrameCM=0; // If set, then the clickmenu will NOT display in the top frame.
1581
1582 /**
1583 * Constructor function for script class.
1584 *
1585 * @return void
1586 */
1587 function init() {
1588
1589 // Setting GPvars:
1590 $this->backPath = t3lib_div::_GP('backPath');
1591 $this->item = t3lib_div::_GP('item');
1592 $this->reloadListFrame = t3lib_div::_GP('reloadListFrame');
1593
1594 // Setting pseudo module name
1595 $this->MCONF['name']='xMOD_alt_clickmenu.php';
1596
1597 // Takes the backPath as a parameter BUT since we are worried about someone forging a backPath (XSS security hole) we will check with sent md5 hash:
1598 $inputBP = explode('|', $this->backPath);
1599 if (count($inputBP)==2 && $inputBP[1]==t3lib_div::shortMD5($inputBP[0].'|'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'])) {
1600 $this->backPath = $inputBP[0];
1601 } else {
1602 $this->backPath = $GLOBALS['BACK_PATH'];
1603 }
1604
1605 // Setting internal array of classes for extending the clickmenu:
1606 $this->extClassArray = $GLOBALS['TBE_MODULES_EXT']['xMOD_alt_clickmenu']['extendCMclasses'];
1607
1608 // Traversing that array and setting files for inclusion:
1609 if (is_array($this->extClassArray)) {
1610 foreach($this->extClassArray as $extClassConf) {
1611 if ($extClassConf['path']) $this->include_once[]=$extClassConf['path'];
1612 }
1613 }
1614
1615 // Initialize template object
1616 if (!$this->ajax) {
1617 $this->doc = t3lib_div::makeInstance('template');
1618 $this->doc->backPath = $GLOBALS['BACK_PATH'];
1619 }
1620
1621 // Setting mode for display and background image in the top frame
1622 $this->dontDisplayTopFrameCM= $this->doc->isCMlayers() && !$GLOBALS['BE_USER']->getTSConfigVal('options.contextMenu.options.alwaysShowClickMenuInTopFrame');
1623 if ($this->dontDisplayTopFrameCM) {
1624 $this->doc->bodyTagId.= '-notop';
1625 }
1626
1627 // Setting clickmenu timeout
1628 $secs = t3lib_utility_Math::forceIntegerInRange($GLOBALS['BE_USER']->getTSConfigVal('options.contextMenu.options.clickMenuTimeOut'), 1, 100, 5); // default is 5
1629
1630 // Setting the JavaScript controlling the timer on the page
1631 $listFrameDoc = $this->reloadListFrame!=2 ? 'top.content.list_frame' : 'top.content';
1632 $this->doc->JScode.=$this->doc->wrapScriptTags('
1633 var date = new Date();
1634 var mo_timeout = Math.floor(date.getTime()/1000);
1635
1636 roImg = "' . t3lib_iconWorks::getSpriteIconClasses('status-status-current') . '";
1637
1638 routImg = "t3-icon-empty";
1639
1640 function mo(c) { //
1641 var name="roimg_"+c;
1642 document.getElementById(name).className = roImg;
1643 updateTime();
1644 }
1645 function mout(c) { //
1646 var name="roimg_"+c;
1647 document[name].src = routImg;
1648 updateTime();
1649 }
1650 function updateTime() { //
1651 date = new Date();
1652 mo_timeout = Math.floor(date.getTime()/1000);
1653 }
1654 function timeout_func() { //
1655 date = new Date();
1656 if (Math.floor(date.getTime()/1000)-mo_timeout > '.$secs.') {
1657 hideCM();
1658 return false;
1659 } else {
1660 window.setTimeout("timeout_func();",1*1000);
1661 }
1662 }
1663 function hideCM() { //
1664 window.location.href="alt_topmenu_dummy.php";
1665 return false;
1666 }
1667
1668 // Start timer
1669 timeout_func();
1670
1671 '.($this->reloadListFrame ? '
1672 // Reload list frame:
1673 if('.$listFrameDoc.'){'.$listFrameDoc.'.location.href='.$listFrameDoc.'.location.href;}' :
1674 '').'
1675 ');
1676 }
1677
1678 /**
1679 * Main function - generating the click menu in whatever form it has.
1680 *
1681 * @return void
1682 */
1683 function main() {
1684 $this->ajax = t3lib_div::_GP('ajax') ? TRUE : FALSE;
1685
1686 // Initialize Clipboard object:
1687 $clipObj = t3lib_div::makeInstance('t3lib_clipboard');
1688 $clipObj->initializeClipboard();
1689 $clipObj->lockToNormal(); // This locks the clipboard to the Normal for this request.
1690
1691 // Update clipboard if some actions are sent.
1692 $CB = t3lib_div::_GET('CB');
1693 $clipObj->setCmd($CB);
1694 $clipObj->cleanCurrent();
1695 $clipObj->endClipboard(); // Saves
1696
1697 // Create clickmenu object
1698 $clickMenu = t3lib_div::makeInstance('clickMenu');
1699
1700 // Set internal vars in clickmenu object:
1701 $clickMenu->clipObj = $clipObj;
1702 $clickMenu->extClassArray = $this->extClassArray;
1703 $clickMenu->dontDisplayTopFrameCM = $this->dontDisplayTopFrameCM;
1704 $clickMenu->backPath = $this->backPath;
1705
1706 // Start page
1707 if(!$this->ajax) {
1708 $this->content.= $this->doc->startPage('Context Sensitive Menu');
1709 }
1710 // Set content of the clickmenu with the incoming var, "item"
1711 $this->content.= $clickMenu->init();
1712 }
1713
1714 /**
1715 * End page and output content.
1716 *
1717 * @return void
1718 */
1719 function printContent() {
1720 if (!$this->ajax) {
1721 $this->content.= $this->doc->endPage();
1722 $this->content = $this->doc->insertStylesAndJS($this->content);
1723 echo $this->content;
1724 } else {
1725 t3lib_ajax::outputXMLreply($this->content);
1726 }
1727 }
1728 }
1729
1730 // Make instance:
1731 $SOBE = t3lib_div::makeInstance('SC_alt_clickmenu');
1732 $SOBE->init();
1733
1734 // Include files?
1735 foreach($SOBE->include_once as $INC_FILE) include_once($INC_FILE);
1736
1737 $SOBE->main();
1738 $SOBE->printContent();
1739
1740 ?>