*** empty log message ***
[Packages/TYPO3.CMS.git] / typo3 / alt_shortcut.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * Shortcut frame
29 * Appears in the bottom frame of the backend frameset.
30 * Provides links to registered shortcuts
31 * If the 'cms' extension is loaded you will also have a field for entering page id/alias which will be found/edited
32 *
33 * $Id$
34 * Revised for TYPO3 3.6 2/2003 by Kasper Skaarhoj
35 * XHTML compliant output
36 *
37 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
38 */
39 /**
40 * [CLASS/FUNCTION INDEX of SCRIPT]
41 *
42 *
43 *
44 * 82: class SC_alt_shortcut
45 * 121: function preinit()
46 * 146: function preprocess()
47 * 203: function init()
48 * 237: function main()
49 * 345: function editLoadedFunc()
50 * 406: function editPageIdFunc()
51 * 454: function printContent()
52 *
53 * SECTION: OTHER FUNCTIONS:
54 * 482: function mIconFilename($Ifilename,$backPath)
55 * 495: function getIcon($modName)
56 * 519: function itemLabel($inlabel,$modName,$M_modName='')
57 *
58 * TOTAL FUNCTIONS: 10
59 * (This index is automatically created/updated by the extension "extdeveval")
60 *
61 */
62
63
64 require('init.php');
65 require('template.php');
66 $LANG->includeLLFile('EXT:lang/locallang_misc.xml');
67 require_once(PATH_t3lib.'class.t3lib_loadmodules.php');
68 require_once(PATH_t3lib.'class.t3lib_basicfilefunc.php');
69
70
71
72
73
74
75 /**
76 * Script Class for the shortcut frame, bottom frame of the backend frameset
77 *
78 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
79 * @package TYPO3
80 * @subpackage core
81 */
82 class SC_alt_shortcut {
83
84 // Internal, static: GPvar
85 var $modName;
86 var $M_modName;
87 var $URL;
88 var $editSC;
89 var $deleteCategory;
90 var $editName;
91 var $editGroup;
92 var $whichItem;
93
94 // Internal, static:
95 var $loadModules; // Modules object
96 var $doc; // Document template object
97 var $nGroups; // Number of groups
98 var $nGlobals; // Number of globals
99
100 // Internal, dynamic:
101 var $content; // Accumulation of output HTML (string)
102 var $lines; // Accumulation of table cells (array)
103
104 var $editLoaded; // Flag for defining whether we are editing
105 var $editError; // Can contain edit error message
106 var $editPath; // Set to the record path of the record being edited.
107 var $editSC_rec; // Holds the shortcut record when editing
108 var $theEditRec; // Page record to be edited
109 var $editPage; // Page alias or id to be edited
110 var $selOpt; // Select options.
111 var $searchFor; // Text to search for...
112
113 var $alternativeTableUid = array(); // Array with key 0/1 being table/uid of record to edit. Internally set.
114
115
116
117 /**
118 * Pre-initialization - setting input variables for storing shortcuts etc.
119 *
120 * @return void
121 */
122 function preinit() {
123 global $TBE_MODULES;
124
125 // Setting GPvars:
126 $this->modName = t3lib_div::_GP('modName');
127 $this->M_modName = t3lib_div::_GP('motherModName');
128 $this->URL = t3lib_div::_GP('URL');
129 $this->editSC = t3lib_div::_GP('editShortcut');
130
131 $this->deleteCategory = t3lib_div::_GP('deleteCategory');
132 $this->editPage = t3lib_div::_GP('editPage');
133 $this->changeWorkspace = t3lib_div::_GP('changeWorkspace');
134 $this->changeWorkspacePreview = t3lib_div::_GP('changeWorkspacePreview');
135 $this->editName = t3lib_div::_GP('editName');
136 $this->editGroup = t3lib_div::_GP('editGroup');
137 $this->whichItem = t3lib_div::_GP('whichItem');
138
139 // Creating modules object
140 $this->loadModules = t3lib_div::makeInstance('t3lib_loadModules');
141 $this->loadModules->load($TBE_MODULES);
142 }
143
144 /**
145 * Adding shortcuts, editing shortcuts etc.
146 *
147 * @return void
148 */
149 function preprocess() {
150 global $BE_USER;
151
152 // Adding a shortcut being set from another frame
153 if ($this->modName && $this->URL) {
154 $fields_values = array(
155 'userid' => $BE_USER->user['uid'],
156 'module_name' => $this->modName.'|'.$this->M_modName,
157 'url' => $this->URL,
158 'sorting' => time()
159 );
160 $GLOBALS['TYPO3_DB']->exec_INSERTquery('sys_be_shortcuts', $fields_values);
161 }
162
163 // Selection-clause for users - so users can deleted only their own shortcuts (except admins)
164 $addUSERWhere = (!$BE_USER->isAdmin()?' AND userid='.intval($BE_USER->user['uid']):'');
165
166 // Deleting shortcuts:
167 if (strcmp($this->deleteCategory,'')) {
168 if (t3lib_div::testInt($this->deleteCategory)) {
169 $GLOBALS['TYPO3_DB']->exec_DELETEquery('sys_be_shortcuts', 'sc_group='.intval($this->deleteCategory).$addUSERWhere);
170 }
171 }
172
173 // If other changes in post-vars:
174 if (is_array($_POST)) {
175 // Saving:
176 if (isset($_POST['_savedok_x']) || isset($_POST['_saveclosedok_x'])) {
177 $fields_values = array(
178 'description' => $this->editName,
179 'sc_group' => intval($this->editGroup)
180 );
181 if ($fields_values['sc_group']<0 && !$BE_USER->isAdmin()) {
182 $fields_values['sc_group']=0;
183 }
184
185 $GLOBALS['TYPO3_DB']->exec_UPDATEquery('sys_be_shortcuts', 'uid='.intval($this->whichItem).$addUSERWhere, $fields_values);
186 }
187 // If save without close, keep the session going...
188 if (isset($_POST['_savedok_x'])) {
189 $this->editSC=$this->whichItem;
190 }
191 // Deleting a single shortcut ?
192 if (isset($_POST['_deletedok_x'])) {
193 $GLOBALS['TYPO3_DB']->exec_DELETEquery('sys_be_shortcuts', 'uid='.intval($this->whichItem).$addUSERWhere);
194
195 if (!$this->editSC) $this->editSC=-1; // Just to have the checkbox set...
196 }
197 }
198
199 }
200
201 /**
202 * Initialize (page output)
203 *
204 * @return void
205 */
206 function init() {
207 global $BACK_PATH;
208
209 $this->doc = t3lib_div::makeInstance('template');
210 $this->doc->backPath = $BACK_PATH;
211 $this->doc->form='<form action="alt_shortcut.php" name="shForm" method="post">';
212 $this->doc->docType='xhtml_trans';
213 $this->doc->divClass='typo3-shortcut';
214 $this->doc->JScode.=$this->doc->wrapScriptTags('
215 function jump(url,modName,mainModName) { //
216 // Clear information about which entry in nav. tree that might have been highlighted.
217 top.fsMod.navFrameHighlightedID = new Array();
218 if (top.content && top.content.nav_frame && top.content.nav_frame.refresh_nav) {
219 top.content.nav_frame.refresh_nav();
220 }
221
222 top.nextLoadModuleUrl = url;
223 top.goToModule(modName);
224 }
225 function editSh(uid) { //
226 document.location="alt_shortcut.php?editShortcut="+uid;
227 }
228 function submitEditPage(id) { //
229 document.location="alt_shortcut.php?editPage="+top.rawurlencode(id);
230 }
231 function changeWorkspace(workspaceId) { //
232 document.location="alt_shortcut.php?changeWorkspace="+top.rawurlencode(workspaceId);
233 }
234 function changeWorkspacePreview(newstate) { //
235 document.location="alt_shortcut.php?changeWorkspacePreview="+newstate;
236 }
237
238 ');
239 $this->content.=$this->doc->startPage('Shortcut frame');
240 }
241
242 /**
243 * Main function, creating content in the frame
244 *
245 * @return void
246 */
247 function main() {
248 global $BE_USER,$LANG,$TCA;
249
250 // Setting groups and globals
251 $this->nGroups=4;
252 $this->nGlobals=5;
253
254 $globalGroups=array(-100);
255 $shortCutGroups = $BE_USER->getTSConfig('options.shortcutGroups');
256 for($a=1;$a<=$this->nGlobals;$a++) {
257 if ($BE_USER->isAdmin() || strcmp($shortCutGroups['properties'][$a],'')) {
258 $globalGroups[]=-$a;
259 }
260 }
261
262 // Fetching shortcuts to display for this user:
263 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_be_shortcuts', '((userid='.$BE_USER->user['uid'].' AND sc_group>=0) OR sc_group IN ('.implode(',',$globalGroups).'))', '', 'sc_group,sorting');
264
265 // Init vars:
266 $this->lines=array();
267 $this->editSC_rec='';
268 $this->selOpt=array();
269 $formerGr='';
270
271 // Traverse shortcuts
272 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
273 if ($this->editSC && $row['uid']==$this->editSC) {
274 $this->editSC_rec=$row;
275 }
276
277 if (strcmp($formerGr,$row['sc_group'])) {
278 if ($row['sc_group']!=-100) {
279 if ($row['sc_group']>=0) {
280 $onC = 'if (confirm('.$GLOBALS['LANG']->JScharCode($LANG->getLL('shortcut_delAllInCat')).')){document.location=\'alt_shortcut.php?deleteCategory='.$row['sc_group'].'\';}return false;';
281 $this->lines[]='<td>&nbsp;</td><td class="bgColor5"><a href="#" onclick="'.htmlspecialchars($onC).'" title="'.$LANG->getLL('shortcut_delAllInCat',1).'">'.abs($row['sc_group']).'</a></td>';
282 } else {
283 $this->lines[]='<td>&nbsp;</td><td class="bgColor5">'.abs($row['sc_group']).'</td>';
284 }
285 }
286 }
287
288 $mParts = explode('|',$row['module_name']);
289 $row['module_name']=$mParts[0];
290 $row['M_module_name']=$mParts[1];
291 $mParts = explode('_',$row['M_module_name']?$row['M_module_name']:$row['module_name']);
292 $qParts = parse_url($row['url']);
293
294 $bgColorClass = $row['uid']==$this->editSC ? 'bgColor5' : ($row['sc_group']<0 ? 'bgColor6' : 'bgColor4');
295 $titleA = $this->itemLabel($row['description']&&($row['uid']!=$this->editSC) ? $row['description'] : t3lib_div::fixed_lgd(rawurldecode($qParts['query']),150),$row['module_name'],$row['M_module_name']);
296
297 $editSH = ($row['sc_group']>=0 || $BE_USER->isAdmin()) ? 'editSh('.intval($row['uid']).');' : "alert('".$LANG->getLL('shortcut_onlyAdmin')."')";
298 $jumpSC = 'jump(unescape(\''.rawurlencode($row['url']).'\'),\''.implode('_',$mParts).'\',\''.$mParts[0].'\');';
299 $onC = 'if (document.shForm.editShortcut_check && document.shForm.editShortcut_check.checked){'.$editSH.'}else{'.$jumpSC.'}return false;';
300 $this->lines[]='<td class="'.$bgColorClass.'"><a href="#" onclick="'.htmlspecialchars($onC).'"><img src="'.$this->getIcon($row['module_name']).'" title="'.htmlspecialchars($titleA).'" alt="" /></a></td>';
301 if (trim($row['description'])) {
302 $kkey = strtolower(substr($row['description'],0,20)).'_'.$row['uid'];
303 $this->selOpt[$kkey]='<option value="'.htmlspecialchars($jumpSC).'">'.htmlspecialchars(t3lib_div::fixed_lgd_cs($row['description'],50)).'</option>';
304 }
305 $formerGr=$row['sc_group'];
306 }
307 ksort($this->selOpt);
308 array_unshift($this->selOpt,'<option>['.$LANG->getLL('shortcut_selSC',1).']</option>');
309
310 $this->editLoadedFunc();
311 $this->editPageIdFunc();
312
313 if (!$this->editLoaded && t3lib_extMgm::isLoaded('cms')) {
314 $editIdCode = '<td nowrap="nowrap">'.$LANG->getLL('shortcut_editID',1).': <input type="text" value="'.($this->editError?htmlspecialchars($this->editPage):'').'" name="editPage"'.$this->doc->formWidth(15).' onchange="submitEditPage(this.value);" />'.
315 ($this->editError?'&nbsp;<strong><span class="typo3-red">'.htmlspecialchars($this->editError).'</span></strong>':'').
316 (is_array($this->theEditRec)?'&nbsp;<strong>'.$LANG->getLL('shortcut_loadEdit',1).' \''.t3lib_BEfunc::getRecordTitle('pages',$this->theEditRec,1).'\'</strong> ('.htmlspecialchars($this->editPath).')':'').
317 ($this->searchFor?'&nbsp;'.$LANG->getLL('shortcut_searchFor',1).' <strong>\''.htmlspecialchars($this->searchFor).'\'</strong>':'').
318 '</td>';
319 } else $editIdCode = '';
320
321 // Adding CSH:
322 $editIdCode.= '<td>&nbsp;'.t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'shortcuts', $GLOBALS['BACK_PATH'],'',TRUE).'</td>';
323
324 // Compile it all:
325 $this->content.='
326
327 <table border="0" cellpadding="0" cellspacing="0" width="99%">
328 <tr>
329 <td>
330 <!--
331 Shortcut Display Table:
332 -->
333 <table border="0" cellpadding="0" cellspacing="2" id="typo3-shortcuts">
334 <tr>
335 '.implode('
336 ',$this->lines).$editIdCode.'
337 </tr>
338 </table>
339 </td>
340 <td align="right">
341 '.$this->workspaceSelector().
342 t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'workspaceSelector', $GLOBALS['BACK_PATH'],'',TRUE).'
343 </td>
344 </tr>
345 </table>
346 ';
347
348 // Launch Edit page:
349 if ($this->theEditRec['uid']) {
350 $this->content.=$this->doc->wrapScriptTags('top.loadEditId('.$this->theEditRec['uid'].');');
351 }
352
353 // Load alternative table/uid into editing form.
354 if (count($this->alternativeTableUid)==2 && isset($TCA[$this->alternativeTableUid[0]]) && t3lib_div::testInt($this->alternativeTableUid[1])) {
355 $JSaction = t3lib_BEfunc::editOnClick('&edit['.$this->alternativeTableUid[0].']['.$this->alternativeTableUid[1].']=edit','','dummy.php');
356 $this->content.=$this->doc->wrapScriptTags('function editArbitraryElement() { top.content.'.$JSaction.'; } editArbitraryElement();');
357 }
358
359 // Load search for something.
360 if ($this->searchFor) {
361 $firstMP = intval($GLOBALS['WEBMOUNTS'][0]);
362 $this->content.= $this->doc->wrapScriptTags('jump(unescape("'.rawurlencode('db_list.php?id='.$firstMP.'&search_field='.rawurlencode($this->searchFor).'&search_levels=4').'"),"web_list","web");');
363 }
364 }
365
366 /**
367 * Creates lines for the editing form.
368 *
369 * @return void
370 */
371 function editLoadedFunc() {
372 global $BE_USER,$LANG;
373
374 $this->editLoaded=0;
375 if (is_array($this->editSC_rec) && ($this->editSC_rec['sc_group']>=0 || $BE_USER->isAdmin())) { // sc_group numbers below 0 requires admin to edit those. sc_group numbers above zero must always be owned by the user himself.
376 $this->editLoaded=1;
377
378 $opt=array();
379 $opt[]='<option value="0"></option>';
380 for($a=1;$a<=$this->nGroups;$a++) {
381 $opt[]='<option value="'.$a.'"'.(!strcmp($this->editSC_rec['sc_group'],$a)?' selected="selected"':'').'>'.$LANG->getLL('shortcut_group',1).' '.$a.'</option>';
382 }
383 if ($BE_USER->isAdmin()) {
384 for($a=1;$a<=$this->nGlobals;$a++) {
385 $opt[]='<option value="-'.$a.'"'.(!strcmp($this->editSC_rec['sc_group'],'-'.$a)?' selected="selected"':'').'>'.$LANG->getLL('shortcut_GLOBAL',1).': '.$a.'</option>';
386 }
387 $opt[]='<option value="-100"'.(!strcmp($this->editSC_rec['sc_group'],'-100')?' selected="selected"':'').'>'.$LANG->getLL('shortcut_GLOBAL',1).': '.$LANG->getLL('shortcut_ALL',1).'</option>';
388 }
389
390 // border="0" hspace="2" width="21" height="16" - not XHTML compliant in <input type="image" ...>
391 $manageForm='
392
393
394 <!--
395 Shortcut Editing Form:
396 -->
397 <table border="0" cellpadding="0" cellspacing="0" id="typo3-shortcuts-editing">
398 <tr>
399 <td>&nbsp;&nbsp;</td>
400 <td><input type="image" class="c-inputButton" name="_savedok"'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/savedok.gif','').' title="'.$LANG->getLL('shortcut_save',1).'" /></td>
401 <td><input type="image" class="c-inputButton" name="_saveclosedok"'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/saveandclosedok.gif','').' title="'.$LANG->getLL('shortcut_saveClose',1).'" /></td>
402 <td><input type="image" class="c-inputButton" name="_closedok"'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/closedok.gif','').' title="'.$LANG->getLL('shortcut_close',1).'" /></td>
403 <td><input type="image" class="c-inputButton" name="_deletedok"'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/deletedok.gif','').' title="'.$LANG->getLL('shortcut_delete',1).'" /></td>
404 <td><input name="editName" type="text" value="'.htmlspecialchars($this->editSC_rec['description']).'"'.$this->doc->formWidth(15).' /></td>
405 <td><select name="editGroup">'.implode('',$opt).'</select></td>
406 </tr>
407 </table>
408 <input type="hidden" name="whichItem" value="'.$this->editSC_rec['uid'].'" />
409
410 ';
411 } else $manageForm='';
412 //debug(count($opt));
413 if (!$this->editLoaded && count($this->selOpt)>1) {
414 $this->lines[]='<td>&nbsp;</td>';
415 $this->lines[]='<td><select name="_selSC" onchange="eval(this.options[this.selectedIndex].value);this.selectedIndex=0;">'.implode('',$this->selOpt).'</select></td>';
416 }
417 if (count($this->lines)) {
418 if (!$BE_USER->getTSConfigVal('options.mayNotCreateEditShortcuts')) {
419 $this->lines=array_merge(array('<td><input type="checkbox" name="editShortcut_check" value="1"'.($this->editSC?' checked="checked"':'').' />'.$LANG->getLL('shortcut_edit',1).'&nbsp;</td>'),$this->lines);
420 $this->lines[]='<td>'.$manageForm.'</td>';
421 }
422 $this->lines[]='<td><img src="clear.gif" width="10" height="1" alt="" /></td>';
423 }
424 }
425
426 /**
427 * If "editPage" value is sent to script and it points to an accessible page, the internal var $this->theEditRec is set to the page record which should be loaded.
428 * Returns void
429 *
430 * @return void
431 */
432 function editPageIdFunc() {
433 global $BE_USER,$LANG;
434
435 if (!t3lib_extMgm::isLoaded('cms')) return;
436
437 // EDIT page:
438 $this->editPage = trim(strtolower($this->editPage));
439 $this->editError = '';
440 $this->theEditRec = '';
441 $this->searchFor = '';
442 if ($this->editPage) {
443
444 // First, test alternative value consisting of [table]:[uid] and if not found, proceed with traditional page ID resolve:
445 $this->alternativeTableUid = explode(':',$this->editPage);
446 if (!(count($this->alternativeTableUid)==2 && $BE_USER->isAdmin())) { // We restrict it to admins only just because I'm not really sure if alt_doc.php properly checks permissions of passed records for editing. If alt_doc.php does that, then we can remove this.
447
448 $where = ' AND ('.$BE_USER->getPagePermsClause(2).' OR '.$BE_USER->getPagePermsClause(16).')';
449 if (t3lib_div::testInt($this->editPage)) {
450 $this->theEditRec = t3lib_BEfunc::getRecordWSOL('pages',$this->editPage,'*',$where);
451 } else {
452 $records = t3lib_BEfunc::getRecordsByField('pages','alias',$this->editPage,$where);
453 if (is_array($records)) {
454 reset($records);
455 $this->theEditRec = current($records);
456 t3lib_BEfunc::workspaceOL('pages',$this->theEditRec);
457 }
458 }
459 if (!is_array($this->theEditRec)) {
460 unset($this->theEditRec);
461 $this->searchFor = $this->editPage;
462 } elseif (!$BE_USER->isInWebMount($this->theEditRec['uid'])) {
463 unset($this->theEditRec);
464 $this->editError=$LANG->getLL('shortcut_notEditable');
465 } else {
466
467 // Visual path set:
468 $perms_clause = $BE_USER->getPagePermsClause(1);
469 $this->editPath = t3lib_BEfunc::getRecordPath($this->theEditRec['pid'], $perms_clause, 30);
470
471 if(!$BE_USER->getTSConfigVal('options.shortcut_onEditId_dontSetPageTree')) {
472
473 // Expanding page tree:
474 t3lib_BEfunc::openPageTree($this->theEditRec['pid'],!$BE_USER->getTSConfigVal('options.shortcut_onEditId_keepExistingExpanded'));
475 }
476 }
477 }
478 }
479 }
480
481 /**
482 * Outputting the accumulated content to screen
483 *
484 * @return void
485 */
486 function printContent() {
487 $this->content.= $this->doc->endPage();
488 echo $this->content;
489 }
490
491
492
493
494
495
496
497
498
499 /***************************
500 *
501 * WORKSPACE FUNCTIONS:
502 *
503 ***************************/
504
505 /**
506 * Create selector for workspaces and change workspace if command is given to do that.
507 *
508 * @return string HTML
509 */
510 function workspaceSelector() {
511 global $TYPO3_DB,$BE_USER,$LANG;
512
513 // Changing workspace and if so, reloading entire backend:
514 if (strlen($this->changeWorkspace)) {
515 $BE_USER->setWorkspace($this->changeWorkspace);
516 return $this->doc->wrapScriptTags('top.document.location="alt_main.php";');
517 }
518 // Changing workspace and if so, reloading entire backend:
519 if (strlen($this->changeWorkspacePreview)) {
520 $BE_USER->setWorkspacePreview($this->changeWorkspacePreview);
521 }
522
523 // Create options array:
524 $options = array();
525 if ($BE_USER->checkWorkspace(array('uid' => 0))) {
526 $options[0] = '['.$LANG->getLL('shortcut_onlineWS').']';
527 }
528 if ($BE_USER->checkWorkspace(array('uid' => -1))) {
529 $options[-1] = '['.$LANG->getLL('shortcut_offlineWS').']';
530 }
531
532 // Add custom workspaces (selecting all, filtering by BE_USER check):
533 $workspaces = $TYPO3_DB->exec_SELECTgetRows('uid,title,adminusers,members,reviewers','sys_workspace','pid=0'.t3lib_BEfunc::deleteClause('sys_workspace'),'','title');
534 foreach($workspaces as $rec) {
535 if ($BE_USER->checkWorkspace($rec)) {
536 $options[$rec['uid']] = $rec['uid'].': '.$rec['title'];
537 }
538 }
539
540 // Build selector box:
541 if (count($options)) {
542 foreach($options as $value => $label) {
543 $selected = ((int)$BE_USER->workspace===$value ? ' selected="selected"' : '');
544 $options[$value] = '<option value="'.htmlspecialchars($value).'"'.$selected.'>'.htmlspecialchars($label).'</option>';
545 }
546 } else {
547 $options[] = '<option value="-99">'.$LANG->getLL('shortcut_noWSfound',1).'</option>';
548 }
549
550 $selector = '';
551 // Preview:
552 if ($BE_USER->workspace!==0) {
553 $selector.= 'Frontend Preview: <input type="checkbox" onclick="changeWorkspacePreview('.($BE_USER->user['workspace_preview'] ? 0 : 1).')"; '.($BE_USER->user['workspace_preview'] ? 'checked="checked"' : '').'/>&nbsp;';
554 }
555
556 $selector.= '<a href="mod/user/ws/index.php" target="content">'.
557 t3lib_iconWorks::getIconImage('sys_workspace',array(),$this->doc->backPath,'align="top"').
558 '</a>'.
559 '<select name="_workspaceSelector" onchange="changeWorkspace(this.options[this.selectedIndex].value);">'.implode('',$options).'</select>';
560
561 return $selector;
562 }
563
564
565
566
567
568
569
570 /***************************
571 *
572 * OTHER FUNCTIONS:
573 *
574 ***************************/
575
576 /**
577 * Returns relative filename for icon.
578 *
579 * @param string Absolute filename of the icon
580 * @param string Backpath string to prepend the icon after made relative
581 * @return void
582 */
583 function mIconFilename($Ifilename,$backPath) {
584 if (t3lib_div::isAbsPath($Ifilename)) {
585 $Ifilename = '../'.substr($Ifilename,strlen(PATH_site));
586 }
587 return $backPath.$Ifilename;
588 }
589
590 /**
591 * Returns icon for shortcut display
592 *
593 * @param string Backend module name
594 * @return string Icon file name
595 */
596 function getIcon($modName) {
597 global $LANG;
598 if ($LANG->moduleLabels['tabs_images'][$modName.'_tab']) {
599 $icon = $this->mIconFilename($LANG->moduleLabels['tabs_images'][$modName.'_tab'],'');
600 } elseif ($modName=='xMOD_alt_doc.php') {
601 $icon = 'gfx/edit2.gif';
602 } elseif ($modName=='xMOD_file_edit.php') {
603 $icon = 'gfx/edit_file.gif';
604 } elseif ($modName=='xMOD_wizard_rte.php') {
605 $icon = 'gfx/edit_rtewiz.gif';
606 } else {
607 $icon = 'gfx/dummy_module.gif';
608 }
609 return $icon;
610 }
611
612 /**
613 * Returns title-label for icon
614 *
615 * @param string In-label
616 * @param string Backend module name (key)
617 * @param string Backend module label (user defined?)
618 * @return string Label for the shortcut item
619 */
620 function itemLabel($inlabel,$modName,$M_modName='') {
621 global $LANG;
622 if (substr($modName,0,5)=='xMOD_') {
623 $label=substr($modName,5);
624 } else {
625 $split = explode('_',$modName);
626 $label = $LANG->moduleLabels['tabs'][$split[0].'_tab'];
627 if (count($split)>1) {
628 $label.='>'.$LANG->moduleLabels['tabs'][$modName.'_tab'];
629 }
630 }
631 if ($M_modName) $label.=' ('.$M_modName.')';
632 $label.=': '.$inlabel;
633 return $label;
634 }
635 }
636
637 // Include extension?
638 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_shortcut.php']) {
639 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_shortcut.php']);
640 }
641
642
643
644
645
646
647
648
649
650
651
652 // Make instance:
653 $SOBE = t3lib_div::makeInstance('SC_alt_shortcut');
654 $SOBE->preinit();
655 $SOBE->preprocess();
656 $SOBE->init();
657 $SOBE->main();
658 $SOBE->printContent();
659 ?>