[ Index ]
 

Code source de Typo3 4.1.3

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/t3lib/ -> class.t3lib_tsfebeuserauth.php (source)

   1  <?php
   2  /***************************************************************
   3  *  Copyright notice
   4  *
   5  *  (c) 1999-2007 Kasper Skaarhoj (kasperYYYY@typo3.com)
   6  *  All rights reserved
   7  *
   8  *  This script is part of the TYPO3 project. The TYPO3 project is
   9  *  free software; you can redistribute it and/or modify
  10  *  it under the terms of the GNU General Public License as published by
  11  *  the Free Software Foundation; either version 2 of the License, or
  12  *  (at your option) any later version.
  13  *
  14  *  The GNU General Public License can be found at
  15  *  http://www.gnu.org/copyleft/gpl.html.
  16  *  A copy is found in the textfile GPL.txt and important notices to the license
  17  *  from the author is found in LICENSE.txt distributed with these scripts.
  18  *
  19  *
  20  *  This script is distributed in the hope that it will be useful,
  21  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  22  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  23  *  GNU General Public License for more details.
  24  *
  25  *  This copyright notice MUST APPEAR in all copies of the script!
  26  ***************************************************************/
  27  /**
  28   * Class for TYPO3 backend user authentication in the TSFE frontend
  29   *
  30   * $Id: class.t3lib_tsfebeuserauth.php 1985 2007-02-04 21:23:18Z masi $
  31   * Revised for TYPO3 3.6 July/2003 by Kasper Skaarhoj
  32   * XHTML compliant
  33   *
  34   * @author    Kasper Skaarhoj <kasperYYYY@typo3.com>
  35   */
  36  /**
  37   * [CLASS/FUNCTION INDEX of SCRIPT]
  38   *
  39   *
  40   *
  41   *  103: class t3lib_tsfeBeUserAuth extends t3lib_beUserAuth
  42   *  129:     function extInitFeAdmin()
  43   *  154:     function extPrintFeAdminDialog()
  44   *
  45   *              SECTION: Creating sections of the Admin Panel
  46   *  250:     function extGetCategory_preview($out='')
  47   *  283:     function extGetCategory_cache($out='')
  48   *  321:     function extGetCategory_publish($out='')
  49   *  356:     function extGetCategory_edit($out='')
  50   *  400:     function extGetCategory_tsdebug($out='')
  51   *  433:     function extGetCategory_info($out='')
  52   *
  53   *              SECTION: Admin Panel Layout Helper functions
  54   *  506:     function extGetHead($pre)
  55   *  526:     function extItemLink($pre,$str)
  56   *  542:     function extGetItem($pre,$element)
  57   *  559:     function extFw($str)
  58   *  568:     function ext_makeToolBar()
  59   *
  60   *              SECTION: TSFE BE user Access Functions
  61   *  637:     function checkBackendAccessSettingsFromInitPhp()
  62   *  682:     function extPageReadAccess($pageRec)
  63   *  693:     function extAdmModuleEnabled($key)
  64   *  709:     function extSaveFeAdminConfig()
  65   *  741:     function extGetFeAdminValue($pre,$val='')
  66   *  783:     function extIsAdmMenuOpen($pre)
  67   *
  68   *              SECTION: TSFE BE user Access Functions
  69   *  818:     function extGetTreeList($id,$depth,$begin=0,$perms_clause)
  70   *  849:     function extGetNumberOfCachedPages($page_id)
  71   *
  72   *              SECTION: Localization handling
  73   *  888:     function extGetLL($key)
  74   *
  75   *              SECTION: Frontend Editing
  76   *  932:     function extIsEditAction()
  77   *  954:     function extIsFormShown()
  78   *  970:     function extEditAction()
  79   *
  80   * TOTAL FUNCTIONS: 25
  81   * (This index is automatically created/updated by the extension "extdeveval")
  82   *
  83   */
  84  
  85  
  86  
  87  
  88  
  89  
  90  
  91  
  92  
  93  
  94  
  95  /**
  96   * TYPO3 backend user authentication in the TSFE frontend.
  97   * This includes mainly functions related to the Admin Panel
  98   *
  99   * @author    Kasper Skaarhoj <kasperYYYY@typo3.com>
 100   * @package TYPO3
 101   * @subpackage t3lib
 102   */
 103  class t3lib_tsfeBeUserAuth extends t3lib_beUserAuth {
 104      var $formfield_uname = '';             // formfield with login-name
 105      var $formfield_uident = '';         // formfield with password
 106      var $formfield_chalvalue = '';        // formfield with a unique value which is used to encrypt the password and username
 107      var $security_level = '';                // sets the level of security. *'normal' = clear-text. 'challenged' = hashed password/username from form in $formfield_uident. 'superchallenged' = hashed password hashed again with username.
 108      var $writeStdLog = 0;                    // Decides if the writelog() function is called at login and logout
 109      var $writeAttemptLog = 0;                // If the writelog() functions is called if a login-attempt has be tried without success
 110      var $auth_include = '';                        // this is the name of the include-file containing the login form. If not set, login CAN be anonymous. If set login IS needed.
 111  
 112      var $extNeedUpdate=0;
 113      var $extPublishList='';
 114      var $extPageInTreeInfo=array();
 115      var $ext_forcePreview=0;
 116      var $langSplitIndex=0;
 117      var $extAdmEnabled = 0;    // General flag which is set if the adminpanel should be displayed at all..
 118  
 119  
 120  
 121  
 122      /**
 123       * Initialize the usage of Admin Panel.
 124       * Called from index_ts.php if a backend users is correctly logged in.
 125       * Sets $this->extAdminConfig to the "admPanel" config for the user and $this->extAdmEnabled = 1 IF access is enabled.
 126       *
 127       * @return    void
 128       */
 129  	function extInitFeAdmin()    {
 130          $this->extAdminConfig = $this->getTSConfigProp('admPanel');
 131          if (is_array($this->extAdminConfig['enable.']))    {
 132              reset($this->extAdminConfig['enable.']);
 133              while(list($k,$v)=each($this->extAdminConfig['enable.']))    {
 134                  if ($v)    {
 135                      $this->extAdmEnabled=1;    // Enable panel
 136                      break;
 137                  }
 138              }
 139          }
 140  
 141              // Init TSFE_EDIT variables if either the admPanel is enabled or if forceDisplayIcons is set
 142          if($this->extAdmEnabled || $this->extGetFeAdminValue('edit', 'displayIcons'))    {
 143              $this->TSFE_EDIT = t3lib_div::_POST('TSFE_EDIT');
 144          }
 145      }
 146  
 147      /**
 148       * Creates and returns the HTML code for the Admin Panel in the TSFE frontend.
 149       * Called from index_ts.php - in the end of the script
 150       *
 151       * @return    string        HTML for the Admin Panel
 152       * @see index_ts.php
 153       */
 154  	function extPrintFeAdminDialog()    {
 155          $out='';
 156          if ($this->uc['TSFE_adminConfig']['display_top'])    {
 157              if ($this->extAdmModuleEnabled('preview'))    $out.= $this->extGetCategory_preview();
 158              if ($this->extAdmModuleEnabled('cache'))    $out.= $this->extGetCategory_cache();
 159              if ($this->extAdmModuleEnabled('publish'))    $out.= $this->extGetCategory_publish();
 160              if ($this->extAdmModuleEnabled('edit'))        $out.= $this->extGetCategory_edit();
 161              if ($this->extAdmModuleEnabled('tsdebug'))    $out.= $this->extGetCategory_tsdebug();
 162              if ($this->extAdmModuleEnabled('info'))        $out.= $this->extGetCategory_info();
 163          }
 164  
 165          $header='
 166              <tr class="typo3-adminPanel-hRow" style="background-color:#9ba1a8;">
 167                  <td colspan="4" nowrap="nowrap">'.
 168                      $this->extItemLink('top','<img src="'.TYPO3_mainDir.'gfx/ol/'.($this->uc['TSFE_adminConfig']['display_top']?'minus':'plus').'bullet.gif" width="18" height="16" align="absmiddle" border="0" alt="" /><strong>'.$this->extFw($this->extGetLL('adminOptions')).'</strong>').
 169                      $this->extFw(': '.$this->user['username']).'
 170                      <img src="clear.gif" width="40" height="1" alt="" />
 171                      <input type="hidden" name="TSFE_ADMIN_PANEL[display_top]" value="'.$this->uc['TSFE_adminConfig']['display_top'].'" />'.($this->extNeedUpdate?'<input type="submit" value="'.$this->extGetLL('update').'" />':'').'</td>
 172              </tr>';
 173  
 174          $query = !t3lib_div::_GET('id') ? ('<input type="hidden" name="id" value="'.$GLOBALS['TSFE']->id.'" />'.chr(10)) : '';
 175              // the dummy field is needed for Firefox: to force a page reload on submit with must change the form value with JavaScript (see "onsubmit" attribute of the "form" element")
 176          $query.= '<input type="hidden" name="TSFE_ADMIN_PANEL[DUMMY]" value="">';
 177          foreach (t3lib_div::_GET() as $k => $v)    {
 178              if ($k != 'TSFE_ADMIN_PANEL')    {
 179                  if (is_array($v))    {
 180                      $query.=$this->extPrintFeAdminDialogHiddenFields($k,$v);
 181                  } else {
 182                      $query.='<input type="hidden" name="'.$k.'" value="'.htmlspecialchars($v).'">'.chr(10);
 183                  }
 184              }
 185          }
 186  
 187          $out='
 188  <!--
 189      ADMIN PANEL
 190  -->
 191  <a name="TSFE_ADMIN"></a>
 192  <form name="TSFE_ADMIN_PANEL_FORM" action="'.htmlspecialchars(t3lib_div::getIndpEnv('SCRIPT_NAME')).'#TSFE_ADMIN" method="get" style="margin:0;" onsubmit="document.forms.TSFE_ADMIN_PANEL_FORM[\'TSFE_ADMIN_PANEL[DUMMY]\'].value=Math.random().toString().substring(2,8)">'.
 193  $query.
 194  '    <table border="0" cellpadding="0" cellspacing="0" class="typo3-adminPanel" style="background-color:#f6f2e6; border: 1px solid black; z-index:0; position:absolute;">'.$header.$out.'
 195      </table>
 196  </form>';
 197  
 198          if ($this->uc['TSFE_adminConfig']['display_top'])    {
 199              $out.='<script type="text/javascript" src="t3lib/jsfunc.evalfield.js"></script>';
 200              $out.='
 201              <script type="text/javascript">
 202                      /*<![CDATA[*/
 203                  var evalFunc = new evalFunc();
 204                      // TSFEtypo3FormFieldSet()
 205  				function TSFEtypo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue)    {    //
 206                      var theFObj = new evalFunc_dummy (evallist,is_in, checkbox, checkboxValue);
 207                      var theValue = document.TSFE_ADMIN_PANEL_FORM[theField].value;
 208                      if (checkbox && theValue==checkboxValue)    {
 209                          document.TSFE_ADMIN_PANEL_FORM[theField+"_hr"].value="";
 210                          document.TSFE_ADMIN_PANEL_FORM[theField+"_cb"].checked = "";
 211                      } else {
 212                          document.TSFE_ADMIN_PANEL_FORM[theField+"_hr"].value = evalFunc.outputObjValue(theFObj, theValue);
 213                          document.TSFE_ADMIN_PANEL_FORM[theField+"_cb"].checked = "on";
 214                      }
 215                  }
 216                      // TSFEtypo3FormFieldGet()
 217  				function TSFEtypo3FormFieldGet(theField, evallist, is_in, checkbox, checkboxValue, checkbox_off)    {    //
 218                      var theFObj = new evalFunc_dummy (evallist,is_in, checkbox, checkboxValue);
 219                      if (checkbox_off)    {
 220                          document.TSFE_ADMIN_PANEL_FORM[theField].value=checkboxValue;
 221                      }else{
 222                          document.TSFE_ADMIN_PANEL_FORM[theField].value = evalFunc.evalObjValue(theFObj, document.TSFE_ADMIN_PANEL_FORM[theField+"_hr"].value);
 223                      }
 224                      TSFEtypo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue);
 225                  }
 226                      /*]]>*/
 227              </script>
 228              <script language="javascript" type="text/javascript">'.$this->extJSCODE.'</script>';
 229          }
 230          return "\n\n\n\n".$out.'<br />';
 231      }
 232  
 233      /**
 234       * Fetches recursively all GET parameters as hidden fields.
 235       * Called from extPrintFeAdminDialog.
 236       *
 237       * @param    string        current key
 238       * @param    mixed        current value
 239       * @return    string        hidden fields
 240       * @see extPrintFeAdminDialog()
 241       */
 242  	function extPrintFeAdminDialogHiddenFields($key,&$val)    {
 243          $out='';
 244          foreach($val as $k => $v)    {
 245              if (is_array($v))    {
 246                  $out.=$this->extPrintFeAdminDialogHiddenFields($key.'['.$k.']',$v);
 247              } else {
 248                  $out.='<input type="hidden" name="'.$key.'['.$k.']" value="'.htmlspecialchars($v).'">'.chr(10);
 249              }
 250          }
 251          return $out;
 252      }
 253  
 254  
 255  
 256  
 257  
 258  
 259  
 260  
 261  
 262  
 263  
 264  
 265  
 266  
 267  
 268  
 269      /*****************************************************
 270       *
 271       * Creating sections of the Admin Panel
 272       *
 273       ****************************************************/
 274  
 275      /**
 276       * Creates the content for the "preview" section ("module") of the Admin Panel
 277       *
 278       * @param    string        Optional start-value; The generated content is added to this variable.
 279       * @return    string        HTML content for the section. Consists of a string with table-rows with four columns.
 280       * @see extPrintFeAdminDialog()
 281       */
 282  	function extGetCategory_preview($out='')    {
 283          $out.=$this->extGetHead('preview');
 284          if ($this->uc['TSFE_adminConfig']['display_preview'])    {
 285              $this->extNeedUpdate = 1;
 286              $out.= $this->extGetItem('preview_showHiddenPages', '<input type="hidden" name="TSFE_ADMIN_PANEL[preview_showHiddenPages]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[preview_showHiddenPages]" value="1"'.($this->uc['TSFE_adminConfig']['preview_showHiddenPages']?' checked="checked"':'').' />');
 287              $out.= $this->extGetItem('preview_showHiddenRecords', '<input type="hidden" name="TSFE_ADMIN_PANEL[preview_showHiddenRecords]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[preview_showHiddenRecords]" value="1"'.($this->uc['TSFE_adminConfig']['preview_showHiddenRecords']?' checked="checked"':'').' />');
 288  
 289                  // Simulate date
 290              $out.= $this->extGetItem('preview_simulateDate', '<input type="checkbox" name="TSFE_ADMIN_PANEL[preview_simulateDate]_cb" onclick="TSFEtypo3FormFieldGet(\'TSFE_ADMIN_PANEL[preview_simulateDate]\', \'datetime\', \'\',1,0,1);" /><input type="text" name="TSFE_ADMIN_PANEL[preview_simulateDate]_hr" onchange="TSFEtypo3FormFieldGet(\'TSFE_ADMIN_PANEL[preview_simulateDate]\', \'datetime\', \'\', 1,0);" /><input type="hidden" name="TSFE_ADMIN_PANEL[preview_simulateDate]" value="'.$this->uc['TSFE_adminConfig']['preview_simulateDate'].'" />');
 291              $this->extJSCODE.= 'TSFEtypo3FormFieldSet("TSFE_ADMIN_PANEL[preview_simulateDate]", "datetime", "", 1,0);';
 292  
 293                  // Simulate fe_user:
 294              $options = '<option value="0"></option>';
 295              $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
 296                          'fe_groups.uid, fe_groups.title',
 297                          'fe_groups,pages',
 298                          'pages.uid=fe_groups.pid AND pages.deleted=0 '.t3lib_BEfunc::deleteClause('fe_groups').' AND '.$this->getPagePermsClause(1)
 299                      );
 300              while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))    {
 301                  $options.= '<option value="'.$row['uid'].'"'.($this->uc['TSFE_adminConfig']['preview_simulateUserGroup']==$row['uid']?' selected="selected"':'').'>'.htmlspecialchars('['.$row['uid'].'] '.$row['title']).'</option>';
 302              }
 303              $out.= $this->extGetItem('preview_simulateUserGroup', '<select name="TSFE_ADMIN_PANEL[preview_simulateUserGroup]">'.$options.'</select>');
 304          }
 305          return $out;
 306      }
 307  
 308      /**
 309       * Creates the content for the "cache" section ("module") of the Admin Panel
 310       *
 311       * @param    string        Optional start-value; The generated content is added to this variable.
 312       * @return    string        HTML content for the section. Consists of a string with table-rows with four columns.
 313       * @see extPrintFeAdminDialog()
 314       */
 315  	function extGetCategory_cache($out='')    {
 316          $out.=$this->extGetHead('cache');
 317          if ($this->uc['TSFE_adminConfig']['display_cache'])    {
 318              $this->extNeedUpdate=1;
 319              $out.=$this->extGetItem('cache_noCache', '<input type="hidden" name="TSFE_ADMIN_PANEL[cache_noCache]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[cache_noCache]" value="1"'.($this->uc['TSFE_adminConfig']['cache_noCache']?' checked="checked"':'').' />');
 320  
 321              $options='';
 322              $options.='<option value="0"'.($this->uc['TSFE_adminConfig']['cache_clearCacheLevels']==0?' selected="selected"':'').'>'.$this->extGetLL('div_Levels_0').'</option>';
 323              $options.='<option value="1"'.($this->uc['TSFE_adminConfig']['cache_clearCacheLevels']==1?' selected="selected"':'').'>'.$this->extGetLL('div_Levels_1').'</option>';
 324              $options.='<option value="2"'.($this->uc['TSFE_adminConfig']['cache_clearCacheLevels']==2?' selected="selected"':'').'>'.$this->extGetLL('div_Levels_2').'</option>';
 325              $out.=$this->extGetItem('cache_clearLevels', '<select name="TSFE_ADMIN_PANEL[cache_clearCacheLevels]">'.$options.'</select>'.
 326                      '<input type="hidden" name="TSFE_ADMIN_PANEL[cache_clearCacheId]" value="'.$GLOBALS['TSFE']->id.'" /><input type="submit" value="'.$this->extGetLL('update').'" />');
 327  
 328                  // Generating tree:
 329              $depth=$this->extGetFeAdminValue('cache','clearCacheLevels');
 330              $outTable='';
 331              $this->extPageInTreeInfo=array();
 332              $this->extPageInTreeInfo[]=array($GLOBALS['TSFE']->page['uid'],$GLOBALS['TSFE']->page['title'],$depth+1);
 333              $this->extGetTreeList($GLOBALS['TSFE']->id, $depth,0,$this->getPagePermsClause(1));
 334              reset($this->extPageInTreeInfo);
 335              while(list(,$row)=each($this->extPageInTreeInfo))    {
 336                  $outTable.='<tr><td nowrap="nowrap"><img src="clear.gif" width="'.(($depth+1-$row[2])*18).'" height="1" alt="" /><img src="'.TYPO3_mainDir.'gfx/i/pages.gif" width="18" height="16" align="absmiddle" border="0" alt="" />'.$this->extFw($row[1]).'</td><td><img src="clear.gif" width="10" height="1" alt="" /></td><td>'.$this->extFw($this->extGetNumberOfCachedPages($row[0])).'</td></tr>';
 337              }
 338              $outTable='<br /><table border="0" cellpadding="0" cellspacing="0">'.$outTable.'</table>';
 339              $outTable.='<input type="submit" name="TSFE_ADMIN_PANEL[action][clearCache]" value="'.$this->extGetLL('cache_doit').'" />';
 340              $out.=$this->extGetItem('cache_cacheEntries', $outTable);
 341  
 342          }
 343          return $out;
 344      }
 345  
 346      /**
 347       * Creates the content for the "publish" section ("module") of the Admin Panel
 348       *
 349       * @param    string        Optional start-value; The generated content is added to this variable.
 350       * @return    string        HTML content for the section. Consists of a string with table-rows with four columns.
 351       * @see extPrintFeAdminDialog()
 352       */
 353  	function extGetCategory_publish($out='')    {
 354          $out.=$this->extGetHead('publish');
 355          if ($this->uc['TSFE_adminConfig']['display_publish'])    {
 356              $this->extNeedUpdate=1;
 357              $options='';
 358              $options.='<option value="0"'.($this->uc['TSFE_adminConfig']['publish_levels']==0?' selected="selected"':'').'>'.$this->extGetLL('div_Levels_0').'</option>';
 359              $options.='<option value="1"'.($this->uc['TSFE_adminConfig']['publish_levels']==1?' selected="selected"':'').'>'.$this->extGetLL('div_Levels_1').'</option>';
 360              $options.='<option value="2"'.($this->uc['TSFE_adminConfig']['publish_levels']==2?' selected="selected"':'').'>'.$this->extGetLL('div_Levels_2').'</option>';
 361              $out.=$this->extGetItem('publish_levels', '<select name="TSFE_ADMIN_PANEL[publish_levels]">'.$options.'</select>'.
 362                      '<input type="hidden" name="TSFE_ADMIN_PANEL[publish_id]" value="'.$GLOBALS['TSFE']->id.'" /><input type="submit" value="'.$this->extGetLL('update').'" />');
 363  
 364                  // Generating tree:
 365              $depth=$this->extGetFeAdminValue('publish','levels');
 366              $outTable='';
 367              $this->extPageInTreeInfo=array();
 368              $this->extPageInTreeInfo[]=array($GLOBALS['TSFE']->page['uid'],$GLOBALS['TSFE']->page['title'],$depth+1);
 369              $this->extGetTreeList($GLOBALS['TSFE']->id, $depth,0,$this->getPagePermsClause(1));
 370              reset($this->extPageInTreeInfo);
 371              while(list(,$row)=each($this->extPageInTreeInfo))    {
 372                  $outTable.='<tr><td nowrap="nowrap"><img src="clear.gif" width="'.(($depth+1-$row[2])*18).'" height="1" alt="" /><img src="'.TYPO3_mainDir.'gfx/i/pages.gif" width="18" height="16" align="absmiddle" border="0" alt="" />'.$this->extFw($row[1]).'</td><td><img src="clear.gif" width="10" height="1" alt="" /></td><td>'.$this->extFw('...').'</td></tr>';
 373              }
 374              $outTable='<br /><table border="0" cellpadding="0" cellspacing="0">'.$outTable.'</table>';
 375              $outTable.='<input type="submit" name="TSFE_ADMIN_PANEL[action][publish]" value="'.$this->extGetLL('publish_doit').'" />';
 376              $out.=$this->extGetItem('publish_tree', $outTable);
 377          }
 378          return $out;
 379      }
 380  
 381      /**
 382       * Creates the content for the "edit" section ("module") of the Admin Panel
 383       *
 384       * @param    string        Optional start-value; The generated content is added to this variable.
 385       * @return    string        HTML content for the section. Consists of a string with table-rows with four columns.
 386       * @see extPrintFeAdminDialog()
 387       */
 388  	function extGetCategory_edit($out='')    {
 389          $out.=$this->extGetHead('edit');
 390          if ($this->uc['TSFE_adminConfig']['display_edit'])    {
 391  
 392                  // If another page module was specified, replace the default Page module with the new one
 393              $newPageModule = trim($GLOBALS['BE_USER']->getTSConfigVal('options.overridePageModule'));
 394              $pageModule = t3lib_BEfunc::isModuleSetInTBE_MODULES($newPageModule) ? $newPageModule : 'web_layout';
 395  
 396              $this->extNeedUpdate=1;
 397              $out.=$this->extGetItem('edit_displayFieldIcons', '<input type="hidden" name="TSFE_ADMIN_PANEL[edit_displayFieldIcons]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[edit_displayFieldIcons]" value="1"'.($this->uc['TSFE_adminConfig']['edit_displayFieldIcons']?' checked="checked"':'').' />');
 398              $out.=$this->extGetItem('edit_displayIcons', '<input type="hidden" name="TSFE_ADMIN_PANEL[edit_displayIcons]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[edit_displayIcons]" value="1"'.($this->uc['TSFE_adminConfig']['edit_displayIcons']?' checked="checked"':'').' />');
 399              $out.=$this->extGetItem('edit_editFormsOnPage', '<input type="hidden" name="TSFE_ADMIN_PANEL[edit_editFormsOnPage]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[edit_editFormsOnPage]" value="1"'.($this->uc['TSFE_adminConfig']['edit_editFormsOnPage']?' checked="checked"':'').' />');
 400              $out.=$this->extGetItem('edit_editNoPopup', '<input type="hidden" name="TSFE_ADMIN_PANEL[edit_editNoPopup]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[edit_editNoPopup]" value="1"'.($this->uc['TSFE_adminConfig']['edit_editNoPopup']?' checked="checked"':'').' />');
 401  
 402              $out.=$this->extGetItem('', $this->ext_makeToolBar());
 403              if (!t3lib_div::_GP('ADMCMD_view'))    {
 404                  $out.=$this->extGetItem('', '<a href="#" onclick="'.
 405                      htmlspecialchars('
 406                          if (parent.opener && parent.opener.top && parent.opener.top.TS)    {
 407                              parent.opener.top.fsMod.recentIds["web"]='.intval($GLOBALS['TSFE']->page['uid']).';
 408                              if (parent.opener.top.content && parent.opener.top.content.nav_frame && parent.opener.top.content.nav_frame.refresh_nav)    {
 409                                  parent.opener.top.content.nav_frame.refresh_nav();
 410                              }
 411                              parent.opener.top.goToModule("'.$pageModule.'");
 412                              parent.opener.top.focus();
 413                          } else {
 414                              vHWin=window.open(\''.TYPO3_mainDir.'alt_main.php\',\''.md5('Typo3Backend-'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']).'\',\'status=1,menubar=1,scrollbars=1,resizable=1\');
 415                              vHWin.focus();
 416                          }
 417                          return false;
 418                          ').
 419                      '">'.$this->extFw($this->extGetLL('edit_openAB')).'</a>');
 420              }
 421          }
 422          return $out;
 423      }
 424  
 425      /**
 426       * Creates the content for the "tsdebug" section ("module") of the Admin Panel
 427       *
 428       * @param    string        Optional start-value; The generated content is added to this variable.
 429       * @return    string        HTML content for the section. Consists of a string with table-rows with four columns.
 430       * @see extPrintFeAdminDialog()
 431       */
 432  	function extGetCategory_tsdebug($out='')    {
 433          $out.=$this->extGetHead('tsdebug');
 434          if ($this->uc['TSFE_adminConfig']['display_tsdebug'])    {
 435              $this->extNeedUpdate=1;
 436  
 437              $content='';
 438              $content.=$this->extGetItem('tsdebug_tree', '<input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_tree]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[tsdebug_tree]" value="1"'.($this->uc['TSFE_adminConfig']['tsdebug_tree']?' checked="checked"':'').' />');
 439              $content.=$this->extGetItem('tsdebug_displayTimes', '<input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_displayTimes]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[tsdebug_displayTimes]" value="1"'.($this->uc['TSFE_adminConfig']['tsdebug_displayTimes']?' checked="checked"':'').' />');
 440              $content.=$this->extGetItem('tsdebug_displayMessages', '<input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_displayMessages]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[tsdebug_displayMessages]" value="1"'.($this->uc['TSFE_adminConfig']['tsdebug_displayMessages']?' checked="checked"':'').' />');
 441              $content.=$this->extGetItem('tsdebug_LR', '<input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_LR]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[tsdebug_LR]" value="1"'.($this->uc['TSFE_adminConfig']['tsdebug_LR']?' checked="checked"':'').' />');
 442              $content.=$this->extGetItem('tsdebug_displayContent', '<input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_displayContent]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[tsdebug_displayContent]" value="1"'.($this->uc['TSFE_adminConfig']['tsdebug_displayContent']?' checked="checked"':'').' />');
 443              $content.=$this->extGetItem('tsdebug_displayQueries', '<input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_displayQueries]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[tsdebug_displayQueries]" value="1"'.($this->uc['TSFE_adminConfig']['tsdebug_displayQueries']?' checked="checked"':'').' />');
 444              $content.=$this->extGetItem('tsdebug_forceTemplateParsing', '<input type="hidden" name="TSFE_ADMIN_PANEL[tsdebug_forceTemplateParsing]" value="0" /><input type="checkbox" name="TSFE_ADMIN_PANEL[tsdebug_forceTemplateParsing]" value="1"'.($this->uc['TSFE_adminConfig']['tsdebug_forceTemplateParsing']?' checked="checked"':'').' />');
 445  
 446              $out.='<tr><td colspan="4" nowrap="nowrap"><table border="0" cellpadding="0" cellspacing="0">'.$content.'</table></td></tr>';
 447  
 448              $GLOBALS['TT']->printConf['flag_tree'] = $this->extGetFeAdminValue('tsdebug','tree');
 449              $GLOBALS['TT']->printConf['allTime'] = $this->extGetFeAdminValue('tsdebug','displayTimes');
 450              $GLOBALS['TT']->printConf['flag_messages'] = $this->extGetFeAdminValue('tsdebug','displayMessages');
 451              $GLOBALS['TT']->printConf['flag_content'] = $this->extGetFeAdminValue('tsdebug','displayContent');
 452              $GLOBALS['TT']->printConf['flag_queries'] = $this->extGetFeAdminValue('tsdebug','displayQueries');
 453              $out.='<tr><td><img src="clear.gif" width="50" height="1" alt="" /></td><td colspan="3">'.$GLOBALS['TT']->printTSlog().'</td></tr>';
 454          }
 455          return $out;
 456      }
 457  
 458      /**
 459       * Creates the content for the "info" section ("module") of the Admin Panel
 460       *
 461       * @param    string        Optional start-value; The generated content is added to this variable.
 462       * @return    string        HTML content for the section. Consists of a string with table-rows with four columns.
 463       * @see extPrintFeAdminDialog()
 464       */
 465  	function extGetCategory_info($out='')    {
 466          $out.=$this->extGetHead('info');
 467          if ($this->uc['TSFE_adminConfig']['display_info'])    {
 468  
 469              if (is_array($GLOBALS['TSFE']->imagesOnPage) && $this->extGetFeAdminValue('cache','noCache'))    {
 470                  reset($GLOBALS['TSFE']->imagesOnPage);
 471                  $theBytes=0;
 472                  $count=0;
 473                  $fileTable='';
 474                  while(list(,$file)=each($GLOBALS['TSFE']->imagesOnPage))    {
 475                      $fs=@filesize($file);
 476                      $fileTable.='<tr><td>'.$this->extFw($file).'</td><td align="right">'.$this->extFw(t3lib_div::formatSize($fs)).'</td></tr>';
 477                      $theBytes+=$fs;
 478                      $count++;
 479                  }
 480                  $fileTable.='<tr><td><strong>'.$this->extFw('Total number of images:').'</strong></td><td>'.$this->extFw($count).'</td></tr>';
 481                  $fileTable.='<tr><td><strong>'.$this->extFw('Total image file sizes:').'</strong></td><td align="right">'.$this->extFw(t3lib_div::formatSize($theBytes)).'</td></tr>';
 482                  $fileTable.='<tr><td><strong>'.$this->extFw('Document size:').'</strong></td><td align="right">'.$this->extFw(t3lib_div::formatSize(strlen($GLOBALS['TSFE']->content))).'</td></tr>';
 483                  $fileTable.='<tr><td><strong>'.$this->extFw('Total page load:').'</strong></td><td align="right">'.$this->extFw(t3lib_div::formatSize(strlen($GLOBALS['TSFE']->content)+$theBytes)).'</td></tr>';
 484                  $fileTable.='<tr><td>&nbsp;</td></tr>';
 485              }
 486  
 487              $fileTable.='<tr><td>'.$this->extFw('id:').'</td><td>'.$this->extFw($GLOBALS['TSFE']->id).'</td></tr>';
 488              $fileTable.='<tr><td>'.$this->extFw('type:').'</td><td>'.$this->extFw($GLOBALS['TSFE']->type).'</td></tr>';
 489              $fileTable.='<tr><td>'.$this->extFw('gr_list:').'</td><td>'.$this->extFw($GLOBALS['TSFE']->gr_list).'</td></tr>';
 490              $fileTable.='<tr><td>'.$this->extFw('no_cache:').'</td><td>'.$this->extFw($GLOBALS['TSFE']->no_cache).'</td></tr>';
 491              $fileTable.='<tr><td>'.$this->extFw('fe_user, name:').'</td><td>'.$this->extFw($GLOBALS['TSFE']->fe_user->user['username']).'</td></tr>';
 492              $fileTable.='<tr><td>'.$this->extFw('fe_user, uid:').'</td><td>'.$this->extFw($GLOBALS['TSFE']->fe_user->user['uid']).'</td></tr>';
 493              $fileTable.='<tr><td>&nbsp;</td></tr>';
 494  
 495                  // parsetime:
 496              $fileTable.='<tr><td>'.$this->extFw('Total parsetime:').'</td><td>'.$this->extFw($GLOBALS['TSFE']->scriptParseTime.' ms').'</td></tr>';
 497  
 498              $fileTable='<table border="0" cellpadding="0" cellspacing="0">'.$fileTable.'</table>';
 499  
 500              $out.='<tr><td><img src="clear.gif" width="50" height="1" alt="" /></td><td colspan="3">'.$fileTable.'</td></tr>';
 501          }
 502          return $out;
 503      }
 504  
 505  
 506  
 507  
 508  
 509  
 510  
 511  
 512  
 513  
 514  
 515  
 516  
 517  
 518  
 519  
 520  
 521  
 522      /*****************************************************
 523       *
 524       * Admin Panel Layout Helper functions
 525       *
 526       ****************************************************/
 527  
 528      /**
 529       * Returns a row (with colspan=4) which is a header for a section in the Admin Panel.
 530       * It will have a plus/minus icon and a label which is linked so that it submits the form which surrounds the whole Admin Panel when clicked, alterting the TSFE_ADMIN_PANEL[display_'.$pre.'] value
 531       * See the functions extGetCategory_*
 532       *
 533       * @param    string        The suffix to the display_ label. Also selects the label from the LOCAL_LANG array.
 534       * @return    string        HTML table row.
 535       * @access private
 536       * @see extGetItem()
 537       */
 538  	function extGetHead($pre)    {
 539          $out.='<img src="'.TYPO3_mainDir.'gfx/ol/blank.gif" width="18" height="16" align="absmiddle" border="0" alt="" />';
 540          $out.='<img src="'.TYPO3_mainDir.'gfx/ol/'.($this->uc['TSFE_adminConfig']['display_'.$pre]?'minus':'plus').'bullet.gif" width="18" height="16" align="absmiddle" border="0" alt="" />';
 541          $out.=$this->extFw($this->extGetLL($pre));
 542          $out=$this->extItemLink($pre,$out);
 543          return '
 544                  <tr class="typo3-adminPanel-itemHRow" style="background-color:#abbbb4;">
 545                      <td colspan="4" nowrap="nowrap" style="border-top:dashed 1px #007a8c;">'.$out.'<input type="hidden" name="TSFE_ADMIN_PANEL[display_'.$pre.']" value="'.$this->uc['TSFE_adminConfig']['display_'.$pre].'" /></td>
 546                  </tr>';
 547      }
 548  
 549      /**
 550       * Wraps a string in a link which will open/close a certain part of the Admin Panel
 551       *
 552       * @param    string        The code for the display_ label/key
 553       * @param    string        Input string
 554       * @return    string        Linked input string
 555       * @access private
 556       * @see extGetHead()
 557       */
 558  	function extItemLink($pre,$str)    {
 559          return '<a href="#" style="text-decoration:none;" onclick="'.
 560              htmlspecialchars('document.TSFE_ADMIN_PANEL_FORM[\'TSFE_ADMIN_PANEL[display_'.$pre.']\'].value='.($this->uc['TSFE_adminConfig']['display_'.$pre]?'0':'1').'; document.TSFE_ADMIN_PANEL_FORM.submit(); return false;').
 561              '">'.$str.'</a>';
 562      }
 563  
 564      /**
 565       * Returns a row (with 4 columns) for content in a section of the Admin Panel.
 566       * It will take $pre as a key to a label to display and $element as the content to put into the forth cell.
 567       *
 568       * @param    string        Key to label
 569       * @param    string        The HTML content for the forth table cell.
 570       * @return    string        HTML table row.
 571       * @access private
 572       * @see extGetHead()
 573       */
 574  	function extGetItem($pre,$element)    {
 575          return '
 576                      <tr class="typo3-adminPanel-itemRow">
 577                          <td><img src="clear.gif" width="50" height="1" alt="" /></td>
 578                          <td nowrap="nowrap">'.($pre ? $this->extFw($this->extGetLL($pre)) : '&nbsp;').'</td>
 579                          <td><img src="clear.gif" width="40" height="1" alt="" /></td>
 580                          <td>'.$element.'</td>
 581                      </tr>';
 582  
 583      }
 584  
 585      /**
 586       * Wraps a string in a font-tag with verdana, size 1 and black
 587       *
 588       * @param    string        The string to wrap
 589       * @return    string
 590       */
 591  	function extFw($str)    {
 592          return '<font face="verdana,arial" size="1" color="black">'.$str.'</font>';
 593      }
 594  
 595      /**
 596       * Creates the tool bar links for the "edit" section of the Admin Panel.
 597       *
 598       * @return    string        A string containing images wrapped in <a>-tags linking them to proper functions.
 599       */
 600  	function ext_makeToolBar()    {
 601              //  If mod.web_list.newContentWiz.overrideWithExtension is set, use that extension's create new content wizard instead:
 602          $tmpTSc = t3lib_BEfunc::getModTSconfig($this->pageinfo['uid'],'mod.web_list');
 603          $tmpTSc = $tmpTSc ['properties']['newContentWiz.']['overrideWithExtension'];
 604          $newContentWizScriptPath = t3lib_extMgm::isLoaded($tmpTSc) ? (t3lib_extMgm::extRelPath($tmpTSc).'mod1/db_new_content_el.php') : (TYPO3_mainDir.'sysext/cms/layout/db_new_content_el.php');
 605  
 606  
 607          $perms = $GLOBALS['BE_USER']->calcPerms($GLOBALS['TSFE']->page);
 608          $langAllowed = $GLOBALS['BE_USER']->checkLanguageAccess($GLOBALS['TSFE']->sys_language_uid);
 609  
 610          $toolBar = '';
 611          $id = $GLOBALS['TSFE']->id;
 612          $toolBar.='<a href="'.htmlspecialchars(TYPO3_mainDir.'show_rechis.php?element='.rawurlencode('pages:'.$id).'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'#latest">'.
 613                      '<img src="'.TYPO3_mainDir.'gfx/history2.gif" width="13" height="12" hspace="2" border="0" align="top" title="'.$this->extGetLL('edit_recordHistory').'" alt="" /></a>';
 614  
 615          if ($perms&16 && $langAllowed)    {
 616              $params = '';
 617              if ($GLOBALS['TSFE']->sys_language_uid)    $params = '&sys_language_uid='.$GLOBALS['TSFE']->sys_language_uid;
 618              $toolBar.='<a href="'.htmlspecialchars($newContentWizScriptPath.'?id='.$id.$params.'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'.
 619                          '<img src="'.TYPO3_mainDir.'gfx/new_record.gif" width="16" height="12" hspace="1" border="0" align="top" title="'.$this->extGetLL('edit_newContentElement').'" alt="" /></a>';
 620          }
 621          if ($perms&2)    {
 622              $toolBar.='<a href="'.htmlspecialchars(TYPO3_mainDir.'move_el.php?table=pages&uid='.$id.'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'.
 623                      '<img src="'.TYPO3_mainDir.'gfx/move_page.gif" width="11" height="12" hspace="2" border="0" align="top" title="'.$this->extGetLL('edit_move_page').'" alt="" /></a>';
 624          }
 625          if ($perms&8)    {
 626              $toolBar.='<a href="'.htmlspecialchars(TYPO3_mainDir.'db_new.php?id='.$id.'&pagesOnly=1&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'.
 627                      '<img src="'.TYPO3_mainDir.'gfx/new_page.gif" width="13" height="12" hspace="0" border="0" align="top" title="'.$this->extGetLL('edit_newPage').'" alt="" /></a>';
 628          }
 629          if ($perms&2)    {
 630              $params='&edit[pages]['.$id.']=edit';
 631              $toolBar.='<a href="'.htmlspecialchars(TYPO3_mainDir.'alt_doc.php?'.$params.'&noView=1&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'.
 632                      '<img src="'.TYPO3_mainDir.'gfx/edit2.gif" width="11" height="12" hspace="2" border="0" align="top" title="'.$this->extGetLL('edit_editPageProperties').'" alt="" /></a>';
 633  
 634              if ($GLOBALS['TSFE']->sys_language_uid && $langAllowed)    {
 635                  $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
 636                      'uid,pid,t3ver_state',    'pages_language_overlay',
 637                      'pid='.intval($id).' AND sys_language_uid='.$GLOBALS['TSFE']->sys_language_uid.$GLOBALS['TSFE']->sys_page->enableFields('pages_language_overlay'),
 638                      '', '', '1');
 639                  $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
 640                  $GLOBALS['TSFE']->sys_page->versionOL('pages_language_overlay',$row);
 641                  if (is_array($row))    {
 642                      $params='&edit[pages_language_overlay]['.$row['uid'].']=edit';
 643                      $toolBar.='<a href="'.htmlspecialchars(TYPO3_mainDir.'alt_doc.php?'.$params.'&noView=1&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'.
 644                              '<img src="'.TYPO3_mainDir.'gfx/edit3.gif" width="11" height="12" hspace="2" border="0" align="top" title="'.$this->extGetLL('edit_editPageOverlay').'" alt="" /></a>';
 645                  }
 646              }
 647          }
 648          if ($this->check('modules','web_list'))    {
 649              $toolBar.='<a href="'.htmlspecialchars(TYPO3_mainDir.'db_list.php?id='.$id.'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'.
 650                      '<img src="'.TYPO3_mainDir.'gfx/list.gif" width="11" height="11" hspace="2" border="0" align="top" title="'.$this->extGetLL('edit_db_list').'" alt="" /></a>';
 651          }
 652          return $toolBar;
 653      }
 654  
 655  
 656  
 657  
 658  
 659  
 660  
 661  
 662  
 663  
 664  
 665  
 666  
 667  
 668  
 669  
 670  
 671  
 672  
 673      /*****************************************************
 674       *
 675       * TSFE BE user Access Functions
 676       *
 677       ****************************************************/
 678  
 679      /**
 680       * Implementing the access checks that the typo3/init.php script does before a user is ever logged in.
 681       * Used in the frontend.
 682       *
 683       * @return    boolean        Returns true if access is OK
 684       * @see typo3/init.php, t3lib_beuserauth::backendCheckLogin()
 685       */
 686  	function checkBackendAccessSettingsFromInitPhp()    {
 687          global $TYPO3_CONF_VARS;
 688  
 689          // **********************
 690          // Check Hardcoded lock on BE:
 691          // **********************
 692          if ($TYPO3_CONF_VARS['BE']['adminOnly'] < 0)    {
 693              return FALSE;
 694          }
 695  
 696          // **********************
 697          // Check IP
 698          // **********************
 699          if (trim($TYPO3_CONF_VARS['BE']['IPmaskList']))    {
 700              if (!t3lib_div::cmpIP(t3lib_div::getIndpEnv('REMOTE_ADDR'), $TYPO3_CONF_VARS['BE']['IPmaskList']))    {
 701                  return FALSE;
 702              }
 703          }
 704  
 705  
 706          // **********************
 707          // Check SSL (https)
 708          // **********************
 709          if (intval($TYPO3_CONF_VARS['BE']['lockSSL']) && $TYPO3_CONF_VARS['BE']['lockSSL'] != 3)    {
 710              if (!t3lib_div::getIndpEnv('TYPO3_SSL'))    {
 711                  return FALSE;
 712              }
 713          }
 714  
 715              // Finally a check from t3lib_beuserauth::backendCheckLogin()
 716          if (!$TYPO3_CONF_VARS['BE']['adminOnly'] || $this->isAdmin())    {
 717              return TRUE;
 718          } else return FALSE;
 719       }
 720  
 721  
 722      /**
 723       * Evaluates if the Backend User has read access to the input page record.
 724       * The evaluation is based on both read-permission and whether the page is found in one of the users webmounts. Only if both conditions are true will the function return true.
 725       * Read access means that previewing is allowed etc.
 726       * Used in index_ts.php
 727       *
 728       * @param    array        The page record to evaluate for
 729       * @return    boolean        True if read access
 730       */
 731  	function extPageReadAccess($pageRec)    {
 732          return $this->isInWebMount($pageRec['uid']) && $this->doesUserHaveAccess($pageRec,1);
 733      }
 734  
 735      /**
 736       * Checks if a Admin Panel section ("module") is available for the user. If so, true is returned.
 737       *
 738       * @param    string        The module key, eg. "edit", "preview", "info" etc.
 739       * @return    boolean
 740       * @see extPrintFeAdminDialog()
 741       */
 742  	function extAdmModuleEnabled($key)    {
 743              // Returns true if the module checked is "preview" and the forcePreview flag is set.
 744          if ($key=="preview" && $this->ext_forcePreview)    return true;
 745              // If key is not set, only "all" is checked
 746          if ($this->extAdminConfig['enable.']['all'])    return true;
 747          if ($this->extAdminConfig['enable.'][$key])    {
 748              return true;
 749          }
 750      }
 751  
 752      /**
 753       * Saves any change in settings made in the Admin Panel.
 754       * Called from index_ts.php right after access check for the Admin Panel
 755       *
 756       * @return    void
 757       */
 758  	function extSaveFeAdminConfig()    {
 759          $input = t3lib_div::_GET('TSFE_ADMIN_PANEL');
 760          if (is_array($input))    {
 761                  // Setting
 762              $this->uc['TSFE_adminConfig'] = array_merge(!is_array($this->uc['TSFE_adminConfig'])?array():$this->uc['TSFE_adminConfig'], $input);            // Candidate for t3lib_div::array_merge() if integer-keys will some day make trouble...
 763              unset($this->uc['TSFE_adminConfig']['action']);
 764  
 765                  // Actions:
 766              if ($input['action']['clearCache'] && $this->extAdmModuleEnabled('cache'))    {
 767                  $this->extPageInTreeInfo=array();
 768                  $theStartId = intval($input['cache_clearCacheId']);
 769                  $GLOBALS['TSFE']->clearPageCacheContent_pidList($this->extGetTreeList($theStartId, $this->extGetFeAdminValue('cache','clearCacheLevels'),0,$this->getPagePermsClause(1)).$theStartId);
 770              }
 771              if ($input['action']['publish'] && $this->extAdmModuleEnabled('publish'))    {
 772                  $theStartId = intval($input['publish_id']);
 773                  $this->extPublishList = $this->extGetTreeList($theStartId, $this->extGetFeAdminValue('publish','levels'),0,$this->getPagePermsClause(1)).$theStartId;
 774              }
 775  
 776                  // Saving
 777              $this->writeUC();
 778          }
 779          $GLOBALS['TT']->LR = $this->extGetFeAdminValue('tsdebug','LR');
 780          if ($this->extGetFeAdminValue('cache','noCache'))    {$GLOBALS['TSFE']->set_no_cache();}
 781      }
 782  
 783      /**
 784       * Returns the value for a Admin Panel setting. You must specify both the module-key and the internal setting key.
 785       *
 786       * @param    string        Module key
 787       * @param    string        Setting key
 788       * @return    string        The setting value
 789       */
 790  	function extGetFeAdminValue($pre,$val='')    {
 791          if ($this->extAdmModuleEnabled($pre))    {    // Check if module is enabled.
 792                  // Exceptions where the values can be overridden from backend:
 793                  // deprecated
 794              if ($pre.'_'.$val == 'edit_displayIcons' && $this->extAdminConfig['module.']['edit.']['forceDisplayIcons'])    {
 795                  return true;
 796              }
 797              if ($pre.'_'.$val == 'edit_displayFieldIcons' && $this->extAdminConfig['module.']['edit.']['forceDisplayFieldIcons'])    {
 798                  return true;
 799              }
 800  
 801                  // override all settings with user TSconfig
 802              if ($this->extAdminConfig['override.'][$pre.'.'][$val] && $val)    {
 803                  return $this->extAdminConfig['override.'][$pre.'.'][$val];
 804              }
 805              if ($this->extAdminConfig['override.'][$pre])    {
 806                  return $this->extAdminConfig['override.'][$pre];
 807              }
 808  
 809              $retVal = $val ? $this->uc['TSFE_adminConfig'][$pre.'_'.$val] : 1;
 810  
 811              if ($pre=='preview' && $this->ext_forcePreview)    {
 812                  if (!$val)    {
 813                      return true;
 814                  } else {
 815                      return $retVal;
 816                  }
 817              }
 818  
 819                  // regular check:
 820              if ($this->extIsAdmMenuOpen($pre))    {    // See if the menu is expanded!
 821                  return $retVal;
 822              }
 823          }
 824      }
 825  
 826      /**
 827       * Returns true if admin panel module is open
 828       *
 829       * @param    string        Module key
 830       * @return    boolean        True, if the admin panel is open for the specified admin panel module key.
 831       */
 832  	function extIsAdmMenuOpen($pre)    {
 833          return $this->uc['TSFE_adminConfig']['display_top'] && $this->uc['TSFE_adminConfig']['display_'.$pre];
 834      }
 835  
 836  
 837  
 838  
 839  
 840  
 841  
 842  
 843  
 844  
 845  
 846  
 847  
 848  
 849  
 850  
 851      /*****************************************************
 852       *
 853       * TSFE BE user Access Functions
 854       *
 855       ****************************************************/
 856  
 857      /**
 858       * Generates a list of Page-uid's from $id. List does not include $id itself
 859       * The only pages excluded from the list are deleted pages.
 860       *
 861       * @param    integer        Start page id
 862       * @param    integer        Depth to traverse down the page tree.
 863       * @param    integer        $begin is an optional integer that determines at which level in the tree to start collecting uid's. Zero means 'start right away', 1 = 'next level and out'
 864       * @param    string        Perms clause
 865       * @return    string        Returns the list with a comma in the end (if any pages selected!)
 866       */
 867  	function extGetTreeList($id,$depth,$begin=0,$perms_clause)    {
 868          $depth=intval($depth);
 869          $begin=intval($begin);
 870          $id=intval($id);
 871          $theList='';
 872  
 873          if ($id && $depth>0)    {
 874              $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
 875                          'uid,title',
 876                          'pages',
 877                          'pid='.$id.' AND doktype IN ('.$GLOBALS['TYPO3_CONF_VARS']['FE']['content_doktypes'].') AND deleted=0 AND '.$perms_clause
 878                      );
 879              while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))    {
 880                  if ($begin<=0)    {
 881                      $theList.=$row['uid'].',';
 882                      $this->extPageInTreeInfo[]=array($row['uid'],$row['title'],$depth);
 883                  }
 884                  if ($depth>1)    {
 885                      $theList.=$this->extGetTreeList($row['uid'], $depth-1,$begin-1,$perms_clause);
 886                  }
 887              }
 888          }
 889          return $theList;
 890      }
 891  
 892      /**
 893       * Returns the number of cached pages for a page id.
 894       *
 895       * @param    integer        The page id.
 896       * @return    integer        The number of pages for this page in the table "cache_pages"
 897       */
 898  	function extGetNumberOfCachedPages($page_id)    {
 899          $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'cache_pages', 'page_id='.intval($page_id));
 900          list($num) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
 901          return $num;
 902      }
 903  
 904  
 905  
 906  
 907  
 908  
 909  
 910  
 911  
 912  
 913  
 914  
 915  
 916  
 917  
 918  
 919  
 920  
 921  
 922  
 923  
 924      /*****************************************************
 925       *
 926       * Localization handling
 927       *
 928       ****************************************************/
 929  
 930      /**
 931       * Returns the label for key, $key. If a translation for the language set in $this->uc['lang'] is found that is returned, otherwise the default value.
 932       * IF the global variable $LOCAL_LANG is NOT an array (yet) then this function loads the global $LOCAL_LANG array with the content of "sysext/lang/locallang_tsfe.php" so that the values therein can be used for labels in the Admin Panel
 933       *
 934       * @param    string        Key for a label in the $LOCAL_LANG array of "sysext/lang/locallang_tsfe.php"
 935       * @return    string        The value for the $key
 936       */
 937  	function extGetLL($key)    {
 938          global $LOCAL_LANG;
 939          if (!is_array($LOCAL_LANG))    {
 940              $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_tsfe.php');
 941              #include('./'.TYPO3_mainDir.'sysext/lang/locallang_tsfe.php');
 942              if (!is_array($LOCAL_LANG))        $LOCAL_LANG=array();
 943          }
 944  
 945          $labelStr = htmlspecialchars($GLOBALS['LANG']->getLL($key));    // Label string in the default backend output charset.
 946  
 947              // Convert to utf-8, then to entities:
 948          if ($GLOBALS['LANG']->charSet!='utf-8')    {
 949              $labelStr = $GLOBALS['LANG']->csConvObj->utf8_encode($labelStr,$GLOBALS['LANG']->charSet);
 950          }
 951          $labelStr = $GLOBALS['LANG']->csConvObj->utf8_to_entities($labelStr);
 952  
 953              // Return the result:
 954          return $labelStr;
 955      }
 956  
 957  
 958  
 959  
 960  
 961  
 962  
 963  
 964  
 965  
 966  
 967  
 968  
 969      /*****************************************************
 970       *
 971       * Frontend Editing
 972       *
 973       ****************************************************/
 974  
 975      /**
 976       * Returns true in an edit-action is sent from the Admin Panel
 977       *
 978       * @return    boolean
 979       * @see index_ts.php
 980       */
 981  	function extIsEditAction()    {
 982          if (is_array($this->TSFE_EDIT))    {
 983              if ($this->TSFE_EDIT['cancel'])    {
 984                  unset($this->TSFE_EDIT['cmd']);
 985              } else {
 986                  $cmd = (string)$this->TSFE_EDIT['cmd'];
 987                  if (($cmd!='edit' || (is_array($this->TSFE_EDIT['data']) && ($this->TSFE_EDIT['update'] || $this->TSFE_EDIT['update_close']))) && $cmd!='new')    {
 988                          // $cmd can be a command like "hide" or "move". If $cmd is "edit" or "new" it's an indication to show the formfields. But if data is sent with update-flag then $cmd = edit is accepted because edit may be sendt because of .keepGoing flag.
 989                      return true;
 990                  }
 991              }
 992          }
 993          return false;
 994      }
 995  
 996      /**
 997       * Returns true if an edit form is shown on the page.
 998       * Used from index_ts.php where a true return-value will result in classes etc. being included.
 999       *
1000       * @return    boolean
1001       * @see index_ts.php
1002       */
1003  	function extIsFormShown()    {
1004          if (is_array($this->TSFE_EDIT))    {
1005              $cmd=(string)$this->TSFE_EDIT['cmd'];
1006              if ($cmd=='edit' || $cmd=='new')    {
1007                  return true;
1008              }
1009          }
1010      }
1011  
1012      /**
1013       * Management of the on-page frontend editing forms and edit panels.
1014       * Basically taking in the data and commands and passes them on to the proper classes as they should be.
1015       *
1016       * @return    void
1017       * @see index_ts.php
1018       */
1019  	function extEditAction()    {
1020          global $TCA, $TYPO3_CONF_VARS;
1021              // Commands:
1022          list($table,$uid) = explode(':',$this->TSFE_EDIT['record']);
1023          if ($this->TSFE_EDIT['cmd'] && $table && $uid && isset($TCA[$table]))    {
1024              $tce = t3lib_div::makeInstance('t3lib_TCEmain');
1025              $tce->stripslashes_values=0;
1026              $recData=array();
1027              $cmdData=array();
1028              $cmd=$this->TSFE_EDIT['cmd'];
1029  
1030              // ****************
1031              // extEditAction HOOK
1032              // ****************
1033              if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['extEditAction'])) {
1034                  $_params = array();
1035                  foreach($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['extEditAction'] as $_funcRef) {
1036                                  t3lib_div::callUserFunction($_funcRef,$_params,$this);
1037                  }
1038              }
1039  
1040              switch($cmd)    {
1041                  case 'hide':
1042                  case 'unhide':
1043                      $hideField = $TCA[$table]['ctrl']['enablecolumns']['disabled'];
1044                      if ($hideField)    {
1045                          $recData[$table][$uid][$hideField]=($cmd=='hide'?1:0);
1046                          $tce->start($recData,Array());
1047                          $tce->process_datamap();
1048                      }
1049                  break;
1050                  case 'up':
1051                  case 'down':
1052                      $sortField = $TCA[$table]['ctrl']['sortby'];
1053                      if ($sortField)    {
1054                          if ($cmd=='up')    {
1055                              $op= '<';
1056                              $desc=' DESC';
1057                          } else {
1058                              $op= '>';
1059                              $desc='';
1060                          }
1061                              // Get self:
1062                          $fields = array_unique(t3lib_div::trimExplode(',',$TCA[$table]['ctrl']['copyAfterDuplFields'].',uid,pid,'.$sortField,1));
1063                          $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(implode(',',$fields), $table, 'uid='.$uid);
1064                          if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))    {
1065                                  // record before or after
1066                              $preview = $this->extGetFeAdminValue('preview');
1067                              $copyAfterFieldsQuery = '';
1068                              if ($preview)    {$ignore = array('starttime'=>1, 'endtime'=>1, 'disabled'=>1, 'fe_group'=>1);}
1069                              if ($TCA[$table]['ctrl']['copyAfterDuplFields'])    {
1070                                  $cAFields = t3lib_div::trimExplode(',',$TCA[$table]['ctrl']['copyAfterDuplFields'],1);
1071                                  while(list(,$fN)=each($cAFields))    {
1072                                      $copyAfterFieldsQuery.=' AND '.$fN.'="'.$row[$fN].'"';
1073                                  }
1074                              }
1075  
1076                              $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1077                                          'uid,pid',
1078                                          $table,
1079                                          'pid='.intval($row['pid']).
1080                                              ' AND '.$sortField.$op.intval($row[$sortField]).
1081                                              $copyAfterFieldsQuery.
1082                                              $GLOBALS['TSFE']->sys_page->enableFields($table,'',$ignore),
1083                                          '',
1084                                          $sortField.$desc,
1085                                          '2'
1086                                      );
1087                              if ($row2 = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))    {
1088                                  if($cmd=='down')    {
1089                                      $cmdData[$table][$uid]['move']= -$row2['uid'];
1090                                  } elseif ($row3 = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {    // Must take the second record above...
1091                                      $cmdData[$table][$uid]['move']= -$row3['uid'];
1092                                  } else {    // ... and if that does not exist, use pid
1093                                      $cmdData[$table][$uid]['move']= $row['pid'];
1094                                  }
1095                              } elseif ($cmd=='up') {
1096                                  $cmdData[$table][$uid]['move']= $row['pid'];
1097                              }
1098                          }
1099                          if (count($cmdData))    {
1100                              $tce->start(Array(),$cmdData);
1101                              $tce->process_cmdmap();
1102                          }
1103                      }
1104                  break;
1105                  case 'delete':
1106                      $cmdData[$table][$uid]['delete']= 1;
1107                      if (count($cmdData))    {
1108                          $tce->start(Array(),$cmdData);
1109                          $tce->process_cmdmap();
1110                      }
1111                  break;
1112              }
1113          }
1114              // Data:
1115          if (($this->TSFE_EDIT['doSave'] || $this->TSFE_EDIT['update'] || $this->TSFE_EDIT['update_close']) && is_array($this->TSFE_EDIT['data']))    {
1116              $tce = t3lib_div::makeInstance('t3lib_TCEmain');
1117              $tce->stripslashes_values=0;
1118              $tce->start($this->TSFE_EDIT['data'],Array());
1119              $tce->process_uploads($_FILES);
1120              $tce->process_datamap();
1121          }
1122      }
1123  }
1124  
1125  
1126  if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_tsfebeuserauth.php'])    {
1127      include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_tsfebeuserauth.php']);
1128  }
1129  ?>


Généré le : Sun Nov 25 17:13:16 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics