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 ***************************************************************/
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
33 * Revised for TYPO3 3.6 2/2003 by Kasper Skårhøj
34 * XHTML compliant output
36 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
41 require('template.php');
42 $LANG->includeLLFile('EXT:lang/locallang_misc.xml');
50 * Script Class for the shortcut frame, bottom frame of the backend frameset
52 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
56 class SC_alt_shortcut
{
58 // Internal, static: GPvar
70 * Object for backend modules, load modules-object
72 * @var t3lib_loadModules
75 protected $isAjaxCall;
78 * Document template object
85 var $content; // Accumulation of output HTML (string)
86 var $lines; // Accumulation of table cells (array)
88 var $editLoaded; // Flag for defining whether we are editing
89 var $editError; // Can contain edit error message
90 var $editPath; // Set to the record path of the record being edited.
91 var $editSC_rec; // Holds the shortcut record when editing
92 var $theEditRec; // Page record to be edited
93 var $editPage; // Page alias or id to be edited
94 var $selOpt; // Select options.
95 var $searchFor; // Text to search for...
96 var $groupLabels=array(); // Labels of all groups. If value is 1, the system will try to find a label in the locallang array.
98 var $alternativeTableUid = array(); // Array with key 0/1 being table/uid of record to edit. Internally set.
103 * Pre-initialization - setting input variables for storing shortcuts etc.
109 $this->isAjaxCall
= (boolean
) t3lib_div
::_GP('ajax');
110 $this->modName
= t3lib_div
::_GP('modName');
111 $this->M_modName
= t3lib_div
::_GP('motherModName');
112 $this->URL
= t3lib_div
::_GP('URL');
113 $this->editSC
= t3lib_div
::_GP('editShortcut');
115 $this->deleteCategory
= t3lib_div
::_GP('deleteCategory');
116 $this->editPage
= t3lib_div
::_GP('editPage');
117 $this->changeWorkspace
= t3lib_div
::_GP('changeWorkspace');
118 $this->changeWorkspacePreview
= t3lib_div
::_GP('changeWorkspacePreview');
119 $this->editName
= t3lib_div
::_GP('editName');
120 $this->editGroup
= t3lib_div
::_GP('editGroup');
121 $this->whichItem
= t3lib_div
::_GP('whichItem');
123 // Creating modules object
124 $this->loadModules
= t3lib_div
::makeInstance('t3lib_loadModules');
125 $this->loadModules
->load($GLOBALS['TBE_MODULES']);
129 * Adding shortcuts, editing shortcuts etc.
133 function preprocess() {
134 $description = ''; // Default description
135 $url = urldecode($this->URL
);
136 $queryParts = parse_url($url);
138 // Lookup the title of this page and use it as default description
139 $page_id = $this->getLinkedPageId($url);
140 if (t3lib_utility_Math
::canBeInterpretedAsInteger($page_id)) {
141 if (preg_match('/\&edit\[(.*)\]\[(.*)\]=edit/',$url,$matches)) {
143 $description = ''; // TODO: Set something useful
146 $pageRow = t3lib_BEfunc
::getRecord('pages',$page_id);
147 if (count($pageRow)) {
148 // If $page_id is an integer, set the description to the title of that page
149 $description = $pageRow['title'];
153 if (preg_match('/\/$/', $page_id)) {
154 // 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
155 $description = basename($page_id);
160 // Adding a shortcut being set from another frame,
161 // but only if it's a relative URL (i.e. scheme part is not defined)
162 if ($this->modName
&& $this->URL
&& empty($queryParts['scheme'])) {
163 $fields_values = array(
164 'userid' => $GLOBALS['BE_USER']->user
['uid'],
165 'module_name' => $this->modName
.'|'.$this->M_modName
,
167 'description' => $description,
168 'sorting' => $GLOBALS['EXEC_TIME'],
170 $GLOBALS['TYPO3_DB']->exec_INSERTquery('sys_be_shortcuts', $fields_values);
173 // Selection-clause for users - so users can deleted only their own shortcuts (except admins)
174 $addUSERWhere = (!$GLOBALS['BE_USER']->isAdmin() ?
' AND userid=' . intval($GLOBALS['BE_USER']->user
['uid']) : '');
176 // Deleting shortcuts:
177 if (strcmp($this->deleteCategory
,'')) {
178 if (t3lib_utility_Math
::canBeInterpretedAsInteger($this->deleteCategory
)) {
179 $GLOBALS['TYPO3_DB']->exec_DELETEquery('sys_be_shortcuts', 'sc_group='.intval($this->deleteCategory
).$addUSERWhere);
183 // If other changes in post-vars:
184 if (is_array($_POST)) {
186 if (isset($_POST['_savedok_x']) ||
isset($_POST['_saveclosedok_x'])) {
187 $fields_values = array(
188 'description' => $this->editName
,
189 'sc_group' => intval($this->editGroup
)
191 if ($fields_values['sc_group'] < 0 && !$GLOBALS['BE_USER']->isAdmin()) {
192 $fields_values['sc_group']=0;
195 $GLOBALS['TYPO3_DB']->exec_UPDATEquery('sys_be_shortcuts', 'uid='.intval($this->whichItem
).$addUSERWhere, $fields_values);
197 // If save without close, keep the session going...
198 if (isset($_POST['_savedok_x'])) {
199 $this->editSC
=$this->whichItem
;
201 // Deleting a single shortcut ?
202 if (isset($_POST['_deletedok_x'])) {
203 $GLOBALS['TYPO3_DB']->exec_DELETEquery('sys_be_shortcuts', 'uid='.intval($this->whichItem
).$addUSERWhere);
205 if (!$this->editSC
) $this->editSC
=-1; // Just to have the checkbox set...
212 * Initialize (page output)
217 $this->doc
= t3lib_div
::makeInstance('template');
218 $this->doc
->backPath
= $GLOBALS['BACK_PATH'];
219 $this->doc
->form
='<form action="alt_shortcut.php" name="shForm" method="post">';
220 $this->doc
->divClass
='typo3-shortcut';
221 $this->doc
->JScode
.=$this->doc
->wrapScriptTags('
222 function jump(url,modName,mainModName) { //
223 // Clear information about which entry in nav. tree that might have been highlighted.
224 top.fsMod.navFrameHighlightedID = new Array();
225 if (top.content && top.content.nav_frame && top.content.nav_frame.refresh_nav) {
226 top.content.nav_frame.refresh_nav();
229 top.nextLoadModuleUrl = url;
230 top.goToModule(modName);
232 function editSh(uid) { //
233 window.location.href="alt_shortcut.php?editShortcut="+uid;
235 function submitEditPage(id) { //
236 window.location.href="alt_shortcut.php?editPage="+top.rawurlencodeAndRemoveSiteUrl(id);
238 function changeWorkspace(workspaceId) { //
239 window.location.href="alt_shortcut.php?changeWorkspace="+top.rawurlencodeAndRemoveSiteUrl(workspaceId);
241 function changeWorkspacePreview(newstate) { //
242 window.location.href="alt_shortcut.php?changeWorkspacePreview="+newstate;
244 function refreshShortcuts() {
245 window.location.href = document.URL;
249 $this->content
.=$this->doc
->startPage('Shortcut frame');
253 * Main function, creating content in the frame
259 // By default, 5 groups are set
260 $this->groupLabels
=array(
269 $bookmarkGroups = $GLOBALS['BE_USER']->getTSConfigProp('options.bookmarkGroups');
270 if (is_array($bookmarkGroups) && count($bookmarkGroups)) {
271 foreach ($bookmarkGroups as $k=>$v) {
272 if (strcmp('',$v) && strcmp('0',$v)) {
273 $this->groupLabels
[$k] = (string)$v;
274 } elseif ($GLOBALS['BE_USER']->isAdmin()) {
275 unset($this->groupLabels
[$k]);
280 // List of global groups that will be loaded. All global groups have negative IDs.
281 $globalGroups = -100; // Group -100 is kind of superglobal and can't be changed.
282 if (count($this->groupLabels
)) {
283 $globalGroups .= ','.implode(',',array_keys($this->groupLabels
));
284 $globalGroups = str_replace(',',',-',$globalGroups); // Ugly hack to make the UIDs negative - is there any better solution?
287 // Fetching shortcuts to display for this user:
288 $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');
291 $this->lines
=array();
292 $this->linesPre
=array();
293 $this->editSC_rec
='';
294 $this->selOpt
=array();
297 // Traverse shortcuts
298 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
299 $mParts = explode('|',$row['module_name']);
300 $row['module_name']=$mParts[0];
301 $row['M_module_name']=$mParts[1];
302 $mParts = explode('_',$row['M_module_name']?
$row['M_module_name']:$row['module_name']);
303 $qParts = parse_url($row['url']);
305 if (!$GLOBALS['BE_USER']->isAdmin()) {
306 // Check for module access
307 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 :-)
311 $page_id = $this->getLinkedPageId($row['url']);
312 if (t3lib_utility_Math
::canBeInterpretedAsInteger($page_id)) {
313 // Check for webmount access
314 if (!$GLOBALS['BE_USER']->isInWebMount($page_id)) continue;
316 // Check for record access
317 $pageRow = t3lib_BEfunc
::getRecord('pages',$page_id);
318 if (!$GLOBALS['BE_USER']->doesUserHaveAccess($pageRow,$perms=1)) continue;
322 if ($this->editSC
&& $row['uid']==$this->editSC
) {
323 $this->editSC_rec
=$row;
326 $sc_group = $row['sc_group'];
327 if ($sc_group && strcmp($formerGr,$sc_group)) {
328 if ($sc_group!=-100) {
329 if ($this->groupLabels
[abs($sc_group)] && strcmp('1',$this->groupLabels
[abs($sc_group)])) {
330 $label = $this->groupLabels
[abs($sc_group)];
332 $label = $GLOBALS['LANG']->getLL('shortcut_group_'.abs($sc_group),1);
333 if (!$label) $label = $GLOBALS['LANG']->getLL('shortcut_group',1).' '.abs($sc_group); // Fallback label
337 $onC = 'if (confirm('.$GLOBALS['LANG']->JScharCode($GLOBALS['LANG']->getLL('bookmark_delAllInCat')).')){window.location.href=\'alt_shortcut.php?deleteCategory='.$sc_group.'\';}return false;';
338 $this->linesPre
[]='<td> </td><td class="bgColor5"><a href="#" onclick="'.htmlspecialchars($onC).'" title="'.$GLOBALS['LANG']->getLL('bookmark_delAllInCat',1).'">'.$label.'</a></td>';
340 $label = $GLOBALS['LANG']->getLL('bookmark_global',1).': '.($label ?
$label : abs($sc_group)); // Fallback label
341 $this->lines
[]='<td> </td><td class="bgColor5">'.$label.'</td>';
347 $bgColorClass = $row['uid']==$this->editSC ?
'bgColor5' : ($row['sc_group']<0 ?
'bgColor6' : 'bgColor4');
349 if ($row['description']&&($row['uid']!=$this->editSC
)) {
350 $label = $row['description'];
352 $label = t3lib_div
::fixed_lgd_cs(rawurldecode($qParts['query']),150);
354 $titleA = $this->itemLabel($label,$row['module_name'],$row['M_module_name']);
356 $editSH = ($row['sc_group']>=0 ||
$GLOBALS['BE_USER']->isAdmin()) ?
'editSh('.intval($row['uid']).');' : "alert('".$GLOBALS['LANG']->getLL('bookmark_onlyAdmin')."')";
357 $jumpSC = 'jump(unescape(\''.rawurlencode($row['url']).'\'),\''.implode('_',$mParts).'\',\''.$mParts[0].'\');';
358 $onC = 'if (document.shForm.editShortcut_check && document.shForm.editShortcut_check.checked){'.$editSH.'}else{'.$jumpSC.'}return false;';
359 if ($sc_group>=0) { // user defined groups show up first
360 $this->linesPre
[]='<td class="'.$bgColorClass.'"><a href="#" onclick="'.htmlspecialchars($onC).'"><img src="'.$this->getIcon($row['module_name']).'" title="'.htmlspecialchars($titleA).'" alt="" /></a></td>';
362 $this->lines
[]='<td class="'.$bgColorClass.'"><a href="#" onclick="'.htmlspecialchars($onC).'"><img src="'.$this->getIcon($row['module_name']).'" title="'.htmlspecialchars($titleA).'" alt="" /></a></td>';
364 if (trim($row['description'])) {
365 $kkey = strtolower(substr($row['description'],0,20)).'_'.$row['uid'];
366 $this->selOpt
[$kkey]='<option value="'.htmlspecialchars($jumpSC).'">'.htmlspecialchars(t3lib_div
::fixed_lgd_cs($row['description'],50)).'</option>';
368 $formerGr=$row['sc_group'];
370 ksort($this->selOpt
);
371 array_unshift($this->selOpt
,'<option>['.$GLOBALS['LANG']->getLL('bookmark_selSC',1).']</option>');
373 $this->editLoadedFunc();
374 $this->editPageIdFunc();
376 if (!$this->editLoaded
&& t3lib_extMgm
::isLoaded('cms')) {
377 $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);" />'.
378 ($this->editError?
' <strong><span class="typo3-red">'.htmlspecialchars($this->editError
).'</span></strong>':'').
379 (is_array($this->theEditRec
)?
' <strong>'.$GLOBALS['LANG']->getLL('bookmark_loadEdit',1).' \''.t3lib_BEfunc
::getRecordTitle('pages',$this->theEditRec
,TRUE).'\'</strong> ('.htmlspecialchars($this->editPath
).')':'').
380 ($this->searchFor?
' '.$GLOBALS['LANG']->getLL('bookmark_searchFor',1).' <strong>\''.htmlspecialchars($this->searchFor
).'\'</strong>':'').
382 } else $editIdCode = '';
385 $editIdCode.= '<td> '.t3lib_BEfunc
::cshItem('xMOD_csh_corebe', 'bookmarks', $GLOBALS['BACK_PATH'],'',TRUE).'</td>';
390 <table border="0" cellpadding="0" cellspacing="0" width="99%">
394 Shortcut Display Table:
396 <table border="0" cellpadding="0" cellspacing="2" id="typo3-shortcuts">
399 if ($GLOBALS['BE_USER']->getTSConfigVal('options.enableBookmarks')) {
400 $this->content
.= implode('
403 $this->content
.= $editIdCode . '
408 if ($this->hasWorkspaceAccess()) {
409 $this->content
.= $this->workspaceSelector() .
410 t3lib_BEfunc
::cshItem('xMOD_csh_corebe', 'workspaceSelector', $GLOBALS['BACK_PATH'],'',TRUE);
419 if ($this->theEditRec
['uid']) {
420 $this->content
.=$this->doc
->wrapScriptTags('top.loadEditId('.$this->theEditRec
['uid'].');');
424 // Load alternative table/uid into editing form.
425 if (count($this->alternativeTableUid
)==2 && isset($GLOBALS['TCA'][$this->alternativeTableUid
[0]]) && t3lib_utility_Math
::canBeInterpretedAsInteger($this->alternativeTableUid
[1])) {
426 $JSaction = t3lib_BEfunc
::editOnClick('&edit['.$this->alternativeTableUid
[0].']['.$this->alternativeTableUid
[1].']=edit','','dummy.php');
427 $this->content
.=$this->doc
->wrapScriptTags('function editArbitraryElement() { top.content.'.$JSaction.'; } editArbitraryElement();');
430 // Load search for something.
431 if ($this->searchFor
) {
432 $urlParameters = array();
433 $urlParameters['id'] = intval($GLOBALS['WEBMOUNTS'][0]);
434 $urlParameters['search_field'] = $this->searchFor
;
435 $urlParameters['search_levels'] = 4;
436 $this->content
.= $this->doc
->wrapScriptTags('jump(unescape("' .
437 rawurlencode(t3lib_BEfunc
::getModuleUrl('web_list', $urlParameters, '')) .
438 '"), "web_list", "web");');
443 * Creates lines for the editing form.
447 function editLoadedFunc() {
449 if (is_array($this->editSC_rec
) && ($this->editSC_rec
['sc_group']>=0 ||
$GLOBALS['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.
453 $opt[]='<option value="0"></option>';
455 foreach($this->groupLabels
as $k=>$v) {
456 if ($v && strcmp('1',$v)) {
459 $label = $GLOBALS['LANG']->getLL('bookmark_group_'.$k,1);
460 if (!$label) $label = $GLOBALS['LANG']->getLL('bookmark_group',1).' '.$k; // Fallback label
462 $opt[]='<option value="'.$k.'"'.(!strcmp($this->editSC_rec
['sc_group'],$k)?
' selected="selected"':'').'>'.$label.'</option>';
465 if ($GLOBALS['BE_USER']->isAdmin()) {
466 foreach($this->groupLabels
as $k=>$v) {
467 if ($v && strcmp('1',$v)) {
470 $label = $GLOBALS['LANG']->getLL('bookmark_group_'.$k,1);
471 if (!$label) $label = $GLOBALS['LANG']->getLL('bookmark_group',1).' '.$k; // Fallback label
473 $label = $GLOBALS['LANG']->getLL('bookmark_global',1).': '.$label; // Add a prefix for global groups
475 $opt[]='<option value="-'.$k.'"'.(!strcmp($this->editSC_rec
['sc_group'],'-'.$k)?
' selected="selected"':'').'>'.$label.'</option>';
477 $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>';
480 // border="0" hspace="2" width="21" height="16" - not XHTML compliant in <input type="image" ...>
484 Shortcut Editing Form:
486 <table border="0" cellpadding="0" cellspacing="0" id="typo3-shortcuts-editing">
488 <td> </td>
489 <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>
490 <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>
491 <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>
492 <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>
493 <td><input name="editName" type="text" value="'.htmlspecialchars($this->editSC_rec
['description']).'"'.$this->doc
->formWidth(15).' /></td>
494 <td><select name="editGroup">'.implode('',$opt).'</select></td>
497 <input type="hidden" name="whichItem" value="'.$this->editSC_rec
['uid'].'" />
500 } else $manageForm='';
502 if (!$this->editLoaded
&& count($this->selOpt
)>1) {
503 $this->lines
[]='<td> </td>';
504 $this->lines
[]='<td><select name="_selSC" onchange="eval(this.options[this.selectedIndex].value);this.selectedIndex=0;">'.implode('',$this->selOpt
).'</select></td>';
507 // $this->linesPre contains elements with sc_group>=0
508 $this->lines
= array_merge($this->linesPre
,$this->lines
);
510 if (count($this->lines
)) {
511 if (!$GLOBALS['BE_USER']->getTSConfigVal('options.mayNotCreateEditBookmarks')) {
512 $this->lines
= array_merge(array(
513 '<td><input type="checkbox" id="editShortcut_check" name="editShortcut_check" value="1"' . ($this->editSC ?
' checked="checked"' : '') . ' />'
514 . ' <label for="editShortcut_check">' . $GLOBALS['LANG']->getLL('bookmark_edit', 1) . '</label> </td>'
516 $this->lines
[] = '<td>' . $manageForm . '</td>';
518 $this->lines
[] = '<td><img src="clear.gif" width="10" height="1" alt="" /></td>';
523 * 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.
528 function editPageIdFunc() {
529 if (!t3lib_extMgm
::isLoaded('cms')) return;
532 $this->editPage
= trim($GLOBALS['LANG']->csConvObj
->conv_case($GLOBALS['LANG']->charSet
,$this->editPage
,'toLower'));
533 $this->editError
= '';
534 $this->theEditRec
= '';
535 $this->searchFor
= '';
536 if ($this->editPage
) {
538 // First, test alternative value consisting of [table]:[uid] and if not found, proceed with traditional page ID resolve:
539 $this->alternativeTableUid
= explode(':',$this->editPage
);
540 if (!(count($this->alternativeTableUid
)==2 && $GLOBALS['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.
542 $where = ' AND ('.$GLOBALS['BE_USER']->getPagePermsClause(2).' OR '.$GLOBALS['BE_USER']->getPagePermsClause(16).')';
543 if (t3lib_utility_Math
::canBeInterpretedAsInteger($this->editPage
)) {
544 $this->theEditRec
= t3lib_BEfunc
::getRecordWSOL('pages',$this->editPage
,'*',$where);
546 $records = t3lib_BEfunc
::getRecordsByField('pages','alias',$this->editPage
,$where);
547 if (is_array($records)) {
548 $this->theEditRec
= reset($records);
549 t3lib_BEfunc
::workspaceOL('pages',$this->theEditRec
);
552 if (!is_array($this->theEditRec
)) {
553 unset($this->theEditRec
);
554 $this->searchFor
= $this->editPage
;
555 } elseif (!$GLOBALS['BE_USER']->isInWebMount($this->theEditRec
['uid'])) {
556 unset($this->theEditRec
);
557 $this->editError
=$GLOBALS['LANG']->getLL('bookmark_notEditable');
561 $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
562 $this->editPath
= t3lib_BEfunc
::getRecordPath($this->theEditRec
['pid'], $perms_clause, 30);
564 if (!$GLOBALS['BE_USER']->getTSConfigVal('options.bookmark_onEditId_dontSetPageTree')) {
565 $bookmarkKeepExpanded = $GLOBALS['BE_USER']->getTSConfigVal('options.bookmark_onEditId_keepExistingExpanded');
567 // Expanding page tree:
568 t3lib_BEfunc
::openPageTree($this->theEditRec
['pid'], !$bookmarkKeepExpanded);
576 * Outputting the accumulated content to screen
580 function printContent() {
583 $this->content
.= $this->doc
->endPage();
584 $this->content
= $this->doc
->insertStylesAndJS($this->content
);
586 if($this->editPage
&& $this->isAjaxCall
) {
590 if($this->theEditRec
['uid']) {
591 $data['type'] = 'page';
592 $data['editRecord'] = $this->theEditRec
['uid'];
595 // edit alternative table/uid
596 if(count($this->alternativeTableUid
) == 2
597 && isset($GLOBALS['TCA'][$this->alternativeTableUid
[0]])
598 && t3lib_utility_Math
::canBeInterpretedAsInteger($this->alternativeTableUid
[1])) {
599 $data['type'] = 'alternative';
600 $data['alternativeTable'] = $this->alternativeTableUid
[0];
601 $data['alternativeUid'] = $this->alternativeTableUid
[1];
604 // search for something else
605 if($this->searchFor
) {
606 $data['type'] = 'search';
607 $data['firstMountPoint'] = intval($GLOBALS['WEBMOUNTS'][0]);
608 $data['searchFor'] = $this->searchFor
;
611 $content = json_encode($data);
613 header('Content-type: application/json; charset=utf-8');
614 header('X-JSON: '.$content);
616 $content = $this->content
;
630 /***************************
632 * WORKSPACE FUNCTIONS:
634 ***************************/
637 * Create selector for workspaces and change workspace if command is given to do that.
639 * @return string HTML
641 function workspaceSelector() {
643 // Changing workspace and if so, reloading entire backend:
644 if (strlen($this->changeWorkspace
)) {
645 $GLOBALS['BE_USER']->setWorkspace($this->changeWorkspace
);
646 return $this->doc
->wrapScriptTags('top.location.href="'. t3lib_BEfunc
::getBackendScript() . '";');
648 // Changing workspace and if so, reloading entire backend:
649 if (strlen($this->changeWorkspacePreview
)) {
650 $GLOBALS['BE_USER']->setWorkspacePreview($this->changeWorkspacePreview
);
653 // Create options array:
655 if ($GLOBALS['BE_USER']->checkWorkspace(array('uid' => 0))) {
656 $options[0] = '['.$GLOBALS['LANG']->getLL('bookmark_onlineWS').']';
658 if ($GLOBALS['BE_USER']->checkWorkspace(array('uid' => -1))) {
659 $options[-1] = '['.$GLOBALS['LANG']->getLL('bookmark_offlineWS').']';
662 // Add custom workspaces (selecting all, filtering by BE_USER check):
663 if (t3lib_extMgm
::isLoaded('workspaces')) {
664 $workspaces = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid,title,adminusers,members,reviewers','sys_workspace','pid=0'.t3lib_BEfunc
::deleteClause('sys_workspace'),'','title');
665 if (count($workspaces)) {
666 foreach ($workspaces as $rec) {
667 if ($GLOBALS['BE_USER']->checkWorkspace($rec)) {
668 $options[$rec['uid']] = $rec['uid'].': '.$rec['title'];
674 // Build selector box:
675 if (count($options)) {
676 foreach($options as $value => $label) {
677 $selected = ((int)$GLOBALS['BE_USER']->workspace
===$value ?
' selected="selected"' : '');
678 $options[$value] = '<option value="'.htmlspecialchars($value).'"'.$selected.'>'.htmlspecialchars($label).'</option>';
681 $options[] = '<option value="-99">'.$GLOBALS['LANG']->getLL('bookmark_noWSfound',1).'</option>';
686 if ($GLOBALS['BE_USER']->workspace
!==0) {
687 $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"' : '').'/> ';
690 $selector.= '<a href="mod/user/ws/index.php" target="content">'.
691 t3lib_iconWorks
::getSpriteIconForRecord('sys_workspace', array()).
693 if (count($options) > 1) {
694 $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 Absolute filename of the icon
716 * @param string 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 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 In-label
754 * @param string Backend module name (key)
755 * @param string 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 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();