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