/src/typo3_src-4.2.0alpha1/typo3/alt_shortcut.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2005 Kasper Skaarhoj (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 ***************************************************************/
00068 require('init.php');
00069 require('template.php');
00070 $LANG->includeLLFile('EXT:lang/locallang_misc.xml');
00071 require_once(PATH_t3lib.'class.t3lib_loadmodules.php');
00072 require_once(PATH_t3lib.'class.t3lib_basicfilefunc.php');
00073 
00074 
00075 
00076 
00077 
00078 
00086 class SC_alt_shortcut {
00087 
00088                 // Internal, static: GPvar
00089         var $modName;
00090         var $M_modName;
00091         var $URL;
00092         var $editSC;
00093         var $deleteCategory;
00094         var $editName;
00095         var $editGroup;
00096         var $whichItem;
00097 
00098                 // Internal, static:
00104         var $loadModules;
00105 
00111         var $doc;
00112 
00113                 // Internal, dynamic:
00114         var $content;                   // Accumulation of output HTML (string)
00115         var $lines;                             // Accumulation of table cells (array)
00116 
00117         var $editLoaded;                // Flag for defining whether we are editing
00118         var $editError;                 // Can contain edit error message
00119         var $editPath;                  // Set to the record path of the record being edited.
00120         var $editSC_rec;                // Holds the shortcut record when editing
00121         var $theEditRec;                // Page record to be edited
00122         var $editPage;                  // Page alias or id to be edited
00123         var $selOpt;                    // Select options.
00124         var $searchFor;                 // Text to search for...
00125         var $groupLabels=array();       // Labels of all groups. If value is 1, the system will try to find a label in the locallang array.
00126 
00127         var $alternativeTableUid = array();     // Array with key 0/1 being table/uid of record to edit. Internally set.
00128 
00129 
00130 
00136         function preinit()      {
00137                 global $TBE_MODULES;
00138 
00139                         // Setting GPvars:
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 
00163         function preprocess()   {
00164                 global $BE_USER;
00165                 $description = '';      // Default description
00166                 $url = urldecode($this->URL);
00167 
00168                         // Lookup the title of this page and use it as default description
00169                 $page_id = $this->getLinkedPageId($url);
00170                 if (t3lib_div::testInt($page_id))       {
00171                         if (preg_match('/\&edit\[(.*)\]\[(.*)\]=edit/',$url,$matches))  {
00172                                         // Edit record
00173                                 $description = '';      // TODO: Set something useful
00174                         } else {
00175                                         // Page listing
00176                                 $pageRow = t3lib_BEfunc::getRecord('pages',$page_id);
00177                                 if (count($pageRow))    {
00178                                                 // If $page_id is an integer, set the description to the title of that page
00179                                         $description = $pageRow['title'];
00180                                 }
00181                         }
00182                 } else {
00183                         if (preg_match('/\/$/', $page_id))      {
00184                                         // 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
00185                                 $description = basename($page_id);
00186                         }
00187                 }
00188 
00189 
00190                         // Adding a shortcut being set from another frame
00191                 if ($this->modName && $this->URL)       {
00192                         $fields_values = array(
00193                                 'userid' => $BE_USER->user['uid'],
00194                                 'module_name' => $this->modName.'|'.$this->M_modName,
00195                                 'url' => $this->URL,
00196                                 'description' => $description,
00197                                 'sorting' => time(),
00198                         );
00199                         $GLOBALS['TYPO3_DB']->exec_INSERTquery('sys_be_shortcuts', $fields_values);
00200                 }
00201 
00202                         // Selection-clause for users - so users can deleted only their own shortcuts (except admins)
00203                 $addUSERWhere = (!$BE_USER->isAdmin()?' AND userid='.intval($BE_USER->user['uid']):'');
00204 
00205                         // Deleting shortcuts:
00206                 if (strcmp($this->deleteCategory,''))   {
00207                         if (t3lib_div::testInt($this->deleteCategory))  {
00208                                 $GLOBALS['TYPO3_DB']->exec_DELETEquery('sys_be_shortcuts', 'sc_group='.intval($this->deleteCategory).$addUSERWhere);
00209                         }
00210                 }
00211 
00212                         // If other changes in post-vars:
00213                 if (is_array($_POST))   {
00214                                 // Saving:
00215                         if (isset($_POST['_savedok_x']) || isset($_POST['_saveclosedok_x']))    {
00216                                 $fields_values = array(
00217                                         'description' => $this->editName,
00218                                         'sc_group' => intval($this->editGroup)
00219                                 );
00220                                 if ($fields_values['sc_group']<0 && !$BE_USER->isAdmin())       {
00221                                         $fields_values['sc_group']=0;
00222                                 }
00223 
00224                                 $GLOBALS['TYPO3_DB']->exec_UPDATEquery('sys_be_shortcuts', 'uid='.intval($this->whichItem).$addUSERWhere, $fields_values);
00225                         }
00226                                 // If save without close, keep the session going...
00227                         if (isset($_POST['_savedok_x']))        {
00228                                 $this->editSC=$this->whichItem;
00229                         }
00230                                 // Deleting a single shortcut ?
00231                         if (isset($_POST['_deletedok_x']))      {
00232                                 $GLOBALS['TYPO3_DB']->exec_DELETEquery('sys_be_shortcuts', 'uid='.intval($this->whichItem).$addUSERWhere);
00233 
00234                                 if (!$this->editSC)     $this->editSC=-1;       // Just to have the checkbox set...
00235                         }
00236                 }
00237 
00238         }
00239 
00245         function init() {
00246                 global $BACK_PATH;
00247 
00248                 $this->doc = t3lib_div::makeInstance('template');
00249                 $this->doc->backPath = $BACK_PATH;
00250                 $this->doc->form='<form action="alt_shortcut.php" name="shForm" method="post">';
00251                 $this->doc->docType='xhtml_trans';
00252                 $this->doc->divClass='typo3-shortcut';
00253                 $this->doc->JScode.=$this->doc->wrapScriptTags('
00254                         function jump(url,modName,mainModName)  {       //
00255                                         // Clear information about which entry in nav. tree that might have been highlighted.
00256                                 top.fsMod.navFrameHighlightedID = new Array();
00257                                 if (top.content && top.content.nav_frame && top.content.nav_frame.refresh_nav)  {
00258                                         top.content.nav_frame.refresh_nav();
00259                                 }
00260 
00261                                 top.nextLoadModuleUrl = url;
00262                                 top.goToModule(modName);
00263                         }
00264                         function editSh(uid)    {       //
00265                                 window.location.href="alt_shortcut.php?editShortcut="+uid;
00266                         }
00267                         function submitEditPage(id)     {       //
00268                                 window.location.href="alt_shortcut.php?editPage="+top.rawurlencode(id);
00269                         }
00270                         function changeWorkspace(workspaceId)   {       //
00271                                 window.location.href="alt_shortcut.php?changeWorkspace="+top.rawurlencode(workspaceId);
00272                         }
00273                         function changeWorkspacePreview(newstate)       {       //
00274                                 window.location.href="alt_shortcut.php?changeWorkspacePreview="+newstate;
00275                         }
00276                         function refreshShortcuts() { 
00277                                 window.location.href = document.URL;
00278                         }
00279 
00280                         ');
00281                 $this->content.=$this->doc->startPage('Shortcut frame');
00282         }
00283 
00289         function main() {
00290                 global $BE_USER,$LANG,$TCA;
00291 
00292                         // By default, 5 groups are set
00293                 $this->groupLabels=array(
00294                         1 => 1,
00295                         2 => 1,
00296                         3 => 1,
00297                         4 => 1,
00298                         5 => 1,
00299                 );
00300 
00301                 $shortCutGroups = $BE_USER->getTSConfig('options.shortcutGroups');
00302                 if (is_array($shortCutGroups['properties']) && count($shortCutGroups['properties']))    {
00303                         foreach ($shortCutGroups['properties'] as $k=>$v)       {
00304                                 if (strcmp('',$v) && strcmp('0',$v))    {
00305                                         $this->groupLabels[$k] = (string)$v;
00306                                 } elseif ($BE_USER->isAdmin())  {
00307                                         unset($this->groupLabels[$k]);
00308                                 }
00309                         }
00310                 }
00311 
00312                         // List of global groups that will be loaded. All global groups have negative IDs.
00313                 $globalGroups = -100;   // Group -100 is kind of superglobal and can't be changed.
00314                 if (count($this->groupLabels))  {
00315                         $globalGroups .= ','.implode(',',array_keys($this->groupLabels));
00316                         $globalGroups = str_replace(',',',-',$globalGroups);    // Ugly hack to make the UIDs negative - is there any better solution?
00317                 }
00318 
00319                         // Fetching shortcuts to display for this user:
00320                 $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');
00321 
00322                         // Init vars:
00323                 $this->lines=array();
00324                 $this->linesPre=array();
00325                 $this->editSC_rec='';
00326                 $this->selOpt=array();
00327                 $formerGr='';
00328 
00329                         // Traverse shortcuts
00330                 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
00331                         $mParts = explode('|',$row['module_name']);
00332                         $row['module_name']=$mParts[0];
00333                         $row['M_module_name']=$mParts[1];
00334                         $mParts = explode('_',$row['M_module_name']?$row['M_module_name']:$row['module_name']);
00335                         $qParts = parse_url($row['url']);
00336 
00337                         if (!$BE_USER->isAdmin())       {
00338                                         // Check for module access
00339                                 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 :-)
00340                                         continue;
00341                                 }
00342 
00343                                 $page_id = $this->getLinkedPageId($row['url']);
00344                                 if (t3lib_div::testInt($page_id))       {
00345                                                 // Check for webmount access
00346                                         if (!$GLOBALS['BE_USER']->isInWebMount($page_id)) continue;
00347 
00348                                                 // Check for record access
00349                                         $pageRow = t3lib_BEfunc::getRecord('pages',$page_id);
00350                                         if (!$GLOBALS['BE_USER']->doesUserHaveAccess($pageRow,$perms=1)) continue;
00351                                 }
00352                         }
00353 
00354                         if ($this->editSC && $row['uid']==$this->editSC)        {
00355                                 $this->editSC_rec=$row;
00356                         }
00357 
00358                         $sc_group = $row['sc_group'];
00359                         if ($sc_group && strcmp($formerGr,$sc_group))   {
00360                                 if ($sc_group!=-100)    {
00361                                         if ($this->groupLabels[abs($sc_group)] && strcmp('1',$this->groupLabels[abs($sc_group)]))       {
00362                                                 $label = $this->groupLabels[abs($sc_group)];
00363                                         } else {
00364                                                 $label = $LANG->getLL('shortcut_group_'.abs($sc_group),1);
00365                                                 if (!$label)    $label = $LANG->getLL('shortcut_group',1).' '.abs($sc_group);   // Fallback label
00366                                         }
00367 
00368                                         if ($sc_group>=0)       {
00369                                                 $onC = 'if (confirm('.$GLOBALS['LANG']->JScharCode($LANG->getLL('shortcut_delAllInCat')).')){window.location.href=\'alt_shortcut.php?deleteCategory='.$sc_group.'\';}return false;';
00370                                                 $this->linesPre[]='<td>&nbsp;</td><td class="bgColor5"><a href="#" onclick="'.htmlspecialchars($onC).'" title="'.$LANG->getLL('shortcut_delAllInCat',1).'">'.$label.'</a></td>';
00371                                         } else {
00372                                                 $label = $LANG->getLL('shortcut_global',1).': '.($label ? $label : abs($sc_group));     // Fallback label
00373                                                 $this->lines[]='<td>&nbsp;</td><td class="bgColor5">'.$label.'</td>';
00374                                         }
00375                                         unset($label);
00376                                 }
00377                         }
00378 
00379                         $bgColorClass = $row['uid']==$this->editSC ? 'bgColor5' : ($row['sc_group']<0 ? 'bgColor6' : 'bgColor4');
00380 
00381                         if ($row['description']&&($row['uid']!=$this->editSC))  {
00382                                 $label = $row['description'];
00383                         } else {
00384                                 $label = t3lib_div::fixed_lgd(rawurldecode($qParts['query']),150);
00385                         }
00386                         $titleA = $this->itemLabel($label,$row['module_name'],$row['M_module_name']);
00387 
00388                         $editSH = ($row['sc_group']>=0 || $BE_USER->isAdmin()) ? 'editSh('.intval($row['uid']).');' : "alert('".$LANG->getLL('shortcut_onlyAdmin')."')";
00389                         $jumpSC = 'jump(unescape(\''.rawurlencode($row['url']).'\'),\''.implode('_',$mParts).'\',\''.$mParts[0].'\');';
00390                         $onC = 'if (document.shForm.editShortcut_check && document.shForm.editShortcut_check.checked){'.$editSH.'}else{'.$jumpSC.'}return false;';
00391                         if ($sc_group>=0)       {       // user defined groups show up first
00392                                 $this->linesPre[]='<td class="'.$bgColorClass.'"><a href="#" onclick="'.htmlspecialchars($onC).'"><img src="'.$this->getIcon($row['module_name']).'" title="'.htmlspecialchars($titleA).'" alt="" /></a></td>';
00393                         } else {
00394                                 $this->lines[]='<td class="'.$bgColorClass.'"><a href="#" onclick="'.htmlspecialchars($onC).'"><img src="'.$this->getIcon($row['module_name']).'" title="'.htmlspecialchars($titleA).'" alt="" /></a></td>';
00395                         }
00396                         if (trim($row['description']))  {
00397                                 $kkey = strtolower(substr($row['description'],0,20)).'_'.$row['uid'];
00398                                 $this->selOpt[$kkey]='<option value="'.htmlspecialchars($jumpSC).'">'.htmlspecialchars(t3lib_div::fixed_lgd_cs($row['description'],50)).'</option>';
00399                         }
00400                         $formerGr=$row['sc_group'];
00401                 }
00402                 ksort($this->selOpt);
00403                 array_unshift($this->selOpt,'<option>['.$LANG->getLL('shortcut_selSC',1).']</option>');
00404 
00405                 $this->editLoadedFunc();
00406                 $this->editPageIdFunc();
00407 
00408                 if (!$this->editLoaded && t3lib_extMgm::isLoaded('cms'))        {
00409                                 $editIdCode = '<td nowrap="nowrap">'.$LANG->getLL('shortcut_editID',1).': <input type="text" value="'.($this->editError?htmlspecialchars($this->editPage):'').'" name="editPage"'.$this->doc->formWidth(15).' onchange="submitEditPage(this.value);" />'.
00410                                         ($this->editError?'&nbsp;<strong><span class="typo3-red">'.htmlspecialchars($this->editError).'</span></strong>':'').
00411                                         (is_array($this->theEditRec)?'&nbsp;<strong>'.$LANG->getLL('shortcut_loadEdit',1).' \''.t3lib_BEfunc::getRecordTitle('pages',$this->theEditRec,TRUE).'\'</strong> ('.htmlspecialchars($this->editPath).')':'').
00412                                         ($this->searchFor?'&nbsp;'.$LANG->getLL('shortcut_searchFor',1).' <strong>\''.htmlspecialchars($this->searchFor).'\'</strong>':'').
00413                                         '</td>';
00414                 } else $editIdCode = '';
00415 
00416                         // Adding CSH:
00417                 $editIdCode.= '<td>&nbsp;'.t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'shortcuts', $GLOBALS['BACK_PATH'],'',TRUE).'</td>';
00418 
00419                         // Compile it all:
00420                 $this->content.='
00421 
00422                         <table border="0" cellpadding="0" cellspacing="0" width="99%">
00423                                 <tr>
00424                                         <td>
00425                                                 <!--
00426                                                         Shortcut Display Table:
00427                                                 -->
00428                                                 <table border="0" cellpadding="0" cellspacing="2" id="typo3-shortcuts">
00429                                                         <tr>
00430                                                         '.implode('
00431                                                         ',$this->lines).$editIdCode.'
00432                                                         </tr>
00433                                                 </table>
00434                                         </td>
00435                                         <td align="right">';
00436                 if ($this->hasWorkspaceAccess()) {
00437                         $this->content .= $this->workspaceSelector() .
00438                                                                 t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'workspaceSelector', $GLOBALS['BACK_PATH'],'',TRUE);
00439                 }
00440                 $this->content .= '
00441                                         </td>
00442                                 </tr>
00443                         </table>
00444                         ';
00445 
00446                         // Launch Edit page:
00447                 if ($this->theEditRec['uid'])   {
00448                         $this->content.=$this->doc->wrapScriptTags('top.loadEditId('.$this->theEditRec['uid'].');');
00449                 }
00450 
00451                         // Load alternative table/uid into editing form.
00452                 if (count($this->alternativeTableUid)==2 && isset($TCA[$this->alternativeTableUid[0]]) && t3lib_div::testInt($this->alternativeTableUid[1]))    {
00453                         $JSaction = t3lib_BEfunc::editOnClick('&edit['.$this->alternativeTableUid[0].']['.$this->alternativeTableUid[1].']=edit','','dummy.php');
00454                         $this->content.=$this->doc->wrapScriptTags('function editArbitraryElement() { top.content.'.$JSaction.'; } editArbitraryElement();');
00455                 }
00456 
00457                         // Load search for something.
00458                 if ($this->searchFor)   {
00459                         $firstMP = intval($GLOBALS['WEBMOUNTS'][0]);
00460                         $this->content.= $this->doc->wrapScriptTags('jump(unescape("'.rawurlencode('db_list.php?id='.$firstMP.'&search_field='.rawurlencode($this->searchFor).'&search_levels=4').'"),"web_list","web");');
00461                 }
00462         }
00463 
00469         function editLoadedFunc()       {
00470                 global $BE_USER,$LANG;
00471 
00472                 $this->editLoaded=0;
00473                 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.
00474                         $this->editLoaded=1;
00475 
00476                         $opt=array();
00477                         $opt[]='<option value="0"></option>';
00478 
00479                         foreach($this->groupLabels as $k=>$v)   {
00480                                 if ($v && strcmp('1',$v))       {
00481                                         $label = $v;
00482                                 } else {
00483                                         $label = $LANG->getLL('shortcut_group_'.$k,1);
00484                                         if (!$label)    $label = $LANG->getLL('shortcut_group',1).' '.$k;       // Fallback label
00485                                 }
00486                                 $opt[]='<option value="'.$k.'"'.(!strcmp($this->editSC_rec['sc_group'],$k)?' selected="selected"':'').'>'.$label.'</option>';
00487                         }
00488 
00489                         if ($BE_USER->isAdmin())        {
00490                                 foreach($this->groupLabels as $k=>$v)   {
00491                                         if ($v && strcmp('1',$v))       {
00492                                                 $label = $v;
00493                                         } else {
00494                                                 $label = $LANG->getLL('shortcut_group_'.$k,1);
00495                                                 if (!$label)    $label = $LANG->getLL('shortcut_group',1).' '.$k;       // Fallback label
00496                                         }
00497                                         $label = $LANG->getLL('shortcut_global',1).': '.$label; // Add a prefix for global groups
00498 
00499                                         $opt[]='<option value="-'.$k.'"'.(!strcmp($this->editSC_rec['sc_group'],'-'.$k)?' selected="selected"':'').'>'.$label.'</option>';
00500                                 }
00501                                 $opt[]='<option value="-100"'.(!strcmp($this->editSC_rec['sc_group'],'-100')?' selected="selected"':'').'>'.$LANG->getLL('shortcut_global',1).': '.$LANG->getLL('shortcut_all',1).'</option>';
00502                         }
00503 
00504                                 // border="0" hspace="2" width="21" height="16" - not XHTML compliant in <input type="image" ...>
00505                         $manageForm='
00506 
00507                                 <!--
00508                                         Shortcut Editing Form:
00509                                 -->
00510                                 <table border="0" cellpadding="0" cellspacing="0" id="typo3-shortcuts-editing">
00511                                         <tr>
00512                                                 <td>&nbsp;&nbsp;</td>
00513                                                 <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>
00514                                                 <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>
00515                                                 <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>
00516                                                 <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>
00517                                                 <td><input name="editName" type="text" value="'.htmlspecialchars($this->editSC_rec['description']).'"'.$this->doc->formWidth(15).' /></td>
00518                                                 <td><select name="editGroup">'.implode('',$opt).'</select></td>
00519                                         </tr>
00520                                 </table>
00521                                 <input type="hidden" name="whichItem" value="'.$this->editSC_rec['uid'].'" />
00522 
00523                                 ';
00524                 } else $manageForm='';
00525 
00526                 if (!$this->editLoaded && count($this->selOpt)>1)       {
00527                         $this->lines[]='<td>&nbsp;</td>';
00528                         $this->lines[]='<td><select name="_selSC" onchange="eval(this.options[this.selectedIndex].value);this.selectedIndex=0;">'.implode('',$this->selOpt).'</select></td>';
00529                 }
00530 
00531                         // $this->linesPre contains elements with sc_group>=0
00532                 $this->lines = array_merge($this->linesPre,$this->lines);
00533 
00534                 if (count($this->lines))        {
00535                         if (!$BE_USER->getTSConfigVal('options.mayNotCreateEditShortcuts'))     {
00536                                 $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('shortcut_edit',1).'</label>&nbsp;</td>'),$this->lines);
00537                                 $this->lines[]='<td>'.$manageForm.'</td>';
00538                         }
00539                         $this->lines[]='<td><img src="clear.gif" width="10" height="1" alt="" /></td>';
00540                 }
00541         }
00542 
00549         function editPageIdFunc()       {
00550                 global $BE_USER,$LANG;
00551 
00552                 if (!t3lib_extMgm::isLoaded('cms'))     return;
00553 
00554                         // EDIT page:
00555                 $this->editPage = trim($LANG->csConvObj->conv_case($LANG->charSet,$this->editPage,'toLower'));
00556                 $this->editError = '';
00557                 $this->theEditRec = '';
00558                 $this->searchFor = '';
00559                 if ($this->editPage)    {
00560 
00561                                 // First, test alternative value consisting of [table]:[uid] and if not found, proceed with traditional page ID resolve:
00562                         $this->alternativeTableUid = explode(':',$this->editPage);
00563                         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.
00564 
00565                                 $where = ' AND ('.$BE_USER->getPagePermsClause(2).' OR '.$BE_USER->getPagePermsClause(16).')';
00566                                 if (t3lib_div::testInt($this->editPage))        {
00567                                         $this->theEditRec = t3lib_BEfunc::getRecordWSOL('pages',$this->editPage,'*',$where);
00568                                 } else {
00569                                         $records = t3lib_BEfunc::getRecordsByField('pages','alias',$this->editPage,$where);
00570                                         if (is_array($records)) {
00571                                                 reset($records);
00572                                                 $this->theEditRec = current($records);
00573                                                 t3lib_BEfunc::workspaceOL('pages',$this->theEditRec);
00574                                         }
00575                                 }
00576                                 if (!is_array($this->theEditRec))       {
00577                                         unset($this->theEditRec);
00578                                         $this->searchFor = $this->editPage;
00579                                 } elseif (!$BE_USER->isInWebMount($this->theEditRec['uid'])) {
00580                                         unset($this->theEditRec);
00581                                         $this->editError=$LANG->getLL('shortcut_notEditable');
00582                                 } else {
00583 
00584                                                 // Visual path set:
00585                                         $perms_clause = $BE_USER->getPagePermsClause(1);
00586                                         $this->editPath = t3lib_BEfunc::getRecordPath($this->theEditRec['pid'], $perms_clause, 30);
00587 
00588                                         if(!$BE_USER->getTSConfigVal('options.shortcut_onEditId_dontSetPageTree')) {
00589 
00590                                                         // Expanding page tree:
00591                                                 t3lib_BEfunc::openPageTree($this->theEditRec['pid'],!$BE_USER->getTSConfigVal('options.shortcut_onEditId_keepExistingExpanded'));
00592                                         }
00593                                 }
00594                         }
00595                 }
00596         }
00597 
00603         function printContent() {
00604                 $this->content.= $this->doc->endPage();
00605                 $this->content = $this->doc->insertStylesAndJS($this->content);
00606                 echo $this->content;
00607         }
00608 
00609 
00610 
00611 
00612 
00613 
00614 
00615 
00616 
00617         /***************************
00618          *
00619          * WORKSPACE FUNCTIONS:
00620          *
00621          ***************************/
00622 
00628         function workspaceSelector()    {
00629                 global $TYPO3_DB,$BE_USER,$LANG;
00630 
00631                         // Changing workspace and if so, reloading entire backend:
00632                 if (strlen($this->changeWorkspace))     {
00633                         $BE_USER->setWorkspace($this->changeWorkspace);
00634                         return $this->doc->wrapScriptTags('top.location.href="alt_main.php";');
00635                 }
00636                         // Changing workspace and if so, reloading entire backend:
00637                 if (strlen($this->changeWorkspacePreview))      {
00638                         $BE_USER->setWorkspacePreview($this->changeWorkspacePreview);
00639                 }
00640 
00641                         // Create options array:
00642                 $options = array();
00643                 if ($BE_USER->checkWorkspace(array('uid' => 0)))        {
00644                         $options[0] = '['.$LANG->getLL('shortcut_onlineWS').']';
00645                 }
00646                 if ($BE_USER->checkWorkspace(array('uid' => -1)))       {
00647                         $options[-1] = '['.$LANG->getLL('shortcut_offlineWS').']';
00648                 }
00649 
00650                         // Add custom workspaces (selecting all, filtering by BE_USER check):
00651                 $workspaces = $TYPO3_DB->exec_SELECTgetRows('uid,title,adminusers,members,reviewers','sys_workspace','pid=0'.t3lib_BEfunc::deleteClause('sys_workspace'),'','title');
00652                 if (count($workspaces)) {
00653                         foreach ($workspaces as $rec)   {
00654                                 if ($BE_USER->checkWorkspace($rec))     {
00655                                         $options[$rec['uid']] = $rec['uid'].': '.$rec['title'];
00656                                 }
00657                         }
00658                 }
00659 
00660                         // Build selector box:
00661                 if (count($options))    {
00662                         foreach($options as $value => $label)   {
00663                                 $selected = ((int)$BE_USER->workspace===$value ? ' selected="selected"' : '');
00664                                 $options[$value] = '<option value="'.htmlspecialchars($value).'"'.$selected.'>'.htmlspecialchars($label).'</option>';
00665                         }
00666                 } else {
00667                         $options[] = '<option value="-99">'.$LANG->getLL('shortcut_noWSfound',1).'</option>';
00668                 }
00669 
00670                 $selector = '';
00671                         // Preview:
00672                 if ($BE_USER->workspace!==0)    {
00673                         $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"' : '').'/>&nbsp;';
00674                 }
00675 
00676                 $selector.= '<a href="mod/user/ws/index.php" target="content">'.
00677                                         t3lib_iconWorks::getIconImage('sys_workspace',array(),$this->doc->backPath,'align="top"').
00678                                         '</a>';
00679                 if (count($options) > 1) {
00680                         $selector .= '<select name="_workspaceSelector" onchange="changeWorkspace(this.options[this.selectedIndex].value);">'.implode('',$options).'</select>';
00681                 }
00682 
00683                 return $selector;
00684         }
00685 
00686 
00687 
00688 
00689 
00690 
00691 
00692         /***************************
00693          *
00694          * OTHER FUNCTIONS:
00695          *
00696          ***************************/
00697 
00705         function mIconFilename($Ifilename,$backPath)    {
00706                         // Change icon of fileadmin references - otherwise it doesn't differ with Web->List
00707                 $Ifilename = str_replace ('mod/file/list/list.gif', 'mod/file/file.gif', $Ifilename);
00708 
00709                 if (t3lib_div::isAbsPath($Ifilename))   {
00710                         $Ifilename = '../'.substr($Ifilename,strlen(PATH_site));
00711                 }
00712                 return $backPath.$Ifilename;
00713         }
00714 
00721         function getIcon($modName)      {
00722                 global $LANG;
00723                 if ($LANG->moduleLabels['tabs_images'][$modName.'_tab'])        {
00724                         $icon = $this->mIconFilename($LANG->moduleLabels['tabs_images'][$modName.'_tab'],'');
00725                 } elseif ($modName=='xMOD_alt_doc.php') {
00726                         $icon = 'gfx/edit2.gif';
00727                 } elseif ($modName=='xMOD_file_edit.php') {
00728                         $icon = 'gfx/edit_file.gif';
00729                 } elseif ($modName=='xMOD_wizard_rte.php') {
00730                         $icon = 'gfx/edit_rtewiz.gif';
00731                 } else {
00732                         $icon = 'gfx/dummy_module.gif';
00733                 }
00734                 return $icon;
00735         }
00736 
00745         function itemLabel($inlabel,$modName,$M_modName='')     {
00746                 global $LANG;
00747                 if (substr($modName,0,5)=='xMOD_')      {
00748                         $label=substr($modName,5);
00749                 } else {
00750                         $split = explode('_',$modName);
00751                         $label = $LANG->moduleLabels['tabs'][$split[0].'_tab'];
00752                         if (count($split)>1)    {
00753                                 $label.='>'.$LANG->moduleLabels['tabs'][$modName.'_tab'];
00754                         }
00755                 }
00756                 if ($M_modName) $label.=' ('.$M_modName.')';
00757                 $label.=': '.$inlabel;
00758                 return $label;
00759         }
00760 
00767         function getLinkedPageId($url)  {
00768                 return preg_replace('/.*[\?&]id=([^&]+).*/', '$1', $url);
00769         }
00770 
00776         function hasWorkspaceAccess() {
00777                 $MCONF = array();
00778                 include('mod/user/ws/conf.php');
00779                 return $GLOBALS['BE_USER']->modAccess(array('name' => 'user', 'access' => 'user,group'), false) && $GLOBALS['BE_USER']->modAccess($MCONF, false);
00780         }
00781 }
00782 
00783 // Include extension?
00784 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_shortcut.php'])  {
00785         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_shortcut.php']);
00786 }
00787 
00788 
00789 
00790 
00791 
00792 
00793 
00794 
00795 
00796 
00797 
00798 // Make instance:
00799 $SOBE = t3lib_div::makeInstance('SC_alt_shortcut');
00800 $SOBE->preinit();
00801 $SOBE->preprocess();
00802 $SOBE->init();
00803 $SOBE->main();
00804 $SOBE->printContent();
00805 ?>

This documentation has been generated automatically from TYPO3 source code using Doxygen and is provided as is by Cast Iron Coding as a courtesy to other TYPO3 developers and users. Please consider Cast Iron Coding — a full-service web development agency in Portland, Oregon specializing in TYPO3 extension development — for all of your TYPO3 development and consulting needs!