Only changes to function indexes, comments and stripping of trailing whitespace in...
[Packages/TYPO3.CMS.git] / typo3 / alt_clickmenu.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2004 Kasper Skaarhoj (kasper@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 * $Id$
39 * Revised for TYPO3 3.6 2/2003 by Kasper Skaarhoj
40 * XHTML compliant
41 *
42 * @author Kasper Skaarhoj <kasper@typo3.com>
43 */
44 /**
45 * [CLASS/FUNCTION INDEX of SCRIPT]
46 *
47 *
48 *
49 * 123: class clickMenu
50 * 155: function init($item)
51 * 198: function doDisplayTopFrameCM()
52 *
53 * SECTION: DATABASE
54 * 226: function printDBClickMenu($table,$uid)
55 * 313: function printNewDBLevel($table,$uid)
56 * 350: function externalProcessingOfDBMenuItems($menuItems)
57 * 362: function processingByExtClassArray($menuItems,$table,$uid)
58 * 381: function urlRefForCM($url,$retUrl='',$hideCM=1)
59 * 398: function DB_copycut($table,$uid,$type)
60 * 421: function DB_paste($table,$uid,$type,$elInfo)
61 * 442: function DB_info($table,$uid)
62 * 458: function DB_history($table,$uid)
63 * 477: function DB_perms($table,$uid,$rec)
64 * 496: function DB_db_list($table,$uid,$rec)
65 * 515: function DB_moveWizard($table,$uid,$rec)
66 * 536: function DB_newWizard($table,$uid,$rec)
67 * 559: function DB_editAccess($table,$uid)
68 * 577: function DB_editPageHeader($uid)
69 * 595: function DB_edit($table,$uid)
70 * 637: function DB_new($table,$uid)
71 * 662: function DB_hideUnhide($table,$rec,$hideField)
72 * 686: function DB_delete($table,$uid,$elInfo)
73 * 707: function DB_view($id,$anchor='')
74 *
75 * SECTION: FILE
76 * 736: function printFileClickMenu($path)
77 * 800: function externalProcessingOfFileMenuItems($menuItems)
78 * 814: function FILE_launch($path,$script,$type,$image)
79 * 833: function FILE_copycut($path,$type)
80 * 853: function FILE_delete($path)
81 * 875: function FILE_paste($path,$target,$elInfo)
82 *
83 * SECTION: COMMON
84 * 915: function printItems($menuItems,$item)
85 * 960: function printLayerJScode($menuItems)
86 * 998: function wrapColorTableCM($str)
87 * 1021: function menuItemsForTopFrame($menuItems)
88 * 1038: function menuItemsForClickMenu($menuItems)
89 * 1073: function linkItem($str,$icon,$onClick,$onlyCM=0,$dontHide=0)
90 * 1097: function excludeIcon($iconCode)
91 * 1107: function label($label)
92 * 1116: function isCMlayers()
93 * 1126: function frameLocation($str)
94 *
95 *
96 * 1151: class SC_alt_clickmenu
97 * 1169: function init()
98 * 1260: function main()
99 * 1295: function printContent()
100 *
101 * TOTAL FUNCTIONS: 41
102 * (This index is automatically created/updated by the extension "extdeveval")
103 *
104 */
105
106
107 require ('init.php');
108 require ('template.php');
109 require_once (PATH_t3lib.'class.t3lib_clipboard.php');
110 $LANG->includeLLFile('EXT:lang/locallang_misc.php');
111
112
113
114
115 /**
116 * Class for generating the click menu
117 *
118 * @author Kasper Skaarhoj <kasper@typo3.com>
119 * @package TYPO3
120 * @subpackage core
121 * @internal
122 */
123 class clickMenu {
124
125 // Internal, static: GPvar:
126 var $cmLevel=0; // Defines if the click menu is first level or second. Second means the click menu is triggered from another menu.
127 var $CB; // Clipboard array (submitted by eg. pressing the paste button)
128
129 // Internal, static:
130 var $backPath=''; // Backpath for scripts/images.
131 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)
132 var $listFrame=0; // If set, the calling document should be in the listframe of a frameset.
133 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)
134 var $alwaysContentFrame=0; // If true, the "content" frame is always used for reference (when condensed mode is enabled)
135 var $iParts=array(); // Stores the parts of the input $item string, splitted by "|"
136 var $disabledItems=array(); // Contains list of keywords of items to disable in the menu
137 var $dontDisplayTopFrameCM=0; // If true, the context sensitive menu will not appear in the top frame, only as a layer.
138 var $leftIcons=0; // If true, Show icons on the left.
139 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.
140
141 // Internal, dynamic:
142 var $elCount=0; // Counter for elements in the menu. Used to number the name / id of the mouse-over icon.
143 var $editPageIconSet=0; // Set, when edit icon is drawn.
144 var $editOK=0; // Set to true, if editing of the element is OK.
145 var $rec=array();
146
147
148
149 /**
150 * Initialize click menu
151 *
152 * @param string Input "item" GET var.
153 * @return string The clickmenu HTML content
154 */
155 function init($item) {
156
157 // Setting GPvars:
158 $this->cmLevel = intval(t3lib_div::_GP('cmLevel'));
159 $this->CB = t3lib_div::_GP('CB');
160
161
162 // Explode the incoming command:
163 $this->iParts = explode('|',$item);
164
165 // Setting flags:
166 if ($this->iParts[2]) $this->listFrame=1;
167 if ($GLOBALS['BE_USER']->uc['condensedMode']) $this->alwaysContentFrame=1;
168 if (strcmp($this->iParts[1],'')) $this->isDBmenu=1;
169
170 $TSkey =($this->isDBmenu?'page':'folder').($this->listFrame?'List':'Tree');
171 $this->disabledItems = t3lib_div::trimExplode(',',$GLOBALS['BE_USER']->getTSConfigVal('options.contextMenu.'.$TSkey.'.disableItems'),1);
172 $this->leftIcons = $GLOBALS['BE_USER']->getTSConfigVal('options.contextMenu.options.leftIcons');
173
174 // &cmLevel flag detected (2nd level menu)
175 if (!$this->cmLevel) {
176 // Make 1st level clickmenu:
177 if ($this->isDBmenu) {
178 $CMcontent = $this->printDBClickMenu($this->iParts[0],$this->iParts[1]);
179 } else {
180 $CMcontent = $this->printFileClickMenu($this->iParts[0]);
181 }
182 } else {
183 // Make 2nd level clickmenu (only for DBmenus)
184 if ($this->isDBmenu) {
185 $CMcontent = $this->printNewDBLevel($this->iParts[0],$this->iParts[1]);
186 }
187 }
188
189 // Return clickmenu conten:
190 return $CMcontent;
191 }
192
193 /**
194 * Returns true if the menu should (also?) be displayed in topframe, not just <div>-layers
195 *
196 * @return boolean
197 */
198 function doDisplayTopFrameCM() {
199 return !$GLOBALS['SOBE']->doc->isCMlayers() || !$this->dontDisplayTopFrameCM;
200 }
201
202
203
204
205
206
207
208
209
210
211
212
213 /***************************************
214 *
215 * DATABASE
216 *
217 ***************************************/
218
219 /**
220 * Make 1st level clickmenu:
221 *
222 * @param string Table name
223 * @param integer UID for the current record.
224 * @return string HTML content
225 */
226 function printDBClickMenu($table,$uid) {
227 global $TCA, $BE_USER;
228
229 // Get record:
230 $this->rec = t3lib_BEfunc::getRecord($table,$uid);
231 $menuItems=array();
232 $root=0;
233 if ($table=='pages' && !strcmp($uid,'0')) { // Rootlevel
234 $root=1;
235 }
236
237 // If record found (or root), go ahead and fill the $menuItems array which will contain data for the elements to render.
238 if (is_array($this->rec) || $root) {
239 // Get permissions
240 $lCP = $BE_USER->calcPerms(t3lib_BEfunc::getRecord('pages',($table=='pages'?$this->rec['uid']:$this->rec['pid'])));
241
242 // View
243 if (!in_array('view',$this->disabledItems)) {
244 if ($table=='pages') $menuItems['view']=$this->DB_view($uid);
245 if ($table==$GLOBALS['TYPO3_CONF_VARS']['SYS']['contentTable']) $menuItems['view']=$this->DB_view($this->rec['pid'],'#'.$uid);
246 }
247
248 // Edit:
249 if(!$root && ($BE_USER->isPSet($lCP,$table,'edit')||$BE_USER->isPSet($lCP,$table,'editcontent'))) {
250 if (!in_array('edit',$this->disabledItems)) $menuItems['edit']=$this->DB_edit($table,$uid);
251 $this->editOK=1;
252 }
253
254 // New:
255 if (!in_array('new',$this->disabledItems) && $BE_USER->isPSet($lCP,$table,'new')) $menuItems['new']=$this->DB_new($table,$uid);
256
257 // Info:
258 if(!in_array('info',$this->disabledItems) && !$root) $menuItems['info']=$this->DB_info($table,$uid);
259
260 $menuItems[]='spacer';
261
262 // Copy:
263 if(!in_array('copy',$this->disabledItems) && !$root) $menuItems['copy']=$this->DB_copycut($table,$uid,'copy');
264 // Cut:
265 if(!in_array('cut',$this->disabledItems) && !$root) $menuItems['cut']=$this->DB_copycut($table,$uid,'cut');
266
267 // Paste:
268 $elFromAllTables = count($this->clipObj->elFromTable(''));
269 if (!in_array('paste',$this->disabledItems) && $elFromAllTables) {
270 $selItem = $this->clipObj->getSelectedRecord();
271 $elInfo=array(
272 $selItem['_RECORD_TITLE'],
273 ($root?$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']:t3lib_div::fixed_lgd(t3lib_BEfunc::getRecordTitle($table,$this->rec),$BE_USER->uc['titleLen'])),
274 $this->clipObj->currentMode()
275 );
276 if ($table=='pages' && ($lCP & 8)) {
277 if ($elFromAllTables) $menuItems['pasteinto']=$this->DB_paste('',$uid,'into',$elInfo);
278 }
279
280 $elFromTable = count($this->clipObj->elFromTable($table));
281 if (!$root && $elFromTable && $TCA[$table]['ctrl']['sortby']) $menuItems['pasteafter']=$this->DB_paste($table,-$uid,'after',$elInfo);
282 }
283
284 // Delete:
285 $elInfo=array(t3lib_div::fixed_lgd(t3lib_BEfunc::getRecordTitle($table,$this->rec),$BE_USER->uc['titleLen']));
286 if(!in_array('delete',$this->disabledItems) && !$root && $BE_USER->isPSet($lCP,$table,'delete')) {
287 $menuItems[]='spacer';
288 $menuItems['delete']=$this->DB_delete($table,$uid,$elInfo);
289 }
290 }
291
292 // Adding external elements to the menuItems array
293 $menuItems = $this->processingByExtClassArray($menuItems,$table,$uid);
294
295 // Processing by external functions?
296 $menuItems = $this->externalProcessingOfDBMenuItems($menuItems);
297
298 // Return the printed elements:
299 return $this->printItems($menuItems,
300 $root?
301 '<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/i/_icon_website.gif','width="18" height="16"').' class="absmiddle" alt="" />'.htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']):
302 t3lib_iconWorks::getIconImage($table,$this->rec,$this->PH_backPath,' class="absmiddle" title="'.htmlspecialchars(t3lib_BEfunc::getRecordIconAltText($this->rec,$table)).'"').t3lib_BEfunc::getRecordTitle($table,$this->rec,1)
303 );
304 }
305
306 /**
307 * Make 2nd level clickmenu (only for DBmenus)
308 *
309 * @param string Table name
310 * @param integer UID for the current record.
311 * @return string HTML content
312 */
313 function printNewDBLevel($table,$uid) {
314 global $TCA, $BE_USER;
315
316 // Setting internal record to the table/uid :
317 $this->rec = t3lib_BEfunc::getRecord($table,$uid);
318 $menuItems=array();
319 $root=0;
320 if ($table=='pages' && !strcmp($uid,'0')) { // Rootlevel
321 $root=1;
322 }
323
324 // If record was found, check permissions and get menu items.
325 if (is_array($this->rec) || $root) {
326 $lCP = $BE_USER->calcPerms(t3lib_BEfunc::getRecord('pages',($table=='pages'?$this->rec['uid']:$this->rec['pid'])));
327 // Edit:
328 if(!$root && ($BE_USER->isPSet($lCP,$table,'edit')||$BE_USER->isPSet($lCP,$table,'editcontent'))) {
329 $this->editOK=1;
330 }
331
332 $menuItems = $this->processingByExtClassArray($menuItems,$table,$uid);
333 }
334
335 // Return the printed elements:
336 if (!is_array($menuItems)) $menuItems=array();
337 return $this->printItems($menuItems,
338 $root?
339 '<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/i/_icon_website.gif','width="18" height="16"').' class="absmiddle" alt="" />'.htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']):
340 t3lib_iconWorks::getIconImage($table,$this->rec,$this->PH_backPath,' class="absmiddle" title="'.htmlspecialchars(t3lib_BEfunc::getRecordIconAltText($this->rec,$table)).'"').t3lib_BEfunc::getRecordTitle($table,$this->rec,1)
341 );
342 }
343
344 /**
345 * Processing the $menuItems array (for extension classes) (DATABASE RECORDS)
346 *
347 * @param array $menuItems array for manipulation.
348 * @return array Processed $menuItems array
349 */
350 function externalProcessingOfDBMenuItems($menuItems) {
351 return $menuItems;
352 }
353
354 /**
355 * Processing the $menuItems array by external classes (typ. adding items)
356 *
357 * @param array $menuItems array for manipulation.
358 * @param string Table name
359 * @param integer UID for the current record.
360 * @return array Processed $menuItems array
361 */
362 function processingByExtClassArray($menuItems,$table,$uid) {
363 if (is_array($this->extClassArray)) {
364 reset($this->extClassArray);
365 while(list(,$conf)=each($this->extClassArray)) {
366 $obj=t3lib_div::makeInstance($conf['name']);
367 $menuItems = $obj->main($this,$menuItems,$table,$uid);
368 }
369 }
370 return $menuItems;
371 }
372
373 /**
374 * Returning JavaScript for the onClick event linking to the input URL.
375 *
376 * @param string The URL relative to TYPO3_mainDir
377 * @param string The return_url-parameter
378 * @param boolean If set, the "hideCM()" will be called
379 * @return string JavaScript for an onClick event.
380 */
381 function urlRefForCM($url,$retUrl='',$hideCM=1) {
382 $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
383 $editOnClick='var docRef=(top.content.list_frame)?top.content.list_frame:'.$loc.'; docRef.document.location=top.TS.PATH_typo3+\''.$url.'\''.
384 ($retUrl?"+'&".$retUrl."='+top.rawurlencode(".$this->frameLocation('docRef.document').')':'').';'.
385 ($hideCM?'return hideCM();':'');
386 return $editOnClick;
387 }
388
389 /**
390 * Adding CM element for Clipboard "copy" and "cut"
391 *
392 * @param string Table name
393 * @param integer UID for the current record.
394 * @param string Type: "copy" or "cut"
395 * @return array Item array, element in $menuItems
396 * @internal
397 */
398 function DB_copycut($table,$uid,$type) {
399 if ($this->clipObj->current=='normal') {
400 $isSel = $this->clipObj->isSelected($table,$uid);
401 }
402
403 return $this->linkItem(
404 $this->label($type),
405 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/clip_'.$type.($isSel==$type?'_h':'').'.gif','width="12" height="12"').' alt="" />'),
406 "top.loadTopMenu('".$this->clipObj->selUrlDB($table,$uid,($type=='copy'?1:0),($isSel==$type),array('reloadListFrame'=>$this->listFrame))."');return false;"
407 );
408 }
409
410 /**
411 * Adding CM element for Clipboard "paste into"/"paste after"
412 * NOTICE: $table and $uid should follow the special syntax for paste, see clipboard-class :: pasteUrl();
413 *
414 * @param string Table name
415 * @param integer UID for the current record. NOTICE: Special syntax!
416 * @param string Type: "into" or "after"
417 * @param array Contains instructions about whether to copy or cut an element.
418 * @return array Item array, element in $menuItems
419 * @see t3lib_clipboard::pasteUrl()
420 * @internal
421 */
422 function DB_paste($table,$uid,$type,$elInfo) {
423 $editOnClick = '';
424 $loc = 'top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
425 $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])).')';
426 $editOnClick = 'if('.$conf.'){'.$loc.'.document.location=top.TS.PATH_typo3+\''.$this->clipObj->pasteUrl($table,$uid,0).'&redirect=\'+top.rawurlencode('.$this->frameLocation($loc.'.document').'); hideCM();}';
427
428 return $this->linkItem(
429 $this->label('paste'.$type),
430 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/clip_paste'.$type.'.gif','width="12" height="12"').' alt="" />'),
431 $editOnClick.'return false;'
432 );
433 }
434
435 /**
436 * Adding CM element for Info
437 *
438 * @param string Table name
439 * @param integer UID for the current record.
440 * @return array Item array, element in $menuItems
441 * @internal
442 */
443 function DB_info($table,$uid) {
444 return $this->linkItem(
445 $this->label('info'),
446 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/zoom2.gif','width="12" height="12"').' alt="" />'),
447 "top.launchView('".$table."', '".$uid."'); return hideCM();"
448 );
449 }
450
451 /**
452 * Adding CM element for History
453 *
454 * @param string Table name
455 * @param integer UID for the current record.
456 * @return array Item array, element in $menuItems
457 * @internal
458 */
459 function DB_history($table,$uid) {
460 $url = 'show_rechis.php?element='.rawurlencode($table.':'.$uid);
461 return $this->linkItem(
462 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_history')),
463 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/history2.gif','width="13" height="12"').' alt="" />'),
464 $this->urlRefForCM($url,'returnUrl'),
465 0
466 );
467 }
468
469 /**
470 * Adding CM element for Permission setting
471 *
472 * @param string Table name
473 * @param integer UID for the current record.
474 * @param array The "pages" record with "perms_*" fields inside.
475 * @return array Item array, element in $menuItems
476 * @internal
477 */
478 function DB_perms($table,$uid,$rec) {
479 $url = 'mod/web/perm/index.php?id='.$uid.($rec['perms_userid']==$GLOBALS['BE_USER']->user['uid']||$GLOBALS['BE_USER']->isAdmin()?'&return_id='.$uid.'&edit=1':'');
480 return $this->linkItem(
481 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_perms')),
482 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/perm.gif','width="7" height="12"').' alt="" />'),
483 $this->urlRefForCM($url),
484 0
485 );
486 }
487
488 /**
489 * Adding CM element for DBlist
490 *
491 * @param string Table name
492 * @param integer UID for the current record.
493 * @param array Record of the element (needs "pid" field if not pages-record)
494 * @return array Item array, element in $menuItems
495 * @internal
496 */
497 function DB_db_list($table,$uid,$rec) {
498 $url = t3lib_div::getIndpEnv('TYPO3_REQUEST_DIR').'db_list.php?table='.($table=='pages'?'':$table).'&id='.($table=='pages'?$uid:$rec['pid']);
499 return $this->linkItem(
500 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_db_list')),
501 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/list.gif','width="11" height="11"').' alt="" />'),
502 "top.nextLoadModuleUrl='".$url."';top.goToModule('web_list',1);",
503 0
504 );
505 }
506
507 /**
508 * Adding CM element for Moving wizard
509 *
510 * @param string Table name
511 * @param integer UID for the current record.
512 * @param array Record. Needed for tt-content elements which will have the sys_language_uid sent
513 * @return array Item array, element in $menuItems
514 * @internal
515 */
516 function DB_moveWizard($table,$uid,$rec) {
517 $url = 'move_el.php?table='.$table.'&uid='.$uid.
518 ($table=='tt_content'?'&sys_language_uid='.intval($rec['sys_language_uid']):''); // Hardcoded field for tt_content elements.
519
520 return $this->linkItem(
521 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_moveWizard'.($table=='pages'?'_page':''))),
522 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/move_'.($table=='pages'?'page':'record').'.gif','width="11" height="12"').' alt="" />'),
523 $this->urlRefForCM($url,'returnUrl'),
524 0
525 );
526 }
527
528 /**
529 * Adding CM element for Create new wizard (either db_new.php or sysext/cms/layout/db_new_content_el.php or custom wizard)
530 *
531 * @param string Table name
532 * @param integer UID for the current record.
533 * @param array Record.
534 * @return array Item array, element in $menuItems
535 * @internal
536 */
537 function DB_newWizard($table,$uid,$rec) {
538 // If mod.web_list.newContentWiz.overrideWithExtension is set, use that extension's create new content wizard instead:
539 $tmpTSc = t3lib_BEfunc::getModTSconfig($this->pageinfo['uid'],'mod.web_list');
540 $tmpTSc = $tmpTSc ['properties']['newContentWiz.']['overrideWithExtension'];
541 $newContentWizScriptPath = t3lib_extMgm::isLoaded($tmpTSc) ? (t3lib_extMgm::extRelPath($tmpTSc).'mod1/db_new_content_el.php') : (TYPO3_mainDir.'sysext/cms/layout/db_new_content_el.php');
542
543 $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']);
544 return $this->linkItem(
545 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_newWizard')),
546 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/new_'.($table=='pages'?'page':'record').'.gif','width="'.($table=='pages'?'13':'16').'" height="12"').' alt="" />'),
547 $this->urlRefForCM($url,'returnUrl'),
548 0
549 );
550 }
551
552 /**
553 * Adding CM element for Editing of the access related fields of a table (disable, starttime, endtime, fe_groups)
554 *
555 * @param string Table name
556 * @param integer UID for the current record.
557 * @return array Item array, element in $menuItems
558 * @internal
559 */
560 function DB_editAccess($table,$uid) {
561 $addParam='&columnsOnly='.rawurlencode(implode(',',$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']).($table=='pages' ? ',extendToSubpages' :''));
562 $url = 'alt_doc.php?edit['.$table.']['.$uid.']=edit'.$addParam;
563 return $this->linkItem(
564 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_editAccess')),
565 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/editaccess.gif','width="12" height="12"').' alt="" />'),
566 $this->urlRefForCM($url,'returnUrl'),
567 1 // no top frame CM!
568 );
569 }
570
571 /**
572 * Adding CM element for edit page header
573 *
574 * @param integer page uid to edit (PID)
575 * @return array Item array, element in $menuItems
576 * @internal
577 */
578 function DB_editPageHeader($uid) {
579 $url = 'alt_doc.php?edit[pages]['.$uid.']=edit';
580 return $this->linkItem(
581 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_editPageHeader')),
582 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/edit2.gif','width="11" height="12"').' alt="" />'),
583 $this->urlRefForCM($url,'returnUrl'),
584 1 // no top frame CM!
585 );
586 }
587
588 /**
589 * Adding CM element for regular editing of the element!
590 *
591 * @param string Table name
592 * @param integer UID for the current record.
593 * @return array Item array, element in $menuItems
594 * @internal
595 */
596 function DB_edit($table,$uid) {
597 global $BE_USER;
598 // If another module was specified, replace the default Page module with the new one
599 $newPageModule = trim($BE_USER->getTSConfigVal('options.overridePageModule'));
600 $pageModule = t3lib_BEfunc::isModuleSetInTBE_MODULES($newPageModule) ? $newPageModule : 'web_layout';
601
602 $editOnClick='';
603 $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
604 $addParam='';
605 $theIcon = t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/edit2.gif','width="11" height="12"');
606 if (
607 $this->iParts[0]=='pages' &&
608 $this->iParts[1] &&
609 $BE_USER->check('modules', $pageModule)
610 ) {
611 $theIcon = t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/edit_page.gif','width="12" height="12"');
612 $this->editPageIconSet=1;
613 if ($BE_USER->uc['classicPageEditMode'] || !t3lib_extMgm::isLoaded('cms')) {
614 $addParam='&editRegularContentFromId='.intval($this->iParts[1]);
615 } else {
616 $editOnClick="top.fsMod.recentIds['web']=".intval($this->iParts[1]).";top.goToModule('".$pageModule."',1);";
617 }
618 }
619 if (!$editOnClick) {
620 $editOnClick="if(".$loc."){".$loc.".document.location=top.TS.PATH_typo3+'alt_doc.php?returnUrl='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'&edit[".$table."][".$uid."]=edit".$addParam."';}";
621 }
622
623 return $this->linkItem(
624 $this->label('edit'),
625 $this->excludeIcon('<img'.$theIcon.' alt="" />'),
626 $editOnClick.'return hideCM();'
627 );
628 }
629
630 /**
631 * Adding CM element for regular Create new element
632 *
633 * @param string Table name
634 * @param integer UID for the current record.
635 * @return array Item array, element in $menuItems
636 * @internal
637 */
638 function DB_new($table,$uid) {
639 $editOnClick='';
640 $loc='top.content'.(!$this->alwaysContentFrame?'.list_frame':'');
641 $editOnClick='if('.$loc.'){'.$loc.".document.location=top.TS.PATH_typo3+'".
642 ($this->listFrame?
643 "alt_doc.php?returnUrl='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'&edit[".$table."][-".$uid."]=new'":
644 'db_new.php?id='.intval($uid)."'").
645 ';}';
646
647 return $this->linkItem(
648 $this->label('new'),
649 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/new_'.($table=='pages'&&$this->listFrame?'page':'el').'.gif','width="'.($table=='pages'?'13':'11').'" height="12"').' alt="" />'),
650 $editOnClick.'return hideCM();'
651 );
652 }
653
654 /**
655 * Adding CM element for hide/unhide of the input record
656 *
657 * @param string Table name
658 * @param array Record array
659 * @param string Name of the hide field
660 * @return array Item array, element in $menuItems
661 * @internal
662 */
663 function DB_hideUnhide($table,$rec,$hideField) {
664 $uid=$rec['uid'];
665 $editOnClick='';
666 $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
667 $editOnClick='if('.$loc.'){'.$loc.".document.location=top.TS.PATH_typo3+'tce_db.php?redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'".
668 "&data[".$table.']['.$uid.']['.$hideField.']='.($rec[$hideField]?0:1).'&prErr=1&vC='.$GLOBALS['BE_USER']->veriCode()."';hideCM();}";
669
670 return $this->linkItem(
671 $this->label(($rec[$hideField]?'un':'').'hide'),
672 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/button_'.($rec[$hideField]?'un':'').'hide.gif','width="11" height="10"').' alt="" />'),
673 $editOnClick.'return false;',
674 1
675 );
676 }
677
678 /**
679 * Adding CM element for Delete
680 *
681 * @param string Table name
682 * @param integer UID for the current record.
683 * @param array Label for including in the confirmation message, EXT:lang/locallang_core.php:mess.delete
684 * @return array Item array, element in $menuItems
685 * @internal
686 */
687 function DB_delete($table,$uid,$elInfo) {
688 $editOnClick='';
689 $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
690 $editOnClick='if('.$loc." && confirm(".$GLOBALS['LANG']->JScharCode(sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:mess.delete'),$elInfo[0])).")){".$loc.".document.location=top.TS.PATH_typo3+'tce_db.php?redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'".
691 "&cmd[".$table.']['.$uid.'][delete]=1&prErr=1&vC='.$GLOBALS['BE_USER']->veriCode()."';hideCM();}";
692
693 return $this->linkItem(
694 $this->label('delete'),
695 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/garbage.gif','width="11" height="12"').' alt="" />'),
696 $editOnClick.'return false;'
697 );
698 }
699
700 /**
701 * Adding CM element for View Page
702 *
703 * @param integer Page uid (PID)
704 * @param string Anchor, if any
705 * @return array Item array, element in $menuItems
706 * @internal
707 */
708 function DB_view($id,$anchor='') {
709 return $this->linkItem(
710 $this->label('view'),
711 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/zoom.gif','width="12" height="12"').' alt="" />'),
712 t3lib_BEfunc::viewOnClick($id,$this->PH_backPath,t3lib_BEfunc::BEgetRootLine($id),$anchor).'return hideCM();'
713 );
714 }
715
716
717
718
719
720
721
722
723
724
725 /***************************************
726 *
727 * FILE
728 *
729 ***************************************/
730
731 /**
732 * Make 1st level clickmenu:
733 *
734 * @param string The absolute path
735 * @return string HTML content
736 */
737 function printFileClickMenu($path) {
738 $menuItems=array();
739
740 if (@file_exists($path) && t3lib_div::isAllowedAbsPath($path)) {
741 $fI = pathinfo($path);
742 $icon = is_dir($path) ? 'folder.gif' : t3lib_BEfunc::getFileIcon(strtolower($fI['extension']));
743 $size=' ('.t3lib_div::formatSize(filesize($path)).'bytes)';
744 $icon = '<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/fileicons/'.$icon,'width="18" height="16"').' class="absmiddle" title="'.htmlspecialchars($fI['basename'].$size).'" alt="" />';
745
746 // edit
747 if (!in_array('edit',$this->disabledItems) && is_file($path) && t3lib_div::inList($GLOBALS['TYPO3_CONF_VARS']['SYS']['textfile_ext'],$fI['extension'])) $menuItems['edit']=$this->FILE_launch($path,'file_edit.php','edit','edit_file.gif');
748 // rename
749 if (!in_array('rename',$this->disabledItems)) $menuItems['rename']=$this->FILE_launch($path,'file_rename.php','rename','rename.gif');
750 // upload
751 if (!in_array('upload',$this->disabledItems) && is_dir($path)) $menuItems['upload']=$this->FILE_launch($path,'file_upload.php','upload','upload.gif');
752 // new
753 if (!in_array('new',$this->disabledItems) && is_dir($path)) $menuItems['new']=$this->FILE_launch($path,'file_newfolder.php','new','new_file.gif');
754 // info
755 if (!in_array('info',$this->disabledItems)) $menuItems['info']=$this->DB_info($path,'');
756
757 $menuItems[]='spacer';
758
759 // copy:
760 if (!in_array('copy',$this->disabledItems)) $menuItems['copy']=$this->FILE_copycut($path,'copy');
761 // cut:
762 if (!in_array('cut',$this->disabledItems)) $menuItems['cut']=$this->FILE_copycut($path,'cut');
763
764 // Paste:
765 $elFromAllTables = count($this->clipObj->elFromTable('_FILE'));
766 if (!in_array('paste',$this->disabledItems) && $elFromAllTables && is_dir($path)) {
767 $elArr = $this->clipObj->elFromTable('_FILE');
768 reset($elArr);
769 $selItem = current($elArr);
770 $elInfo=array(
771 basename($selItem),
772 basename($path),
773 $this->clipObj->currentMode()
774 );
775 $menuItems['pasteinto']=$this->FILE_paste($path,$selItem,$elInfo);
776 }
777
778 $menuItems[]='spacer';
779
780 // delete:
781 if (!in_array('delete',$this->disabledItems)) $menuItems['delete']=$this->FILE_delete($path);
782 }
783
784 // Adding external elements to the menuItems array
785 $menuItems = $this->processingByExtClassArray($menuItems,$path,0);
786
787 // Processing by external functions?
788 $menuItems = $this->externalProcessingOfFileMenuItems($menuItems);
789
790 // Return the printed elements:
791 return $this->printItems($menuItems,$icon.basename($path));
792 }
793
794
795 /**
796 * Processing the $menuItems array (for extension classes) (FILES)
797 *
798 * @param array $menuItems array for manipulation.
799 * @return array Processed $menuItems array
800 */
801 function externalProcessingOfFileMenuItems($menuItems) {
802 return $menuItems;
803 }
804
805 /**
806 * Multi-function for adding an entry to the $menuItems array
807 *
808 * @param string Path to the file/directory (target)
809 * @param string Script (eg. file_edit.php) to pass &target= to
810 * @param string "type" is the code which fetches the correct label for the element from "cm."
811 * @param string icon image-filename from "gfx/" (12x12 icon)
812 * @return array Item array, element in $menuItems
813 * @internal
814 */
815 function FILE_launch($path,$script,$type,$image) {
816 $loc='top.content'.(!$this->alwaysContentFrame?'.list_frame':'');
817 $editOnClick='if('.$loc.'){'.$loc.".document.location=top.TS.PATH_typo3+'".$script.'?target='.rawurlencode($path)."';}";
818
819 return $this->linkItem(
820 $this->label($type),
821 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/'.$image,'width="12" height="12"').' alt="" />'),
822 $editOnClick.'return hideCM();'
823 );
824 }
825
826 /**
827 * Returns element for copy or cut of files.
828 *
829 * @param string Path to the file/directory (target)
830 * @param string Type: "copy" or "cut"
831 * @return array Item array, element in $menuItems
832 * @internal
833 */
834 function FILE_copycut($path,$type) {
835 $table='_FILE'; // Pseudo table name for use in the clipboard.
836 $uid = t3lib_div::shortmd5($path);
837 if ($this->clipObj->current=='normal') {
838 $isSel = $this->clipObj->isSelected($table,$uid);
839 }
840 return $this->linkItem(
841 $this->label($type),
842 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/clip_'.$type.($isSel==$type?'_h':'').'.gif','width="12" height="12"').' alt="" />'),
843 "top.loadTopMenu('".$this->clipObj->selUrlFile($path,($type=='copy'?1:0),($isSel==$type))."');return false;"
844 );
845 }
846
847 /**
848 * Creates element for deleting of target
849 *
850 * @param string Path to the file/directory (target)
851 * @return array Item array, element in $menuItems
852 * @internal
853 */
854 function FILE_delete($path) {
855 $editOnClick='';
856 $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
857 $editOnClick='if('.$loc." && confirm(".$GLOBALS['LANG']->JScharCode(sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:mess.delete'),basename($path))).")){".$loc.".document.location=top.TS.PATH_typo3+'tce_file.php?redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'".
858 "&file[delete][0][data]=".rawurlencode($path).'&vC='.$GLOBALS['BE_USER']->veriCode()."';hideCM();}";
859
860 return $this->linkItem(
861 $this->label('delete'),
862 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/garbage.gif','width="11" height="12"').' alt="" />'),
863 $editOnClick.'return false;'
864 );
865 }
866
867 /**
868 * Creates element for pasting files.
869 *
870 * @param string Path to the file/directory (target)
871 * @param string target - NOT USED.
872 * @param array Various values for the labels.
873 * @return array Item array, element in $menuItems
874 * @internal
875 */
876 function FILE_paste($path,$target,$elInfo) {
877 $editOnClick='';
878 $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
879 $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])).")";
880 $editOnClick='if('.$conf.'){'.$loc.".document.location=top.TS.PATH_typo3+'".$this->clipObj->pasteUrl('_FILE',$path,0).
881 "&redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').'); hideCM();}';
882
883 return $this->linkItem(
884 $this->label('pasteinto'),
885 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/clip_pasteinto.gif','width="12" height="12"').' alt="" />'),
886 $editOnClick.'return false;'
887 );
888 }
889
890
891
892
893
894
895
896
897
898
899
900
901
902 /***************************************
903 *
904 * COMMON
905 *
906 **************************************/
907
908 /**
909 * Prints the items from input $menuItems array - both as topframe menu AND the JS section for writing to the div-layers.
910 * Of course the topframe menu will appear only if $this->doDisplayTopFrameCM() returns true
911 *
912 * @param array $menuItems array
913 * @param string HTML code for the element which was clicked - shown in the end of the horizontal menu in topframe after the close-button.
914 * @return string HTML code
915 */
916 function printItems($menuItems,$item) {
917 $out='';
918
919 // Adding topframe part (horizontal clickmenu)
920 if ($this->doDisplayTopFrameCM()) {
921 $out.= '
922
923 <!--
924 Table, which contains the click menu when shown in the top frame of the backend:
925 -->
926 <table border="0" cellpadding="0" cellspacing="0" id="typo3-CSM-top">
927 <tr>
928
929 <!-- Items: -->
930 <td class="c-item">'.
931 implode('</td>
932 <td><img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/acm_spacer2.gif','width="8" height="12"').' alt="" /></td>
933 <td class="c-item">',$this->menuItemsForTopFrame($menuItems)).
934 '</td>
935
936 <!-- Close button: -->
937 <td class="c-closebutton"><a href="#" onclick="hideCM();return false;"><img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/close_12h.gif','width="11" height="12"').' title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.close',1).'" alt="" /></a></td>
938
939 <!-- The item of the clickmenu: -->
940 <td class="c-itemicon">'.$item.'</td>
941 </tr>
942 </table>
943 ';
944
945 // Set remaining BACK_PATH to blank (if any)
946 $out = str_replace($this->PH_backPath,'',$out);
947 }
948 // Adding JS part:
949 $out.=$this->printLayerJScode($menuItems);
950
951 // Return the content
952 return $out;
953 }
954
955 /**
956 * Create the JavaScript section
957 *
958 * @param array The $menuItems array to print
959 * @return string The JavaScript section which will print the content of the CM to the div-layer in the target frame.
960 */
961 function printLayerJScode($menuItems) {
962 $script='';
963 if ($this->isCMlayers()) { // Clipboard must not be submitted - then it's probably a copy/cut situation.
964 $frameName = '.'.($this->listFrame ? 'list_frame' : 'nav_frame');
965 if ($this->alwaysContentFrame) $frameName='';
966
967 // Create the table displayed in the clickmenu layer:
968 $CMtable = '
969 <table border="0" cellpadding="0" cellspacing="0" class="typo3-CSM bgColor4">
970 '.implode('',$this->menuItemsForClickMenu($menuItems)).'
971 </table>';
972
973 // Wrap the inner table in another table to create outer border:
974 $CMtable = $this->wrapColorTableCM($CMtable);
975
976 // Set back path place holder to real back path
977 $CMtable = str_replace($this->PH_backPath,$this->backPath,$CMtable);
978
979 // Create JavaScript section:
980 $script=$GLOBALS['TBE_TEMPLATE']->wrapScriptTags('
981
982 if (top.content && top.content'.$frameName.' && top.content'.$frameName.'.setLayerObj) {
983 top.content'.$frameName.'.setLayerObj(unescape("'.t3lib_div::rawurlencodeJS($CMtable).'"),'.$this->cmLevel.');
984 }
985 '.(!$this->doDisplayTopFrameCM()?'hideCM();':'')
986 );
987 }
988
989 return $script;
990 }
991
992 /**
993 * Wrapping the input string in a table with background color 4 and a black border style.
994 * For the pop-up menu
995 *
996 * @param string HTML content to wrap in table.
997 * @return string
998 */
999 function wrapColorTableCM($str) {
1000
1001 // Clear-gifs needed if opera is to set the table row height correctly in skins.
1002 $str = '<table border="0" cellspacing="0" class="typo3-CSM-wrapperCM">
1003 <tr class="c-rowA">
1004 <td class="c-aa">'.$str.'</td>
1005 <td class="c-ab"></td>
1006 </tr>
1007 <tr class="c-rowB">
1008 <td class="c-ba"><img src="clear.gif" width="1" height="1" alt="" /></td>
1009 <td class="c-bb"><img src="clear.gif" width="1" height="1" alt="" /></td>
1010 </tr>
1011 </table>';
1012 return $str;
1013 }
1014
1015 /**
1016 * Traverses the menuItems and generates an output array for implosion in the topframe horizontal menu
1017 *
1018 * @param array $menuItem array
1019 * @param array Array with HTML content to be imploded between <td>-tags
1020 * @return array Array of menu items for top frame.
1021 */
1022 function menuItemsForTopFrame($menuItems) {
1023 reset($menuItems);
1024 $out=array();
1025 while(list(,$i)=each($menuItems)) {
1026 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)
1027 if (is_array($i) && !$i[4]) $out[]=$i[0];
1028 }
1029 return $out;
1030 }
1031
1032 /**
1033 * Traverses the menuItems and generates an output array for implosion in the CM div-layers table.
1034 *
1035 * @param array $menuItem array
1036 * @param array Array with HTML content to be imploded between <td>-tags
1037 * @return array array for implosion in the CM div-layers table.
1038 */
1039 function menuItemsForClickMenu($menuItems) {
1040 reset($menuItems);
1041 $out=array();
1042 while(list($cc,$i)=each($menuItems)) {
1043 if (is_string($i) && $i=='spacer') { // MAKE horizontal spacer
1044 $out[]='
1045 <tr class="bgColor2">
1046 <td colspan="2"><img src="clear.gif" width="1" height="1" alt="" /></td>
1047 </tr>';
1048 } else { // Just make normal element:
1049 $onClick=$i[3];
1050 $onClick=eregi_replace('return[[:space:]]+hideCM\(\)[[:space:]]*;','',$onClick);
1051 $onClick=eregi_replace('return[[:space:]]+false[[:space:]]*;','',$onClick);
1052 $onClick=eregi_replace('hideCM\(\);','',$onClick);
1053 if (!$i[5]) $onClick.='hideEmpty();';
1054
1055 $out[]='
1056 <tr class="typo3-CSM-itemRow" onclick="'.htmlspecialchars($onClick).'" onmouseover="this.bgColor=\''.$GLOBALS['TBE_TEMPLATE']->bgColor5.'\';" onmouseout="this.bgColor=\'\';">
1057 '.(!$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>').'
1058 </tr>';
1059 }
1060 }
1061 return $out;
1062 }
1063
1064 /**
1065 * Creating an array with various elements for the clickmenu entry
1066 *
1067 * @param string The label, htmlspecialchar'ed already
1068 * @param string <img>-tag for the icon
1069 * @param string JavaScript onclick event for label/icon
1070 * @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)
1071 * @param boolean If set, the clickmenu layer will not hide itself onclick - used for secondary menus to appear...
1072 * @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!
1073 */
1074 function linkItem($str,$icon,$onClick,$onlyCM=0,$dontHide=0) {
1075 $this->elCount++;
1076
1077 $WHattribs = t3lib_iconWorks::skinImg($BACK_PATH,'gfx/content_client.gif','width="7" height="10"',2);
1078
1079 return array(
1080 '<img src="clear.gif" '.$WHattribs.' class="c-roimg" name="roimg_'.$this->elCount.'" alt="" />'.
1081 '<a href="#" onclick="'.htmlspecialchars($onClick).'" onmouseover="mo('.$this->elCount.');" onmouseout="mout('.$this->elCount.');">'.
1082 $str.$icon.
1083 '</a>',
1084 $str,
1085 $icon,
1086 $onClick,
1087 $onlyCM,
1088 $dontHide
1089 );
1090 }
1091
1092 /**
1093 * Returns the input string IF not a user setting has disabled display of icons.
1094 *
1095 * @param string The icon-image tag
1096 * @return string The icon-image tag prefixed with space char IF the icon should be printed at all due to user settings
1097 */
1098 function excludeIcon($iconCode) {
1099 return ($GLOBALS['BE_USER']->uc['noMenuMode'] && strcmp($GLOBALS['BE_USER']->uc['noMenuMode'],'icons')) ? '' : ' '.$iconCode;
1100 }
1101
1102 /**
1103 * Get label from locallang_core.php:cm.*
1104 *
1105 * @param string The "cm."-suffix to get.
1106 * @return string
1107 */
1108 function label($label) {
1109 return $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:cm.'.$label,1));
1110 }
1111
1112 /**
1113 * Returns true if there should be writing to the div-layers (commands sent to clipboard MUST NOT write to div-layers)
1114 *
1115 * @return boolean
1116 */
1117 function isCMlayers() {
1118 return $GLOBALS['SOBE']->doc->isCMlayers() && !$this->CB;
1119 }
1120
1121 /**
1122 * Appends ".location" to input string
1123 *
1124 * @param string Input string, probably a JavaScript document reference
1125 * @return string
1126 */
1127 function frameLocation($str) {
1128 return $str.'.location';
1129 }
1130 }
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144 /**
1145 * Script Class for the Context Sensitive Menu in TYPO3 (rendered in top frame, normally writing content dynamically to list frames).
1146 *
1147 * @author Kasper Skaarhoj <kasper@typo3.com>
1148 * @package TYPO3
1149 * @subpackage core
1150 * @see template::getContextMenuCode()
1151 */
1152 class SC_alt_clickmenu {
1153
1154 // Internal, static: GPvar:
1155 var $backPath; // Back path.
1156 var $item; // Definition of which item the click menu should be made for.
1157 var $reloadListFrame; // Defines the name of the document object for which to reload the URL.
1158
1159 // Internal:
1160 var $content=''; // Content accumulation
1161 var $doc; // Template object
1162 var $include_once=array(); // Files to include_once() - set in init() function
1163 var $extClassArray=array(); // Internal array of classes for extending the clickmenu
1164 var $dontDisplayTopFrameCM=0; // If set, then the clickmenu will NOT display in the top frame.
1165
1166 /**
1167 * Constructor function for script class.
1168 *
1169 * @return void
1170 */
1171 function init() {
1172 global $BE_USER,$BACK_PATH;
1173
1174 // Setting GPvars:
1175 $this->backPath = t3lib_div::_GP('backPath');
1176 $this->item = t3lib_div::_GP('item');
1177 $this->reloadListFrame = t3lib_div::_GP('reloadListFrame');
1178
1179 // Setting pseudo module name
1180 $this->MCONF['name']='xMOD_alt_clickmenu.php';
1181
1182 // 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:
1183 $inputBP = explode('|',$this->backPath);
1184 if (count($inputBP)==2 && $inputBP[1]==t3lib_div::shortMD5($inputBP[0].'|'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'])) {
1185 $this->backPath = $inputBP[0];
1186 } else {
1187 $this->backPath = $BACK_PATH;
1188 }
1189
1190 // Setting internal array of classes for extending the clickmenu:
1191 $this->extClassArray = $GLOBALS['TBE_MODULES_EXT']['xMOD_alt_clickmenu']['extendCMclasses'];
1192
1193 // Traversing that array and setting files for inclusion:
1194 if (is_array($this->extClassArray)) {
1195 foreach($this->extClassArray as $extClassConf) {
1196 if ($extClassConf['path']) $this->include_once[]=$extClassConf['path'];
1197 }
1198 }
1199
1200 // Initialize template object
1201 $this->doc = t3lib_div::makeInstance('template');
1202 $this->doc->docType='xhtml_trans';
1203 $this->doc->backPath = $BACK_PATH;
1204
1205 // Setting mode for display and background image in the top frame
1206 $this->dontDisplayTopFrameCM= $this->doc->isCMlayers() && !$BE_USER->getTSConfigVal('options.contextMenu.options.alwaysShowClickMenuInTopFrame');
1207 if ($this->dontDisplayTopFrameCM) {
1208 $this->doc->bodyTagId.= '-notop';
1209 }
1210
1211 // Setting clickmenu timeout
1212 $secs = t3lib_div::intInRange($BE_USER->getTSConfigVal('options.contextMenu.options.clickMenuTimeOut'),1,100,5); // default is 5
1213
1214 // Setting the JavaScript controlling the timer on the page
1215 $this->doc->JScode.=$this->doc->wrapScriptTags('
1216 var date = new Date();
1217 var mo_timeout = Math.floor(date.getTime()/1000);
1218
1219 roImg =new Image();
1220 roImg.src = "'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/content_client.gif','width="7" height="10"',1).'";
1221
1222 routImg =new Image();
1223 routImg.src = "clear.gif";
1224
1225 function mo(c) { //
1226 var name="roimg_"+c;
1227 document[name].src = roImg.src;
1228 updateTime();
1229 }
1230 function mout(c) { //
1231 var name="roimg_"+c;
1232 document[name].src = routImg.src;
1233 updateTime();
1234 }
1235 function updateTime() { //
1236 date = new Date();
1237 mo_timeout = Math.floor(date.getTime()/1000);
1238 }
1239 function timeout_func() { //
1240 date = new Date();
1241 if (Math.floor(date.getTime()/1000)-mo_timeout > '.$secs.') {
1242 hideCM();
1243 return false;
1244 } else {
1245 window.setTimeout("timeout_func();",1*1000);
1246 }
1247 }
1248 function hideCM() { //
1249 document.location="alt_topmenu_dummy.php";
1250 return false;
1251 }
1252
1253 // Start timer
1254 timeout_func();
1255
1256 '.($this->reloadListFrame ? '
1257 // Reload list frame:
1258 if(top.content.list_frame){top.content.list_frame.document.location=top.content.list_frame.document.location;}' :
1259 '').'
1260 ');
1261 }
1262
1263 /**
1264 * Main function - generating the click menu in whatever form it has.
1265 *
1266 * @return void
1267 */
1268 function main() {
1269
1270 // Initialize Clipboard object:
1271 $clipObj = t3lib_div::makeInstance('t3lib_clipboard');
1272 $clipObj->initializeClipboard();
1273 $clipObj->lockToNormal(); // This locks the clipboard to the Normal for this request.
1274
1275 // Update clipboard if some actions are sent.
1276 $CB = t3lib_div::_GET('CB');
1277
1278 $clipObj->setCmd($CB);
1279 $clipObj->cleanCurrent();
1280 $clipObj->endClipboard(); // Saves
1281
1282 // Create clickmenu object
1283 $clickMenu = t3lib_div::makeInstance('clickMenu');
1284
1285 // Set internal vars in clickmenu object:
1286 $clickMenu->clipObj = $clipObj;
1287 $clickMenu->extClassArray = $this->extClassArray;
1288 $clickMenu->dontDisplayTopFrameCM = $this->dontDisplayTopFrameCM;
1289 $clickMenu->backPath = $this->backPath;
1290
1291 // Start page
1292 $this->content.=$this->doc->startPage('Context Sensitive Menu');
1293
1294 // Set content of the clickmenu with the incoming var, "item"
1295 $this->content.= $clickMenu->init($this->item);
1296 }
1297
1298 /**
1299 * End page and output content.
1300 *
1301 * @return void
1302 */
1303 function printContent() {
1304 $this->content.= $this->doc->endPage();
1305 echo $this->content;
1306 }
1307 }
1308
1309 // Include extension?
1310 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_clickmenu.php']) {
1311 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_clickmenu.php']);
1312 }
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323 // Make instance:
1324 $SOBE = t3lib_div::makeInstance('SC_alt_clickmenu');
1325 $SOBE->init();
1326
1327 // Include files?
1328 foreach($SOBE->include_once as $INC_FILE) include_once($INC_FILE);
1329
1330 $SOBE->main();
1331 $SOBE->printContent();
1332 ?>