Updated copyright notices to show "2004"
[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 * 154: function init($item)
51 * 194: function doDisplayTopFrameCM()
52 *
53 * SECTION: DATABASE
54 * 222: function printDBClickMenu($table,$uid)
55 * 309: function printNewDBLevel($table,$uid)
56 * 346: function externalProcessingOfDBMenuItems($menuItems)
57 * 358: function processingByExtClassArray($menuItems,$table,$uid)
58 * 377: function urlRefForCM($url,$retUrl='',$hideCM=1)
59 * 394: function DB_copycut($table,$uid,$type)
60 * 417: function DB_paste($table,$uid,$type,$elInfo)
61 * 438: function DB_info($table,$uid)
62 * 454: function DB_history($table,$uid)
63 * 473: function DB_perms($table,$uid,$rec)
64 * 492: function DB_db_list($table,$uid,$rec)
65 * 511: function DB_moveWizard($table,$uid,$rec)
66 * 532: function DB_newWizard($table,$uid,$rec)
67 * 550: function DB_editAccess($table,$uid)
68 * 568: function DB_editPageHeader($uid)
69 * 586: function DB_edit($table,$uid)
70 * 625: function DB_new($table,$uid)
71 * 650: function DB_hideUnhide($table,$rec,$hideField)
72 * 674: function DB_delete($table,$uid,$elInfo)
73 * 695: function DB_view($id,$anchor='')
74 *
75 * SECTION: FILE
76 * 724: function printFileClickMenu($path)
77 * 788: function externalProcessingOfFileMenuItems($menuItems)
78 * 802: function FILE_launch($path,$script,$type,$image)
79 * 821: function FILE_copycut($path,$type)
80 * 841: function FILE_delete($path)
81 * 863: function FILE_paste($path,$target,$elInfo)
82 *
83 * SECTION: COMMON
84 * 903: function printItems($menuItems,$item)
85 * 945: function printLayerJScode($menuItems)
86 * 980: function wrapColorTableCM($str)
87 * 995: function menuItemsForTopFrame($menuItems)
88 * 1012: function menuItemsForClickMenu($menuItems)
89 * 1047: function linkItem($str,$icon,$onClick,$onlyCM=0,$dontHide=0)
90 * 1071: function excludeIcon($iconCode)
91 * 1081: function label($label)
92 * 1090: function isCMlayers()
93 * 1100: function frameLocation($str)
94 *
95 *
96 * 1125: class SC_alt_clickmenu
97 * 1143: function init()
98 * 1226: function main()
99 * 1266: 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::GPvar('cmLevel'));
159 $this->CB = t3lib_div::GPvar('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 return $this->linkItem(
403 $this->label($type),
404 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/clip_'.$type.($isSel==$type?'_h':'').'.gif','width="12" height="12"').' alt="" />'),
405 "top.loadTopMenu('".$this->clipObj->selUrlDB($table,$uid,($type=='copy'?1:0),($isSel==$type))."');return false;"
406 );
407 }
408
409 /**
410 * Adding CM element for Clipboard "paste into"/"paste after"
411 * NOTICE: $table and $uid should follow the special syntax for paste, see clipboard-class :: pasteUrl();
412 *
413 * @param string Table name
414 * @param integer UID for the current record. NOTICE: Special syntax!
415 * @param string Type: "into" or "after"
416 * @param array Contains instructions about whether to copy or cut an element.
417 * @return array Item array, element in $menuItems
418 * @see t3lib_clipboard::pasteUrl()
419 * @internal
420 */
421 function DB_paste($table,$uid,$type,$elInfo) {
422 $editOnClick='';
423 $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
424 $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])).')';
425 $editOnClick='if('.$conf.'){'.$loc.'.document.location=top.TS.PATH_typo3+\''.$this->clipObj->pasteUrl($table,$uid,0).'&redirect=\'+top.rawurlencode('.$this->frameLocation($loc.'.document').'); hideCM();}';
426
427 return $this->linkItem(
428 $this->label('paste'.$type),
429 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/clip_paste'.$type.'.gif','width="12" height="12"').' alt="" />'),
430 $editOnClick.'return false;'
431 );
432 }
433
434 /**
435 * Adding CM element for Info
436 *
437 * @param string Table name
438 * @param integer UID for the current record.
439 * @return array Item array, element in $menuItems
440 * @internal
441 */
442 function DB_info($table,$uid) {
443 return $this->linkItem(
444 $this->label('info'),
445 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/zoom2.gif','width="12" height="12"').' alt="" />'),
446 "top.launchView('".$table."', '".$uid."'); return hideCM();"
447 );
448 }
449
450 /**
451 * Adding CM element for History
452 *
453 * @param string Table name
454 * @param integer UID for the current record.
455 * @return array Item array, element in $menuItems
456 * @internal
457 */
458 function DB_history($table,$uid) {
459 $url = 'show_rechis.php?element='.rawurlencode($table.':'.$uid);
460 return $this->linkItem(
461 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_history')),
462 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/history2.gif','width="13" height="12"').' alt="" />'),
463 $this->urlRefForCM($url,'returnUrl'),
464 0
465 );
466 }
467
468 /**
469 * Adding CM element for Permission setting
470 *
471 * @param string Table name
472 * @param integer UID for the current record.
473 * @param array The "pages" record with "perms_*" fields inside.
474 * @return array Item array, element in $menuItems
475 * @internal
476 */
477 function DB_perms($table,$uid,$rec) {
478 $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':'');
479 return $this->linkItem(
480 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_perms')),
481 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/perm.gif','width="7" height="12"').' alt="" />'),
482 $this->urlRefForCM($url),
483 0
484 );
485 }
486
487 /**
488 * Adding CM element for DBlist
489 *
490 * @param string Table name
491 * @param integer UID for the current record.
492 * @param array Record of the element (needs "pid" field if not pages-record)
493 * @return array Item array, element in $menuItems
494 * @internal
495 */
496 function DB_db_list($table,$uid,$rec) {
497 $url = t3lib_div::getIndpEnv('TYPO3_REQUEST_DIR').'db_list.php?table='.($table=='pages'?'':$table).'&id='.($table=='pages'?$uid:$rec['pid']);
498 return $this->linkItem(
499 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_db_list')),
500 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/list.gif','width="11" height="11"').' alt="" />'),
501 "top.nextLoadModuleUrl='".$url."';top.goToModule('web_list',1);",
502 0
503 );
504 }
505
506 /**
507 * Adding CM element for Moving wizard
508 *
509 * @param string Table name
510 * @param integer UID for the current record.
511 * @param array Record. Needed for tt-content elements which will have the sys_language_uid sent
512 * @return array Item array, element in $menuItems
513 * @internal
514 */
515 function DB_moveWizard($table,$uid,$rec) {
516 $url = 'move_el.php?table='.$table.'&uid='.$uid.
517 ($table=='tt_content'?'&sys_language_uid='.intval($rec['sys_language_uid']):''); // Hardcoded field for tt_content elements.
518
519 return $this->linkItem(
520 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_moveWizard'.($table=='pages'?'_page':''))),
521 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/move_'.($table=='pages'?'page':'record').'.gif','width="11" height="12"').' alt="" />'),
522 $this->urlRefForCM($url,'returnUrl'),
523 0
524 );
525 }
526
527 /**
528 * Adding CM element for Create new wizard (either db_new.php or sysext/cms/layout/db_new_content_el.php or custom wizard)
529 *
530 * @param string Table name
531 * @param integer UID for the current record.
532 * @param array Record.
533 * @return array Item array, element in $menuItems
534 * @internal
535 */
536 function DB_newWizard($table,$uid,$rec) {
537 // If mod.web_list.newContentWiz.overrideWithExtension is set, use that extension's create new content wizard instead:
538 $tmpTSc = t3lib_BEfunc::getModTSconfig($this->pageinfo['uid'],'mod.web_list');
539 $tmpTSc = $tmpTSc ['properties']['newContentWiz.']['overrideWithExtension'];
540 $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');
541
542 $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']);
543 return $this->linkItem(
544 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_newWizard')),
545 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/new_'.($table=='pages'?'page':'record').'.gif','width="'.($table=='pages'?'13':'16').'" height="12"').' alt="" />'),
546 $this->urlRefForCM($url,'returnUrl'),
547 0
548 );
549 }
550
551 /**
552 * Adding CM element for Editing of the access related fields of a table (disable, starttime, endtime, fe_groups)
553 *
554 * @param string Table name
555 * @param integer UID for the current record.
556 * @return array Item array, element in $menuItems
557 * @internal
558 */
559 function DB_editAccess($table,$uid) {
560 $addParam='&columnsOnly='.implode(',',$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']);
561 $url = 'alt_doc.php?edit['.$table.']['.$uid.']=edit'.$addParam;
562 return $this->linkItem(
563 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_editAccess')),
564 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/editaccess.gif','width="12" height="12"').' alt="" />'),
565 $this->urlRefForCM($url,'returnUrl'),
566 1 // no top frame CM!
567 );
568 }
569
570 /**
571 * Adding CM element for edit page header
572 *
573 * @param integer page uid to edit (PID)
574 * @return array Item array, element in $menuItems
575 * @internal
576 */
577 function DB_editPageHeader($uid) {
578 $url = 'alt_doc.php?edit[pages]['.$uid.']=edit';
579 return $this->linkItem(
580 $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->getLL('CM_editPageHeader')),
581 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/edit2.gif','width="11" height="12"').' alt="" />'),
582 $this->urlRefForCM($url,'returnUrl'),
583 1 // no top frame CM!
584 );
585 }
586
587 /**
588 * Adding CM element for regular editing of the element!
589 *
590 * @param string Table name
591 * @param integer UID for the current record.
592 * @return array Item array, element in $menuItems
593 * @internal
594 */
595 function DB_edit($table,$uid) {
596 global $BE_USER;
597 // If another module was specified, replace the default Page module with the new one
598 $newPageModule = trim($BE_USER->getTSConfigVal('options.overridePageModule'));
599 $pageModule = t3lib_BEfunc::isModuleSetInTBE_MODULES($newPageModule) ? $newPageModule : 'web_layout';
600
601 $editOnClick='';
602 $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
603 $addParam='';
604 $theIcon = t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/edit2.gif','width="11" height="12"');
605 if (
606 $this->iParts[0]=='pages' &&
607 $this->iParts[1] &&
608 $BE_USER->check('modules', $pageModule)
609 ) {
610 $theIcon = t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/edit_page.gif','width="12" height="12"');
611 $this->editPageIconSet=1;
612 if ($BE_USER->uc['classicPageEditMode'] || !t3lib_extMgm::isLoaded('cms')) {
613 $addParam='&editRegularContentFromId='.intval($this->iParts[1]);
614 } else {
615 $editOnClick="top.fsMod.recentIds['web']=".intval($this->iParts[1]).";top.goToModule('".$pageModule."',1);";
616 }
617 }
618 if (!$editOnClick) {
619 $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."';}";
620 }
621
622 return $this->linkItem(
623 $this->label('edit'),
624 $this->excludeIcon('<img'.$theIcon.' alt="" />'),
625 $editOnClick.'return hideCM();'
626 );
627 }
628
629 /**
630 * Adding CM element for regular Create new element
631 *
632 * @param string Table name
633 * @param integer UID for the current record.
634 * @return array Item array, element in $menuItems
635 * @internal
636 */
637 function DB_new($table,$uid) {
638 $editOnClick='';
639 $loc='top.content'.(!$this->alwaysContentFrame?'.list_frame':'');
640 $editOnClick='if('.$loc.'){'.$loc.".document.location=top.TS.PATH_typo3+'".
641 ($this->listFrame?
642 "alt_doc.php?returnUrl='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'&edit[".$table."][-".$uid."]=new'":
643 'db_new.php?id='.intval($uid)."'").
644 ';}';
645
646 return $this->linkItem(
647 $this->label('new'),
648 $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="" />'),
649 $editOnClick.'return hideCM();'
650 );
651 }
652
653 /**
654 * Adding CM element for hide/unhide of the input record
655 *
656 * @param string Table name
657 * @param array Record array
658 * @param string Name of the hide field
659 * @return array Item array, element in $menuItems
660 * @internal
661 */
662 function DB_hideUnhide($table,$rec,$hideField) {
663 $uid=$rec['uid'];
664 $editOnClick='';
665 $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
666 $editOnClick='if('.$loc.'){'.$loc.".document.location=top.TS.PATH_typo3+'tce_db.php?redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'".
667 "&data[".$table.']['.$uid.']['.$hideField.']='.($rec[$hideField]?0:1).'&prErr=1&vC='.$GLOBALS['BE_USER']->veriCode()."';hideCM();}";
668
669 return $this->linkItem(
670 $this->label(($rec[$hideField]?'un':'').'hide'),
671 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/button_'.($rec[$hideField]?'un':'').'hide.gif','width="11" height="10"').' alt="" />'),
672 $editOnClick.'return false;',
673 1
674 );
675 }
676
677 /**
678 * Adding CM element for Delete
679 *
680 * @param string Table name
681 * @param integer UID for the current record.
682 * @param array Label for including in the confirmation message, EXT:lang/locallang_core.php:mess.delete
683 * @return array Item array, element in $menuItems
684 * @internal
685 */
686 function DB_delete($table,$uid,$elInfo) {
687 $editOnClick='';
688 $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
689 $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').")+'".
690 "&cmd[".$table.']['.$uid.'][delete]=1&prErr=1&vC='.$GLOBALS['BE_USER']->veriCode()."';hideCM();}";
691
692 return $this->linkItem(
693 $this->label('delete'),
694 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/garbage.gif','width="11" height="12"').' alt="" />'),
695 $editOnClick.'return false;'
696 );
697 }
698
699 /**
700 * Adding CM element for View Page
701 *
702 * @param integer Page uid (PID)
703 * @param string Anchor, if any
704 * @return array Item array, element in $menuItems
705 * @internal
706 */
707 function DB_view($id,$anchor='') {
708 return $this->linkItem(
709 $this->label('view'),
710 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/zoom.gif','width="12" height="12"').' alt="" />'),
711 t3lib_BEfunc::viewOnClick($id,$this->PH_backPath,t3lib_BEfunc::BEgetRootLine($id),$anchor).'return hideCM();'
712 );
713 }
714
715
716
717
718
719
720
721
722
723
724 /***************************************
725 *
726 * FILE
727 *
728 ***************************************/
729
730 /**
731 * Make 1st level clickmenu:
732 *
733 * @param string The absolute path
734 * @return string HTML content
735 */
736 function printFileClickMenu($path) {
737 $menuItems=array();
738
739 if (@file_exists($path) && t3lib_div::isAllowedAbsPath($path)) {
740 $fI = pathinfo($path);
741 $icon = is_dir($path) ? 'folder.gif' : t3lib_BEfunc::getFileIcon(strtolower($fI['extension']));
742 $size=' ('.t3lib_div::formatSize(filesize($path)).'bytes)';
743 $icon = '<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/fileicons/'.$icon,'width="18" height="16"').' class="absmiddle" title="'.htmlspecialchars($fI['basename'].$size).'" alt="" />';
744
745 // edit
746 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');
747 // rename
748 if (!in_array('rename',$this->disabledItems)) $menuItems['rename']=$this->FILE_launch($path,'file_rename.php','rename','rename.gif');
749 // upload
750 if (!in_array('upload',$this->disabledItems) && is_dir($path)) $menuItems['upload']=$this->FILE_launch($path,'file_upload.php','upload','upload.gif');
751 // new
752 if (!in_array('new',$this->disabledItems) && is_dir($path)) $menuItems['new']=$this->FILE_launch($path,'file_newfolder.php','new','new_file.gif');
753 // info
754 if (!in_array('info',$this->disabledItems)) $menuItems['info']=$this->DB_info($path,'');
755
756 $menuItems[]='spacer';
757
758 // copy:
759 if (!in_array('copy',$this->disabledItems)) $menuItems['copy']=$this->FILE_copycut($path,'copy');
760 // cut:
761 if (!in_array('cut',$this->disabledItems)) $menuItems['cut']=$this->FILE_copycut($path,'cut');
762
763 // Paste:
764 $elFromAllTables = count($this->clipObj->elFromTable('_FILE'));
765 if (!in_array('paste',$this->disabledItems) && $elFromAllTables && is_dir($path)) {
766 $elArr = $this->clipObj->elFromTable('_FILE');
767 reset($elArr);
768 $selItem = current($elArr);
769 $elInfo=array(
770 basename($selItem),
771 basename($path),
772 $this->clipObj->currentMode()
773 );
774 $menuItems['pasteinto']=$this->FILE_paste($path,$selItem,$elInfo);
775 }
776
777 $menuItems[]='spacer';
778
779 // delete:
780 if (!in_array('delete',$this->disabledItems)) $menuItems['delete']=$this->FILE_delete($path);
781 }
782
783 // Adding external elements to the menuItems array
784 $menuItems = $this->processingByExtClassArray($menuItems,$path,0);
785
786 // Processing by external functions?
787 $menuItems = $this->externalProcessingOfFileMenuItems($menuItems);
788
789 // Return the printed elements:
790 return $this->printItems($menuItems,$icon.basename($path));
791 }
792
793
794 /**
795 * Processing the $menuItems array (for extension classes) (FILES)
796 *
797 * @param array $menuItems array for manipulation.
798 * @return array Processed $menuItems array
799 */
800 function externalProcessingOfFileMenuItems($menuItems) {
801 return $menuItems;
802 }
803
804 /**
805 * Multi-function for adding an entry to the $menuItems array
806 *
807 * @param string Path to the file/directory (target)
808 * @param string Script (eg. file_edit.php) to pass &target= to
809 * @param string "type" is the code which fetches the correct label for the element from "cm."
810 * @param string icon image-filename from "gfx/" (12x12 icon)
811 * @return array Item array, element in $menuItems
812 * @internal
813 */
814 function FILE_launch($path,$script,$type,$image) {
815 $loc='top.content'.(!$this->alwaysContentFrame?'.list_frame':'');
816 $editOnClick='if('.$loc.'){'.$loc.".document.location=top.TS.PATH_typo3+'".$script.'?target='.rawurlencode($path)."';}";
817
818 return $this->linkItem(
819 $this->label($type),
820 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/'.$image,'width="12" height="12"').' alt="" />'),
821 $editOnClick.'return hideCM();'
822 );
823 }
824
825 /**
826 * Returns element for copy or cut of files.
827 *
828 * @param string Path to the file/directory (target)
829 * @param string Type: "copy" or "cut"
830 * @return array Item array, element in $menuItems
831 * @internal
832 */
833 function FILE_copycut($path,$type) {
834 $table='_FILE'; // Pseudo table name for use in the clipboard.
835 $uid = t3lib_div::shortmd5($path);
836 if ($this->clipObj->current=='normal') {
837 $isSel = $this->clipObj->isSelected($table,$uid);
838 }
839 return $this->linkItem(
840 $this->label($type),
841 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/clip_'.$type.($isSel==$type?'_h':'').'.gif','width="12" height="12"').' alt="" />'),
842 "top.loadTopMenu('".$this->clipObj->selUrlFile($path,($type=='copy'?1:0),($isSel==$type))."');return false;"
843 );
844 }
845
846 /**
847 * Creates element for deleting of target
848 *
849 * @param string Path to the file/directory (target)
850 * @return array Item array, element in $menuItems
851 * @internal
852 */
853 function FILE_delete($path) {
854 $editOnClick='';
855 $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
856 $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').")+'".
857 "&file[delete][0][data]=".rawurlencode($path).'&vC='.$GLOBALS['BE_USER']->veriCode()."';hideCM();}";
858
859 return $this->linkItem(
860 $this->label('delete'),
861 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/garbage.gif','width="11" height="12"').' alt="" />'),
862 $editOnClick.'return false;'
863 );
864 }
865
866 /**
867 * Creates element for pasting files.
868 *
869 * @param string Path to the file/directory (target)
870 * @param string target - NOT USED.
871 * @param array Various values for the labels.
872 * @return array Item array, element in $menuItems
873 * @internal
874 */
875 function FILE_paste($path,$target,$elInfo) {
876 $editOnClick='';
877 $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
878 $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])).")";
879 $editOnClick='if('.$conf.'){'.$loc.".document.location=top.TS.PATH_typo3+'".$this->clipObj->pasteUrl('_FILE',$path,0).
880 "&redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').'); hideCM();}';
881
882 return $this->linkItem(
883 $this->label('pasteinto'),
884 $this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/clip_pasteinto.gif','width="12" height="12"').' alt="" />'),
885 $editOnClick.'return false;'
886 );
887 }
888
889
890
891
892
893
894
895
896
897
898
899
900
901 /***************************************
902 *
903 * COMMON
904 *
905 **************************************/
906
907 /**
908 * Prints the items from input $menuItems array - both as topframe menu AND the JS section for writing to the div-layers.
909 * Of course the topframe menu will appear only if $this->doDisplayTopFrameCM() returns true
910 *
911 * @param array $menuItems array
912 * @param string HTML code for the element which was clicked - shown in the end of the horizontal menu in topframe after the close-button.
913 * @return string HTML code
914 */
915 function printItems($menuItems,$item) {
916 $out='';
917
918 // Adding topframe part (horizontal clickmenu)
919 if ($this->doDisplayTopFrameCM()) {
920 $out.= '
921
922 <!--
923 Table, which contains the click menu when shown in the top frame of the backend:
924 -->
925 <table border="0" cellpadding="0" cellspacing="0" id="typo3-CSM-top">
926 <tr>
927
928 <!-- Items: -->
929 <td class="c-item">'.
930 implode('</td>
931 <td><img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/acm_spacer2.gif','width="8" height="12"').' alt="" /></td>
932 <td class="c-item">',$this->menuItemsForTopFrame($menuItems)).
933 '</td>
934
935 <!-- Close button: -->
936 <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>
937
938 <!-- The item of the clickmenu: -->
939 <td class="c-itemicon">'.$item.'</td>
940 </tr>
941 </table>
942 ';
943
944 // Set remaining BACK_PATH to blank (if any)
945 $out = str_replace($this->PH_backPath,'',$out);
946 }
947 // Adding JS part:
948 $out.=$this->printLayerJScode($menuItems);
949
950 // Return the content
951 return $out;
952 }
953
954 /**
955 * Create the JavaScript section
956 *
957 * @param array The $menuItems array to print
958 * @return string The JavaScript section which will print the content of the CM to the div-layer in the target frame.
959 */
960 function printLayerJScode($menuItems) {
961 $script='';
962 if ($this->isCMlayers()) { // Clipboard must not be submitted - then it's probably a copy/cut situation.
963 $frameName = '.'.($this->listFrame ? 'list_frame' : 'nav_frame');
964 if ($this->alwaysContentFrame) $frameName='';
965
966 // Create the table displayed in the clickmenu layer:
967 $CMtable = '
968 <table border="0" cellpadding="0" cellspacing="0" class="typo3-CSM bgColor4">
969 '.implode('',$this->menuItemsForClickMenu($menuItems)).'
970 </table>';
971
972 // Wrap the inner table in another table to create outer border:
973 $CMtable = $this->wrapColorTableCM($CMtable);
974
975 // Set back path place holder to real back path
976 $CMtable = str_replace($this->PH_backPath,$this->backPath,$CMtable);
977
978 // Create JavaScript section:
979 $script=$GLOBALS['TBE_TEMPLATE']->wrapScriptTags('
980
981 if (top.content && top.content'.$frameName.' && top.content'.$frameName.'.setLayerObj) {
982 top.content'.$frameName.'.setLayerObj(unescape("'.t3lib_div::rawurlencodeJS($CMtable).'"),'.$this->cmLevel.');
983 }
984 '.(!$this->doDisplayTopFrameCM()?'hideCM();':'')
985 );
986 }
987
988 return $script;
989 }
990
991 /**
992 * Wrapping the input string in a table with background color 4 and a black border style.
993 * For the pop-up menu
994 *
995 * @param string HTML content to wrap in table.
996 * @return string
997 */
998 function wrapColorTableCM($str) {
999
1000 // Clear-gifs needed if opera is to set the table row height correctly in skins.
1001 $str = '<table border="0" cellspacing="0" class="typo3-CSM-wrapperCM">
1002 <tr class="c-rowA">
1003 <td class="c-aa">'.$str.'</td>
1004 <td class="c-ab"></td>
1005 </tr>
1006 <tr class="c-rowB">
1007 <td class="c-ba"><img src="clear.gif" width="1" height="1" alt="" /></td>
1008 <td class="c-bb"><img src="clear.gif" width="1" height="1" alt="" /></td>
1009 </tr>
1010 </table>';
1011 return $str;
1012 }
1013
1014 /**
1015 * Traverses the menuItems and generates an output array for implosion in the topframe horizontal menu
1016 *
1017 * @param array $menuItem array
1018 * @param array Array with HTML content to be imploded between <td>-tags
1019 * @return array Array of menu items for top frame.
1020 */
1021 function menuItemsForTopFrame($menuItems) {
1022 reset($menuItems);
1023 $out=array();
1024 while(list(,$i)=each($menuItems)) {
1025 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)
1026 if (is_array($i) && !$i[4]) $out[]=$i[0];
1027 }
1028 return $out;
1029 }
1030
1031 /**
1032 * Traverses the menuItems and generates an output array for implosion in the CM div-layers table.
1033 *
1034 * @param array $menuItem array
1035 * @param array Array with HTML content to be imploded between <td>-tags
1036 * @return array array for implosion in the CM div-layers table.
1037 */
1038 function menuItemsForClickMenu($menuItems) {
1039 reset($menuItems);
1040 $out=array();
1041 while(list($cc,$i)=each($menuItems)) {
1042 if (is_string($i) && $i=='spacer') { // MAKE horizontal spacer
1043 $out[]='
1044 <tr class="bgColor2">
1045 <td colspan="2"><img src="clear.gif" width="1" height="1" alt="" /></td>
1046 </tr>';
1047 } else { // Just make normal element:
1048 $onClick=$i[3];
1049 $onClick=eregi_replace('return[[:space:]]+hideCM\(\)[[:space:]]*;','',$onClick);
1050 $onClick=eregi_replace('return[[:space:]]+false[[:space:]]*;','',$onClick);
1051 $onClick=eregi_replace('hideCM\(\);','',$onClick);
1052 if (!$i[5]) $onClick.='hideEmpty();';
1053
1054 $out[]='
1055 <tr class="typo3-CSM-itemRow" onclick="'.htmlspecialchars($onClick).'" onmouseover="this.bgColor=\''.$GLOBALS['TBE_TEMPLATE']->bgColor5.'\';" onmouseout="this.bgColor=\'\';">
1056 '.(!$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>').'
1057 </tr>';
1058 }
1059 }
1060 return $out;
1061 }
1062
1063 /**
1064 * Creating an array with various elements for the clickmenu entry
1065 *
1066 * @param string The label, htmlspecialchar'ed already
1067 * @param string <img>-tag for the icon
1068 * @param string JavaScript onclick event for label/icon
1069 * @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)
1070 * @param boolean If set, the clickmenu layer will not hide itself onclick - used for secondary menus to appear...
1071 * @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!
1072 */
1073 function linkItem($str,$icon,$onClick,$onlyCM=0,$dontHide=0) {
1074 $this->elCount++;
1075
1076 $WHattribs = t3lib_iconWorks::skinImg($BACK_PATH,'gfx/content_client.gif','width="7" height="10"',2);
1077
1078 return array(
1079 '<img src="clear.gif" '.$WHattribs.' class="c-roimg" name="roimg_'.$this->elCount.'" alt="" />'.
1080 '<a href="#" onclick="'.htmlspecialchars($onClick).'" onmouseover="mo('.$this->elCount.');" onmouseout="mout('.$this->elCount.');">'.
1081 $str.$icon.
1082 '</a>',
1083 $str,
1084 $icon,
1085 $onClick,
1086 $onlyCM,
1087 $dontHide
1088 );
1089 }
1090
1091 /**
1092 * Returns the input string IF not a user setting has disabled display of icons.
1093 *
1094 * @param string The icon-image tag
1095 * @return string The icon-image tag prefixed with space char IF the icon should be printed at all due to user settings
1096 */
1097 function excludeIcon($iconCode) {
1098 return ($GLOBALS['BE_USER']->uc['noMenuMode'] && strcmp($GLOBALS['BE_USER']->uc['noMenuMode'],'icons')) ? '' : ' '.$iconCode;
1099 }
1100
1101 /**
1102 * Get label from locallang_core.php:cm.*
1103 *
1104 * @param string The "cm."-suffix to get.
1105 * @return string
1106 */
1107 function label($label) {
1108 return $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:cm.'.$label,1));
1109 }
1110
1111 /**
1112 * Returns true if there should be writing to the div-layers (commands sent to clipboard MUST NOT write to div-layers)
1113 *
1114 * @return boolean
1115 */
1116 function isCMlayers() {
1117 return $GLOBALS['SOBE']->doc->isCMlayers() && !$this->CB;
1118 }
1119
1120 /**
1121 * Appends ".location" to input string
1122 *
1123 * @param string Input string, probably a JavaScript document reference
1124 * @return string
1125 */
1126 function frameLocation($str) {
1127 return $str.'.location';
1128 }
1129 }
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143 /**
1144 * Script Class for the Context Sensitive Menu in TYPO3 (rendered in top frame, normally writing content dynamically to list frames).
1145 *
1146 * @author Kasper Skaarhoj <kasper@typo3.com>
1147 * @package TYPO3
1148 * @subpackage core
1149 * @see template::getContextMenuCode()
1150 */
1151 class SC_alt_clickmenu {
1152
1153 // Internal, static: GPvar:
1154 var $backPath; // Back path.
1155 var $item; // Definition of which item the click menu should be made for.
1156
1157 // Internal:
1158 var $content=''; // Content accumulation
1159 var $doc; // Template object
1160 var $include_once=array(); // Files to include_once() - set in init() function
1161 var $extClassArray=array(); // Internal array of classes for extending the clickmenu
1162 var $dontDisplayTopFrameCM=0; // If set, then the clickmenu will NOT display in the top frame.
1163
1164 /**
1165 * Constructor function for script class.
1166 *
1167 * @return void
1168 */
1169 function init() {
1170 global $BE_USER,$BACK_PATH;
1171
1172 // Setting GPvars:
1173 $this->backPath = t3lib_div::GPvar('backPath');
1174 $this->item = t3lib_div::GPvar('item');
1175
1176 // Setting pseudo module name
1177 $this->MCONF['name']='xMOD_alt_clickmenu.php';
1178
1179 // 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:
1180 $inputBP = explode('|',$this->backPath);
1181 if (count($inputBP)==2 && $inputBP[1]==t3lib_div::shortMD5($inputBP[0].'|'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'])) {
1182 $this->backPath = $inputBP[0];
1183 } else {
1184 $this->backPath = $BACK_PATH;
1185 }
1186
1187 // Setting internal array of classes for extending the clickmenu:
1188 $this->extClassArray = $GLOBALS['TBE_MODULES_EXT']['xMOD_alt_clickmenu']['extendCMclasses'];
1189
1190 // Traversing that array and setting files for inclusion:
1191 if (is_array($this->extClassArray)) {
1192 foreach($this->extClassArray as $extClassConf) {
1193 if ($extClassConf['path']) $this->include_once[]=$extClassConf['path'];
1194 }
1195 }
1196
1197 // Initialize template object
1198 $this->doc = t3lib_div::makeInstance('template');
1199 $this->doc->docType='xhtml_trans';
1200 $this->doc->backPath = $BACK_PATH;
1201
1202 // Setting mode for display and background image in the top frame
1203 $this->dontDisplayTopFrameCM= $this->doc->isCMlayers() && !$BE_USER->getTSConfigVal('options.contextMenu.options.alwaysShowClickMenuInTopFrame');
1204 if ($this->dontDisplayTopFrameCM) {
1205 $this->doc->bodyTagId.= '-notop';
1206 }
1207
1208 // Setting clickmenu timeout
1209 $secs = t3lib_div::intInRange($BE_USER->getTSConfigVal('options.contextMenu.options.clickMenuTimeOut'),1,100,5); // default is 5
1210
1211 // Setting the JavaScript controlling the timer on the page
1212 $this->doc->JScode.=$this->doc->wrapScriptTags('
1213 var date = new Date();
1214 var mo_timeout = Math.floor(date.getTime()/1000);
1215
1216 roImg =new Image();
1217 roImg.src = "'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/content_client.gif','width="7" height="10"',1).'";
1218
1219 routImg =new Image();
1220 routImg.src = "clear.gif";
1221
1222 function mo(c) { //
1223 var name="roimg_"+c;
1224 document[name].src = roImg.src;
1225 updateTime();
1226 }
1227 function mout(c) { //
1228 var name="roimg_"+c;
1229 document[name].src = routImg.src;
1230 updateTime();
1231 }
1232 function updateTime() { //
1233 date = new Date();
1234 mo_timeout = Math.floor(date.getTime()/1000);
1235 }
1236 function timeout_func() { //
1237 date = new Date();
1238 if (Math.floor(date.getTime()/1000)-mo_timeout > '.$secs.') {
1239 hideCM();
1240 return false;
1241 } else {
1242 window.setTimeout("timeout_func();",1*1000);
1243 }
1244 }
1245 function hideCM() { //
1246 document.location="alt_topmenu_dummy.php";
1247 return false;
1248 }
1249
1250 // Start timer
1251 timeout_func();
1252 ');
1253 }
1254
1255 /**
1256 * Main function - generating the click menu in whatever form it has.
1257 *
1258 * @return void
1259 */
1260 function main() {
1261 global $HTTP_GET_VARS;
1262
1263 // Initialize Clipboard object:
1264 $clipObj = t3lib_div::makeInstance('t3lib_clipboard');
1265 $clipObj->initializeClipboard();
1266 $clipObj->lockToNormal(); // This locks the clipboard to the Normal for this request.
1267
1268 // Update clipboard if some actions are sent.
1269 $CB = $HTTP_GET_VARS['CB'];
1270 $clipObj->setCmd($CB);
1271 $clipObj->cleanCurrent();
1272 $clipObj->endClipboard(); // Saves
1273
1274 // Create clickmenu object
1275 $clickMenu = t3lib_div::makeInstance('clickMenu');
1276
1277 // Set internal vars in clickmenu object:
1278 $clickMenu->clipObj = $clipObj;
1279 $clickMenu->extClassArray = $this->extClassArray;
1280 $clickMenu->dontDisplayTopFrameCM = $this->dontDisplayTopFrameCM;
1281 $clickMenu->backPath = $this->backPath;
1282
1283 // Start page
1284 $this->content.=$this->doc->startPage('Context Sensitive Menu');
1285
1286 // Set content of the clickmenu with the incoming var, "item"
1287 $this->content.= $clickMenu->init($this->item);
1288 }
1289
1290 /**
1291 * End page and output content.
1292 *
1293 * @return void
1294 */
1295 function printContent() {
1296 $this->content.= $this->doc->endPage();
1297 echo $this->content;
1298 }
1299 }
1300
1301 // Include extension?
1302 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_clickmenu.php']) {
1303 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_clickmenu.php']);
1304 }
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315 // Make instance:
1316 $SOBE = t3lib_div::makeInstance('SC_alt_clickmenu');
1317 $SOBE->init();
1318
1319 // Include files?
1320 foreach($SOBE->include_once as $INC_FILE) include_once($INC_FILE);
1321
1322 $SOBE->main();
1323 $SOBE->printContent();
1324 ?>