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)) {
324 if ($this->editSC
&& $row['uid']==$this->editSC
) {
325 $this->editSC_rec
=$row;
328 $sc_group = $row['sc_group'];
329 if ($sc_group && strcmp($formerGr,$sc_group)) {
330 if ($sc_group!=-100) {
331 if ($this->groupLabels
[abs($sc_group)] && strcmp('1',$this->groupLabels
[abs($sc_group)])) {
332 $label = $this->groupLabels
[abs($sc_group)];
334 $label = $GLOBALS['LANG']->getLL('shortcut_group_'.abs($sc_group),1);
335 if (!$label) $label = $GLOBALS['LANG']->getLL('shortcut_group',1).' '.abs($sc_group); // Fallback label
339 $onC = 'if (confirm('.$GLOBALS['LANG']->JScharCode($GLOBALS['LANG']->getLL('bookmark_delAllInCat')).')){window.location.href=\'alt_shortcut.php?deleteCategory='.$sc_group.'\';}return false;';
340 $this->linesPre
[]='<td> </td><td class="bgColor5"><a href="#" onclick="'.htmlspecialchars($onC).'" title="'.$GLOBALS['LANG']->getLL('bookmark_delAllInCat',1).'">'.$label.'</a></td>';
342 $label = $GLOBALS['LANG']->getLL('bookmark_global',1).': '.($label ?
$label : abs($sc_group)); // Fallback label
343 $this->lines
[]='<td> </td><td class="bgColor5">'.$label.'</td>';
349 $bgColorClass = $row['uid']==$this->editSC ?
'bgColor5' : ($row['sc_group']<0 ?
'bgColor6' : 'bgColor4');
351 if ($row['description'] && ($row['uid']!=$this->editSC
)) {
352 $label = $row['description'];
354 $label = t3lib_div
::fixed_lgd_cs(rawurldecode($qParts['query']),150);
356 $titleA = $this->itemLabel($label,$row['module_name'],$row['M_module_name']);
358 $editSH = ($row['sc_group']>=0 ||
$GLOBALS['BE_USER']->isAdmin()) ?
'editSh('.intval($row['uid']).');' : "alert('".$GLOBALS['LANG']->getLL('bookmark_onlyAdmin')."')";
359 $jumpSC = 'jump(unescape(\''.rawurlencode($row['url']).'\'),\''.implode('_',$mParts).'\',\''.$mParts[0].'\');';
360 $onC = 'if (document.shForm.editShortcut_check && document.shForm.editShortcut_check.checked){'.$editSH.'}else{'.$jumpSC.'}return false;';
361 if ($sc_group>=0) { // user defined groups show up first
362 $this->linesPre
[]='<td class="'.$bgColorClass.'"><a href="#" onclick="'.htmlspecialchars($onC).'"><img src="'.$this->getIcon($row['module_name']).'" title="'.htmlspecialchars($titleA).'" alt="" /></a></td>';
364 $this->lines
[]='<td class="'.$bgColorClass.'"><a href="#" onclick="'.htmlspecialchars($onC).'"><img src="'.$this->getIcon($row['module_name']).'" title="'.htmlspecialchars($titleA).'" alt="" /></a></td>';
366 if (trim($row['description'])) {
367 $kkey = strtolower(substr($row['description'],0,20)).'_'.$row['uid'];
368 $this->selOpt
[$kkey]='<option value="'.htmlspecialchars($jumpSC).'">'.htmlspecialchars(t3lib_div
::fixed_lgd_cs($row['description'],50)).'</option>';
370 $formerGr=$row['sc_group'];
372 ksort($this->selOpt
);
373 array_unshift($this->selOpt
,'<option>['.$GLOBALS['LANG']->getLL('bookmark_selSC',1).']</option>');
375 $this->editLoadedFunc();
376 $this->editPageIdFunc();
378 if (!$this->editLoaded
&& t3lib_extMgm
::isLoaded('cms')) {
379 $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);" />'.
380 ($this->editError?
' <strong><span class="typo3-red">'.htmlspecialchars($this->editError
).'</span></strong>':'').
381 (is_array($this->theEditRec
)?
' <strong>'.$GLOBALS['LANG']->getLL('bookmark_loadEdit',1).' \''.t3lib_BEfunc
::getRecordTitle('pages',$this->theEditRec
,TRUE).'\'</strong> ('.htmlspecialchars($this->editPath
).')':'').
382 ($this->searchFor?
' '.$GLOBALS['LANG']->getLL('bookmark_searchFor',1).' <strong>\''.htmlspecialchars($this->searchFor
).'\'</strong>':'').
384 } else $editIdCode = '';
387 $editIdCode.= '<td> '.t3lib_BEfunc
::cshItem('xMOD_csh_corebe', 'bookmarks', $GLOBALS['BACK_PATH'],'',TRUE).'</td>';
392 <table border="0" cellpadding="0" cellspacing="0" width="99%">
396 Shortcut Display Table:
398 <table border="0" cellpadding="0" cellspacing="2" id="typo3-shortcuts">
401 if ($GLOBALS['BE_USER']->getTSConfigVal('options.enableBookmarks')) {
402 $this->content
.= implode('
405 $this->content
.= $editIdCode . '
410 if ($this->hasWorkspaceAccess()) {
411 $this->content
.= $this->workspaceSelector() .
412 t3lib_BEfunc
::cshItem('xMOD_csh_corebe', 'workspaceSelector', $GLOBALS['BACK_PATH'],'',TRUE);
421 if ($this->theEditRec
['uid']) {
422 $this->content
.=$this->doc
->wrapScriptTags('top.loadEditId('.$this->theEditRec
['uid'].');');
426 // Load alternative table/uid into editing form.
427 if (count($this->alternativeTableUid
)==2 && isset($GLOBALS['TCA'][$this->alternativeTableUid
[0]]) && t3lib_utility_Math
::canBeInterpretedAsInteger($this->alternativeTableUid
[1])) {
428 $JSaction = t3lib_BEfunc
::editOnClick('&edit['.$this->alternativeTableUid
[0].']['.$this->alternativeTableUid
[1].']=edit','','dummy.php');
429 $this->content
.=$this->doc
->wrapScriptTags('function editArbitraryElement() { top.content.'.$JSaction.'; } editArbitraryElement();');
432 // Load search for something.
433 if ($this->searchFor
) {
434 $urlParameters = array();
435 $urlParameters['id'] = intval($GLOBALS['WEBMOUNTS'][0]);
436 $urlParameters['search_field'] = $this->searchFor
;
437 $urlParameters['search_levels'] = 4;
438 $this->content
.= $this->doc
->wrapScriptTags('jump(unescape("' .
439 rawurlencode(t3lib_BEfunc
::getModuleUrl('web_list', $urlParameters, '')) .
440 '"), "web_list", "web");');
445 * Creates lines for the editing form.
449 function editLoadedFunc() {
451 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.
455 $opt[]='<option value="0"></option>';
457 foreach($this->groupLabels
as $k=>$v) {
458 if ($v && strcmp('1',$v)) {
461 $label = $GLOBALS['LANG']->getLL('bookmark_group_'.$k,1);
462 if (!$label) $label = $GLOBALS['LANG']->getLL('bookmark_group',1).' '.$k; // Fallback label
464 $opt[]='<option value="'.$k.'"'.(!strcmp($this->editSC_rec
['sc_group'],$k)?
' selected="selected"':'').'>'.$label.'</option>';
467 if ($GLOBALS['BE_USER']->isAdmin()) {
468 foreach($this->groupLabels
as $k=>$v) {
469 if ($v && strcmp('1',$v)) {
472 $label = $GLOBALS['LANG']->getLL('bookmark_group_'.$k,1);
473 if (!$label) $label = $GLOBALS['LANG']->getLL('bookmark_group',1).' '.$k; // Fallback label
475 $label = $GLOBALS['LANG']->getLL('bookmark_global',1).': '.$label; // Add a prefix for global groups
477 $opt[]='<option value="-'.$k.'"'.(!strcmp($this->editSC_rec
['sc_group'],'-'.$k)?
' selected="selected"':'').'>'.$label.'</option>';
479 $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>';
482 // border="0" hspace="2" width="21" height="16" - not XHTML compliant in <input type="image" ...>
486 Shortcut Editing Form:
488 <table border="0" cellpadding="0" cellspacing="0" id="typo3-shortcuts-editing">
490 <td> </td>
491 <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>
492 <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>
493 <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>
494 <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>
495 <td><input name="editName" type="text" value="'.htmlspecialchars($this->editSC_rec
['description']).'"'.$this->doc
->formWidth(15).' /></td>
496 <td><select name="editGroup">'.implode('',$opt).'</select></td>
499 <input type="hidden" name="whichItem" value="'.$this->editSC_rec
['uid'].'" />
502 } else $manageForm='';
504 if (!$this->editLoaded
&& count($this->selOpt
)>1) {
505 $this->lines
[]='<td> </td>';
506 $this->lines
[]='<td><select name="_selSC" onchange="eval(this.options[this.selectedIndex].value);this.selectedIndex=0;">'.implode('',$this->selOpt
).'</select></td>';
509 // $this->linesPre contains elements with sc_group>=0
510 $this->lines
= array_merge($this->linesPre
,$this->lines
);
512 if (count($this->lines
)) {
513 if (!$GLOBALS['BE_USER']->getTSConfigVal('options.mayNotCreateEditBookmarks')) {
514 $this->lines
= array_merge(array(
515 '<td><input type="checkbox" id="editShortcut_check" name="editShortcut_check" value="1"' . ($this->editSC ?
' checked="checked"' : '') . ' />'
516 . ' <label for="editShortcut_check">' . $GLOBALS['LANG']->getLL('bookmark_edit', 1) . '</label> </td>'
518 $this->lines
[] = '<td>' . $manageForm . '</td>';
520 $this->lines
[] = '<td><img src="clear.gif" width="10" height="1" alt="" /></td>';
525 * 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.
530 function editPageIdFunc() {
531 if (!t3lib_extMgm
::isLoaded('cms')) return;
534 $this->editPage
= trim($GLOBALS['LANG']->csConvObj
->conv_case($GLOBALS['LANG']->charSet
,$this->editPage
,'toLower'));
535 $this->editError
= '';
536 $this->theEditRec
= '';
537 $this->searchFor
= '';
538 if ($this->editPage
) {
540 // First, test alternative value consisting of [table]:[uid] and if not found, proceed with traditional page ID resolve:
541 $this->alternativeTableUid
= explode(':',$this->editPage
);
542 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.
544 $where = ' AND ('.$GLOBALS['BE_USER']->getPagePermsClause(2).' OR '.$GLOBALS['BE_USER']->getPagePermsClause(16).')';
545 if (t3lib_utility_Math
::canBeInterpretedAsInteger($this->editPage
)) {
546 $this->theEditRec
= t3lib_BEfunc
::getRecordWSOL('pages',$this->editPage
,'*',$where);
548 $records = t3lib_BEfunc
::getRecordsByField('pages','alias',$this->editPage
,$where);
549 if (is_array($records)) {
550 $this->theEditRec
= reset($records);
551 t3lib_BEfunc
::workspaceOL('pages',$this->theEditRec
);
554 if (!is_array($this->theEditRec
)) {
555 unset($this->theEditRec
);
556 $this->searchFor
= $this->editPage
;
557 } elseif (!$GLOBALS['BE_USER']->isInWebMount($this->theEditRec
['uid'])) {
558 unset($this->theEditRec
);
559 $this->editError
=$GLOBALS['LANG']->getLL('bookmark_notEditable');
563 $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
564 $this->editPath
= t3lib_BEfunc
::getRecordPath($this->theEditRec
['pid'], $perms_clause, 30);
566 if (!$GLOBALS['BE_USER']->getTSConfigVal('options.bookmark_onEditId_dontSetPageTree')) {
567 $bookmarkKeepExpanded = $GLOBALS['BE_USER']->getTSConfigVal('options.bookmark_onEditId_keepExistingExpanded');
569 // Expanding page tree:
570 t3lib_BEfunc
::openPageTree($this->theEditRec
['pid'], !$bookmarkKeepExpanded);
578 * Outputting the accumulated content to screen
582 function printContent() {
585 $this->content
.= $this->doc
->endPage();
586 $this->content
= $this->doc
->insertStylesAndJS($this->content
);
588 if($this->editPage
&& $this->isAjaxCall
) {
592 if($this->theEditRec
['uid']) {
593 $data['type'] = 'page';
594 $data['editRecord'] = $this->theEditRec
['uid'];
597 // edit alternative table/uid
598 if(count($this->alternativeTableUid
) == 2
599 && isset($GLOBALS['TCA'][$this->alternativeTableUid
[0]])
600 && t3lib_utility_Math
::canBeInterpretedAsInteger($this->alternativeTableUid
[1])) {
601 $data['type'] = 'alternative';
602 $data['alternativeTable'] = $this->alternativeTableUid
[0];
603 $data['alternativeUid'] = $this->alternativeTableUid
[1];
606 // search for something else
607 if($this->searchFor
) {
608 $data['type'] = 'search';
609 $data['firstMountPoint'] = intval($GLOBALS['WEBMOUNTS'][0]);
610 $data['searchFor'] = $this->searchFor
;
613 $content = json_encode($data);
615 header('Content-type: application/json; charset=utf-8');
616 header('X-JSON: '.$content);
618 $content = $this->content
;
632 /***************************
634 * WORKSPACE FUNCTIONS:
636 ***************************/
639 * Create selector for workspaces and change workspace if command is given to do that.
641 * @return string HTML
643 function workspaceSelector() {
645 // Changing workspace and if so, reloading entire backend:
646 if (strlen($this->changeWorkspace
)) {
647 $GLOBALS['BE_USER']->setWorkspace($this->changeWorkspace
);
648 return $this->doc
->wrapScriptTags('top.location.href="'. t3lib_BEfunc
::getBackendScript() . '";');
650 // Changing workspace and if so, reloading entire backend:
651 if (strlen($this->changeWorkspacePreview
)) {
652 $GLOBALS['BE_USER']->setWorkspacePreview($this->changeWorkspacePreview
);
655 // Create options array:
657 if ($GLOBALS['BE_USER']->checkWorkspace(array('uid' => 0))) {
658 $options[0] = '['.$GLOBALS['LANG']->getLL('bookmark_onlineWS').']';
660 if ($GLOBALS['BE_USER']->checkWorkspace(array('uid' => -1))) {
661 $options[-1] = '['.$GLOBALS['LANG']->getLL('bookmark_offlineWS').']';
664 // Add custom workspaces (selecting all, filtering by BE_USER check):
665 if (t3lib_extMgm
::isLoaded('workspaces')) {
666 $workspaces = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid,title,adminusers,members,reviewers','sys_workspace','pid=0'.t3lib_BEfunc
::deleteClause('sys_workspace'),'','title');
667 if (count($workspaces)) {
668 foreach ($workspaces as $rec) {
669 if ($GLOBALS['BE_USER']->checkWorkspace($rec)) {
670 $options[$rec['uid']] = $rec['uid'].': '.$rec['title'];
676 // Build selector box:
677 if (count($options)) {
678 foreach($options as $value => $label) {
679 $selected = ((int)$GLOBALS['BE_USER']->workspace
===$value ?
' selected="selected"' : '');
680 $options[$value] = '<option value="'.htmlspecialchars($value).'"'.$selected.'>'.htmlspecialchars($label).'</option>';
683 $options[] = '<option value="-99">'.$GLOBALS['LANG']->getLL('bookmark_noWSfound',1).'</option>';
688 if ($GLOBALS['BE_USER']->workspace
!==0) {
689 $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"' : '').'/> ';
692 $selector.= '<a href="mod/user/ws/index.php" target="content">'.
693 t3lib_iconWorks
::getSpriteIconForRecord('sys_workspace', array()).
695 if (count($options) > 1) {
696 $selector .= '<select name="_workspaceSelector" onchange="changeWorkspace(this.options[this.selectedIndex].value);">'.implode('',$options).'</select>';
708 /***************************
712 ***************************/
715 * Returns relative filename for icon.
717 * @param string Absolute filename of the icon
718 * @param string Backpath string to prepend the icon after made relative
721 function mIconFilename($Ifilename,$backPath) {
722 // Change icon of fileadmin references - otherwise it doesn't differ with Web->List
723 $Ifilename = str_replace ('mod/file/list/list.gif', 'mod/file/file.gif', $Ifilename);
725 if (t3lib_div
::isAbsPath($Ifilename)) {
726 $Ifilename = '../'.substr($Ifilename,strlen(PATH_site
));
728 return $backPath.$Ifilename;
732 * Returns icon for shortcut display
734 * @param string Backend module name
735 * @return string Icon file name
737 function getIcon($modName) {
738 if ($GLOBALS['LANG']->moduleLabels
['tabs_images'][$modName.'_tab']) {
739 $icon = $this->mIconFilename($GLOBALS['LANG']->moduleLabels
['tabs_images'][$modName.'_tab'],'');
740 } elseif ($modName=='xMOD_alt_doc.php') {
741 $icon = 'gfx/edit2.gif';
742 } elseif ($modName=='xMOD_file_edit.php') {
743 $icon = 'gfx/edit_file.gif';
744 } elseif ($modName=='xMOD_wizard_rte.php') {
745 $icon = 'gfx/edit_rtewiz.gif';
747 $icon = 'gfx/dummy_module.gif';
753 * Returns title-label for icon
755 * @param string In-label
756 * @param string Backend module name (key)
757 * @param string Backend module label (user defined?)
758 * @return string Label for the shortcut item
760 function itemLabel($inlabel,$modName,$M_modName='') {
761 if (substr($modName,0,5)=='xMOD_') {
762 $label=substr($modName,5);
764 $split = explode('_',$modName);
765 $label = $GLOBALS['LANG']->moduleLabels
['tabs'][$split[0].'_tab'];
766 if (count($split)>1) {
767 $label.='>'.$GLOBALS['LANG']->moduleLabels
['tabs'][$modName.'_tab'];
770 if ($M_modName) $label.=' ('.$M_modName.')';
771 $label.=': '.$inlabel;
776 * Return the ID of the page in the URL if found.
778 * @param string The URL of the current shortcut link
779 * @return string If a page ID was found, it is returned. Otherwise: 0
781 function getLinkedPageId($url) {
782 return preg_replace('/.*[\?&]id=([^&]+).*/', '$1', $url);
786 * Checks if user has access to Workspace module.
788 * @return boolean Returns TRUE if user has access to workspace module.
790 function hasWorkspaceAccess() {
792 include('mod/user/ws/conf.php');
793 return $GLOBALS['BE_USER']->modAccess(array('name' => 'user', 'access' => 'user,group'), FALSE) && $GLOBALS['BE_USER']->modAccess($MCONF, FALSE);
798 $SOBE = t3lib_div
::makeInstance('SC_alt_shortcut');
803 $SOBE->printContent();