2 /***************************************************************
5 * (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
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.
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.
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.
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
30 * Appears in the bottom frame of the backend frameset.
31 * Provides links to registered shortcuts
32 * If the 'cms' extension is loaded you will also have a field for entering page id/alias which will be found/edited
34 * Revised for TYPO3 3.6 2/2003 by Kasper Skårhøj
35 * XHTML compliant output
37 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
41 require('template.php');
42 $LANG->includeLLFile('EXT:lang/locallang_misc.xml');
45 * Script Class for the shortcut frame, bottom frame of the backend frameset
47 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
51 class SC_alt_shortcut
{
53 // Internal, static: GPvar
65 * Object for backend modules, load modules-object
67 * @var t3lib_loadModules
70 protected $isAjaxCall;
73 * Document template object
80 // Accumulation of output HTML (string)
82 // Accumulation of table cells (array)
84 // Flag for defining whether we are editing
86 // Can contain edit error message
88 // Set to the record path of the record being edited.
90 // Holds the shortcut record when editing
92 // Page record to be edited
94 // Page alias or id to be edited
98 // Text to search for...
100 // Labels of all groups. If value is 1, the system will try to find a label in the locallang array.
101 var $groupLabels = array();
102 // Array with key 0/1 being table/uid of record to edit. Internally set.
103 var $alternativeTableUid = array();
106 * Pre-initialization - setting input variables for storing shortcuts etc.
112 $this->isAjaxCall
= (boolean
) t3lib_div
::_GP('ajax');
113 $this->modName
= t3lib_div
::_GP('modName');
114 $this->M_modName
= t3lib_div
::_GP('motherModName');
115 $this->URL
= t3lib_div
::_GP('URL');
116 $this->editSC
= t3lib_div
::_GP('editShortcut');
118 $this->deleteCategory
= t3lib_div
::_GP('deleteCategory');
119 $this->editPage
= t3lib_div
::_GP('editPage');
120 $this->changeWorkspace
= t3lib_div
::_GP('changeWorkspace');
121 $this->changeWorkspacePreview
= t3lib_div
::_GP('changeWorkspacePreview');
122 $this->editName
= t3lib_div
::_GP('editName');
123 $this->editGroup
= t3lib_div
::_GP('editGroup');
124 $this->whichItem
= t3lib_div
::_GP('whichItem');
126 // Creating modules object
127 $this->loadModules
= t3lib_div
::makeInstance('t3lib_loadModules');
128 $this->loadModules
->load($GLOBALS['TBE_MODULES']);
132 * Adding shortcuts, editing shortcuts etc.
136 function preprocess() {
137 // Default description
139 $url = urldecode($this->URL
);
140 $queryParts = parse_url($url);
142 // Lookup the title of this page and use it as default description
143 $page_id = $this->getLinkedPageId($url);
144 if (t3lib_utility_Math
::canBeInterpretedAsInteger($page_id)) {
145 if (preg_match('/\&edit\[(.*)\]\[(.*)\]=edit/', $url, $matches)) {
147 // TODO: Set something useful
151 $pageRow = t3lib_BEfunc
::getRecord('pages', $page_id);
152 if (count($pageRow)) {
153 // If $page_id is an integer, set the description to the title of that page
154 $description = $pageRow['title'];
158 if (preg_match('/\/$/', $page_id)) {
159 // If $page_id is a string and ends with a slash, assume it is a fileadmin reference and set the description to the basename of that path
160 $description = basename($page_id);
164 // Adding a shortcut being set from another frame,
165 // but only if it's a relative URL (i.e. scheme part is not defined)
166 if ($this->modName
&& $this->URL
&& empty($queryParts['scheme'])) {
167 $fields_values = array(
168 'userid' => $GLOBALS['BE_USER']->user
['uid'],
169 'module_name' => $this->modName
.'|'.$this->M_modName
,
171 'description' => $description,
172 'sorting' => $GLOBALS['EXEC_TIME'],
174 $GLOBALS['TYPO3_DB']->exec_INSERTquery('sys_be_shortcuts', $fields_values);
177 // Selection-clause for users - so users can deleted only their own shortcuts (except admins)
178 $addUSERWhere = (!$GLOBALS['BE_USER']->isAdmin() ?
' AND userid=' . intval($GLOBALS['BE_USER']->user
['uid']) : '');
180 // Deleting shortcuts:
181 if (strcmp($this->deleteCategory
, '')) {
182 if (t3lib_utility_Math
::canBeInterpretedAsInteger($this->deleteCategory
)) {
183 $GLOBALS['TYPO3_DB']->exec_DELETEquery('sys_be_shortcuts', 'sc_group='.intval($this->deleteCategory
).$addUSERWhere);
187 // If other changes in post-vars:
188 if (is_array($_POST)) {
190 if (isset($_POST['_savedok_x']) ||
isset($_POST['_saveclosedok_x'])) {
191 $fields_values = array(
192 'description' => $this->editName
,
193 'sc_group' => intval($this->editGroup
)
195 if ($fields_values['sc_group'] < 0 && !$GLOBALS['BE_USER']->isAdmin()) {
196 $fields_values['sc_group'] = 0;
199 $GLOBALS['TYPO3_DB']->exec_UPDATEquery('sys_be_shortcuts', 'uid='.intval($this->whichItem
).$addUSERWhere, $fields_values);
201 // If save without close, keep the session going...
202 if (isset($_POST['_savedok_x'])) {
203 $this->editSC
=$this->whichItem
;
205 // Deleting a single shortcut ?
206 if (isset($_POST['_deletedok_x'])) {
207 $GLOBALS['TYPO3_DB']->exec_DELETEquery('sys_be_shortcuts', 'uid='.intval($this->whichItem
).$addUSERWhere);
208 // Just to have the checkbox set...
209 if (!$this->editSC
) $this->editSC
= -1;
215 * Initialize (page output)
220 $this->doc
= t3lib_div
::makeInstance('template');
221 $this->doc
->backPath
= $GLOBALS['BACK_PATH'];
222 $this->doc
->form
= '<form action="alt_shortcut.php" name="shForm" method="post">';
223 $this->doc
->divClass
= 'typo3-shortcut';
224 $this->doc
->JScode
.= $this->doc
->wrapScriptTags('
225 function jump(url,modName,mainModName) { //
226 // Clear information about which entry in nav. tree that might have been highlighted.
227 top.fsMod.navFrameHighlightedID = new Array();
228 if (top.content && top.content.nav_frame && top.content.nav_frame.refresh_nav) {
229 top.content.nav_frame.refresh_nav();
232 top.nextLoadModuleUrl = url;
233 top.goToModule(modName);
235 function editSh(uid) { //
236 window.location.href="alt_shortcut.php?editShortcut="+uid;
238 function submitEditPage(id) { //
239 window.location.href="alt_shortcut.php?editPage="+top.rawurlencodeAndRemoveSiteUrl(id);
241 function changeWorkspace(workspaceId) { //
242 window.location.href="alt_shortcut.php?changeWorkspace="+top.rawurlencodeAndRemoveSiteUrl(workspaceId);
244 function changeWorkspacePreview(newstate) { //
245 window.location.href="alt_shortcut.php?changeWorkspacePreview="+newstate;
247 function refreshShortcuts() {
248 window.location.href = document.URL;
252 $this->content
.= $this->doc
->startPage('Shortcut frame');
256 * Main function, creating content in the frame
262 // By default, 5 groups are set
263 $this->groupLabels
=array(
271 $bookmarkGroups = $GLOBALS['BE_USER']->getTSConfigProp('options.bookmarkGroups');
272 if (is_array($bookmarkGroups) && count($bookmarkGroups)) {
273 foreach ($bookmarkGroups as $k=>$v) {
274 if (strcmp('', $v) && strcmp('0', $v)) {
275 $this->groupLabels
[$k] = (string)$v;
276 } elseif ($GLOBALS['BE_USER']->isAdmin()) {
277 unset($this->groupLabels
[$k]);
282 // List of global groups that will be loaded. All global groups have negative IDs.
283 $globalGroups = -100; // Group -100 is kind of superglobal and can't be changed.
284 if (count($this->groupLabels
)) {
285 $globalGroups .= ','.implode(',', array_keys($this->groupLabels
));
286 $globalGroups = str_replace(',', ',-', $globalGroups); // Ugly hack to make the UIDs negative - is there any better solution?
289 // Fetching shortcuts to display for this user:
290 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_be_shortcuts', '((userid='.$GLOBALS['BE_USER']->user
['uid'].' AND sc_group>=0) OR sc_group IN ('.$globalGroups.'))', '', 'sc_group,sorting');
293 $this->lines
= array();
294 $this->linesPre
= array();
295 $this->editSC_rec
= '';
296 $this->selOpt
= array();
299 // Traverse shortcuts
300 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
301 $mParts = explode('|', $row['module_name']);
302 $row['module_name'] = $mParts[0];
303 $row['M_module_name'] = $mParts[1];
304 $mParts = explode('_', $row['M_module_name']?
$row['M_module_name']:$row['module_name']);
305 $qParts = parse_url($row['url']);
307 if (!$GLOBALS['BE_USER']->isAdmin()) {
308 // Check for module access
309 if (!isset($GLOBALS['LANG']->moduleLabels
['tabs_images'][implode('_', $mParts).'_tab'])) { // Nice hack to check if the user has access to this module - otherwise the translation label would not have been loaded :-)
313 $page_id = $this->getLinkedPageId($row['url']);
314 if (t3lib_utility_Math
::canBeInterpretedAsInteger($page_id)) {
315 // Check for webmount access
316 if (!$GLOBALS['BE_USER']->isInWebMount($page_id)) continue;
318 // Check for record access
319 $pageRow = t3lib_BEfunc
::getRecord('pages', $page_id);
320 if (!$GLOBALS['BE_USER']->doesUserHaveAccess($pageRow, $perms = 1)) {
326 if ($this->editSC
&& $row['uid'] == $this->editSC
) {
327 $this->editSC_rec
=$row;
330 $sc_group = $row['sc_group'];
331 if ($sc_group && strcmp($formerGr, $sc_group)) {
332 if ($sc_group != -100) {
333 if ($this->groupLabels
[abs($sc_group)] && strcmp('1', $this->groupLabels
[abs($sc_group)])) {
334 $label = $this->groupLabels
[abs($sc_group)];
336 $label = $GLOBALS['LANG']->getLL('shortcut_group_'.abs($sc_group), 1);
338 if (!$label) $label = $GLOBALS['LANG']->getLL('shortcut_group', 1).' '.abs($sc_group);
341 if ($sc_group >= 0) {
342 $onC = 'if (confirm('.$GLOBALS['LANG']->JScharCode($GLOBALS['LANG']->getLL('bookmark_delAllInCat')).')){window.location.href=\'alt_shortcut.php?deleteCategory='.$sc_group.'\';}return false;';
343 $this->linesPre
[] = '<td> </td><td class="bgColor5"><a href="#" onclick="'.htmlspecialchars($onC).'" title="'.$GLOBALS['LANG']->getLL('bookmark_delAllInCat', 1).'">'.$label.'</a></td>';
346 $label = $GLOBALS['LANG']->getLL('bookmark_global', 1).': '.($label ?
$label : abs($sc_group));
347 $this->lines
[] = '<td> </td><td class="bgColor5">'.$label.'</td>';
353 $bgColorClass = $row['uid'] == $this->editSC ?
'bgColor5' : ($row['sc_group'] < 0 ?
'bgColor6' : 'bgColor4');
355 if ($row['description'] && ($row['uid'] != $this->editSC
)) {
356 $label = $row['description'];
358 $label = t3lib_div
::fixed_lgd_cs(rawurldecode($qParts['query']), 150);
360 $titleA = $this->itemLabel($label, $row['module_name'], $row['M_module_name']);
362 $editSH = ($row['sc_group']>=0 ||
$GLOBALS['BE_USER']->isAdmin()) ?
'editSh('.intval($row['uid']).');' : "alert('".$GLOBALS['LANG']->getLL('bookmark_onlyAdmin')."')";
363 $jumpSC = 'jump(unescape(\''.rawurlencode($row['url']).'\'),\''.implode('_', $mParts).'\',\''.$mParts[0].'\');';
364 $onC = 'if (document.shForm.editShortcut_check && document.shForm.editShortcut_check.checked){'.$editSH.'}else{'.$jumpSC.'}return false;';
365 // user defined groups show up first
366 if ($sc_group >= 0) {
367 $this->linesPre
[] = '<td class="'.$bgColorClass.'"><a href="#" onclick="'.htmlspecialchars($onC).'"><img src="'.$this->getIcon($row['module_name']).'" title="'.htmlspecialchars($titleA).'" alt="" /></a></td>';
369 $this->lines
[] = '<td class="'.$bgColorClass.'"><a href="#" onclick="'.htmlspecialchars($onC).'"><img src="'.$this->getIcon($row['module_name']).'" title="'.htmlspecialchars($titleA).'" alt="" /></a></td>';
371 if (trim($row['description'])) {
372 $kkey = strtolower(substr($row['description'], 0, 20)).'_'.$row['uid'];
373 $this->selOpt
[$kkey] = '<option value="'.htmlspecialchars($jumpSC).'">'.htmlspecialchars(t3lib_div
::fixed_lgd_cs($row['description'], 50)).'</option>';
375 $formerGr = $row['sc_group'];
377 ksort($this->selOpt
);
378 array_unshift($this->selOpt
, '<option>['.$GLOBALS['LANG']->getLL('bookmark_selSC', 1).']</option>');
380 $this->editLoadedFunc();
381 $this->editPageIdFunc();
383 if (!$this->editLoaded
&& t3lib_extMgm
::isLoaded('cms')) {
384 $editIdCode = '<td nowrap="nowrap">'.$GLOBALS['LANG']->getLL('bookmark_editID', 1).': <input type="text" value="'.($this->editError?
htmlspecialchars($this->editPage
):'').'" name="editPage"'.$this->doc
->formWidth(15).' onchange="submitEditPage(this.value);" />'.
385 ($this->editError?
' <strong><span class="typo3-red">'.htmlspecialchars($this->editError
).'</span></strong>':'').
386 (is_array($this->theEditRec
) ?
' <strong>' . $GLOBALS['LANG']->getLL('bookmark_loadEdit', 1) . ' \'' . t3lib_BEfunc
::getRecordTitle('pages', $this->theEditRec
, TRUE
) . '\'</strong> (' . htmlspecialchars($this->editPath
) . ')' : '') .
387 ($this->searchFor?
' '.$GLOBALS['LANG']->getLL('bookmark_searchFor', 1).' <strong>\''.htmlspecialchars($this->searchFor
).'\'</strong>':'').
389 } else $editIdCode = '';
392 $editIdCode .= '<td> '.t3lib_BEfunc
::cshItem('xMOD_csh_corebe', 'bookmarks', $GLOBALS['BACK_PATH'], '', TRUE
).'</td>';
397 <table border="0" cellpadding="0" cellspacing="0" width="99%">
401 Shortcut Display Table:
403 <table border="0" cellpadding="0" cellspacing="2" id="typo3-shortcuts">
406 if ($GLOBALS['BE_USER']->getTSConfigVal('options.enableBookmarks')) {
407 $this->content
.= implode('
410 $this->content
.= $editIdCode . '
415 if ($this->hasWorkspaceAccess()) {
416 $this->content
.= $this->workspaceSelector() .
417 t3lib_BEfunc
::cshItem('xMOD_csh_corebe', 'workspaceSelector', $GLOBALS['BACK_PATH'], '', TRUE
);
426 if ($this->theEditRec
['uid']) {
427 $this->content
.= $this->doc
->wrapScriptTags('top.loadEditId('.$this->theEditRec
['uid'].');');
431 // Load alternative table/uid into editing form.
432 if (count($this->alternativeTableUid
) == 2 && isset($GLOBALS['TCA'][$this->alternativeTableUid
[0]]) && t3lib_utility_Math
::canBeInterpretedAsInteger($this->alternativeTableUid
[1])) {
433 $JSaction = t3lib_BEfunc
::editOnClick('&edit['.$this->alternativeTableUid
[0].']['.$this->alternativeTableUid
[1].']=edit', '', 'dummy.php');
434 $this->content
.= $this->doc
->wrapScriptTags('function editArbitraryElement() { top.content.'.$JSaction.'; } editArbitraryElement();');
437 // Load search for something.
438 if ($this->searchFor
) {
439 $urlParameters = array();
440 $urlParameters['id'] = intval($GLOBALS['WEBMOUNTS'][0]);
441 $urlParameters['search_field'] = $this->searchFor
;
442 $urlParameters['search_levels'] = 4;
443 $this->content
.= $this->doc
->wrapScriptTags('jump(unescape("' .
444 rawurlencode(t3lib_BEfunc
::getModuleUrl('web_list', $urlParameters, '')) .
445 '"), "web_list", "web");');
450 * Creates lines for the editing form.
454 function editLoadedFunc() {
455 $this->editLoaded
= 0;
456 // sc_group numbers below 0 requires admin to edit those. sc_group
457 // numbers above zero must always be owned by the user himself.
458 if (is_array($this->editSC_rec
) && ($this->editSC_rec
['sc_group'] >= 0 ||
$GLOBALS['BE_USER']->isAdmin())) {
459 $this->editLoaded
= 1;
462 $opt[]='<option value="0"></option>';
464 foreach ($this->groupLabels
as $k => $v) {
465 if ($v && strcmp('1', $v)) {
468 $label = $GLOBALS['LANG']->getLL('bookmark_group_'.$k, 1);
470 if (!$label) $label = $GLOBALS['LANG']->getLL('bookmark_group', 1).' '.$k;
472 $opt[] = '<option value="'.$k.'"'.(!strcmp($this->editSC_rec
['sc_group'], $k)?
' selected="selected"':'').'>'.$label.'</option>';
475 if ($GLOBALS['BE_USER']->isAdmin()) {
476 foreach ($this->groupLabels
as $k => $v) {
477 if ($v && strcmp('1', $v)) {
480 $label = $GLOBALS['LANG']->getLL('bookmark_group_'.$k, 1);
482 if (!$label) $label = $GLOBALS['LANG']->getLL('bookmark_group', 1).' '.$k;
484 // Add a prefix for global groups
485 $label = $GLOBALS['LANG']->getLL('bookmark_global', 1).': '.$label;
487 $opt[] = '<option value="-'.$k.'"'.(!strcmp($this->editSC_rec
['sc_group'], '-'.$k)?
' selected="selected"':'').'>'.$label.'</option>';
489 $opt[] = '<option value="-100"'.(!strcmp($this->editSC_rec
['sc_group'], '-100')?
' selected="selected"':'').'>'.$GLOBALS['LANG']->getLL('bookmark_global', 1).': '.$GLOBALS['LANG']->getLL('bookmark_all', 1).'</option>';
492 // border="0" hspace="2" width="21" height="16" - not XHTML compliant in <input type="image" ...>
496 Shortcut Editing Form:
498 <table border="0" cellpadding="0" cellspacing="0" id="typo3-shortcuts-editing">
500 <td> </td>
501 <td><input type="image" class="c-inputButton" name="_savedok"'.t3lib_iconWorks
::skinImg($this->doc
->backPath
, 'gfx/savedok.gif', '').' title="'.$GLOBALS['LANG']->getLL('shortcut_save', 1).'" /></td>
502 <td><input type="image" class="c-inputButton" name="_saveclosedok"'.t3lib_iconWorks
::skinImg($this->doc
->backPath
, 'gfx/saveandclosedok.gif', '').' title="'.$GLOBALS['LANG']->getLL('bookmark_saveClose', 1).'" /></td>
503 <td><input type="image" class="c-inputButton" name="_closedok"'.t3lib_iconWorks
::skinImg($this->doc
->backPath
, 'gfx/closedok.gif', '').' title="'.$GLOBALS['LANG']->getLL('bookmark_close', 1).'" /></td>
504 <td><input type="image" class="c-inputButton" name="_deletedok"'.t3lib_iconWorks
::skinImg($this->doc
->backPath
, 'gfx/deletedok.gif', '').' title="'.$GLOBALS['LANG']->getLL('bookmark_delete', 1).'" /></td>
505 <td><input name="editName" type="text" value="'.htmlspecialchars($this->editSC_rec
['description']).'"'.$this->doc
->formWidth(15).' /></td>
506 <td><select name="editGroup">'.implode('', $opt).'</select></td>
509 <input type="hidden" name="whichItem" value="'.$this->editSC_rec
['uid'].'" />
512 } else $manageForm = '';
514 if (!$this->editLoaded
&& count($this->selOpt
)>1) {
515 $this->lines
[] = '<td> </td>';
516 $this->lines
[] = '<td><select name="_selSC" onchange="eval(this.options[this.selectedIndex].value);this.selectedIndex=0;">'.implode('', $this->selOpt
).'</select></td>';
519 // $this->linesPre contains elements with sc_group>=0
520 $this->lines
= array_merge($this->linesPre
, $this->lines
);
522 if (count($this->lines
)) {
523 if (!$GLOBALS['BE_USER']->getTSConfigVal('options.mayNotCreateEditBookmarks')) {
524 $this->lines
= array_merge(array(
525 '<td><input type="checkbox" id="editShortcut_check" name="editShortcut_check" value="1"' . ($this->editSC ?
' checked="checked"' : '') . ' />'
526 . ' <label for="editShortcut_check">' . $GLOBALS['LANG']->getLL('bookmark_edit', 1) . '</label> </td>'
528 $this->lines
[] = '<td>' . $manageForm . '</td>';
530 $this->lines
[] = '<td><img src="clear.gif" width="10" height="1" alt="" /></td>';
535 * 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.
540 function editPageIdFunc() {
541 if (!t3lib_extMgm
::isLoaded('cms')) return;
544 $this->editPage
= trim($GLOBALS['LANG']->csConvObj
->conv_case($GLOBALS['LANG']->charSet
, $this->editPage
, 'toLower'));
545 $this->editError
= '';
546 $this->theEditRec
= '';
547 $this->searchFor
= '';
548 if ($this->editPage
) {
550 // First, test alternative value consisting of [table]:[uid] and if not found, proceed with traditional page ID resolve:
551 $this->alternativeTableUid
= explode(':', $this->editPage
);
552 // We restrict it to admins only just because I'm not really sure if alt_doc.php properly
553 // checks permissions of passed records for editing. If alt_doc.php does that, then we can remove this.
554 if (!(count($this->alternativeTableUid
)==2 && $GLOBALS['BE_USER']->isAdmin())) {
556 $where = ' AND ('.$GLOBALS['BE_USER']->getPagePermsClause(2).' OR '.$GLOBALS['BE_USER']->getPagePermsClause(16).')';
557 if (t3lib_utility_Math
::canBeInterpretedAsInteger($this->editPage
)) {
558 $this->theEditRec
= t3lib_BEfunc
::getRecordWSOL('pages', $this->editPage
, '*', $where);
560 $records = t3lib_BEfunc
::getRecordsByField('pages', 'alias', $this->editPage
, $where);
561 if (is_array($records)) {
562 $this->theEditRec
= reset($records);
563 t3lib_BEfunc
::workspaceOL('pages', $this->theEditRec
);
566 if (!is_array($this->theEditRec
)) {
567 unset($this->theEditRec
);
568 $this->searchFor
= $this->editPage
;
569 } elseif (!$GLOBALS['BE_USER']->isInWebMount($this->theEditRec
['uid'])) {
570 unset($this->theEditRec
);
571 $this->editError
= $GLOBALS['LANG']->getLL('bookmark_notEditable');
575 $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
576 $this->editPath
= t3lib_BEfunc
::getRecordPath($this->theEditRec
['pid'], $perms_clause, 30);
578 if (!$GLOBALS['BE_USER']->getTSConfigVal('options.bookmark_onEditId_dontSetPageTree')) {
579 $bookmarkKeepExpanded = $GLOBALS['BE_USER']->getTSConfigVal('options.bookmark_onEditId_keepExistingExpanded');
581 // Expanding page tree:
582 t3lib_BEfunc
::openPageTree($this->theEditRec
['pid'], !$bookmarkKeepExpanded);
590 * Outputting the accumulated content to screen
594 function printContent() {
597 $this->content
.= $this->doc
->endPage();
598 $this->content
= $this->doc
->insertStylesAndJS($this->content
);
600 if ($this->editPage
&& $this->isAjaxCall
) {
604 if ($this->theEditRec
['uid']) {
605 $data['type'] = 'page';
606 $data['editRecord'] = $this->theEditRec
['uid'];
609 // edit alternative table/uid
610 if (count($this->alternativeTableUid
) == 2
611 && isset($GLOBALS['TCA'][$this->alternativeTableUid
[0]])
612 && t3lib_utility_Math
::canBeInterpretedAsInteger($this->alternativeTableUid
[1])) {
613 $data['type'] = 'alternative';
614 $data['alternativeTable'] = $this->alternativeTableUid
[0];
615 $data['alternativeUid'] = $this->alternativeTableUid
[1];
618 // search for something else
619 if ($this->searchFor
) {
620 $data['type'] = 'search';
621 $data['firstMountPoint'] = intval($GLOBALS['WEBMOUNTS'][0]);
622 $data['searchFor'] = $this->searchFor
;
625 $content = json_encode($data);
627 header('Content-type: application/json; charset=utf-8');
628 header('X-JSON: '.$content);
630 $content = $this->content
;
636 /***************************
638 * WORKSPACE FUNCTIONS:
640 ***************************/
643 * Create selector for workspaces and change workspace if command is given to do that.
645 * @return string HTML
647 function workspaceSelector() {
649 // Changing workspace and if so, reloading entire backend:
650 if (strlen($this->changeWorkspace
)) {
651 $GLOBALS['BE_USER']->setWorkspace($this->changeWorkspace
);
652 return $this->doc
->wrapScriptTags('top.location.href="'. t3lib_BEfunc
::getBackendScript() . '";');
654 // Changing workspace and if so, reloading entire backend:
655 if (strlen($this->changeWorkspacePreview
)) {
656 $GLOBALS['BE_USER']->setWorkspacePreview($this->changeWorkspacePreview
);
659 // Create options array:
661 if ($GLOBALS['BE_USER']->checkWorkspace(array('uid' => 0))) {
662 $options[0] = '['.$GLOBALS['LANG']->getLL('bookmark_onlineWS').']';
664 if ($GLOBALS['BE_USER']->checkWorkspace(array('uid' => -1))) {
665 $options[-1] = '['.$GLOBALS['LANG']->getLL('bookmark_offlineWS').']';
668 // Add custom workspaces (selecting all, filtering by BE_USER check):
669 if (t3lib_extMgm
::isLoaded('workspaces')) {
670 $workspaces = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid,title,adminusers,members,reviewers', 'sys_workspace', 'pid=0'.t3lib_BEfunc
::deleteClause('sys_workspace'), '', 'title');
671 if (count($workspaces)) {
672 foreach ($workspaces as $rec) {
673 if ($GLOBALS['BE_USER']->checkWorkspace($rec)) {
674 $options[$rec['uid']] = $rec['uid'].': '.$rec['title'];
680 // Build selector box:
681 if (count($options)) {
682 foreach ($options as $value => $label) {
683 $selected = ((int)$GLOBALS['BE_USER']->workspace
=== $value ?
' selected="selected"' : '');
684 $options[$value] = '<option value="'.htmlspecialchars($value).'"'.$selected.'>'.htmlspecialchars($label).'</option>';
687 $options[] = '<option value="-99">'.$GLOBALS['LANG']->getLL('bookmark_noWSfound', 1).'</option>';
692 if ($GLOBALS['BE_USER']->workspace
!== 0) {
693 $selector .= '<label for="workspacePreview">Frontend Preview:</label> <input type="checkbox" name="workspacePreview" id="workspacePreview" onclick="changeWorkspacePreview('.($GLOBALS['BE_USER']->user
['workspace_preview'] ?
0 : 1).')"; '.($GLOBALS['BE_USER']->user
['workspace_preview'] ?
'checked="checked"' : '').'/> ';
696 $selector .= '<a href="mod/user/ws/index.php" target="content">'.
697 t3lib_iconWorks
::getSpriteIconForRecord('sys_workspace', array()).
699 if (count($options) > 1) {
700 $selector .= '<select name="_workspaceSelector" onchange="changeWorkspace(this.options[this.selectedIndex].value);">'.implode('', $options).'</select>';
706 /***************************
710 ***************************/
713 * Returns relative filename for icon.
715 * @param string $Ifilename Absolute filename of the icon
716 * @param string $backPath Backpath string to prepend the icon after made relative
719 function mIconFilename($Ifilename, $backPath) {
720 // Change icon of fileadmin references - otherwise it doesn't differ with Web->List
721 $Ifilename = str_replace ('mod/file/list/list.gif', 'mod/file/file.gif', $Ifilename);
723 if (t3lib_div
::isAbsPath($Ifilename)) {
724 $Ifilename = '../'.substr($Ifilename, strlen(PATH_site
));
726 return $backPath.$Ifilename;
730 * Returns icon for shortcut display
732 * @param string $modName Backend module name
733 * @return string Icon file name
735 function getIcon($modName) {
736 if ($GLOBALS['LANG']->moduleLabels
['tabs_images'][$modName.'_tab']) {
737 $icon = $this->mIconFilename($GLOBALS['LANG']->moduleLabels
['tabs_images'][$modName.'_tab'], '');
738 } elseif ($modName == 'xMOD_alt_doc.php') {
739 $icon = 'gfx/edit2.gif';
740 } elseif ($modName == 'xMOD_file_edit.php') {
741 $icon = 'gfx/edit_file.gif';
742 } elseif ($modName == 'xMOD_wizard_rte.php') {
743 $icon = 'gfx/edit_rtewiz.gif';
745 $icon = 'gfx/dummy_module.gif';
751 * Returns title-label for icon
753 * @param string $inlabel In-label
754 * @param string $modName Backend module name (key)
755 * @param string $M_modName Backend module label (user defined?)
756 * @return string Label for the shortcut item
758 function itemLabel($inlabel, $modName, $M_modName = '') {
759 if (substr($modName, 0, 5) == 'xMOD_') {
760 $label = substr($modName, 5);
762 $split = explode('_', $modName);
763 $label = $GLOBALS['LANG']->moduleLabels
['tabs'][$split[0].'_tab'];
764 if (count($split) > 1) {
765 $label .= '>'.$GLOBALS['LANG']->moduleLabels
['tabs'][$modName.'_tab'];
768 if ($M_modName) $label .= ' ('.$M_modName.')';
769 $label .= ': '.$inlabel;
774 * Return the ID of the page in the URL if found.
776 * @param string $url The URL of the current shortcut link
777 * @return string If a page ID was found, it is returned. Otherwise: 0
779 function getLinkedPageId($url) {
780 return preg_replace('/.*[\?&]id=([^&]+).*/', '$1', $url);
784 * Checks if user has access to Workspace module.
786 * @return boolean Returns TRUE if user has access to workspace module.
788 function hasWorkspaceAccess() {
790 include('mod/user/ws/conf.php');
791 return $GLOBALS['BE_USER']->modAccess(array('name' => 'user', 'access' => 'user,group'), FALSE
) && $GLOBALS['BE_USER']->modAccess($MCONF, FALSE
);
796 $SOBE = t3lib_div
::makeInstance('SC_alt_shortcut');
801 $SOBE->printContent();