|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com) 00006 * All rights reserved 00007 * 00008 * This script is part of the TYPO3 project. The TYPO3 project is 00009 * free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * The GNU General Public License can be found at 00015 * http://www.gnu.org/copyleft/gpl.html. 00016 * A copy is found in the textfile GPL.txt and important notices to the license 00017 * from the author is found in LICENSE.txt distributed with these scripts. 00018 * 00019 * 00020 * This script is distributed in the hope that it will be useful, 00021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 * GNU General Public License for more details. 00024 * 00025 * This copyright notice MUST APPEAR in all copies of the script! 00026 ***************************************************************/ 00027 /** 00028 * Shortcut frame 00029 * Appears in the bottom frame of the backend frameset. 00030 * Provides links to registered shortcuts 00031 * If the 'cms' extension is loaded you will also have a field for entering page id/alias which will be found/edited 00032 * 00033 * $Id: alt_shortcut.php 10478 2011-02-17 11:08:43Z ohader $ 00034 * Revised for TYPO3 3.6 2/2003 by Kasper Skårhøj 00035 * XHTML compliant output 00036 * 00037 * @author Kasper Skårhøj <kasperYYYY@typo3.com> 00038 */ 00039 /** 00040 * [CLASS/FUNCTION INDEX of SCRIPT] 00041 * 00042 * 00043 * 00044 * 86: class SC_alt_shortcut 00045 * 125: function preinit() 00046 * 152: function preprocess() 00047 * 234: function init() 00048 * 275: function main() 00049 * 452: function editLoadedFunc() 00050 * 532: function editPageIdFunc() 00051 * 586: function printContent() 00052 * 00053 * SECTION: WORKSPACE FUNCTIONS: 00054 * 611: function workspaceSelector() 00055 * 00056 * SECTION: OTHER FUNCTIONS: 00057 * 686: function mIconFilename($Ifilename,$backPath) 00058 * 702: function getIcon($modName) 00059 * 726: function itemLabel($inlabel,$modName,$M_modName='') 00060 * 748: function getLinkedPageId($url) 00061 * 00062 * TOTAL FUNCTIONS: 12 00063 * (This index is automatically created/updated by the extension "extdeveval") 00064 * 00065 */ 00066 00067 00068 require('init.php'); 00069 require('template.php'); 00070 $LANG->includeLLFile('EXT:lang/locallang_misc.xml'); 00071 00072 00073 00074 00075 00076 00077 /** 00078 * Script Class for the shortcut frame, bottom frame of the backend frameset 00079 * 00080 * @author Kasper Skårhøj <kasperYYYY@typo3.com> 00081 * @package TYPO3 00082 * @subpackage core 00083 */ 00084 class SC_alt_shortcut { 00085 00086 // Internal, static: GPvar 00087 var $modName; 00088 var $M_modName; 00089 var $URL; 00090 var $editSC; 00091 var $deleteCategory; 00092 var $editName; 00093 var $editGroup; 00094 var $whichItem; 00095 00096 // Internal, static: 00097 /** 00098 * Object for backend modules, load modules-object 00099 * 00100 * @var t3lib_loadModules 00101 */ 00102 var $loadModules; 00103 protected $isAjaxCall; 00104 00105 /** 00106 * Document template object 00107 * 00108 * @var template 00109 */ 00110 var $doc; 00111 00112 // Internal, dynamic: 00113 var $content; // Accumulation of output HTML (string) 00114 var $lines; // Accumulation of table cells (array) 00115 00116 var $editLoaded; // Flag for defining whether we are editing 00117 var $editError; // Can contain edit error message 00118 var $editPath; // Set to the record path of the record being edited. 00119 var $editSC_rec; // Holds the shortcut record when editing 00120 var $theEditRec; // Page record to be edited 00121 var $editPage; // Page alias or id to be edited 00122 var $selOpt; // Select options. 00123 var $searchFor; // Text to search for... 00124 var $groupLabels=array(); // Labels of all groups. If value is 1, the system will try to find a label in the locallang array. 00125 00126 var $alternativeTableUid = array(); // Array with key 0/1 being table/uid of record to edit. Internally set. 00127 00128 00129 00130 /** 00131 * Pre-initialization - setting input variables for storing shortcuts etc. 00132 * 00133 * @return void 00134 */ 00135 function preinit() { 00136 global $TBE_MODULES; 00137 00138 // Setting GPvars: 00139 $this->isAjaxCall = (boolean) t3lib_div::_GP('ajax'); 00140 $this->modName = t3lib_div::_GP('modName'); 00141 $this->M_modName = t3lib_div::_GP('motherModName'); 00142 $this->URL = t3lib_div::_GP('URL'); 00143 $this->editSC = t3lib_div::_GP('editShortcut'); 00144 00145 $this->deleteCategory = t3lib_div::_GP('deleteCategory'); 00146 $this->editPage = t3lib_div::_GP('editPage'); 00147 $this->changeWorkspace = t3lib_div::_GP('changeWorkspace'); 00148 $this->changeWorkspacePreview = t3lib_div::_GP('changeWorkspacePreview'); 00149 $this->editName = t3lib_div::_GP('editName'); 00150 $this->editGroup = t3lib_div::_GP('editGroup'); 00151 $this->whichItem = t3lib_div::_GP('whichItem'); 00152 00153 // Creating modules object 00154 $this->loadModules = t3lib_div::makeInstance('t3lib_loadModules'); 00155 $this->loadModules->load($TBE_MODULES); 00156 } 00157 00158 /** 00159 * Adding shortcuts, editing shortcuts etc. 00160 * 00161 * @return void 00162 */ 00163 function preprocess() { 00164 global $BE_USER; 00165 $description = ''; // Default description 00166 $url = urldecode($this->URL); 00167 $queryParts = parse_url($url); 00168 00169 // Lookup the title of this page and use it as default description 00170 $page_id = $this->getLinkedPageId($url); 00171 if (t3lib_div::testInt($page_id)) { 00172 if (preg_match('/\&edit\[(.*)\]\[(.*)\]=edit/',$url,$matches)) { 00173 // Edit record 00174 $description = ''; // TODO: Set something useful 00175 } else { 00176 // Page listing 00177 $pageRow = t3lib_BEfunc::getRecord('pages',$page_id); 00178 if (count($pageRow)) { 00179 // If $page_id is an integer, set the description to the title of that page 00180 $description = $pageRow['title']; 00181 } 00182 } 00183 } else { 00184 if (preg_match('/\/$/', $page_id)) { 00185 // 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 00186 $description = basename($page_id); 00187 } 00188 } 00189 00190 00191 // Adding a shortcut being set from another frame, 00192 // but only if it's a relative URL (i.e. scheme part is not defined) 00193 if ($this->modName && $this->URL && empty($queryParts['scheme'])) { 00194 $fields_values = array( 00195 'userid' => $BE_USER->user['uid'], 00196 'module_name' => $this->modName.'|'.$this->M_modName, 00197 'url' => $this->URL, 00198 'description' => $description, 00199 'sorting' => $GLOBALS['EXEC_TIME'], 00200 ); 00201 $GLOBALS['TYPO3_DB']->exec_INSERTquery('sys_be_shortcuts', $fields_values); 00202 } 00203 00204 // Selection-clause for users - so users can deleted only their own shortcuts (except admins) 00205 $addUSERWhere = (!$BE_USER->isAdmin()?' AND userid='.intval($BE_USER->user['uid']):''); 00206 00207 // Deleting shortcuts: 00208 if (strcmp($this->deleteCategory,'')) { 00209 if (t3lib_div::testInt($this->deleteCategory)) { 00210 $GLOBALS['TYPO3_DB']->exec_DELETEquery('sys_be_shortcuts', 'sc_group='.intval($this->deleteCategory).$addUSERWhere); 00211 } 00212 } 00213 00214 // If other changes in post-vars: 00215 if (is_array($_POST)) { 00216 // Saving: 00217 if (isset($_POST['_savedok_x']) || isset($_POST['_saveclosedok_x'])) { 00218 $fields_values = array( 00219 'description' => $this->editName, 00220 'sc_group' => intval($this->editGroup) 00221 ); 00222 if ($fields_values['sc_group']<0 && !$BE_USER->isAdmin()) { 00223 $fields_values['sc_group']=0; 00224 } 00225 00226 $GLOBALS['TYPO3_DB']->exec_UPDATEquery('sys_be_shortcuts', 'uid='.intval($this->whichItem).$addUSERWhere, $fields_values); 00227 } 00228 // If save without close, keep the session going... 00229 if (isset($_POST['_savedok_x'])) { 00230 $this->editSC=$this->whichItem; 00231 } 00232 // Deleting a single shortcut ? 00233 if (isset($_POST['_deletedok_x'])) { 00234 $GLOBALS['TYPO3_DB']->exec_DELETEquery('sys_be_shortcuts', 'uid='.intval($this->whichItem).$addUSERWhere); 00235 00236 if (!$this->editSC) $this->editSC=-1; // Just to have the checkbox set... 00237 } 00238 } 00239 00240 } 00241 00242 /** 00243 * Initialize (page output) 00244 * 00245 * @return void 00246 */ 00247 function init() { 00248 global $BACK_PATH; 00249 00250 $this->doc = t3lib_div::makeInstance('template'); 00251 $this->doc->backPath = $BACK_PATH; 00252 $this->doc->form='<form action="alt_shortcut.php" name="shForm" method="post">'; 00253 $this->doc->divClass='typo3-shortcut'; 00254 $this->doc->JScode.=$this->doc->wrapScriptTags(' 00255 function jump(url,modName,mainModName) { // 00256 // Clear information about which entry in nav. tree that might have been highlighted. 00257 top.fsMod.navFrameHighlightedID = new Array(); 00258 if (top.content && top.content.nav_frame && top.content.nav_frame.refresh_nav) { 00259 top.content.nav_frame.refresh_nav(); 00260 } 00261 00262 top.nextLoadModuleUrl = url; 00263 top.goToModule(modName); 00264 } 00265 function editSh(uid) { // 00266 window.location.href="alt_shortcut.php?editShortcut="+uid; 00267 } 00268 function submitEditPage(id) { // 00269 window.location.href="alt_shortcut.php?editPage="+top.rawurlencodeAndRemoveSiteUrl(id); 00270 } 00271 function changeWorkspace(workspaceId) { // 00272 window.location.href="alt_shortcut.php?changeWorkspace="+top.rawurlencodeAndRemoveSiteUrl(workspaceId); 00273 } 00274 function changeWorkspacePreview(newstate) { // 00275 window.location.href="alt_shortcut.php?changeWorkspacePreview="+newstate; 00276 } 00277 function refreshShortcuts() { 00278 window.location.href = document.URL; 00279 } 00280 00281 '); 00282 $this->content.=$this->doc->startPage('Shortcut frame'); 00283 } 00284 00285 /** 00286 * Main function, creating content in the frame 00287 * 00288 * @return void 00289 */ 00290 function main() { 00291 global $BE_USER,$LANG,$TCA; 00292 00293 // By default, 5 groups are set 00294 $this->groupLabels=array( 00295 1 => 1, 00296 2 => 1, 00297 3 => 1, 00298 4 => 1, 00299 5 => 1, 00300 ); 00301 00302 // "Shortcuts" have been renamed to "Bookmarks" 00303 // @deprecated remove shortcuts code in TYPO3 4.7 00304 $shortCutGroups = $BE_USER->getTSConfigProp('options.shortcutGroups'); 00305 if ($shortCutGroups !== NULL) { 00306 t3lib_div::deprecationLog('options.shortcutGroups - since TYPO3 4.5, will be removed in TYPO3 4.7 - use options.bookmarkGroups instead'); 00307 } 00308 $bookmarkGroups = $BE_USER->getTSConfigProp('options.bookmarkGroups'); 00309 if ($bookmarkGroups !== NULL) { 00310 $shortCutGroups = $bookmarkGroups; 00311 } 00312 if (is_array($shortCutGroups) && count($shortCutGroups)) { 00313 foreach ($shortCutGroups as $k=>$v) { 00314 if (strcmp('',$v) && strcmp('0',$v)) { 00315 $this->groupLabels[$k] = (string)$v; 00316 } elseif ($BE_USER->isAdmin()) { 00317 unset($this->groupLabels[$k]); 00318 } 00319 } 00320 } 00321 00322 // List of global groups that will be loaded. All global groups have negative IDs. 00323 $globalGroups = -100; // Group -100 is kind of superglobal and can't be changed. 00324 if (count($this->groupLabels)) { 00325 $globalGroups .= ','.implode(',',array_keys($this->groupLabels)); 00326 $globalGroups = str_replace(',',',-',$globalGroups); // Ugly hack to make the UIDs negative - is there any better solution? 00327 } 00328 00329 // Fetching shortcuts to display for this user: 00330 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_be_shortcuts', '((userid='.$BE_USER->user['uid'].' AND sc_group>=0) OR sc_group IN ('.$globalGroups.'))', '', 'sc_group,sorting'); 00331 00332 // Init vars: 00333 $this->lines=array(); 00334 $this->linesPre=array(); 00335 $this->editSC_rec=''; 00336 $this->selOpt=array(); 00337 $formerGr=''; 00338 00339 // Traverse shortcuts 00340 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 00341 $mParts = explode('|',$row['module_name']); 00342 $row['module_name']=$mParts[0]; 00343 $row['M_module_name']=$mParts[1]; 00344 $mParts = explode('_',$row['M_module_name']?$row['M_module_name']:$row['module_name']); 00345 $qParts = parse_url($row['url']); 00346 00347 if (!$BE_USER->isAdmin()) { 00348 // Check for module access 00349 if (!isset($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 :-) 00350 continue; 00351 } 00352 00353 $page_id = $this->getLinkedPageId($row['url']); 00354 if (t3lib_div::testInt($page_id)) { 00355 // Check for webmount access 00356 if (!$GLOBALS['BE_USER']->isInWebMount($page_id)) continue; 00357 00358 // Check for record access 00359 $pageRow = t3lib_BEfunc::getRecord('pages',$page_id); 00360 if (!$GLOBALS['BE_USER']->doesUserHaveAccess($pageRow,$perms=1)) continue; 00361 } 00362 } 00363 00364 if ($this->editSC && $row['uid']==$this->editSC) { 00365 $this->editSC_rec=$row; 00366 } 00367 00368 $sc_group = $row['sc_group']; 00369 if ($sc_group && strcmp($formerGr,$sc_group)) { 00370 if ($sc_group!=-100) { 00371 if ($this->groupLabels[abs($sc_group)] && strcmp('1',$this->groupLabels[abs($sc_group)])) { 00372 $label = $this->groupLabels[abs($sc_group)]; 00373 } else { 00374 $label = $LANG->getLL('shortcut_group_'.abs($sc_group),1); 00375 if (!$label) $label = $LANG->getLL('shortcut_group',1).' '.abs($sc_group); // Fallback label 00376 } 00377 00378 if ($sc_group>=0) { 00379 $onC = 'if (confirm('.$GLOBALS['LANG']->JScharCode($LANG->getLL('bookmark_delAllInCat')).')){window.location.href=\'alt_shortcut.php?deleteCategory='.$sc_group.'\';}return false;'; 00380 $this->linesPre[]='<td> </td><td class="bgColor5"><a href="#" onclick="'.htmlspecialchars($onC).'" title="'.$LANG->getLL('bookmark_delAllInCat',1).'">'.$label.'</a></td>'; 00381 } else { 00382 $label = $LANG->getLL('bookmark_global',1).': '.($label ? $label : abs($sc_group)); // Fallback label 00383 $this->lines[]='<td> </td><td class="bgColor5">'.$label.'</td>'; 00384 } 00385 unset($label); 00386 } 00387 } 00388 00389 $bgColorClass = $row['uid']==$this->editSC ? 'bgColor5' : ($row['sc_group']<0 ? 'bgColor6' : 'bgColor4'); 00390 00391 if ($row['description']&&($row['uid']!=$this->editSC)) { 00392 $label = $row['description']; 00393 } else { 00394 $label = t3lib_div::fixed_lgd_cs(rawurldecode($qParts['query']),150); 00395 } 00396 $titleA = $this->itemLabel($label,$row['module_name'],$row['M_module_name']); 00397 00398 $editSH = ($row['sc_group']>=0 || $BE_USER->isAdmin()) ? 'editSh('.intval($row['uid']).');' : "alert('".$LANG->getLL('bookmark_onlyAdmin')."')"; 00399 $jumpSC = 'jump(unescape(\''.rawurlencode($row['url']).'\'),\''.implode('_',$mParts).'\',\''.$mParts[0].'\');'; 00400 $onC = 'if (document.shForm.editShortcut_check && document.shForm.editShortcut_check.checked){'.$editSH.'}else{'.$jumpSC.'}return false;'; 00401 if ($sc_group>=0) { // user defined groups show up first 00402 $this->linesPre[]='<td class="'.$bgColorClass.'"><a href="#" onclick="'.htmlspecialchars($onC).'"><img src="'.$this->getIcon($row['module_name']).'" title="'.htmlspecialchars($titleA).'" alt="" /></a></td>'; 00403 } else { 00404 $this->lines[]='<td class="'.$bgColorClass.'"><a href="#" onclick="'.htmlspecialchars($onC).'"><img src="'.$this->getIcon($row['module_name']).'" title="'.htmlspecialchars($titleA).'" alt="" /></a></td>'; 00405 } 00406 if (trim($row['description'])) { 00407 $kkey = strtolower(substr($row['description'],0,20)).'_'.$row['uid']; 00408 $this->selOpt[$kkey]='<option value="'.htmlspecialchars($jumpSC).'">'.htmlspecialchars(t3lib_div::fixed_lgd_cs($row['description'],50)).'</option>'; 00409 } 00410 $formerGr=$row['sc_group']; 00411 } 00412 ksort($this->selOpt); 00413 array_unshift($this->selOpt,'<option>['.$LANG->getLL('bookmark_selSC',1).']</option>'); 00414 00415 $this->editLoadedFunc(); 00416 $this->editPageIdFunc(); 00417 00418 if (!$this->editLoaded && t3lib_extMgm::isLoaded('cms')) { 00419 $editIdCode = '<td nowrap="nowrap">'.$LANG->getLL('bookmark_editID',1).': <input type="text" value="'.($this->editError?htmlspecialchars($this->editPage):'').'" name="editPage"'.$this->doc->formWidth(15).' onchange="submitEditPage(this.value);" />'. 00420 ($this->editError?' <strong><span class="typo3-red">'.htmlspecialchars($this->editError).'</span></strong>':''). 00421 (is_array($this->theEditRec)?' <strong>'.$LANG->getLL('bookmark_loadEdit',1).' \''.t3lib_BEfunc::getRecordTitle('pages',$this->theEditRec,TRUE).'\'</strong> ('.htmlspecialchars($this->editPath).')':''). 00422 ($this->searchFor?' '.$LANG->getLL('bookmark_searchFor',1).' <strong>\''.htmlspecialchars($this->searchFor).'\'</strong>':''). 00423 '</td>'; 00424 } else $editIdCode = ''; 00425 00426 // Adding CSH: 00427 $editIdCode.= '<td> '.t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'bookmarks', $GLOBALS['BACK_PATH'],'',TRUE).'</td>'; 00428 00429 // Compile it all: 00430 $this->content.=' 00431 00432 <table border="0" cellpadding="0" cellspacing="0" width="99%"> 00433 <tr> 00434 <td> 00435 <!-- 00436 Shortcut Display Table: 00437 --> 00438 <table border="0" cellpadding="0" cellspacing="2" id="typo3-shortcuts"> 00439 <tr> 00440 '; 00441 // "Shortcuts" have been renamed to "Bookmarks" 00442 // @deprecated remove shortcuts code in TYPO3 4.7 00443 $useShortcuts = $GLOBALS['BE_USER']->getTSConfigVal('options.enableShortcuts'); 00444 $useBookmarks = $GLOBALS['BE_USER']->getTSConfigVal('options.enableBookmarks'); 00445 if ($useShortcuts || $useBookmarks) { 00446 $this->content .= implode(' 00447 ', $this->lines); 00448 00449 if ($useShortcuts) { 00450 t3lib_div::deprecationLog('options.enableShortcuts - since TYPO3 4.5, will be removed in TYPO3 4.7 - use options.enableBookmarks instead'); 00451 } 00452 } 00453 $this->content .= $editIdCode . ' 00454 </tr> 00455 </table> 00456 </td> 00457 <td align="right">'; 00458 if ($this->hasWorkspaceAccess()) { 00459 $this->content .= $this->workspaceSelector() . 00460 t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'workspaceSelector', $GLOBALS['BACK_PATH'],'',TRUE); 00461 } 00462 $this->content .= ' 00463 </td> 00464 </tr> 00465 </table> 00466 '; 00467 00468 // Launch Edit page: 00469 if ($this->theEditRec['uid']) { 00470 $this->content.=$this->doc->wrapScriptTags('top.loadEditId('.$this->theEditRec['uid'].');'); 00471 00472 } 00473 00474 // Load alternative table/uid into editing form. 00475 if (count($this->alternativeTableUid)==2 && isset($TCA[$this->alternativeTableUid[0]]) && t3lib_div::testInt($this->alternativeTableUid[1])) { 00476 $JSaction = t3lib_BEfunc::editOnClick('&edit['.$this->alternativeTableUid[0].']['.$this->alternativeTableUid[1].']=edit','','dummy.php'); 00477 $this->content.=$this->doc->wrapScriptTags('function editArbitraryElement() { top.content.'.$JSaction.'; } editArbitraryElement();'); 00478 } 00479 00480 // Load search for something. 00481 if ($this->searchFor) { 00482 $urlParameters = array(); 00483 $urlParameters['id'] = intval($GLOBALS['WEBMOUNTS'][0]); 00484 $urlParameters['search_field'] = $this->searchFor; 00485 $urlParameters['search_levels'] = 4; 00486 $this->content .= $this->doc->wrapScriptTags('jump(unescape("' . 00487 rawurlencode(t3lib_BEfunc::getModuleUrl('web_list', $urlParameters, '')) . 00488 '"), "web_list", "web");'); 00489 } 00490 } 00491 00492 /** 00493 * Creates lines for the editing form. 00494 * 00495 * @return void 00496 */ 00497 function editLoadedFunc() { 00498 global $BE_USER,$LANG; 00499 00500 $this->editLoaded=0; 00501 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. 00502 $this->editLoaded=1; 00503 00504 $opt=array(); 00505 $opt[]='<option value="0"></option>'; 00506 00507 foreach($this->groupLabels as $k=>$v) { 00508 if ($v && strcmp('1',$v)) { 00509 $label = $v; 00510 } else { 00511 $label = $LANG->getLL('bookmark_group_'.$k,1); 00512 if (!$label) $label = $LANG->getLL('bookmark_group',1).' '.$k; // Fallback label 00513 } 00514 $opt[]='<option value="'.$k.'"'.(!strcmp($this->editSC_rec['sc_group'],$k)?' selected="selected"':'').'>'.$label.'</option>'; 00515 } 00516 00517 if ($BE_USER->isAdmin()) { 00518 foreach($this->groupLabels as $k=>$v) { 00519 if ($v && strcmp('1',$v)) { 00520 $label = $v; 00521 } else { 00522 $label = $LANG->getLL('bookmark_group_'.$k,1); 00523 if (!$label) $label = $LANG->getLL('bookmark_group',1).' '.$k; // Fallback label 00524 } 00525 $label = $LANG->getLL('bookmark_global',1).': '.$label; // Add a prefix for global groups 00526 00527 $opt[]='<option value="-'.$k.'"'.(!strcmp($this->editSC_rec['sc_group'],'-'.$k)?' selected="selected"':'').'>'.$label.'</option>'; 00528 } 00529 $opt[]='<option value="-100"'.(!strcmp($this->editSC_rec['sc_group'],'-100')?' selected="selected"':'').'>'.$LANG->getLL('bookmark_global',1).': '.$LANG->getLL('bookmark_all',1).'</option>'; 00530 } 00531 00532 // border="0" hspace="2" width="21" height="16" - not XHTML compliant in <input type="image" ...> 00533 $manageForm=' 00534 00535 <!-- 00536 Shortcut Editing Form: 00537 --> 00538 <table border="0" cellpadding="0" cellspacing="0" id="typo3-shortcuts-editing"> 00539 <tr> 00540 <td> </td> 00541 <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> 00542 <td><input type="image" class="c-inputButton" name="_saveclosedok"'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/saveandclosedok.gif','').' title="'.$LANG->getLL('bookmark_saveClose',1).'" /></td> 00543 <td><input type="image" class="c-inputButton" name="_closedok"'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/closedok.gif','').' title="'.$LANG->getLL('bookmark_close',1).'" /></td> 00544 <td><input type="image" class="c-inputButton" name="_deletedok"'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/deletedok.gif','').' title="'.$LANG->getLL('bookmark_delete',1).'" /></td> 00545 <td><input name="editName" type="text" value="'.htmlspecialchars($this->editSC_rec['description']).'"'.$this->doc->formWidth(15).' /></td> 00546 <td><select name="editGroup">'.implode('',$opt).'</select></td> 00547 </tr> 00548 </table> 00549 <input type="hidden" name="whichItem" value="'.$this->editSC_rec['uid'].'" /> 00550 00551 '; 00552 } else $manageForm=''; 00553 00554 if (!$this->editLoaded && count($this->selOpt)>1) { 00555 $this->lines[]='<td> </td>'; 00556 $this->lines[]='<td><select name="_selSC" onchange="eval(this.options[this.selectedIndex].value);this.selectedIndex=0;">'.implode('',$this->selOpt).'</select></td>'; 00557 } 00558 00559 // $this->linesPre contains elements with sc_group>=0 00560 $this->lines = array_merge($this->linesPre,$this->lines); 00561 00562 if (count($this->lines)) { 00563 // "Shortcuts" have been renamed to "Bookmarks" 00564 // @deprecated remove shortcuts code in TYPO3 4.7 00565 $createShortcuts = !$BE_USER->getTSConfigVal('options.mayNotCreateEditShortcuts'); 00566 $createBookmarks = !$BE_USER->getTSConfigVal('options.mayNotCreateEditBookmarks'); 00567 00568 if ($createShortcuts || $createBookmarks) { 00569 $this->lines=array_merge(array('<td><input type="checkbox" id="editShortcut_check" name="editShortcut_check" value="1"'.($this->editSC?' checked="checked"':'').' /> <label for="editShortcut_check">'.$LANG->getLL('bookmark_edit',1).'</label> </td>'),$this->lines); 00570 $this->lines[]='<td>'.$manageForm.'</td>'; 00571 00572 if ($createShortcuts) { 00573 t3lib_div::deprecationLog('options.mayNotCreateEditShortcuts - since TYPO3 4.5, will be removed in TYPO3 4.7 - use options.mayNotCreateEditBookmarks instead'); 00574 } 00575 } 00576 $this->lines[]='<td><img src="clear.gif" width="10" height="1" alt="" /></td>'; 00577 } 00578 } 00579 00580 /** 00581 * 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. 00582 * Returns void 00583 * 00584 * @return void 00585 */ 00586 function editPageIdFunc() { 00587 global $BE_USER,$LANG; 00588 00589 if (!t3lib_extMgm::isLoaded('cms')) return; 00590 00591 // EDIT page: 00592 $this->editPage = trim($LANG->csConvObj->conv_case($LANG->charSet,$this->editPage,'toLower')); 00593 $this->editError = ''; 00594 $this->theEditRec = ''; 00595 $this->searchFor = ''; 00596 if ($this->editPage) { 00597 00598 // First, test alternative value consisting of [table]:[uid] and if not found, proceed with traditional page ID resolve: 00599 $this->alternativeTableUid = explode(':',$this->editPage); 00600 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. 00601 00602 $where = ' AND ('.$BE_USER->getPagePermsClause(2).' OR '.$BE_USER->getPagePermsClause(16).')'; 00603 if (t3lib_div::testInt($this->editPage)) { 00604 $this->theEditRec = t3lib_BEfunc::getRecordWSOL('pages',$this->editPage,'*',$where); 00605 } else { 00606 $records = t3lib_BEfunc::getRecordsByField('pages','alias',$this->editPage,$where); 00607 if (is_array($records)) { 00608 reset($records); 00609 $this->theEditRec = current($records); 00610 t3lib_BEfunc::workspaceOL('pages',$this->theEditRec); 00611 } 00612 } 00613 if (!is_array($this->theEditRec)) { 00614 unset($this->theEditRec); 00615 $this->searchFor = $this->editPage; 00616 } elseif (!$BE_USER->isInWebMount($this->theEditRec['uid'])) { 00617 unset($this->theEditRec); 00618 $this->editError=$LANG->getLL('bookmark_notEditable'); 00619 } else { 00620 00621 // Visual path set: 00622 $perms_clause = $BE_USER->getPagePermsClause(1); 00623 $this->editPath = t3lib_BEfunc::getRecordPath($this->theEditRec['pid'], $perms_clause, 30); 00624 00625 // "Shortcuts" have been renamed to "Bookmarks" 00626 // @deprecated remove shortcuts code in TYPO3 4.7 00627 $shortcutSetPageTree = !$BE_USER->getTSConfigVal('options.shortcut_onEditId_dontSetPageTree'); 00628 $bookmarkSetPageTree = !$BE_USER->getTSConfigVal('options.bookmark_onEditId_dontSetPageTree'); 00629 00630 if ($shortcutSetPageTree && $bookmarkSetPageTree) { 00631 $shortcutKeepExpanded = $BE_USER->getTSConfigVal('options.shortcut_onEditId_keepExistingExpanded'); 00632 $bookmarkKeepExpanded = $BE_USER->getTSConfigVal('options.bookmark_onEditId_keepExistingExpanded'); 00633 $keepNotExpanded = (!$shortcutKeepExpanded || !$bookmarkKeepExpanded); 00634 00635 // Expanding page tree: 00636 t3lib_BEfunc::openPageTree($this->theEditRec['pid'], $keepNotExpanded); 00637 00638 if ($shortcutSetPageTree) { 00639 t3lib_div::deprecationLog('options.shortcut_onEditId_dontSetPageTree - since TYPO3 4.5, will be removed in TYPO3 4.7 - use options.bookmark_onEditId_dontSetPageTree instead'); 00640 } 00641 if ($shortcutKeepExpanded) { 00642 t3lib_div::deprecationLog('options.shortcut_onEditId_keepExistingExpanded - since TYPO3 4.5, will be removed in TYPO3 4.7 - use options.bookmark_onEditId_keepExistingExpanded instead'); 00643 } 00644 } 00645 } 00646 } 00647 } 00648 } 00649 00650 /** 00651 * Outputting the accumulated content to screen 00652 * 00653 * @return void 00654 */ 00655 function printContent() { 00656 $content = ''; 00657 00658 $this->content.= $this->doc->endPage(); 00659 $this->content = $this->doc->insertStylesAndJS($this->content); 00660 00661 if($this->editPage && $this->isAjaxCall) { 00662 $data = array(); 00663 00664 // edit page 00665 if($this->theEditRec['uid']) { 00666 $data['type'] = 'page'; 00667 $data['editRecord'] = $this->theEditRec['uid']; 00668 } 00669 00670 // edit alternative table/uid 00671 if(count($this->alternativeTableUid) == 2 00672 && isset($GLOBALS['TCA'][$this->alternativeTableUid[0]]) 00673 && t3lib_div::testInt($this->alternativeTableUid[1])) { 00674 $data['type'] = 'alternative'; 00675 $data['alternativeTable'] = $this->alternativeTableUid[0]; 00676 $data['alternativeUid'] = $this->alternativeTableUid[1]; 00677 } 00678 00679 // search for something else 00680 if($this->searchFor) { 00681 $data['type'] = 'search'; 00682 $data['firstMountPoint'] = intval($GLOBALS['WEBMOUNTS'][0]); 00683 $data['searchFor'] = $this->searchFor; 00684 } 00685 00686 $content = json_encode($data); 00687 00688 header('Content-type: application/json; charset=utf-8'); 00689 header('X-JSON: '.$content); 00690 } else { 00691 $content = $this->content; 00692 } 00693 00694 echo $content; 00695 } 00696 00697 00698 00699 00700 00701 00702 00703 00704 00705 /*************************** 00706 * 00707 * WORKSPACE FUNCTIONS: 00708 * 00709 ***************************/ 00710 00711 /** 00712 * Create selector for workspaces and change workspace if command is given to do that. 00713 * 00714 * @return string HTML 00715 */ 00716 function workspaceSelector() { 00717 global $TYPO3_DB,$BE_USER,$LANG; 00718 00719 // Changing workspace and if so, reloading entire backend: 00720 if (strlen($this->changeWorkspace)) { 00721 $BE_USER->setWorkspace($this->changeWorkspace); 00722 return $this->doc->wrapScriptTags('top.location.href="'. t3lib_BEfunc::getBackendScript() . '";'); 00723 } 00724 // Changing workspace and if so, reloading entire backend: 00725 if (strlen($this->changeWorkspacePreview)) { 00726 $BE_USER->setWorkspacePreview($this->changeWorkspacePreview); 00727 } 00728 00729 // Create options array: 00730 $options = array(); 00731 if ($BE_USER->checkWorkspace(array('uid' => 0))) { 00732 $options[0] = '['.$LANG->getLL('bookmark_onlineWS').']'; 00733 } 00734 if ($BE_USER->checkWorkspace(array('uid' => -1))) { 00735 $options[-1] = '['.$LANG->getLL('bookmark_offlineWS').']'; 00736 } 00737 00738 // Add custom workspaces (selecting all, filtering by BE_USER check): 00739 if (t3lib_extMgm::isLoaded('workspaces')) { 00740 $workspaces = $TYPO3_DB->exec_SELECTgetRows('uid,title,adminusers,members,reviewers','sys_workspace','pid=0'.t3lib_BEfunc::deleteClause('sys_workspace'),'','title'); 00741 if (count($workspaces)) { 00742 foreach ($workspaces as $rec) { 00743 if ($BE_USER->checkWorkspace($rec)) { 00744 $options[$rec['uid']] = $rec['uid'].': '.$rec['title']; 00745 } 00746 } 00747 } 00748 } 00749 00750 // Build selector box: 00751 if (count($options)) { 00752 foreach($options as $value => $label) { 00753 $selected = ((int)$BE_USER->workspace===$value ? ' selected="selected"' : ''); 00754 $options[$value] = '<option value="'.htmlspecialchars($value).'"'.$selected.'>'.htmlspecialchars($label).'</option>'; 00755 } 00756 } else { 00757 $options[] = '<option value="-99">'.$LANG->getLL('bookmark_noWSfound',1).'</option>'; 00758 } 00759 00760 $selector = ''; 00761 // Preview: 00762 if ($BE_USER->workspace!==0) { 00763 $selector.= '<label for="workspacePreview">Frontend Preview:</label> <input type="checkbox" name="workspacePreview" id="workspacePreview" onclick="changeWorkspacePreview('.($BE_USER->user['workspace_preview'] ? 0 : 1).')"; '.($BE_USER->user['workspace_preview'] ? 'checked="checked"' : '').'/> '; 00764 } 00765 00766 $selector.= '<a href="mod/user/ws/index.php" target="content">'. 00767 t3lib_iconWorks::getSpriteIconForRecord('sys_workspace', array()). 00768 '</a>'; 00769 if (count($options) > 1) { 00770 $selector .= '<select name="_workspaceSelector" onchange="changeWorkspace(this.options[this.selectedIndex].value);">'.implode('',$options).'</select>'; 00771 } 00772 00773 return $selector; 00774 } 00775 00776 00777 00778 00779 00780 00781 00782 /*************************** 00783 * 00784 * OTHER FUNCTIONS: 00785 * 00786 ***************************/ 00787 00788 /** 00789 * Returns relative filename for icon. 00790 * 00791 * @param string Absolute filename of the icon 00792 * @param string Backpath string to prepend the icon after made relative 00793 * @return void 00794 */ 00795 function mIconFilename($Ifilename,$backPath) { 00796 // Change icon of fileadmin references - otherwise it doesn't differ with Web->List 00797 $Ifilename = str_replace ('mod/file/list/list.gif', 'mod/file/file.gif', $Ifilename); 00798 00799 if (t3lib_div::isAbsPath($Ifilename)) { 00800 $Ifilename = '../'.substr($Ifilename,strlen(PATH_site)); 00801 } 00802 return $backPath.$Ifilename; 00803 } 00804 00805 /** 00806 * Returns icon for shortcut display 00807 * 00808 * @param string Backend module name 00809 * @return string Icon file name 00810 */ 00811 function getIcon($modName) { 00812 global $LANG; 00813 if ($LANG->moduleLabels['tabs_images'][$modName.'_tab']) { 00814 $icon = $this->mIconFilename($LANG->moduleLabels['tabs_images'][$modName.'_tab'],''); 00815 } elseif ($modName=='xMOD_alt_doc.php') { 00816 $icon = 'gfx/edit2.gif'; 00817 } elseif ($modName=='xMOD_file_edit.php') { 00818 $icon = 'gfx/edit_file.gif'; 00819 } elseif ($modName=='xMOD_wizard_rte.php') { 00820 $icon = 'gfx/edit_rtewiz.gif'; 00821 } else { 00822 $icon = 'gfx/dummy_module.gif'; 00823 } 00824 return $icon; 00825 } 00826 00827 /** 00828 * Returns title-label for icon 00829 * 00830 * @param string In-label 00831 * @param string Backend module name (key) 00832 * @param string Backend module label (user defined?) 00833 * @return string Label for the shortcut item 00834 */ 00835 function itemLabel($inlabel,$modName,$M_modName='') { 00836 global $LANG; 00837 if (substr($modName,0,5)=='xMOD_') { 00838 $label=substr($modName,5); 00839 } else { 00840 $split = explode('_',$modName); 00841 $label = $LANG->moduleLabels['tabs'][$split[0].'_tab']; 00842 if (count($split)>1) { 00843 $label.='>'.$LANG->moduleLabels['tabs'][$modName.'_tab']; 00844 } 00845 } 00846 if ($M_modName) $label.=' ('.$M_modName.')'; 00847 $label.=': '.$inlabel; 00848 return $label; 00849 } 00850 00851 /** 00852 * Return the ID of the page in the URL if found. 00853 * 00854 * @param string The URL of the current shortcut link 00855 * @return string If a page ID was found, it is returned. Otherwise: 0 00856 */ 00857 function getLinkedPageId($url) { 00858 return preg_replace('/.*[\?&]id=([^&]+).*/', '$1', $url); 00859 } 00860 00861 /** 00862 * Checks if user has access to Workspace module. 00863 * 00864 * @return boolean Returns true if user has access to workspace module. 00865 */ 00866 function hasWorkspaceAccess() { 00867 $MCONF = array(); 00868 include('mod/user/ws/conf.php'); 00869 return $GLOBALS['BE_USER']->modAccess(array('name' => 'user', 'access' => 'user,group'), false) && $GLOBALS['BE_USER']->modAccess($MCONF, false); 00870 } 00871 } 00872 00873 00874 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/alt_shortcut.php'])) { 00875 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/alt_shortcut.php']); 00876 } 00877 00878 00879 00880 // Make instance: 00881 $SOBE = t3lib_div::makeInstance('SC_alt_shortcut'); 00882 $SOBE->preinit(); 00883 $SOBE->preprocess(); 00884 $SOBE->init(); 00885 $SOBE->main(); 00886 $SOBE->printContent(); 00887 00888 ?>
1.8.0