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,TRUE).'\'</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                 if ($this->hasWorkspaceAccess()) {
00423                         $this->content .= $this->workspaceSelector() .
00424                                                                 t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'workspaceSelector', $GLOBALS['BACK_PATH'],'',TRUE);
00425                 }
00426                 $this->content .= '
00427                                         </td>
00428                                 </tr>
00429                         </table>
00430                         ';
00431 
00432                         // Launch Edit page:
00433                 if ($this->theEditRec['uid'])   {
00434                         $this->content.=$this->doc->wrapScriptTags('top.loadEditId('.$this->theEditRec['uid'].');');
00435                 }
00436 
00437                         // Load alternative table/uid into editing form.
00438                 if (count($this->alternativeTableUid)==2 && isset($TCA[$this->alternativeTableUid[0]]) && t3lib_div::testInt($this->alternativeTableUid[1]))    {
00439                         $JSaction = t3lib_BEfunc::editOnClick('&edit['.$this->alternativeTableUid[0].']['.$this->alternativeTableUid[1].']=edit','','dummy.php');
00440                         $this->content.=$this->doc->wrapScriptTags('function editArbitraryElement() { top.content.'.$JSaction.'; } editArbitraryElement();');
00441                 }
00442 
00443                         // Load search for something.
00444                 if ($this->searchFor)   {
00445                         $firstMP = intval($GLOBALS['WEBMOUNTS'][0]);
00446                         $this->content.= $this->doc->wrapScriptTags('jump(unescape("'.rawurlencode('db_list.php?id='.$firstMP.'&search_field='.rawurlencode($this->searchFor).'&search_levels=4').'"),"web_list","web");');
00447                 }
00448         }
00449 
00455         function editLoadedFunc()       {
00456                 global $BE_USER,$LANG;
00457 
00458                 $this->editLoaded=0;
00459                 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.
00460                         $this->editLoaded=1;
00461 
00462                         $opt=array();
00463                         $opt[]='<option value="0"></option>';
00464 
00465                         foreach($this->groupLabels as $k=>$v)   {
00466                                 if ($v && strcmp('1',$v))       {
00467                                         $label = $v;
00468                                 } else {
00469                                         $label = $LANG->getLL('shortcut_group_'.$k,1);
00470                                         if (!$label)    $label = $LANG->getLL('shortcut_group',1).' '.$k;       // Fallback label
00471                                 }
00472                                 $opt[]='<option value="'.$k.'"'.(!strcmp($this->editSC_rec['sc_group'],$k)?' selected="selected"':'').'>'.$label.'</option>';
00473                         }
00474 
00475                         if ($BE_USER->isAdmin())        {
00476                                 foreach($this->groupLabels as $k=>$v)   {
00477                                         if ($v && strcmp('1',$v))       {
00478                                                 $label = $v;
00479                                         } else {
00480                                                 $label = $LANG->getLL('shortcut_group_'.$k,1);
00481                                                 if (!$label)    $label = $LANG->getLL('shortcut_group',1).' '.$k;       // Fallback label
00482                                         }
00483                                         $label = $LANG->getLL('shortcut_global',1).': '.$label; // Add a prefix for global groups
00484 
00485                                         $opt[]='<option value="-'.$k.'"'.(!strcmp($this->editSC_rec['sc_group'],'-'.$k)?' selected="selected"':'').'>'.$label.'</option>';
00486                                 }
00487                                 $opt[]='<option value="-100"'.(!strcmp($this->editSC_rec['sc_group'],'-100')?' selected="selected"':'').'>'.$LANG->getLL('shortcut_global',1).': '.$LANG->getLL('shortcut_all',1).'</option>';
00488                         }
00489 
00490                                 // border="0" hspace="2" width="21" height="16" - not XHTML compliant in <input type="image" ...>
00491                         $manageForm='
00492 
00493                                 <!--
00494                                         Shortcut Editing Form:
00495                                 -->
00496                                 <table border="0" cellpadding="0" cellspacing="0" id="typo3-shortcuts-editing">
00497                                         <tr>
00498                                                 <td>&nbsp;&nbsp;</td>
00499                                                 <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>
00500                                                 <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>
00501                                                 <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>
00502                                                 <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>
00503                                                 <td><input name="editName" type="text" value="'.htmlspecialchars($this->editSC_rec['description']).'"'.$this->doc->formWidth(15).' /></td>
00504                                                 <td><select name="editGroup">'.implode('',$opt).'</select></td>
00505                                         </tr>
00506                                 </table>
00507                                 <input type="hidden" name="whichItem" value="'.$this->editSC_rec['uid'].'" />
00508 
00509                                 ';
00510                 } else $manageForm='';
00511 
00512                 if (!$this->editLoaded && count($this->selOpt)>1)       {
00513                         $this->lines[]='<td>&nbsp;</td>';
00514                         $this->lines[]='<td><select name="_selSC" onchange="eval(this.options[this.selectedIndex].value);this.selectedIndex=0;">'.implode('',$this->selOpt).'</select></td>';
00515                 }
00516 
00517                         // $this->linesPre contains elements with sc_group>=0
00518                 $this->lines = array_merge($this->linesPre,$this->lines);
00519 
00520                 if (count($this->lines))        {
00521                         if (!$BE_USER->getTSConfigVal('options.mayNotCreateEditShortcuts'))     {
00522                                 $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);
00523                                 $this->lines[]='<td>'.$manageForm.'</td>';
00524                         }
00525                         $this->lines[]='<td><img src="clear.gif" width="10" height="1" alt="" /></td>';
00526                 }
00527         }
00528 
00535         function editPageIdFunc()       {
00536                 global $BE_USER,$LANG;
00537 
00538                 if (!t3lib_extMgm::isLoaded('cms'))     return;
00539 
00540                         // EDIT page:
00541                 $this->editPage = trim($LANG->csConvObj->conv_case($LANG->charSet,$this->editPage,'toLower'));
00542                 $this->editError = '';
00543                 $this->theEditRec = '';
00544                 $this->searchFor = '';
00545                 if ($this->editPage)    {
00546 
00547                                 // First, test alternative value consisting of [table]:[uid] and if not found, proceed with traditional page ID resolve:
00548                         $this->alternativeTableUid = explode(':',$this->editPage);
00549                         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.
00550 
00551                                 $where = ' AND ('.$BE_USER->getPagePermsClause(2).' OR '.$BE_USER->getPagePermsClause(16).')';
00552                                 if (t3lib_div::testInt($this->editPage))        {
00553                                         $this->theEditRec = t3lib_BEfunc::getRecordWSOL('pages',$this->editPage,'*',$where);
00554                                 } else {
00555                                         $records = t3lib_BEfunc::getRecordsByField('pages','alias',$this->editPage,$where);
00556                                         if (is_array($records)) {
00557                                                 reset($records);
00558                                                 $this->theEditRec = current($records);
00559                                                 t3lib_BEfunc::workspaceOL('pages',$this->theEditRec);
00560                                         }
00561                                 }
00562                                 if (!is_array($this->theEditRec))       {
00563                                         unset($this->theEditRec);
00564                                         $this->searchFor = $this->editPage;
00565                                 } elseif (!$BE_USER->isInWebMount($this->theEditRec['uid'])) {
00566                                         unset($this->theEditRec);
00567                                         $this->editError=$LANG->getLL('shortcut_notEditable');
00568                                 } else {
00569 
00570                                                 // Visual path set:
00571                                         $perms_clause = $BE_USER->getPagePermsClause(1);
00572                                         $this->editPath = t3lib_BEfunc::getRecordPath($this->theEditRec['pid'], $perms_clause, 30);
00573 
00574                                         if(!$BE_USER->getTSConfigVal('options.shortcut_onEditId_dontSetPageTree')) {
00575 
00576                                                         // Expanding page tree:
00577                                                 t3lib_BEfunc::openPageTree($this->theEditRec['pid'],!$BE_USER->getTSConfigVal('options.shortcut_onEditId_keepExistingExpanded'));
00578                                         }
00579                                 }
00580                         }
00581                 }
00582         }
00583 
00589         function printContent() {
00590                 $this->content.= $this->doc->endPage();
00591                 $this->content = $this->doc->insertStylesAndJS($this->content);
00592                 echo $this->content;
00593         }
00594 
00595 
00596 
00597 
00598 
00599 
00600 
00601 
00602 
00603         /***************************
00604          *
00605          * WORKSPACE FUNCTIONS:
00606          *
00607          ***************************/
00608 
00614         function workspaceSelector()    {
00615                 global $TYPO3_DB,$BE_USER,$LANG;
00616 
00617                         // Changing workspace and if so, reloading entire backend:
00618                 if (strlen($this->changeWorkspace))     {
00619                         $BE_USER->setWorkspace($this->changeWorkspace);
00620                         return $this->doc->wrapScriptTags('top.location.href="alt_main.php";');
00621                 }
00622                         // Changing workspace and if so, reloading entire backend:
00623                 if (strlen($this->changeWorkspacePreview))      {
00624                         $BE_USER->setWorkspacePreview($this->changeWorkspacePreview);
00625                 }
00626 
00627                         // Create options array:
00628                 $options = array();
00629                 if ($BE_USER->checkWorkspace(array('uid' => 0)))        {
00630                         $options[0] = '['.$LANG->getLL('shortcut_onlineWS').']';
00631                 }
00632                 if ($BE_USER->checkWorkspace(array('uid' => -1)))       {
00633                         $options[-1] = '['.$LANG->getLL('shortcut_offlineWS').']';
00634                 }
00635 
00636                         // Add custom workspaces (selecting all, filtering by BE_USER check):
00637                 $workspaces = $TYPO3_DB->exec_SELECTgetRows('uid,title,adminusers,members,reviewers','sys_workspace','pid=0'.t3lib_BEfunc::deleteClause('sys_workspace'),'','title');
00638                 if (count($workspaces)) {
00639                         foreach ($workspaces as $rec)   {
00640                                 if ($BE_USER->checkWorkspace($rec))     {
00641                                         $options[$rec['uid']] = $rec['uid'].': '.$rec['title'];
00642                                 }
00643                         }
00644                 }
00645 
00646                         // Build selector box:
00647                 if (count($options))    {
00648                         foreach($options as $value => $label)   {
00649                                 $selected = ((int)$BE_USER->workspace===$value ? ' selected="selected"' : '');
00650                                 $options[$value] = '<option value="'.htmlspecialchars($value).'"'.$selected.'>'.htmlspecialchars($label).'</option>';
00651                         }
00652                 } else {
00653                         $options[] = '<option value="-99">'.$LANG->getLL('shortcut_noWSfound',1).'</option>';
00654                 }
00655 
00656                 $selector = '';
00657                         // Preview:
00658                 if ($BE_USER->workspace!==0)    {
00659                         $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;';
00660                 }
00661 
00662                 $selector.= '<a href="mod/user/ws/index.php" target="content">'.
00663                                         t3lib_iconWorks::getIconImage('sys_workspace',array(),$this->doc->backPath,'align="top"').
00664                                         '</a>';
00665                 if (count($options) > 1) {
00666                         $selector .= '<select name="_workspaceSelector" onchange="changeWorkspace(this.options[this.selectedIndex].value);">'.implode('',$options).'</select>';
00667                 }
00668 
00669                 return $selector;
00670         }
00671 
00672 
00673 
00674 
00675 
00676 
00677 
00678         /***************************
00679          *
00680          * OTHER FUNCTIONS:
00681          *
00682          ***************************/
00683 
00691         function mIconFilename($Ifilename,$backPath)    {
00692                         // Change icon of fileadmin references - otherwise it doesn't differ with Web->List
00693                 $Ifilename = str_replace ('mod/file/list/list.gif', 'mod/file/file.gif', $Ifilename);
00694 
00695                 if (t3lib_div::isAbsPath($Ifilename))   {
00696                         $Ifilename = '../'.substr($Ifilename,strlen(PATH_site));
00697                 }
00698                 return $backPath.$Ifilename;
00699         }
00700 
00707         function getIcon($modName)      {
00708                 global $LANG;
00709                 if ($LANG->moduleLabels['tabs_images'][$modName.'_tab'])        {
00710                         $icon = $this->mIconFilename($LANG->moduleLabels['tabs_images'][$modName.'_tab'],'');
00711                 } elseif ($modName=='xMOD_alt_doc.php') {
00712                         $icon = 'gfx/edit2.gif';
00713                 } elseif ($modName=='xMOD_file_edit.php') {
00714                         $icon = 'gfx/edit_file.gif';
00715                 } elseif ($modName=='xMOD_wizard_rte.php') {
00716                         $icon = 'gfx/edit_rtewiz.gif';
00717                 } else {
00718                         $icon = 'gfx/dummy_module.gif';
00719                 }
00720                 return $icon;
00721         }
00722 
00731         function itemLabel($inlabel,$modName,$M_modName='')     {
00732                 global $LANG;
00733                 if (substr($modName,0,5)=='xMOD_')      {
00734                         $label=substr($modName,5);
00735                 } else {
00736                         $split = explode('_',$modName);
00737                         $label = $LANG->moduleLabels['tabs'][$split[0].'_tab'];
00738                         if (count($split)>1)    {
00739                                 $label.='>'.$LANG->moduleLabels['tabs'][$modName.'_tab'];
00740                         }
00741                 }
00742                 if ($M_modName) $label.=' ('.$M_modName.')';
00743                 $label.=': '.$inlabel;
00744                 return $label;
00745         }
00746 
00753         function getLinkedPageId($url)  {
00754                 return preg_replace('/.*[\?&]id=([^&]+).*/', '$1', $url);
00755         }
00756 
00762         function hasWorkspaceAccess() {
00763                 $MCONF = array();
00764                 include('mod/user/ws/conf.php');
00765                 return $GLOBALS['BE_USER']->modAccess($MCONF, false);
00766         }
00767 }
00768 
00769 // Include extension?
00770 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_shortcut.php'])  {
00771         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_shortcut.php']);
00772 }
00773 
00774 
00775 
00776 
00777 
00778 
00779 
00780 
00781 
00782 
00783 
00784 // Make instance:
00785 $SOBE = t3lib_div::makeInstance('SC_alt_shortcut');
00786 $SOBE->preinit();
00787 $SOBE->preprocess();
00788 $SOBE->init();
00789 $SOBE->main();
00790 $SOBE->printContent();
00791 ?>


Généré par Le spécialiste TYPO3 avec  doxygen 1.4.6