00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00064 require('init.php');
00065 require('template.php');
00066 $LANG->includeLLFile('EXT:lang/locallang_misc.xml');
00067 require_once(PATH_t3lib.'class.t3lib_loadmodules.php');
00068 require_once(PATH_t3lib.'class.t3lib_basicfilefunc.php');
00069
00070
00071
00072
00073
00074
00082 class SC_alt_shortcut {
00083
00084
00085 var $modName;
00086 var $M_modName;
00087 var $URL;
00088 var $editSC;
00089 var $deleteCategory;
00090 var $editName;
00091 var $editGroup;
00092 var $whichItem;
00093
00094
00095 var $loadModules;
00096 var $doc;
00097 var $nGroups;
00098 var $nGlobals;
00099
00100
00101 var $content;
00102 var $lines;
00103
00104 var $editLoaded;
00105 var $editError;
00106 var $editPath;
00107 var $editSC_rec;
00108 var $theEditRec;
00109 var $editPage;
00110 var $selOpt;
00111
00112
00118 function preinit() {
00119 global $TBE_MODULES;
00120
00121
00122 $this->modName = t3lib_div::_GP('modName');
00123 $this->M_modName = t3lib_div::_GP('motherModName');
00124 $this->URL = t3lib_div::_GP('URL');
00125 $this->editSC = t3lib_div::_GP('editShortcut');
00126
00127 $this->deleteCategory = t3lib_div::_GP('deleteCategory');
00128 $this->editPage = t3lib_div::_GP('editPage');
00129 $this->editName = t3lib_div::_GP('editName');
00130 $this->editGroup = t3lib_div::_GP('editGroup');
00131 $this->whichItem = t3lib_div::_GP('whichItem');
00132
00133
00134 $this->loadModules = t3lib_div::makeInstance('t3lib_loadModules');
00135 $this->loadModules->load($TBE_MODULES);
00136 }
00137
00143 function preprocess() {
00144 global $BE_USER;
00145
00146
00147 if ($this->modName && $this->URL) {
00148 $fields_values = array(
00149 'userid' => $BE_USER->user['uid'],
00150 'module_name' => $this->modName.'|'.$this->M_modName,
00151 'url' => $this->URL,
00152 'sorting' => time()
00153 );
00154 $GLOBALS['TYPO3_DB']->exec_INSERTquery('sys_be_shortcuts', $fields_values);
00155 }
00156
00157
00158 $addUSERWhere = (!$BE_USER->isAdmin()?' AND userid='.intval($BE_USER->user['uid']):'');
00159
00160
00161 if (strcmp($this->deleteCategory,'')) {
00162 if (t3lib_div::testInt($this->deleteCategory)) {
00163 $GLOBALS['TYPO3_DB']->exec_DELETEquery('sys_be_shortcuts', 'sc_group='.intval($this->deleteCategory).$addUSERWhere);
00164 }
00165 }
00166
00167
00168 if (is_array($_POST)) {
00169
00170 if (isset($_POST['_savedok_x']) || isset($_POST['_saveclosedok_x'])) {
00171 $fields_values = array(
00172 'description' => $this->editName,
00173 'sc_group' => intval($this->editGroup)
00174 );
00175 if ($fields_values['sc_group']<0 && !$BE_USER->isAdmin()) {
00176 $fields_values['sc_group']=0;
00177 }
00178
00179 $GLOBALS['TYPO3_DB']->exec_UPDATEquery('sys_be_shortcuts', 'uid='.intval($this->whichItem).$addUSERWhere, $fields_values);
00180 }
00181
00182 if (isset($_POST['_savedok_x'])) {
00183 $this->editSC=$this->whichItem;
00184 }
00185
00186 if (isset($_POST['_deletedok_x'])) {
00187 $GLOBALS['TYPO3_DB']->exec_DELETEquery('sys_be_shortcuts', 'uid='.intval($this->whichItem).$addUSERWhere);
00188
00189 if (!$this->editSC) $this->editSC=-1;
00190 }
00191 }
00192
00193 }
00194
00200 function init() {
00201 global $BACK_PATH;
00202
00203 $this->doc = t3lib_div::makeInstance('template');
00204 $this->doc->backPath = $BACK_PATH;
00205 $this->doc->form='<form action="alt_shortcut.php" name="shForm" method="post">';
00206 $this->doc->docType='xhtml_trans';
00207 $this->doc->divClass='typo3-shortcut';
00208 $this->doc->JScode.=$this->doc->wrapScriptTags('
00209 function jump(url,modName,mainModName) {
00210
00211 top.fsMod.navFrameHighlightedID = new Array();
00212 if (top.content && top.content.nav_frame && top.content.nav_frame.refresh_nav) {
00213 top.content.nav_frame.refresh_nav();
00214 }
00215
00216 top.nextLoadModuleUrl = url;
00217 top.goToModule(modName);
00218 }
00219 function editSh(uid) {
00220 document.location="alt_shortcut.php?editShortcut="+uid;
00221 }
00222 function submitEditPage(id) {
00223 document.location="alt_shortcut.php?editPage="+top.rawurlencode(id);
00224 }
00225 ');
00226 $this->content.=$this->doc->startPage('Shortcut frame');
00227 }
00228
00234 function main() {
00235 global $BE_USER,$LANG;
00236
00237
00238 $this->nGroups=4;
00239 $this->nGlobals=5;
00240
00241 $globalGroups=array(-100);
00242 $shortCutGroups = $BE_USER->getTSConfig('options.shortcutGroups');
00243 for($a=1;$a<=$this->nGlobals;$a++) {
00244 if ($BE_USER->isAdmin() || strcmp($shortCutGroups['properties'][$a],'')) {
00245 $globalGroups[]=-$a;
00246 }
00247 }
00248
00249
00250 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_be_shortcuts', '((userid='.$BE_USER->user['uid'].' AND sc_group>=0) OR sc_group IN ('.implode(',',$globalGroups).'))', '', 'sc_group,sorting');
00251
00252
00253 $this->lines=array();
00254 $this->editSC_rec='';
00255 $this->selOpt=array();
00256 $formerGr='';
00257
00258
00259 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00260 if ($this->editSC && $row['uid']==$this->editSC) {
00261 $this->editSC_rec=$row;
00262 }
00263
00264 if (strcmp($formerGr,$row['sc_group'])) {
00265 if ($row['sc_group']!=-100) {
00266 if ($row['sc_group']>=0) {
00267 $onC = 'if (confirm('.$GLOBALS['LANG']->JScharCode($LANG->getLL('shortcut_delAllInCat')).')){document.location=\'alt_shortcut.php?deleteCategory='.$row['sc_group'].'\';}return false;';
00268 $this->lines[]='<td> </td><td class="bgColor5"><a href="#" onclick="'.htmlspecialchars($onC).'" title="'.$LANG->getLL('shortcut_delAllInCat',1).'">'.abs($row['sc_group']).'</a></td>';
00269 } else {
00270 $this->lines[]='<td> </td><td class="bgColor5">'.abs($row['sc_group']).'</td>';
00271 }
00272 }
00273 }
00274
00275 $mParts = explode('|',$row['module_name']);
00276 $row['module_name']=$mParts[0];
00277 $row['M_module_name']=$mParts[1];
00278 $mParts = explode('_',$row['M_module_name']?$row['M_module_name']:$row['module_name']);
00279 $qParts = parse_url($row['url']);
00280
00281 $bgColorClass = $row['uid']==$this->editSC ? 'bgColor5' : ($row['sc_group']<0 ? 'bgColor6' : 'bgColor4');
00282 $titleA = $this->itemLabel($row['description']&&($row['uid']!=$this->editSC) ? $row['description'] : t3lib_div::fixed_lgd(rawurldecode($qParts['query']),150),$row['module_name'],$row['M_module_name']);
00283
00284 $editSH = ($row['sc_group']>=0 || $BE_USER->isAdmin()) ? 'editSh('.intval($row['uid']).');' : "alert('".$LANG->getLL('shortcut_onlyAdmin')."')";
00285 $jumpSC = 'jump(unescape(\''.rawurlencode($row['url']).'\'),\''.implode('_',$mParts).'\',\''.$mParts[0].'\');';
00286 $onC = 'if (document.shForm.editShortcut_check && document.shForm.editShortcut_check.checked){'.$editSH.'}else{'.$jumpSC.'}return false;';
00287 $this->lines[]='<td class="'.$bgColorClass.'"><a href="#" onclick="'.htmlspecialchars($onC).'"><img src="'.$this->getIcon($row['module_name']).'" title="'.htmlspecialchars($titleA).'" alt="" /></a></td>';
00288 if (trim($row['description'])) {
00289 $kkey = strtolower(substr($row['description'],0,20)).'_'.$row['uid'];
00290 $this->selOpt[$kkey]='<option value="'.htmlspecialchars($jumpSC).'">'.htmlspecialchars(t3lib_div::fixed_lgd_cs($row['description'],50)).'</option>';
00291 }
00292 $formerGr=$row['sc_group'];
00293 }
00294 ksort($this->selOpt);
00295 array_unshift($this->selOpt,'<option>['.$LANG->getLL('shortcut_selSC',1).']</option>');
00296
00297 $this->editLoadedFunc();
00298 $this->editPageIdFunc();
00299
00300 if (!$this->editLoaded && t3lib_extMgm::isLoaded('cms')) {
00301 $editIdCode = '<td nowrap="nowrap">'.$LANG->getLL('shortcut_editID',1).': <input type="text" value="'.($this->editError?htmlspecialchars($this->editPage):'').'" name="editPage"'.$this->doc->formWidth(5).' onchange="submitEditPage(this.value);" />'.
00302 ($this->editError?' <strong><span class="typo3-red">'.htmlspecialchars($this->editError).'</span></strong>':'').
00303 (is_array($this->theEditRec)?' <strong>'.$LANG->getLL('shortcut_loadEdit',1).' \''.t3lib_BEfunc::getRecordTitle('pages',$this->theEditRec,1).'\'</strong> ('.htmlspecialchars($this->editPath).')':'').
00304 '</td>';
00305 } else $editIdCode = '';
00306
00307
00308 $editIdCode.= '<td> '.t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'shortcuts', $GLOBALS['BACK_PATH'],'',TRUE).'</td>';
00309
00310 $this->content.='
00311
00312
00313 <!--
00314 Shortcut Display Table:
00315 -->
00316 <table border="0" cellpadding="0" cellspacing="2" id="typo3-shortcuts">
00317 <tr>
00318 '.implode('
00319 ',$this->lines).$editIdCode.'
00320 </tr>
00321 </table>
00322
00323 ';
00324
00325 if ($this->theEditRec['uid']) {
00326 $this->content.=$this->doc->wrapScriptTags('top.loadEditId('.$this->theEditRec['uid'].');');
00327 }
00328 }
00329
00335 function editLoadedFunc() {
00336 global $BE_USER,$LANG;
00337
00338 $this->editLoaded=0;
00339 if (is_array($this->editSC_rec) && ($this->editSC_rec['sc_group']>=0 || $BE_USER->isAdmin())) {
00340 $this->editLoaded=1;
00341
00342 $opt=array();
00343 $opt[]='<option value="0"></option>';
00344 for($a=1;$a<=$this->nGroups;$a++) {
00345 $opt[]='<option value="'.$a.'"'.(!strcmp($this->editSC_rec['sc_group'],$a)?' selected="selected"':'').'>'.$LANG->getLL('shortcut_group',1).' '.$a.'</option>';
00346 }
00347 if ($BE_USER->isAdmin()) {
00348 for($a=1;$a<=$this->nGlobals;$a++) {
00349 $opt[]='<option value="-'.$a.'"'.(!strcmp($this->editSC_rec['sc_group'],'-'.$a)?' selected="selected"':'').'>'.$LANG->getLL('shortcut_GLOBAL',1).': '.$a.'</option>';
00350 }
00351 $opt[]='<option value="-100"'.(!strcmp($this->editSC_rec['sc_group'],'-100')?' selected="selected"':'').'>'.$LANG->getLL('shortcut_GLOBAL',1).': '.$LANG->getLL('shortcut_ALL',1).'</option>';
00352 }
00353
00354
00355 $manageForm='
00356
00357
00358 <!--
00359 Shortcut Editing Form:
00360 -->
00361 <table border="0" cellpadding="0" cellspacing="0" id="typo3-shortcuts-editing">
00362 <tr>
00363 <td> </td>
00364 <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>
00365 <td><input type="image" class="c-inputButton" name="_saveclosedok"'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/saveandclosedok.gif','').' title="'.$LANG->getLL('shortcut_saveClose',1).'" /></td>
00366 <td><input type="image" class="c-inputButton" name="_closedok"'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/closedok.gif','').' title="'.$LANG->getLL('shortcut_close',1).'" /></td>
00367 <td><input type="image" class="c-inputButton" name="_deletedok"'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/deletedok.gif','').' title="'.$LANG->getLL('shortcut_delete',1).'" /></td>
00368 <td><input name="editName" type="text" value="'.htmlspecialchars($this->editSC_rec['description']).'"'.$this->doc->formWidth(15).' /></td>
00369 <td><select name="editGroup">'.implode('',$opt).'</select></td>
00370 </tr>
00371 </table>
00372 <input type="hidden" name="whichItem" value="'.$this->editSC_rec['uid'].'" />
00373
00374 ';
00375 } else $manageForm='';
00376
00377 if (!$this->editLoaded && count($this->selOpt)>1) {
00378 $this->lines[]='<td> </td>';
00379 $this->lines[]='<td><select name="_selSC" onchange="eval(this.options[this.selectedIndex].value);this.selectedIndex=0;">'.implode('',$this->selOpt).'</select></td>';
00380 }
00381 if (count($this->lines)) {
00382 if (!$BE_USER->getTSConfigVal('options.mayNotCreateEditShortcuts')) {
00383 $this->lines=array_merge(array('<td><input type="checkbox" name="editShortcut_check" value="1"'.($this->editSC?' checked="checked"':'').' />'.$LANG->getLL('shortcut_edit',1).' </td>'),$this->lines);
00384 $this->lines[]='<td>'.$manageForm.'</td>';
00385 }
00386 $this->lines[]='<td><img src="clear.gif" width="10" height="1" alt="" /></td>';
00387 }
00388 }
00389
00396 function editPageIdFunc() {
00397 global $BE_USER,$LANG;
00398
00399 if (!t3lib_extMgm::isLoaded('cms')) return;
00400
00401
00402 $this->editPage = trim(strtolower($this->editPage));
00403 $this->editError = '';
00404 $this->theEditRec = '';
00405 if ($this->editPage) {
00406 $where = ' AND ('.$BE_USER->getPagePermsClause(2).' OR '.$BE_USER->getPagePermsClause(16).')';
00407 if (t3lib_div::testInt($this->editPage)) {
00408 $this->theEditRec = t3lib_BEfunc::getRecord ('pages',$this->editPage,'*',$where);
00409 } else {
00410 $records = t3lib_BEfunc::getRecordsByField('pages','alias',$this->editPage,$where);
00411 if (is_array($records)) {
00412 reset($records);
00413 $this->theEditRec = current($records);
00414 }
00415 }
00416 if (!is_array($this->theEditRec) || !$BE_USER->isInWebMount($this->theEditRec['uid'])) {
00417 unset($this->theEditRec);
00418 $this->editError=$LANG->getLL('shortcut_notEditable');
00419 } else {
00420
00421 $perms_clause = $BE_USER->getPagePermsClause(1);
00422 $this->editPath = t3lib_BEfunc::getRecordPath($this->theEditRec['pid'], $perms_clause, 30);
00423
00424 if(!$BE_USER->getTSConfigVal('options.shortcut_onEditId_dontSetPageTree')) {
00425
00426
00427 t3lib_BEfunc::openPageTree($this->theEditRec['pid'],!$BE_USER->getTSConfigVal('options.shortcut_onEditId_keepExistingExpanded'));
00428 }
00429 }
00430 }
00431 }
00432
00438 function printContent() {
00439 $this->content.= $this->doc->endPage();
00440 echo $this->content;
00441 }
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00466 function mIconFilename($Ifilename,$backPath) {
00467 if (t3lib_div::isAbsPath($Ifilename)) {
00468 $Ifilename = '../'.substr($Ifilename,strlen(PATH_site));
00469 }
00470 return $backPath.$Ifilename;
00471 }
00472
00479 function getIcon($modName) {
00480 global $LANG;
00481 if ($LANG->moduleLabels['tabs_images'][$modName.'_tab']) {
00482 $icon = $this->mIconFilename($LANG->moduleLabels['tabs_images'][$modName.'_tab'],'');
00483 } elseif ($modName=='xMOD_alt_doc.php') {
00484 $icon = 'gfx/edit2.gif';
00485 } elseif ($modName=='xMOD_file_edit.php') {
00486 $icon = 'gfx/edit_file.gif';
00487 } elseif ($modName=='xMOD_wizard_rte.php') {
00488 $icon = 'gfx/edit_rtewiz.gif';
00489 } else {
00490 $icon = 'gfx/dummy_module.gif';
00491 }
00492 return $icon;
00493 }
00494
00503 function itemLabel($inlabel,$modName,$M_modName='') {
00504 global $LANG;
00505 if (substr($modName,0,5)=='xMOD_') {
00506 $label=substr($modName,5);
00507 } else {
00508 $split = explode('_',$modName);
00509 $label = $LANG->moduleLabels['tabs'][$split[0].'_tab'];
00510 if (count($split)>1) {
00511 $label.='>'.$LANG->moduleLabels['tabs'][$modName.'_tab'];
00512 }
00513 }
00514 if ($M_modName) $label.=' ('.$M_modName.')';
00515 $label.=': '.$inlabel;
00516 return $label;
00517 }
00518 }
00519
00520
00521 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_shortcut.php']) {
00522 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_shortcut.php']);
00523 }
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534
00535
00536 $SOBE = t3lib_div::makeInstance('SC_alt_shortcut');
00537 $SOBE->preinit();
00538 $SOBE->preprocess();
00539 $SOBE->init();
00540 $SOBE->main();
00541 $SOBE->printContent();
00542 ?>