Documentation TYPO3 par Ameos

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


Généré par TYPO3 Ameos avec  doxygen 1.4.6