Added feature #9615: Move frontend editing to a system extension.
authorJeff Segars <jsegars@alumni.rice.edu>
Thu, 6 Nov 2008 17:32:36 +0000 (17:32 +0000)
committerJeff Segars <jsegars@alumni.rice.edu>
Thu, 6 Nov 2008 17:32:36 +0000 (17:32 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@4427 709f56b5-9817-0410-a4d7-c38de5d9e867

15 files changed:
ChangeLog
NEWS.txt
t3lib/class.t3lib_frontendedit.php [new file with mode: 0644]
t3lib/class.t3lib_tsfebeuserauth.php
t3lib/config_default.php
t3lib/exception/class.t3lib_exception_frontendedit.php [new file with mode: 0644]
typo3/sysext/cms/tslib/class.tslib_content.php
typo3/sysext/cms/tslib/class.tslib_fe.php
typo3/sysext/cms/tslib/index_ts.php
typo3/sysext/cms/tslib/publish.php
typo3/sysext/fe_edit/ext_emconf.php [new file with mode: 0644]
typo3/sysext/fe_edit/ext_icon.gif [new file with mode: 0755]
typo3/sysext/fe_edit/ext_localconf.php [new file with mode: 0644]
typo3/sysext/fe_edit/view/class.tx_feedit_adminpanel.php [new file with mode: 0644]
typo3/sysext/fe_edit/view/class.tx_feedit_editpanel.php [new file with mode: 0644]

index 698b112..cb0ced7 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2008-11-07  Jeff Segars  <jeff@webempoweredchurch.org>
+
+       * Added feature #9615: Move frontend editing to a system extension.
+
 2008-11-04  Ingo Renner  <ingo@typo3.org>
 
        * Fixed bug #9681: the Wrap for forgotMessage in the subpart ###TEMPLATE_FORGOT### does not work (credits Steffen Kamper)
index 9bc521c..0dbf829 100644 (file)
--- a/NEWS.txt
+++ b/NEWS.txt
@@ -52,6 +52,8 @@ Compatibility
        * The simulateStaticDocument functionality (URLs like "MyPage.13.0.html" instead of "index.php?id=13")
          was extracted and put to a separate system extension "simulatestatic".
 
+       * The frontend editing functionality was extracted into a separate system extension "frontend_edit".
+
 Development
 ===========
 
diff --git a/t3lib/class.t3lib_frontendedit.php b/t3lib/class.t3lib_frontendedit.php
new file mode 100644 (file)
index 0000000..26634da
--- /dev/null
@@ -0,0 +1,752 @@
+<?php
+/***************************************************************
+*  Copyright notice
+*
+*  (c) 2008 Jeff Segars <jeff@webempoweredchurch.org>
+*  (c) 2008 David Slayback <dave@webempoweredchurch.org>
+*  All rights reserved
+*
+*  This script is part of the TYPO3 project. The TYPO3 project is
+*  free software; you can redistribute it and/or modify
+*  it under the terms of the GNU General Public License as published by
+*  the Free Software Foundation; either version 2 of the License, or
+*  (at your option) any later version.
+*
+*  The GNU General Public License can be found at
+*  http://www.gnu.org/copyleft/gpl.html.
+*  A copy is found in the textfile GPL.txt and important notices to the license
+*  from the author is found in LICENSE.txt distributed with these scripts.
+*
+*
+*  This script is distributed in the hope that it will be useful,
+*  but WITHOUT ANY WARRANTY; without even the implied warranty of
+*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*  GNU General Public License for more details.
+*
+*  This copyright notice MUST APPEAR in all copies of the script!
+***************************************************************/
+
+/**
+ * Controller class for frontend editing.
+ *
+ * @author     Jeff Segars <jeff@webempoweredchurch.org>
+ * @author     David Slayback <dave@webempoweredchurch.org>
+ * @package TYPO3
+ * @subpackage t3lib
+ */
+
+class t3lib_frontendedit {
+
+       /**
+        * TCEmain object.
+        *
+        * @var t3lib_tcemain
+        */
+       protected $tce;
+
+
+       /**
+        * Force preview?
+        *
+        * @var boolean
+        */
+       protected $ext_forcePreview = false;
+
+       /**
+        * Comma separated list of page UIDs to be published.
+        *
+        * @var string
+        */
+       protected $extPublishList = '';
+
+       /**
+        * Creates and initializes the TCEmain object.
+        *
+        * @return      void
+        */
+       public function __construct() {
+               $this->tce = t3lib_div::makeInstance('t3lib_TCEmain');
+               $this->tce->stripslashes_values=0;
+       }
+
+       /**
+        * Initializes configuration options.
+        *
+        * @return      void
+        */
+       public function initConfigOptions() {
+               $this->saveConfigOptions();
+               $this->TSFE_EDIT = t3lib_div::_POST('TSFE_EDIT');
+
+                       // Setting some values based on the admin panel
+               $GLOBALS['TSFE']->forceTemplateParsing = $this->extGetFeAdminValue('tsdebug', 'forceTemplateParsing');
+               $GLOBALS['TSFE']->displayEditIcons = $this->extGetFeAdminValue('edit', 'displayIcons');
+               $GLOBALS['TSFE']->displayFieldEditIcons = $this->extGetFeAdminValue('edit', 'displayFieldIcons');
+
+               if ($this->extGetFeAdminValue('tsdebug', 'displayQueries')) {
+                       if ($GLOBALS['TYPO3_DB']->explainOutput == 0) {         // do not override if the value is already set in t3lib_db
+                                       // Enable execution of EXPLAIN SELECT queries
+                               $GLOBALS['TYPO3_DB']->explainOutput = 3;
+                       }
+               }
+
+               if (t3lib_div::_GP('ADMCMD_editIcons')) {
+                       $GLOBALS['TSFE']->displayFieldEditIcons=1;
+                       $GLOBALS['BE_USER']->uc['TSFE_adminConfig']['edit_editNoPopup']=1;
+               }
+
+               if (t3lib_div::_GP('ADMCMD_simUser')) {
+                       $GLOBALS['BE_USER']->uc['TSFE_adminConfig']['preview_simulateUserGroup']=intval(t3lib_div::_GP('ADMCMD_simUser'));
+                       $this->ext_forcePreview = true;
+               }
+
+               if (t3lib_div::_GP('ADMCMD_simTime')) {
+                       $GLOBALS['BE_USER']->uc['TSFE_adminConfig']['preview_simulateDate']=intval(t3lib_div::_GP('ADMCMD_simTime'));
+                       $this->ext_forcePreview = true;
+               }
+
+                       // Include classes for editing IF editing module in Admin Panel is open
+               if (($this->isAdminModuleEnabled('edit') && $this->isAdminModuleOpen('edit')) || $GLOBALS['TSFE']->displayEditIcons == 1) {
+                       $GLOBALS['TSFE']->includeTCA();
+                       if ($this->isEditAction()) {
+                               require_once (PATH_t3lib . 'class.t3lib_tcemain.php');
+                               $this->editAction();
+                       }
+
+                       if ($this->isEditFormShown()) {
+                               require_once(PATH_t3lib . 'class.t3lib_tceforms.php');
+                               require_once(PATH_t3lib . 'class.t3lib_iconworks.php');
+                               require_once(PATH_t3lib . 'class.t3lib_loaddbgroup.php');
+                               require_once(PATH_t3lib . 'class.t3lib_transferdata.php');
+                       }
+               }
+
+               if ($GLOBALS['TSFE']->forceTemplateParsing || $GLOBALS['TSFE']->displayEditIcons || $GLOBALS['TSFE']->displayFieldEditIcons) {
+                       $GLOBALS['TSFE']->set_no_cache(); 
+               }
+       }
+
+
+       /**
+        * Delegates to the appropriate view and renders the admin panel content.
+        *
+        * @return      string.
+        */
+       public function displayAdmin() {
+               $content = '';
+               $adminClass = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/classes/class.frontendedit.php']['admin'];
+               if ($adminClass && !$GLOBALS['BE_USER']->extAdminConfig['hide']) {
+                       $admin = &t3lib_div::getUserObj($adminClass);
+                       if (is_object($admin)) {
+                               $content =  $admin->display();
+                       }
+               }
+
+               return $content;
+       }
+
+       /**
+        * Generates the "edit panels" which can be shown for a page or records on a page when the Admin Panel is enabled for a backend users surfing the frontend.
+        * With the "edit panel" the user will see buttons with links to editing, moving, hiding, deleting the element
+        * This function is used for the cObject EDITPANEL and the stdWrap property ".editPanel"
+        *
+        * @param       string          A content string containing the content related to the edit panel. For cObject "EDITPANEL" this is empty but not so for the stdWrap property. The edit panel is appended to this string and returned.
+        * @param       array           TypoScript configuration properties for the editPanel
+        * @param       string          The "table:uid" of the record being shown. If empty string then $this->currentRecord is used. For new records (set by $conf['newRecordFromTable']) it's auto-generated to "[tablename]:NEW"
+        * @param       array           Alternative data array to use. Default is $this->data
+        * @return      string          The input content string with the editPanel appended. This function returns only an edit panel appended to the content string if a backend user is logged in (and has the correct permissions). Otherwise the content string is directly returned.
+        * @link        http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=375&cHash=7d8915d508
+        */
+       public function displayEditPanel($content, array $conf, $currentRecord, array $dataArray) {
+               if ($conf['newRecordFromTable']) {
+                       $currentRecord = $conf['newRecordFromTable'] . ':NEW';
+                       $conf['allow'] = 'new';
+               }
+
+               list($table, $uid) = explode(':', $currentRecord);
+
+                       // Page ID for new records, 0 if not specified
+               $newRecordPid = intval($conf['newRecordInPid']);
+               if (!$conf['onlyCurrentPid'] || $dataArray['pid'] == $GLOBALS['TSFE']->id) {
+                       if ($table=='pages') {
+                               $newUid = $uid;
+                       } else {
+                               if ($conf['newRecordFromTable']) {
+                                       $newUid = $GLOBALS['TSFE']->id;
+                                       if ($newRecordPid) {
+                                                $newUid = $newRecordPid;
+                                       }
+                               } else {
+                                       $newUid = -1 * $uid;
+                               }
+                       }
+               }
+
+               if ($GLOBALS['TSFE']->displayEditIcons && $table && $this->allowedToEdit($table, $dataArray, $conf) && $this->allowedToEditLanguage($table, $dataArray)) {
+                       $editClass = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/classes/class.frontendedit.php']['edit'];
+                       if ($editClass) {
+                               $edit = &t3lib_div::getUserObj($editClass, false);
+                               if (is_object($edit)) {
+                                       $allowedActions = $this->getAllowedEditActions($table, $conf, $dataArray['pid']);
+                                       $content = $edit->editPanel($content, $conf, $currentRecord, $dataArray, $table, $allowedActions, $newUid, $this->getHiddenFieldArray($dataArray));
+                               }
+                       }
+               }
+
+               return $content;
+       }
+
+       /**
+        * Gets the hidden fields (array key=field name, value=field value) to be used in the edit panel for a particular content element. 
+        * In the normal case, no hidden fields are needed but special controllers such as TemplaVoila need to track flexform pointers, etc.
+        *
+        * @param       array   The data array for a specific content element.
+        * @return      array
+        */
+       public function getHiddenFieldArray(array $dataArray) {
+                       // No special hidden fields needed.
+               return array();
+       }
+
+       /**
+        * Adds an edit icon to the content string. The edit icon links to alt_doc.php with proper parameters for editing the table/fields of the context.
+        * This implements TYPO3 context sensitive editing facilities. Only backend users will have access (if properly configured as well).
+        *
+        * @param       string          The content to which the edit icons should be appended
+        * @param       string          The parameters defining which table and fields to edit. Syntax is [tablename]:[fieldname],[fieldname],[fieldname],... OR [fieldname],[fieldname],[fieldname],... (basically "[tablename]:" is optional, default table is the one of the "current record" used in the function). The fieldlist is sent as "&columnsOnly=" parameter to alt_doc.php
+        * @param       array           TypoScript properties for configuring the edit icons.
+        * @param       string          The "table:uid" of the record being shown. If empty string then $this->currentRecord is used. For new records (set by $conf['newRecordFromTable']) it's auto-generated to "[tablename]:NEW"
+        * @param       array           Alternative data array to use. Default is $this->data
+        * @param       string          Additional URL parameters for the link pointing to alt_doc.php
+        * @return      string          The input content string, possibly with edit icons added (not necessarily in the end but just after the last string of normal content.
+        */
+
+       public function displayEditIcons($content, $params, array $conf=array(), $currentRecord = '', array $dataArray = array(), $addUrlParamStr = '') {
+                       // Check incoming params:
+               list($currentRecordTable, $currentRecordUID) = explode(':', $currentRecord);
+               list($fieldList, $table) = array_reverse(t3lib_div::trimExplode(':', $params, 1)); // Reverse the array because table is optional
+               if (!$table) {
+                       $table = $currentRecordTable;
+               } elseif ($table != $currentRecordTable) {
+                               return $content;        // If the table is set as the first parameter, and does not match the table of the current record, then just return.
+               }
+
+               $editUid = $dataArray['_LOCALIZED_UID'] ? $dataArray['_LOCALIZED_UID'] : $currentRecordUID;
+
+                       // Edit icons imply that the editing action is generally allowed, assuming page and content element permissions permit it.
+               if(!array_key_exists('allow', $conf)) {
+                       $conf['allow'] = 'edit';
+               }
+
+               if ($GLOBALS['TSFE']->displayFieldEditIcons && $table && $this->allowedToEdit($table, $dataArray, $conf) && $fieldList && $this->allowedToEditLanguage($table, $dataArray)) {
+                       $editClass = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/classes/class.frontendedit.php']['edit'];
+                       if ($editClass) {
+                               $edit = &t3lib_div::getUserObj($editClass);
+                               if (is_object($edit)) {
+                                       $content = $edit->editIcons($content, $params, $conf, $currentRecord, $dataArray, $addURLParamStr, $table, $editUid, $fieldList);
+                               }
+                       }
+               }
+
+               return $content;
+       }
+
+       /**
+        * Checks if a Admin Panel section ("module") is available for the user. If so, true is returned.
+        *
+        * @param       string          The module key, eg. "edit", "preview", "info" etc.
+        * @return      boolean
+        */
+       public function isAdminModuleEnabled($key) {
+                       // Returns true if the module checked is "preview" and the forcePreview flag is set.
+               if ($key=='preview' && $this->ext_forcePreview) {
+                       return true;
+               }
+
+                       // If key is not set, only "all" is checked
+               if ($GLOBALS['BE_USER']->extAdminConfig['enable.']['all']) {
+                       return true;
+               }
+
+               if ($GLOBALS['BE_USER']->extAdminConfig['enable.'][$key]) {
+                       return true;
+               }
+       }
+
+       /**
+        * Saves any change in settings made in the Admin Panel.
+        * Called from index_ts.php right after access check for the Admin Panel
+        *
+        * @return      void
+        */
+       public function saveConfigOptions() {
+               $input = t3lib_div::_GP('TSFE_ADMIN_PANEL');
+               if (is_array($input)) {
+                               // Setting
+                       $GLOBALS['BE_USER']->uc['TSFE_adminConfig'] = array_merge(!is_array($GLOBALS['BE_USER']->uc['TSFE_adminConfig']) ? array() : $GLOBALS['BE_USER']->uc['TSFE_adminConfig'], $input);                      // Candidate for t3lib_div::array_merge() if integer-keys will some day make trouble...
+                       unset($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['action']);
+
+                               // Actions:
+                       if ($input['action']['clearCache'] && $this->isAdminModuleEnabled('cache')) {
+                               $GLOBALS['BE_USER']->extPageInTreeInfo=array();
+                               $theStartId = intval($input['cache_clearCacheId']);
+                               $GLOBALS['TSFE']->clearPageCacheContent_pidList($GLOBALS['BE_USER']->extGetTreeList($theStartId, $this->extGetFeAdminValue('cache', 'clearCacheLevels'), 0, $GLOBALS['BE_USER']->getPagePermsClause(1)) . $theStartId);
+                       }
+                       if ($input['action']['publish'] && $this->isAdminModuleEnabled('publish')) {
+                               $theStartId = intval($input['publish_id']);
+                               $this->extPublishList = $GLOBALS['BE_USER']->extGetTreeList($theStartId, $this->extGetFeAdminValue('publish', 'levels'), 0, $GLOBALS['BE_USER']->getPagePermsClause(1)) . $theStartId;
+                       }
+
+                               // Saving
+                       $GLOBALS['BE_USER']->writeUC();
+               }
+               $GLOBALS['TT']->LR = $this->extGetFeAdminValue('tsdebug', 'LR');
+
+               if ($this->extGetFeAdminValue('cache', 'noCache')) {
+                       $GLOBALS['TSFE']->set_no_cache();
+               }
+
+                       // Hook for post processing the frontend admin configuration. Added with TYPO3 4.2, so naming is now incorrect but preserves compatibility.
+                       // @deprecated  since TYPO3 4.3
+               if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['extSaveFeAdminConfig-postProc'])) {
+                       $_params = array('input' => &$input, 'pObj' => &$this);
+                       foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['extSaveFeAdminConfig-postProc'] as $_funcRef) {
+                               t3lib_div::callUserFunction($_funcRef, $_params, $this);
+                       }
+               }
+       }
+
+       /**
+        * Returns the value for a Admin Panel setting. You must specify both the module-key and the internal setting key.
+        *
+        * @param       string          Module key
+        * @param       string          Setting key
+        * @return      string          The setting value
+        */
+       public function extGetFeAdminValue($pre, $val='') {
+                               // Check if module is enabled.
+               if ($this->isAdminModuleEnabled($pre)) {
+                               // Exceptions where the values can be overridden from backend:
+                               // deprecated
+                       if ($pre . '_' . $val == 'edit_displayIcons' && $GLOBALS['BE_USER']->extAdminConfig['module.']['edit.']['forceDisplayIcons']) {
+                               return true;
+                       }
+                       if ($pre . '_' . $val == 'edit_displayFieldIcons' && $GLOBALS['BE_USER']->extAdminConfig['module.']['edit.']['forceDisplayFieldIcons']) {
+                               return true;
+                       }
+
+                               // override all settings with user TSconfig
+                       if ($GLOBALS['BE_USER']->extAdminConfig['override.'][$pre . '.'][$val] && $val) {
+                               return $GLOBALS['BE_USER']->extAdminConfig['override.'][$pre . '.'][$val];
+                       }
+                       if ($GLOBALS['BE_USER']->extAdminConfig['override.'][$pre]) {
+                               return $GLOBALS['BE_USER']->extAdminConfig['override.'][$pre];
+                       }
+
+                       $retVal = $val ? $GLOBALS['BE_USER']->uc['TSFE_adminConfig'][$pre . '_' . $val] : 1;
+
+                       if ($pre=='preview' && $this->ext_forcePreview) {
+                               if (!$val) {
+                                       return true;
+                               } else {
+                                       return $retVal;
+                               }
+                       }
+                               // regular check:
+                       if ($this->isAdminModuleOpen($pre)) {   // See if the menu is expanded!
+                               return $retVal;
+                       }
+
+                               // Hook for post processing the frontend admin configuration. Added with TYPO3 4.2, so naming is now incorrect but preserves compatibility.
+                               // @deprecated  since TYPO3 4.3
+                       if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['extEditAction-postProc'])) {
+                               $_params = array('cmd' => &$cmd, 'tce' => &$this->tce, 'pObj' => &$this);
+                               foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['extEditAction-postProc'] as $_funcRef) {
+                                       t3lib_div::callUserFunction($_funcRef, $_params, $this);
+                               }
+                       }
+               }
+       }
+
+       /**
+        * Returns the comma-separated list of page UIDs to be published.
+        *
+        * @return      string
+        */
+       public function getExtPublishList() {
+               return $this->extPublishList;
+       }
+
+       /**
+        * Returns true if admin panel module is open
+        *
+        * @param       string          Module key
+        * @return      boolean         True, if the admin panel is open for the specified admin panel module key.
+        */
+       public function isAdminModuleOpen($pre) {
+               return $GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_top'] && $GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_' . $pre];
+       }
+
+       /*****************************************************
+        *
+        * Frontend Editing
+        *
+        ****************************************************/
+
+       /**
+        * Returns true in an edit-action is sent from the Admin Panel
+        *
+        * @return      boolean
+        * @see index_ts.php
+        */
+       public function isEditAction() {
+               if (is_array($this->TSFE_EDIT)) {
+                       if ($this->TSFE_EDIT['cancel']) {
+                               unset($this->TSFE_EDIT['cmd']);
+                       } else {
+                               $cmd = (string) $this->TSFE_EDIT['cmd'];
+                               if (($cmd != 'edit' || (is_array($this->TSFE_EDIT['data']) && ($this->TSFE_EDIT['update'] || $this->TSFE_EDIT['update_close']))) && $cmd != 'new') {
+                                               // $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.
+                                       return true;
+                               }
+                       }
+               }
+               return false;
+       }
+
+       /**
+        * Returns true if an edit form is shown on the page.
+        * Used from index_ts.php where a true return-value will result in classes etc. being included.
+        *
+        * @return      boolean
+        * @see index_ts.php
+        */
+       public function isEditFormShown() {
+               if (is_array($this->TSFE_EDIT)) {
+                       $cmd = (string) $this->TSFE_EDIT['cmd'];
+                       if ($cmd=='edit' || $cmd=='new') {
+                               return true;
+                       }
+               }
+       }
+
+       /**
+        * Management of the on-page frontend editing forms and edit panels.
+        * Basically taking in the data and commands and passes them on to the proper classes as they should be.
+        *
+        * @return      void
+        * @throws t3lib_exception_InvalidFrontendEditAction if TSFE_EDIT[cmd] is not a valid command
+        * @see index_ts.php
+        */
+       public function editAction() {
+                       // Commands:
+               list($table, $uid) = explode(':', $this->TSFE_EDIT['record']);
+               $cmd = $this->TSFE_EDIT['cmd'];
+
+               if ($cmd && $table && $uid && isset($GLOBALS['TCA'][$table])) {
+                               // Hook for defining custom editing actions. Naming is incorrect, but preserves compatibility.
+                       if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['extEditAction'])) {
+                               $_params = array();
+                               foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['extEditAction'] as $_funcRef) {
+                                       t3lib_div::callUserFunction($_funcRef, $_params, $this);
+                               }
+                       }
+                               // Perform the requested editing command.
+                       if(is_callable(array($this, $cmd))) {
+                               $this->$cmd($table, $uid);
+                       } else {
+                               require_once(PATH_t3lib . 'exception/class.t3lib_exception_frontendedit.php');
+                               throw new t3lib_exception_frontendedit(
+                                       'The specified frontend edit command (' . $cmd . ') is not valid.',
+                                       1225818120
+                               );
+
+                       }
+               }
+                       // Data:
+               if (($this->TSFE_EDIT['doSave'] || $this->TSFE_EDIT['update'] || $this->TSFE_EDIT['update_close']) && is_array($this->TSFE_EDIT['data'])) {
+                       $this->save($this->TSFE_EDIT['data']);
+                       // pass this on if needed
+                       if ($newuid = $this->tce->substNEWwithIDs['NEW']) {
+                               $this->TSFE_EDIT['newUID'] = $newuid;
+                       }
+               }
+       }
+
+       /**
+        * Hides a specific record.
+        *
+        * @param       string          The table name for the record to hide.
+        * @param       integer         The UID for the record to hide.
+        * @return      void
+        */
+       public function hide($table, $uid) {
+               $hideField = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled'];
+               if ($hideField) {
+                       $recData = array();
+                       $recData[$table][$uid][$hideField] = 1;
+                       $this->tce->start($recData, array());
+                       $this->tce->process_datamap();
+               }
+       }
+
+       /**
+        * Unhides (shows) a specific record.
+        *
+        * @param       string          The table name for the record to unhide.
+        * @param       integer         The UID for the record to unhide.
+        * @return      void
+        */
+       public function unhide($table, $uid) {
+               $hideField = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled'];
+               if ($hideField) {
+                       $recData = array();
+                       $recData[$table][$uid][$hideField] = 0;
+                       $this->tce->start($recData, array());
+                       $this->tce->process_datamap();
+               }
+       }
+
+       /**
+        * Moves a record up.
+        *
+        * @param       string          The table name for the record to move.
+        * @param       integer         The UID for the record to hide.
+        * @return      void
+        */
+       public function up($table, $uid) {
+               $this->move($table, $uid, 'up');
+       }
+
+       /**
+        * Moves a record down.
+        *
+        * @param       string          The table name for the record to move.
+        * @param       integer         The UID for the record to move.
+        * @return      void
+        */
+       public function down($table, $uid) {
+               $this->move($table, $uid, 'down');
+       }
+
+       /**
+        * Moves a record in the specified direction.
+        *
+        * @param       string          The table name for the record to move.
+        * @param       integer         The UID for the record to move.
+        * @param       string          The direction to move, either 'up' or 'down'.
+        * @return      void
+        */
+       protected function move($table, $uid, $direction) {
+               $cmdData = array();
+               if ($direction == 'up') {
+                       $operator = '<';
+                       $order = 'DESC';
+               } else {
+                       $operator = '>';
+                       $order = 'ASC';
+               }
+
+               $sortField = $GLOBALS['TCA'][$table]['ctrl']['sortby'];
+               if ($sortField) {
+                               // Get self:
+                       $fields = array_unique(t3lib_div::trimExplode(',', $GLOBALS['TCA'][$table]['ctrl']['copyAfterDuplFields'] . ',uid,pid,' . $sortField, true));
+                       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(implode(',', $fields), $table, 'uid=' . $uid);
+                       if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
+                                       // record before or after
+                               $preview = $this->extGetFeAdminValue('preview');
+                               $copyAfterFieldsQuery = '';
+                               if ($preview) {
+                                       $ignore = array('starttime'=>1, 'endtime'=>1, 'disabled'=>1, 'fe_group'=>1);
+                               }
+                               if ($GLOBALS['TCA'][$table]['ctrl']['copyAfterDuplFields']) {
+                                       $cAFields = t3lib_div::trimExplode(',', $GLOBALS['TCA'][$table]['ctrl']['copyAfterDuplFields'], false);
+                                       foreach($cAFields as $fieldName) {
+                                               $copyAfterFieldsQuery .= ' AND ' . $fieldName . '="' . $row[$fieldName] . '"';
+                                       }
+                               }
+
+                               $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
+                                                       'uid,pid',
+                                                       $table,
+                                                       'pid=' . intval($row['pid']) .
+                                                               ' AND ' . $sortField . $operator . intval($row[$sortField]) .
+                                                               $copyAfterFieldsQuery .
+                                                               $GLOBALS['TSFE']->sys_page->enableFields($table, '', $ignore),
+                                                       '',
+                                                       $sortField . ' ' . $order,
+                                                       '2'
+                                               );
+                               if ($row2 = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
+                                       if ($direction == 'down') {
+                                               $cmdData[$table][$uid]['move'] = -$row2['uid'];
+                                       } elseif ($row3 = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {        // Must take the second record above...
+                                               $cmdData[$table][$uid]['move'] = -$row3['uid'];
+                                       } else {        // ... and if that does not exist, use pid
+                                               $cmdData[$table][$uid]['move'] = $row['pid'];
+                                       }
+                               } elseif ($direction == 'up') {
+                                       $cmdData[$table][$uid]['move'] = $row['pid'];
+                               }
+                       }
+                       if (count($cmdData)) {
+                               $this->tce->start(array(), $cmdData);
+                               $this->tce->process_cmdmap();
+                       }
+               }
+       }
+
+       /**
+        * Deletes a specific record.
+        *
+        * @param       string          The table name for the record to delete.
+        * @param       integer         The UID for the record to delete.
+        * @return      void
+        */
+       public function delete($table, $uid) {
+               $cmdData[$table][$uid]['delete'] = 1;
+               if (count($cmdData)) {
+                       $this->tce->start(array(), $cmdData);
+                       $this->tce->process_cmdmap();
+               }
+       }
+
+       /**
+        * Saves a record based on its data array.
+        *
+        * @param       array           Array of record data to be saved.
+        * @return      void
+        */
+       public function save(array $data) {
+               $this->tce->start($data, array());
+               $this->tce->process_uploads($_FILES);
+               $this->tce->process_datamap();
+       }
+
+       /**
+        * Checks whether the user has access to edit the language for the
+        * requested record.
+        *
+        * @param       string          The name of the table.
+        * @param       array           The record.
+        * @return      boolean
+        */
+       protected function allowedToEditLanguage($table, array $currentRecord) {
+                       // If no access right to record languages, return immediately
+               if ($table === 'pages') {
+                       $lang = $GLOBALS['TSFE']->sys_language_uid;
+               } elseif ($table === 'tt_content') {
+                       $lang = $GLOBALS['TSFE']->sys_language_content;
+               } elseif ($GLOBALS['TCA'][$table]['ctrl']['languageField']) {
+                       $lang = $currentRecord[$GLOBALS['TCA'][$table]['ctrl']['languageField']];
+               } else {
+                       $lang = -1;
+               }
+
+               if ($GLOBALS['BE_USER']->checkLanguageAccess($lang)) { 
+                       $languageAccess = true;
+               } else {
+                       $languageAccess = false;
+               }
+
+               return $languageAccess;
+       }
+
+       /**
+        * Checks whether the user is allowed to edit the requested table.
+        *
+        * @param       string  The name of the table.
+        * @param       array   The data array.
+        * @param       array   The configuration array for the edit panel.
+        * @return      boolean
+        */
+       protected function allowedToEdit($table, array $dataArray, array $conf) {
+
+                       // Unless permissions specifically allow it, editing is not allowed.
+               $mayEdit = false;
+
+               if ($table=='pages') {
+                               // 2 = permission to edit the page
+                       if($GLOBALS['BE_USER']->isAdmin() || $GLOBALS['BE_USER']->doesUserHaveAccess($dataArray, 2)) {
+                               $mayEdit = true;
+                       }
+               } else {
+                               // 16 = permission to edit content on the page
+                       if ($GLOBALS['BE_USER']->isAdmin() || $GLOBALS['BE_USER']->doesUserHaveAccess(t3lib_BEfunc::getRecord('pages', $dataArray['pid']), 16)) {
+                               $mayEdit = true;
+                       }
+               }
+
+               if (!$conf['onlyCurrentPid'] || ($dataArray['pid'] == $GLOBALS['TSFE']->id)) {
+                               // Permissions:
+                       $types = t3lib_div::trimExplode(',', t3lib_div::strtolower($conf['allow']),1);
+                       $allow = array_flip($types);
+
+                       $perms = $GLOBALS['BE_USER']->calcPerms($GLOBALS['TSFE']->page);
+                       if ($table == 'pages') {
+                               $allow = $this->getAllowedEditActions($table, $conf, $dataArray['pid'], $allow);
+
+                                       // Can only display editbox if there are options in the menu
+                               if (count($allow)) { 
+                                       $mayEdit = true;
+                               }
+                       } else {
+                               $mayEdit = count($allow) && ($perms & 16);
+                       }
+               }
+
+               return $mayEdit;
+       }
+
+       /**
+        * Takes an array of generally allowed actions and filters that list based on page and content permissions.
+        * 
+        * @param       string  The name of the table.
+        * @param       array   The configuration array.
+        * @param       integer The PID where editing will occur.
+        * @param       string  Comma-separated list of actions that are allowed in general.
+        * @return      array
+        */
+       protected function getAllowedEditActions($table, array $conf, $pid, $allow = '') {
+
+               if (!$allow) {
+                       $types = t3lib_div::trimExplode(',', t3lib_div::strtolower($conf['allow']), true);
+                       $allow = array_flip($types);
+               }
+
+               if (!$conf['onlyCurrentPid'] || $pid == $GLOBALS['TSFE']->id) {
+                               // Permissions:
+                       $types = t3lib_div::trimExplode(',', t3lib_div::strtolower($conf['allow']), true);
+                       $allow = array_flip($types);
+
+                       $perms = $GLOBALS['BE_USER']->calcPerms($GLOBALS['TSFE']->page);
+                       if ($table=='pages') {
+                                       // rootpage!
+                               if (count($GLOBALS['TSFE']->config['rootLine']) == 1) {
+                                       unset($allow['move']);
+                                       unset($allow['hide']);
+                                       unset($allow['delete']);
+                               }
+                               if (!($perms & 2)){
+                                       unset($allow['edit']);
+                                       unset($allow['move']);
+                                       unset($allow['hide']);
+                               }
+                               if (!($perms & 4)) {
+                                       unset($allow['delete']);
+                               }
+                               if (!($perms&8)) {
+                                       unset($allow['new']);
+                               }
+                       }
+               }
+
+               return $allow;
+       }
+}
+
+if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_frontendedit.php']) {
+       include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_frontendedit.php']);
+}
+
+?>
\ No newline at end of file
index 4ca8fe1..aeadd7c 100755 (executable)
  * @subpackage t3lib
  */
 class t3lib_tsfeBeUserAuth extends t3lib_beUserAuth {
-       var $formfield_uname = '';                      // formfield with login-name
-       var $formfield_uident = '';             // formfield with password
-       var $formfield_chalvalue = '';          // formfield with a unique value which is used to encrypt the password and username
-       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.
-       var $writeStdLog = 0;                                   // Decides if the writelog() function is called at login and logout
-       var $writeAttemptLog = 0;                               // If the writelog() functions is called if a login-attempt has be tried without success
-       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.
-
-       var $extNeedUpdate=0;
-       var $extPublishList='';
-       var $extPageInTreeInfo=array();
-       var $ext_forcePreview=0;
-       var $langSplitIndex=0;
-       var $extAdmEnabled = 0; // General flag which is set if the adminpanel should be displayed at all..
-
-
-
-
        /**
-        * Initialize the usage of Admin Panel.
-        * Called from index_ts.php if a backend users is correctly logged in.
-        * Sets $this->extAdminConfig to the "admPanel" config for the user and $this->extAdmEnabled = 1 IF access is enabled.
+        * Form field with login name.
         *
-        * @return      void
+        * @var string
         */
-       function extInitFeAdmin()       {
-               $this->extAdminConfig = $this->getTSConfigProp('admPanel');
-               if (is_array($this->extAdminConfig['enable.'])) {
-                       reset($this->extAdminConfig['enable.']);
-                       while(list($k,$v)=each($this->extAdminConfig['enable.']))       {
-                               if ($v) {
-                                       $this->extAdmEnabled=1; // Enable panel
-                                       break;
-                               }
-                       }
-               }
-
-                       // Init TSFE_EDIT variables if either the admPanel is enabled or if forceDisplayIcons is set
-               if($this->extAdmEnabled || $this->extGetFeAdminValue('edit', 'displayIcons'))   {
-                       $this->TSFE_EDIT = t3lib_div::_POST('TSFE_EDIT');
-               }
-       }
+       public $formfield_uname = '';
 
        /**
-        * Creates and returns the HTML code for the Admin Panel in the TSFE frontend.
-        * Called from index_ts.php - in the end of the script
+        * Form field with password.
         *
-        * @return      string          HTML for the Admin Panel
-        * @see index_ts.php
+        * @var string
         */
-       function extPrintFeAdminDialog()        {
-               $out='';
-               if ($this->uc['TSFE_adminConfig']['display_top'])       {
-                       if ($this->extAdmModuleEnabled('preview'))      $out.= $this->extGetCategory_preview();
-                       if ($this->extAdmModuleEnabled('cache'))        $out.= $this->extGetCategory_cache();
-                       if ($this->extAdmModuleEnabled('publish'))      $out.= $this->extGetCategory_publish();
-                       if ($this->extAdmModuleEnabled('edit'))         $out.= $this->extGetCategory_edit();
-                       if ($this->extAdmModuleEnabled('tsdebug'))      $out.= $this->extGetCategory_tsdebug();
-                       if ($this->extAdmModuleEnabled('info'))         $out.= $this->extGetCategory_info();
-               }
-
-               $row = '<img src="'.TYPO3_mainDir.'gfx/ol/blank.gif" width="18" height="16" align="absmiddle" border="0" alt="" />';
-               $row.= '<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="" />';
-               $row.= '<strong>'.$this->extFw($this->extGetLL('adminOptions')).'</strong>';
-               $row.= $this->extFw(': '.$this->user['username']);
-
-               $header = '
-                       <tr class="typo3-adminPanel-hRow" style="background-color:#9ba1a8;">
-                               <td colspan="4" style="text-align:left; white-space:nowrap;">'.
-                                       $this->extItemLink('top',$row).'
-                                       <img src="clear.gif" width="40" height="1" alt="" />
-                                       <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>
-                       </tr>';
-
-               $query = !t3lib_div::_GET('id') ? ('<input type="hidden" name="id" value="'.$GLOBALS['TSFE']->id.'" />'.chr(10)) : '';
-                       // 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")
-               $query.= '<input type="hidden" name="TSFE_ADMIN_PANEL[DUMMY]" value="">';
-               foreach (t3lib_div::_GET() as $k => $v) {
-                       if ($k != 'TSFE_ADMIN_PANEL') {
-                               if (is_array($v)) {
-                                       $query.= $this->extPrintFeAdminDialogHiddenFields($k,$v);
-                               } else {
-                                       $query.= '<input type="hidden" name="'.$k.'" value="'.htmlspecialchars($v).'">'.chr(10);
-                               }
-                       }
-               }
-
-               $out = '
-<!--
-       ADMIN PANEL
--->
-<a name="TSFE_ADMIN"></a>
-<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)">'.
-$query.'
-       <table border="0" cellpadding="0" cellspacing="0" class="typo3-adminPanel" style="background-color:#f6f2e6; border: 1px solid black; z-index:0; position:absolute;" summary="">'.
-               $header.
-               $out.'
-       </table>
-</form>';
-
-               if ($this->uc['TSFE_adminConfig']['display_top']) {
-                       $out.= '<script type="text/javascript" src="t3lib/jsfunc.evalfield.js"></script>';
-                       $out.= '
-                       <script type="text/javascript">
-                                       /*<![CDATA[*/
-                               var evalFunc = new evalFunc();
-                                       // TSFEtypo3FormFieldSet()
-                               function TSFEtypo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue)      {       //
-                                       var theFObj = new evalFunc_dummy (evallist,is_in, checkbox, checkboxValue);
-                                       var theValue = document.TSFE_ADMIN_PANEL_FORM[theField].value;
-                                       if (checkbox && theValue==checkboxValue)        {
-                                               document.TSFE_ADMIN_PANEL_FORM[theField+"_hr"].value="";
-                                               document.TSFE_ADMIN_PANEL_FORM[theField+"_cb"].checked = "";
-                                       } else {
-                                               document.TSFE_ADMIN_PANEL_FORM[theField+"_hr"].value = evalFunc.outputObjValue(theFObj, theValue);
-                                               document.TSFE_ADMIN_PANEL_FORM[theField+"_cb"].checked = "on";
-                                       }
-                               }
-                                       // TSFEtypo3FormFieldGet()
-                               function TSFEtypo3FormFieldGet(theField, evallist, is_in, checkbox, checkboxValue, checkbox_off)        {       //
-                                       var theFObj = new evalFunc_dummy (evallist,is_in, checkbox, checkboxValue);
-                                       if (checkbox_off)       {
-                                               document.TSFE_ADMIN_PANEL_FORM[theField].value=checkboxValue;
-                                       }else{
-                                               document.TSFE_ADMIN_PANEL_FORM[theField].value = evalFunc.evalObjValue(theFObj, document.TSFE_ADMIN_PANEL_FORM[theField+"_hr"].value);
-                                       }
-                                       TSFEtypo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue);
-                               }
-                                       /*]]>*/
-                       </script>
-                       <script language="javascript" type="text/javascript">'.$this->extJSCODE.'</script>';
-               }
-               return "\n\n\n\n".$out.'<br />';
-       }
-
-       /**
-        * Fetches recursively all GET parameters as hidden fields.
-        * Called from extPrintFeAdminDialog.
-        *
-        * @param       string          current key
-        * @param       mixed           current value
-        * @return      string          hidden fields
-        * @see extPrintFeAdminDialog()
-        */
-       function extPrintFeAdminDialogHiddenFields($key,&$val)  {
-               $out = '';
-               foreach($val as $k => $v)       {
-                       if (is_array($v))       {
-                               $out.= $this->extPrintFeAdminDialogHiddenFields($key.'['.$k.']',$v);
-                       } else {
-                               $out.= '<input type="hidden" name="'.$key.'['.$k.']" value="'.htmlspecialchars($v).'">'.chr(10);
-                       }
-               }
-               return $out;
-       }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-       /*****************************************************
-        *
-        * Creating sections of the Admin Panel
-        *
-        ****************************************************/
+       public $formfield_uident = '';
 
        /**
-        * Creates the content for the "preview" section ("module") of the Admin Panel
+        * Form field with a unique value which is used to encrypt the password and username.
         *
-        * @param       string          Optional start-value; The generated content is added to this variable.
-        * @return      string          HTML content for the section. Consists of a string with table-rows with four columns.
-        * @see extPrintFeAdminDialog()
+        * @var string
         */
-       function extGetCategory_preview($out='')        {
-               $out.= $this->extGetHead('preview');
-               if ($this->uc['TSFE_adminConfig']['display_preview']) {
-                       $this->extNeedUpdate = 1;
-                       $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"':'').' />');
-                       $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"':'').' />');
-
-                               // Simulate date
-                       $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'].'" />');
-                       $this->extJSCODE.= 'TSFEtypo3FormFieldSet("TSFE_ADMIN_PANEL[preview_simulateDate]", "datetime", "", 1,0);';
-
-                               // Simulate fe_user:
-                       $options = '<option value="0">&nbsp;</option>';
-                       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
-                                               'fe_groups.uid, fe_groups.title',
-                                               'fe_groups,pages',
-                                               'pages.uid=fe_groups.pid AND pages.deleted=0 '.t3lib_BEfunc::deleteClause('fe_groups').' AND '.$this->getPagePermsClause(1)
-                                       );
-                       while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
-                               $options.= '<option value="'.$row['uid'].'"'.($this->uc['TSFE_adminConfig']['preview_simulateUserGroup']==$row['uid']?' selected="selected"':'').'>'.htmlspecialchars('['.$row['uid'].'] '.$row['title']).'</option>';
-                       }
-                       $out.= $this->extGetItem('preview_simulateUserGroup', '<select name="TSFE_ADMIN_PANEL[preview_simulateUserGroup]">'.$options.'</select>');
-               }
-               return $out;
-       }
+       public $formfield_chalvalue = '';
 
        /**
-        * Creates the content for the "cache" section ("module") of the Admin Panel
+        * Sets the level of security. *'normal' = clear-text. 'challenged' = hashed password/username.
+        * from form in $formfield_uident. 'superchallenged' = hashed password hashed again with username.
         *
-        * @param       string          Optional start-value; The generated content is added to this variable.
-        * @return      string          HTML content for the section. Consists of a string with table-rows with four columns.
-        * @see extPrintFeAdminDialog()
+        * @var string
         */
-       function extGetCategory_cache($out='')  {
-               $out.= $this->extGetHead('cache');
-               if ($this->uc['TSFE_adminConfig']['display_cache'])     {
-                       $this->extNeedUpdate = 1;
-                       $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"':'').' />');
-
-                       $options = '';
-                       $options.= '<option value="0"'.($this->uc['TSFE_adminConfig']['cache_clearCacheLevels']==0?' selected="selected"':'').'>'.$this->extGetLL('div_Levels_0').'</option>';
-                       $options.= '<option value="1"'.($this->uc['TSFE_adminConfig']['cache_clearCacheLevels']==1?' selected="selected"':'').'>'.$this->extGetLL('div_Levels_1').'</option>';
-                       $options.= '<option value="2"'.($this->uc['TSFE_adminConfig']['cache_clearCacheLevels']==2?' selected="selected"':'').'>'.$this->extGetLL('div_Levels_2').'</option>';
-
-                       $out.= $this->extGetItem('cache_clearLevels', '<select name="TSFE_ADMIN_PANEL[cache_clearCacheLevels]">'.$options.'</select>'.
-                                       '<input type="hidden" name="TSFE_ADMIN_PANEL[cache_clearCacheId]" value="'.$GLOBALS['TSFE']->id.'" /><input type="submit" value="'.$this->extGetLL('update').'" />');
-
-                               // Generating tree:
-                       $depth = $this->extGetFeAdminValue('cache','clearCacheLevels');
-                       $outTable = '';
-                       $this->extPageInTreeInfo = array();
-                       $this->extPageInTreeInfo[] = array($GLOBALS['TSFE']->page['uid'],htmlspecialchars($GLOBALS['TSFE']->page['title']),$depth+1);
-                       $this->extGetTreeList($GLOBALS['TSFE']->id, $depth,0,$this->getPagePermsClause(1));
-                       reset($this->extPageInTreeInfo);
-                       while(list(,$row)=each($this->extPageInTreeInfo)) {
-                               $outTable.= '
-                                       <tr>
-                                               <td style="white-space: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>';
-                       }
-                       $outTable = '<br /><table border="0" cellpadding="0" cellspacing="0" summary="">'.$outTable.'</table>';
-                       $outTable.= '<input type="submit" name="TSFE_ADMIN_PANEL[action][clearCache]" value="'.$this->extGetLL('cache_doit').'" />';
-
-                       $out.= $this->extGetItem('cache_cacheEntries', $outTable);
-               }
-               return $out;
-       }
+       public $security_level = '';
 
        /**
-        * Creates the content for the "publish" section ("module") of the Admin Panel
+        * Decides if the writelog() function is called at login and logout.
         *
-        * @param       string          Optional start-value; The generated content is added to this variable.
-        * @return      string          HTML content for the section. Consists of a string with table-rows with four columns.
-        * @see extPrintFeAdminDialog()
+        * @var boolean
         */
-       function extGetCategory_publish($out='')        {
-               $out.= $this->extGetHead('publish');
-               if ($this->uc['TSFE_adminConfig']['display_publish']) {
-                       $this->extNeedUpdate = 1;
-                       $options = '';
-                       $options.= '<option value="0"'.($this->uc['TSFE_adminConfig']['publish_levels']==0?' selected="selected"':'').'>'.$this->extGetLL('div_Levels_0').'</option>';
-                       $options.= '<option value="1"'.($this->uc['TSFE_adminConfig']['publish_levels']==1?' selected="selected"':'').'>'.$this->extGetLL('div_Levels_1').'</option>';
-                       $options.= '<option value="2"'.($this->uc['TSFE_adminConfig']['publish_levels']==2?' selected="selected"':'').'>'.$this->extGetLL('div_Levels_2').'</option>';
-                       $out.= $this->extGetItem('publish_levels', '<select name="TSFE_ADMIN_PANEL[publish_levels]">'.$options.'</select>'.
-                                       '<input type="hidden" name="TSFE_ADMIN_PANEL[publish_id]" value="'.$GLOBALS['TSFE']->id.'" />&nbsp;<input type="submit" value="'.$this->extGetLL('update').'" />');
-
-                               // Generating tree:
-                       $depth = $this->extGetFeAdminValue('publish','levels');
-                       $outTable = '';
-                       $this->extPageInTreeInfo = array();
-                       $this->extPageInTreeInfo[] = array($GLOBALS['TSFE']->page['uid'],htmlspecialchars($GLOBALS['TSFE']->page['title']),$depth+1);
-                       $this->extGetTreeList($GLOBALS['TSFE']->id, $depth,0,$this->getPagePermsClause(1));
-                       reset($this->extPageInTreeInfo);
-                       while(list(,$row)=each($this->extPageInTreeInfo)) {
-                               $outTable.= '
-                                       <tr>
-                                               <td style="white-space: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>';
-                       }
-                       $outTable = '<br /><table border="0" cellpadding="0" cellspacing="0" summary="">'.$outTable.'</table>';
-                       $outTable.= '<input type="submit" name="TSFE_ADMIN_PANEL[action][publish]" value="'.$this->extGetLL('publish_doit').'" />';
-
-                       $out.= $this->extGetItem('publish_tree', $outTable);
-               }
-               return $out;
-       }
+       public $writeStdLog = false;
 
        /**
-        * Creates the content for the "edit" section ("module") of the Admin Panel
+        * If the writelog() functions is called if a login-attempt has be tried without success.
         *
-        * @param       string          Optional start-value; The generated content is added to this variable.
-        * @return      string          HTML content for the section. Consists of a string with table-rows with four columns.
-        * @see extPrintFeAdminDialog()
+        * @var boolean
         */
-       function extGetCategory_edit($out='')   {
-               $out.= $this->extGetHead('edit');
-               if ($this->uc['TSFE_adminConfig']['display_edit']) {
-
-                               // If another page module was specified, replace the default Page module with the new one
-                       $newPageModule = trim($GLOBALS['BE_USER']->getTSConfigVal('options.overridePageModule'));
-                       $pageModule = t3lib_BEfunc::isModuleSetInTBE_MODULES($newPageModule) ? $newPageModule : 'web_layout';
-
-                       $this->extNeedUpdate = 1;
-                       $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"':'').' />');
-                       $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"':'').' />');
-                       $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"':'').' />');
-                       $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"':'').' />');
-                       $out.= $this->extGetItem('', $this->ext_makeToolBar());
-
-                       if (!t3lib_div::_GP('ADMCMD_view')) {
-                               $out.= $this->extGetItem('', '<a href="#" onclick="'.
-                                       htmlspecialchars('
-                                               if (parent.opener && parent.opener.top && parent.opener.top.TS) {
-                                                       parent.opener.top.fsMod.recentIds["web"]='.intval($GLOBALS['TSFE']->page['uid']).';
-                                                       if (parent.opener.top.content && parent.opener.top.content.nav_frame && parent.opener.top.content.nav_frame.refresh_nav)        {
-                                                               parent.opener.top.content.nav_frame.refresh_nav();
-                                                       }
-                                                       parent.opener.top.goToModule("'.$pageModule.'");
-                                                       parent.opener.top.focus();
-                                               } else {
-                                                       vHWin=window.open(\''.TYPO3_mainDir.t3lib_BEfunc::getBackendScript().'\',\''.md5('Typo3Backend-'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']).'\',\'status=1,menubar=1,scrollbars=1,resizable=1\');
-                                                       vHWin.focus();
-                                               }
-                                               return false;
-                                               ').
-                                       '">'.$this->extFw($this->extGetLL('edit_openAB')).'</a>');
-                       }
-               }
-               return $out;
-       }
+       public $writeAttemptLog = false;
 
        /**
-        * Creates the content for the "tsdebug" section ("module") of the Admin Panel
+        * This is the name of the include-file containing the login form. If not set, login CAN be anonymous. If set login IS needed.
         *
-        * @param       string          Optional start-value; The generated content is added to this variable.
-        * @return      string          HTML content for the section. Consists of a string with table-rows with four columns.
-        * @see extPrintFeAdminDialog()
+        * @var string
         */
-       function extGetCategory_tsdebug($out='')        {
-               $out.= $this->extGetHead('tsdebug');
-               if ($this->uc['TSFE_adminConfig']['display_tsdebug']) {
-                       $this->extNeedUpdate = 1;
-
-                       $out.= $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"':'').' />');
-                       $out.= $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"':'').' />');
-                       $out.= $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"':'').' />');
-                       $out.= $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"':'').' />');
-                       $out.= $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"':'').' />');
-                       $out.= $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"':'').' />');
-                       $out.= $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"':'').' />');
-
-                       $GLOBALS['TT']->printConf['flag_tree'] = $this->extGetFeAdminValue('tsdebug','tree');
-                       $GLOBALS['TT']->printConf['allTime'] = $this->extGetFeAdminValue('tsdebug','displayTimes');
-                       $GLOBALS['TT']->printConf['flag_messages'] = $this->extGetFeAdminValue('tsdebug','displayMessages');
-                       $GLOBALS['TT']->printConf['flag_content'] = $this->extGetFeAdminValue('tsdebug','displayContent');
-                       $GLOBALS['TT']->printConf['flag_queries'] = $this->extGetFeAdminValue('tsdebug','displayQueries');
-
-                       $out.= '
-                               <tr>
-                                       <td><img src="clear.gif" width="50" height="1" alt="" /></td>
-                                       <td colspan="3">'.$GLOBALS['TT']->printTSlog().'</td>
-                               </tr>';
-               }
-               return $out;
-       }
+       public $auth_include = '';
 
        /**
-        * Creates the content for the "info" section ("module") of the Admin Panel
+        * Array of page related information (uid, title, depth).
         *
-        * @param       string          Optional start-value; The generated content is added to this variable.
-        * @return      string          HTML content for the section. Consists of a string with table-rows with four columns.
-        * @see extPrintFeAdminDialog()
+        * @var array
         */
-       function extGetCategory_info($out='')   {
-               $out.= $this->extGetHead('info');
-               if ($this->uc['TSFE_adminConfig']['display_info']) {
-                       $tableArr = array();
-
-                       if ($this->extGetFeAdminValue('cache','noCache')) {
-                               $theBytes = 0;
-                               $count = 0;
-
-                               if (count($GLOBALS['TSFE']->imagesOnPage)) {
-                                       $tableArr[] = array('*Images on this page:*', '');
-                                       foreach ($GLOBALS['TSFE']->imagesOnPage as $file) {
-                                               $fs = @filesize($file);
-                                               $tableArr[] = array('&ndash; '.$file, t3lib_div::formatSize($fs));
-                                               $theBytes+= $fs;
-                                               $count++;
-                                       }
-                               }
-                               $tableArr[] = array('', '');    // Add an empty line
-
-                               $tableArr[] = array('*Total number of images:*', $count);
-                               $tableArr[] = array('*Total image file sizes:*', t3lib_div::formatSize($theBytes));
-                               $tableArr[] = array('*Document size:*', t3lib_div::formatSize(strlen($GLOBALS['TSFE']->content)));
-                               $tableArr[] = array('*Total page load:*', t3lib_div::formatSize(strlen($GLOBALS['TSFE']->content)+$theBytes));
-                               $tableArr[] = array('', '');
-                       }
-
-                       $tableArr[] = array('id:', $GLOBALS['TSFE']->id);
-                       $tableArr[] = array('type:', $GLOBALS['TSFE']->type);
-                       $tableArr[] = array('gr_list:', $GLOBALS['TSFE']->gr_list);
-                       $tableArr[] = array('no_cache:', $GLOBALS['TSFE']->no_cache);
-                       $tableArr[] = array('fe_user, name:', $GLOBALS['TSFE']->fe_user->user['username']);
-                       $tableArr[] = array('fe_user, uid:', $GLOBALS['TSFE']->fe_user->user['uid']);
-                       $tableArr[] = array('', '');    // Add an empty line
-
-                               // parsetime:
-                       $tableArr[] = array('*Total parsetime:*', $GLOBALS['TSFE']->scriptParseTime.' ms');
-
-                       $table = '';
-                       foreach ($tableArr as $arr) {
-                               if (strlen($arr[0])) {  // Put text wrapped by "*" between <strong> tags
-                                       $value1 = preg_replace('/^\*(.*)\*$/', '$1', $arr[0], -1, $count);
-                                       $value1 = ($count?'<strong>':'') . $this->extFw($value1) . ($count?'</strong>':'');
-                               } else {
-                                       $value1 = $this->extFw('&nbsp;');
-                               }
-
-                               $value2 = strlen($arr[1]) ? $arr[1] : '&nbsp;';
-                               $value2 = $this->extFw($value2);
-
-                               $table.= '
-                                       <tr>
-                                               <td style="text-align:left">'.$value1.'</td>
-                                               <td style="text-align:right">'.$value2.'</td>
-                                       </tr>';
-                       }
-
-                       $table = '<table border="0" cellpadding="0" cellspacing="0" summary="">'.$table.'</table>';
-
-                       $out.= '
-                               <tr>
-                                       <td><img src="clear.gif" width="50" height="1" alt="" /></td>
-                                       <td colspan="3">'.$table.'</td>
-                               </tr>';
-               }
-               return $out;
-       }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-       /*****************************************************
-        *
-        * Admin Panel Layout Helper functions
-        *
-        ****************************************************/
+       public $extPageInTreeInfo = array();
 
        /**
-        * Returns a row (with colspan=4) which is a header for a section in the Admin Panel.
-        * 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
-        * See the functions extGetCategory_*
+        * General flag which is set if the adminpanel should be displayed at all.
         *
-        * @param       string          The suffix to the display_ label. Also selects the label from the LOCAL_LANG array.
-        * @return      string          HTML table row.
-        * @access private
-        * @see extGetItem()
+        * @var boolean
         */
-       function extGetHead($pre)       {
-               $out = '<img src="'.TYPO3_mainDir.'gfx/ol/blank.gif" width="18" height="16" align="absmiddle" border="0" alt="" />';
-               $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="" />';
-               $out.= $this->extFw($this->extGetLL($pre));
-
-               $out = $this->extItemLink($pre,$out);
-               return '
-                               <tr class="typo3-adminPanel-itemHRow" style="background-color:#abbbb4;">
-                                       <td colspan="4" style="text-align:left; border-top:dashed 1px #007a8c; white-space:nowrap;">'.$out.'<input type="hidden" name="TSFE_ADMIN_PANEL[display_'.$pre.']" value="'.$this->uc['TSFE_adminConfig']['display_'.$pre].'" /></td>
-                               </tr>';
-       }
+       public $extAdmEnabled = false;
 
        /**
-        * Wraps a string in a link which will open/close a certain part of the Admin Panel
+        * Class for frontend editing.
         *
-        * @param       string          The code for the display_ label/key
-        * @param       string          Input string
-        * @return      string          Linked input string
-        * @access private
-        * @see extGetHead()
+        * @var t3lib_frontendedit
         */
-       function extItemLink($pre,$str) {
-               return '<a href="#" style="text-decoration:none;" onclick="'.
-                       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;').
-                       '">'.$str.'</a>';
-       }
+       public $frontendEdit = null;
 
-       /**
-        * Returns a row (with 4 columns) for content in a section of the Admin Panel.
-        * It will take $pre as a key to a label to display and $element as the content to put into the forth cell.
-        *
-        * @param       string          Key to label
-        * @param       string          The HTML content for the forth table cell.
-        * @return      string          HTML table row.
-        * @access private
-        * @see extGetHead()
-        */
-       function extGetItem($pre,$element)      {
-               $out = '
-                                       <tr class="typo3-adminPanel-itemRow">
-                                               <td><img src="clear.gif" width="50" height="1" alt="" /></td>
-                                               <td style="text-align:left; white-space:nowrap;">'.($pre ? $this->extFw($this->extGetLL($pre)) : '&nbsp;').'</td>
-                                               <td><img src="clear.gif" width="30" height="1" alt="" /></td>
-                                               <td style="text-align:left; white-space:nowrap;">'.$element.'</td>
-                                       </tr>';
-
-               return $out;
-       }
 
-       /**
-        * Wraps a string in a span-tag with black verdana font
-        *
-        * @param       string          The string to wrap
-        * @return      string
-        */
-       function extFw($str)    {
-               return '<span style="font-family:Verdana,Arial,Helvetica,sans-serif; font-size:10px; color:black;">'.$str.'</span>';
-       }
+       public function initializeFrontendEdit() {
+               $this->extAdminConfig = $this->getTSConfigProp('admPanel');
 
-       /**
-        * Creates the tool bar links for the "edit" section of the Admin Panel.
-        *
-        * @return      string          A string containing images wrapped in <a>-tags linking them to proper functions.
-        */
-       function ext_makeToolBar()      {
-                       //  If mod.web_list.newContentWiz.overrideWithExtension is set, use that extension's create new content wizard instead:
-               $tmpTSc = t3lib_BEfunc::getModTSconfig($this->pageinfo['uid'],'mod.web_list');
-               $tmpTSc = $tmpTSc ['properties']['newContentWiz.']['overrideWithExtension'];
-               $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');
-
-               $perms = $GLOBALS['BE_USER']->calcPerms($GLOBALS['TSFE']->page);
-               $langAllowed = $GLOBALS['BE_USER']->checkLanguageAccess($GLOBALS['TSFE']->sys_language_uid);
-
-               $toolBar = '';
-               $id = $GLOBALS['TSFE']->id;
-               $toolBar.= '<a href="'.htmlspecialchars(TYPO3_mainDir.'show_rechis.php?element='.rawurlencode('pages:'.$id).'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'#latest">'.
-                                       '<img src="'.TYPO3_mainDir.'gfx/history2.gif" width="13" height="12" hspace="2" border="0" align="top" title="'.$this->extGetLL('edit_recordHistory').'" alt="" /></a>';
-
-               if ($perms&16 && $langAllowed) {
-                       $params = '';
-                       if ($GLOBALS['TSFE']->sys_language_uid) $params = '&sys_language_uid='.$GLOBALS['TSFE']->sys_language_uid;
-                       $toolBar.= '<a href="'.htmlspecialchars($newContentWizScriptPath.'?id='.$id.$params.'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'.
-                                               '<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>';
-               }
-               if ($perms&2) {
-                       $toolBar.= '<a href="'.htmlspecialchars(TYPO3_mainDir.'move_el.php?table=pages&uid='.$id.'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'.
-                                       '<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>';
-               }
-               if ($perms&8) {
-                       $toolBar.= '<a href="'.htmlspecialchars(TYPO3_mainDir.'db_new.php?id='.$id.'&pagesOnly=1&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'.
-                                       '<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>';
-               }
-               if ($perms&2) {
-                       $params = '&edit[pages]['.$id.']=edit';
-                       $toolBar.= '<a href="'.htmlspecialchars(TYPO3_mainDir.'alt_doc.php?'.$params.'&noView=1&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'.
-                                       '<img src="'.TYPO3_mainDir.'gfx/edit2.gif" width="11" height="12" hspace="2" border="0" align="top" title="'.$this->extGetLL('edit_editPageProperties').'" alt="" /></a>';
-
-                       if ($GLOBALS['TSFE']->sys_language_uid && $langAllowed) {
-                               $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
-                                       'uid,pid,t3ver_state',  'pages_language_overlay',
-                                       'pid='.intval($id).' AND sys_language_uid='.$GLOBALS['TSFE']->sys_language_uid.$GLOBALS['TSFE']->sys_page->enableFields('pages_language_overlay'),
-                                       '', '', '1');
-                               $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
-                               $GLOBALS['TSFE']->sys_page->versionOL('pages_language_overlay',$row);
-                               if (is_array($row)) {
-                                       $params='&edit[pages_language_overlay]['.$row['uid'].']=edit';
-                                       $toolBar.= '<a href="'.htmlspecialchars(TYPO3_mainDir.'alt_doc.php?'.$params.'&noView=1&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'.
-                                                       '<img src="'.TYPO3_mainDir.'gfx/edit3.gif" width="11" height="12" hspace="2" border="0" align="top" title="'.$this->extGetLL('edit_editPageOverlay').'" alt="" /></a>';
+               if (is_array($this->extAdminConfig['enable.'])) {
+                       foreach($this->extAdminConfig['enable.'] as $key => $value) {
+                               if ($value) {
+                                               // @todo        Add support for controller switching (ie. TV controller)
+                                       require_once(PATH_t3lib . 'class.t3lib_frontendedit.php');
+                                       $classname = 't3lib_frontendedit';
+                                       $this->frontendEdit = t3lib_div::makeInstance($classname);
+                                       break;
                                }
                        }
                }
-               if ($this->check('modules','web_list')) {
-                       $toolBar.= '<a href="'.htmlspecialchars(TYPO3_mainDir.'db_list.php?id='.$id.'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'.
-                                       '<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>';
-               }
-
-               return $toolBar;
        }
 
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
        /*****************************************************
         *
         * TSFE BE user Access Functions
@@ -731,16 +200,16 @@ $query.'
         * Used in the frontend.
         *
         * @return      boolean         Returns true if access is OK
-        * @see typo3/init.php, t3lib_beuserauth::backendCheckLogin()
+        * @see typo3/init.php, t3lib_beuserauth::backendCheckLogin()
         */
-       function checkBackendAccessSettingsFromInitPhp()        {
+       public function checkBackendAccessSettingsFromInitPhp() {
                global $TYPO3_CONF_VARS;
 
                // **********************
                // Check Hardcoded lock on BE:
                // **********************
                if ($TYPO3_CONF_VARS['BE']['adminOnly'] < 0) {
-                       return FALSE;
+                       return false;
                }
 
                // **********************
@@ -748,7 +217,7 @@ $query.'
                // **********************
                if (trim($TYPO3_CONF_VARS['BE']['IPmaskList'])) {
                        if (!t3lib_div::cmpIP(t3lib_div::getIndpEnv('REMOTE_ADDR'), $TYPO3_CONF_VARS['BE']['IPmaskList'])) {
-                               return FALSE;
+                               return false;
                        }
                }
 
@@ -758,14 +227,16 @@ $query.'
                // **********************
                if (intval($TYPO3_CONF_VARS['BE']['lockSSL']) && $TYPO3_CONF_VARS['BE']['lockSSL'] != 3) {
                        if (!t3lib_div::getIndpEnv('TYPO3_SSL')) {
-                               return FALSE;
+                               return false;
                        }
                }
 
                        // Finally a check from t3lib_beuserauth::backendCheckLogin()
                if (!$TYPO3_CONF_VARS['BE']['adminOnly'] || $this->isAdmin()) {
-                       return TRUE;
-               } else return FALSE;
+                       return true;
+               } else {
+                       return false;
+               }
         }
 
 
@@ -778,146 +249,10 @@ $query.'
         * @param       array           The page record to evaluate for
         * @return      boolean         True if read access
         */
-       function extPageReadAccess($pageRec)    {
-               return $this->isInWebMount($pageRec['uid']) && $this->doesUserHaveAccess($pageRec,1);
-       }
-
-       /**
-        * Checks if a Admin Panel section ("module") is available for the user. If so, true is returned.
-        *
-        * @param       string          The module key, eg. "edit", "preview", "info" etc.
-        * @return      boolean
-        * @see extPrintFeAdminDialog()
-        */
-       function extAdmModuleEnabled($key)      {
-                       // Returns true if the module checked is "preview" and the forcePreview flag is set.
-               if ($key=="preview" && $this->ext_forcePreview) return true;
-
-                       // If key is not set, only "all" is checked
-               if ($this->extAdminConfig['enable.']['all'])    return true;
-               if ($this->extAdminConfig['enable.'][$key]) {
-                       return true;
-               }
-       }
-
-       /**
-        * Saves any change in settings made in the Admin Panel.
-        * Called from index_ts.php right after access check for the Admin Panel
-        *
-        * @return      void
-        */
-       function extSaveFeAdminConfig() {
-               $input = t3lib_div::_GET('TSFE_ADMIN_PANEL');
-               if (is_array($input)) {
-                               // Setting
-                       $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...
-                       unset($this->uc['TSFE_adminConfig']['action']);
-
-                               // Actions:
-                       if ($input['action']['clearCache'] && $this->extAdmModuleEnabled('cache')) {
-                               $this->extPageInTreeInfo=array();
-                               $theStartId = intval($input['cache_clearCacheId']);
-                               $GLOBALS['TSFE']->clearPageCacheContent_pidList($this->extGetTreeList($theStartId, $this->extGetFeAdminValue('cache','clearCacheLevels'),0,$this->getPagePermsClause(1)).$theStartId);
-                       }
-                       if ($input['action']['publish'] && $this->extAdmModuleEnabled('publish')) {
-                               $theStartId = intval($input['publish_id']);
-                               $this->extPublishList = $this->extGetTreeList($theStartId, $this->extGetFeAdminValue('publish','levels'),0,$this->getPagePermsClause(1)).$theStartId;
-                       }
-
-                               // Saving
-                       $this->writeUC();
-               }
-               $GLOBALS['TT']->LR = $this->extGetFeAdminValue('tsdebug','LR');
-
-               if ($this->extGetFeAdminValue('cache','noCache'))       {
-                       $GLOBALS['TSFE']->set_no_cache();
-               }
-
-                       // Hook for post processing the frontend admin configuration.
-               if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['extSaveFeAdminConfig-postProc'])) {
-                       $_params = array('input' => &$input, 'pObj' => &$this);
-                       foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['extSaveFeAdminConfig-postProc'] as $_funcRef) {
-                               t3lib_div::callUserFunction($_funcRef,$_params,$this);
-                       }
-               }
+       public function extPageReadAccess($pageRec) {
+               return $this->isInWebMount($pageRec['uid']) && $this->doesUserHaveAccess($pageRec, 1);
        }
 
-       /**
-        * Returns the value for a Admin Panel setting. You must specify both the module-key and the internal setting key.
-        *
-        * @param       string          Module key
-        * @param       string          Setting key
-        * @return      string          The setting value
-        */
-       function extGetFeAdminValue($pre,$val='')       {
-               if ($this->extAdmModuleEnabled($pre)) { // Check if module is enabled.
-                               // Exceptions where the values can be overridden from backend:
-                               // deprecated
-                       if ($pre.'_'.$val == 'edit_displayIcons' && $this->extAdminConfig['module.']['edit.']['forceDisplayIcons']) {
-                               return true;
-                       }
-                       if ($pre.'_'.$val == 'edit_displayFieldIcons' && $this->extAdminConfig['module.']['edit.']['forceDisplayFieldIcons']) {
-                               return true;
-                       }
-
-                               // override all settings with user TSconfig
-                       if ($this->extAdminConfig['override.'][$pre.'.'][$val] && $val) {
-                               return $this->extAdminConfig['override.'][$pre.'.'][$val];
-                       }
-                       if ($this->extAdminConfig['override.'][$pre]) {
-                               return $this->extAdminConfig['override.'][$pre];
-                       }
-
-                       $retVal = $val ? $this->uc['TSFE_adminConfig'][$pre.'_'.$val] : 1;
-
-                       if ($pre=='preview' && $this->ext_forcePreview) {
-                               if (!$val) {
-                                       return true;
-                               } else {
-                                       return $retVal;
-                               }
-                       }
-
-                               // regular check:
-                       if ($this->extIsAdmMenuOpen($pre)) {    // See if the menu is expanded!
-                               return $retVal;
-                       }
-
-                               // Hook for post processing the frontend editing action.
-                       if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['extEditAction-postProc'])) {
-                               $_params = array('cmd' => &$cmd, 'tce' => &$tce, 'pObj' => &$this);
-                               foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['extEditAction-postProc'] as $_funcRef) {
-                                       t3lib_div::callUserFunction($_funcRef,$_params,$this);
-                               }
-                       }
-               }
-       }
-
-       /**
-        * Returns true if admin panel module is open
-        *
-        * @param       string          Module key
-        * @return      boolean         True, if the admin panel is open for the specified admin panel module key.
-        */
-       function extIsAdmMenuOpen($pre) {
-               return $this->uc['TSFE_adminConfig']['display_top'] && $this->uc['TSFE_adminConfig']['display_'.$pre];
-       }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
        /*****************************************************
         *
         * TSFE BE user Access Functions
@@ -934,25 +269,25 @@ $query.'
         * @param       string          Perms clause
         * @return      string          Returns the list with a comma in the end (if any pages selected!)
         */
-       function extGetTreeList($id,$depth,$begin=0,$perms_clause)      {
+       public function extGetTreeList($id, $depth, $begin=0, $perms_clause) {
                $depth=intval($depth);
                $begin=intval($begin);
                $id=intval($id);
                $theList='';
 
-               if ($id && $depth>0) {
+               if ($id && $depth > 0) {
                        $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
                                                'uid,title',
                                                'pages',
-                                               'pid='.$id.' AND doktype IN ('.$GLOBALS['TYPO3_CONF_VARS']['FE']['content_doktypes'].') AND deleted=0 AND '.$perms_clause
+                                               'pid=' . $id . ' AND doktype IN (' . $GLOBALS['TYPO3_CONF_VARS']['FE']['content_doktypes'] . ') AND deleted=0 AND ' . $perms_clause
                                        );
                        while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
-                               if ($begin<=0) {
-                                       $theList.= $row['uid'].',';
-                                       $this->extPageInTreeInfo[]=array($row['uid'],$row['title'],$depth);
+                               if ($begin <= 0) {
+                                       $theList .= $row['uid'].',';
+                                       $this->extPageInTreeInfo[] = array($row['uid'], htmlspecialchars($row['title'],$depth));
                                }
-                               if ($depth>1) {
-                                       $theList.= $this->extGetTreeList($row['uid'], $depth-1,$begin-1,$perms_clause);
+                               if ($depth > 1) {
+                                       $theList .= $this->extGetTreeList($row['uid'], $depth-1, $begin-1, $perms_clause);
                                }
                        }
                }
@@ -965,7 +300,7 @@ $query.'
         * @param       integer         The page id.
         * @return      integer         The number of pages for this page in the table "cache_pages"
         */
-       function extGetNumberOfCachedPages($pageId) {
+       public function extGetNumberOfCachedPages($pageId) {
                $pageCache = $GLOBALS['typo3CacheManager']->getCache('cache_pages');
                $pageCacheEntries = $pageCache->findEntriesByTag('pageId_' . (int) $pageId);
 
@@ -1005,7 +340,7 @@ $query.'
         * @param       string          Key for a label in the $LOCAL_LANG array of "sysext/lang/locallang_tsfe.php"
         * @return      string          The value for the $key
         */
-       function extGetLL($key) {
+       public function extGetLL($key) {
                global $LOCAL_LANG;
                if (!is_array($LOCAL_LANG)) {
                        $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_tsfe.php');
@@ -1018,8 +353,8 @@ $query.'
                $labelStr = htmlspecialchars($GLOBALS['LANG']->getLL($key));    // Label string in the default backend output charset.
 
                        // Convert to utf-8, then to entities:
-               if ($GLOBALS['LANG']->charSet!='utf-8') {
-                       $labelStr = $GLOBALS['LANG']->csConvObj->utf8_encode($labelStr,$GLOBALS['LANG']->charSet);
+               if ($GLOBALS['LANG']->charSet != 'utf-8') {
+                       $labelStr = $GLOBALS['LANG']->csConvObj->utf8_encode($labelStr, $GLOBALS['LANG']->charSet);
                }
                $labelStr = $GLOBALS['LANG']->csConvObj->utf8_to_entities($labelStr);
 
@@ -1027,175 +362,6 @@ $query.'
                return $labelStr;
        }
 
-
-
-
-
-
-
-
-
-
-
-
-
-       /*****************************************************
-        *
-        * Frontend Editing
-        *
-        ****************************************************/
-
-       /**
-        * Returns true in an edit-action is sent from the Admin Panel
-        *
-        * @return      boolean
-        * @see index_ts.php
-        */
-       function extIsEditAction()      {
-               if (is_array($this->TSFE_EDIT)) {
-                       if ($this->TSFE_EDIT['cancel']) {
-                               unset($this->TSFE_EDIT['cmd']);
-                       } else {
-                               $cmd = (string)$this->TSFE_EDIT['cmd'];
-                               if (($cmd!='edit' || (is_array($this->TSFE_EDIT['data']) && ($this->TSFE_EDIT['update'] || $this->TSFE_EDIT['update_close']))) && $cmd!='new')  {
-                                               // $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.
-                                       return true;
-                               }
-                       }
-               }
-               return false;
-       }
-
-       /**
-        * Returns true if an edit form is shown on the page.
-        * Used from index_ts.php where a true return-value will result in classes etc. being included.
-        *
-        * @return      boolean
-        * @see index_ts.php
-        */
-       function extIsFormShown()       {
-               if (is_array($this->TSFE_EDIT)) {
-                       $cmd = (string)$this->TSFE_EDIT['cmd'];
-                       if ($cmd=='edit' || $cmd=='new') {
-                               return true;
-                       }
-               }
-       }
-
-       /**
-        * Management of the on-page frontend editing forms and edit panels.
-        * Basically taking in the data and commands and passes them on to the proper classes as they should be.
-        *
-        * @return      void
-        * @see index_ts.php
-        */
-       function extEditAction()        {
-               global $TCA, $TYPO3_CONF_VARS;
-                       // Commands:
-               list($table,$uid) = explode(':',$this->TSFE_EDIT['record']);
-               if ($this->TSFE_EDIT['cmd'] && $table && $uid && isset($TCA[$table])) {
-                       $tce = t3lib_div::makeInstance('t3lib_TCEmain');
-                       $tce->stripslashes_values=0;
-                       $recData = array();
-                       $cmdData = array();
-                       $cmd = $this->TSFE_EDIT['cmd'];
-
-                       // ****************
-                       // extEditAction HOOK
-                       // ****************
-                       if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['extEditAction'])) {
-                               $_params = array();
-                               foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['extEditAction'] as $_funcRef) {
-                                       t3lib_div::callUserFunction($_funcRef,$_params,$this);
-                               }
-                       }
-
-                       switch($cmd) {
-                               case 'hide':
-                               case 'unhide':
-                                       $hideField = $TCA[$table]['ctrl']['enablecolumns']['disabled'];
-                                       if ($hideField) {
-                                               $recData[$table][$uid][$hideField] = ($cmd=='hide' ? 1 : 0);
-                                               $tce->start($recData,Array());
-                                               $tce->process_datamap();
-                                       }
-                               break;
-                               case 'up':
-                               case 'down':
-                                       $sortField = $TCA[$table]['ctrl']['sortby'];
-                                       if ($sortField) {
-                                               if ($cmd=='up') {
-                                                       $op= '<';
-                                                       $desc=' DESC';
-                                               } else {
-                                                       $op= '>';
-                                                       $desc='';
-                                               }
-
-                                                       // Get self:
-                                               $fields = array_unique(t3lib_div::trimExplode(',',$TCA[$table]['ctrl']['copyAfterDuplFields'].',uid,pid,'.$sortField,1));
-                                               $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(implode(',',$fields), $table, 'uid='.$uid);
-                                               if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
-                                                               // record before or after
-                                                       $preview = $this->extGetFeAdminValue('preview');
-                                                       $copyAfterFieldsQuery = '';
-                                                       if ($preview) {
-                                                               $ignore = array('starttime'=>1, 'endtime'=>1, 'disabled'=>1, 'fe_group'=>1);
-                                                       }
-                                                       if ($TCA[$table]['ctrl']['copyAfterDuplFields']) {
-                                                               $cAFields = t3lib_div::trimExplode(',',$TCA[$table]['ctrl']['copyAfterDuplFields'],1);
-                                                               while(list(,$fN)=each($cAFields)) {
-                                                                       $copyAfterFieldsQuery.= ' AND '.$fN.'="'.$row[$fN].'"';
-                                                               }
-                                                       }
-
-                                                       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
-                                                                               'uid,pid',
-                                                                               $table,
-                                                                               'pid='.intval($row['pid']).
-                                                                                       ' AND '.$sortField.$op.intval($row[$sortField]).
-                                                                                       $copyAfterFieldsQuery.
-                                                                                       $GLOBALS['TSFE']->sys_page->enableFields($table,'',$ignore),
-                                                                               '',
-                                                                               $sortField.$desc,
-                                                                               '2'
-                                                                       );
-                                                       if ($row2 = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
-                                                               if($cmd=='down') {
-                                                                       $cmdData[$table][$uid]['move'] = -$row2['uid'];
-                                                               } elseif ($row3 = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {        // Must take the second record above...
-                                                                       $cmdData[$table][$uid]['move'] = -$row3['uid'];
-                                                               } else {        // ... and if that does not exist, use pid
-                                                                       $cmdData[$table][$uid]['move'] = $row['pid'];
-                                                               }
-                                                       } elseif ($cmd=='up') {
-                                                               $cmdData[$table][$uid]['move'] = $row['pid'];
-                                                       }
-                                               }
-                                               if (count($cmdData)) {
-                                                       $tce->start(Array(),$cmdData);
-                                                       $tce->process_cmdmap();
-                                               }
-                                       }
-                               break;
-                               case 'delete':
-                                       $cmdData[$table][$uid]['delete'] = 1;
-                                       if (count($cmdData)) {
-                                               $tce->start(Array(),$cmdData);
-                                               $tce->process_cmdmap();
-                                       }
-                               break;
-                       }
-               }
-                       // Data:
-               if (($this->TSFE_EDIT['doSave'] || $this->TSFE_EDIT['update'] || $this->TSFE_EDIT['update_close']) && is_array($this->TSFE_EDIT['data'])) {
-                       $tce = t3lib_div::makeInstance('t3lib_TCEmain');
-                       $tce->stripslashes_values = 0;
-                       $tce->start($this->TSFE_EDIT['data'],Array());
-                       $tce->process_uploads($_FILES);
-                       $tce->process_datamap();
-               }
-       }
 }
 
 
index 657e87e..80ea453 100755 (executable)
@@ -157,7 +157,7 @@ $TYPO3_CONF_VARS = Array(
                'requiredExt' => 'cms,version,lang,sv', // String list: List of extensions which are REQUIRED and cannot be unloaded by the Extension Manager!
                'excludeForPackaging' => '(CVS|\..*|.*~|.*\.bak)',              // String list: List of directories and files which will not be packaged into extensions nor taken into account otherwise by the Extension Manager. Perl regular expression syntax!
                'extCache' => 1,                                                // Int. 0,1,2,3: 0: ext-scripts (ext_localconf.php and ext_tables.php) are NOT cached, but included every time. 1: scripts cached to typo3conf/temp_CACHED_[sitePathHash]* (saves some milliseconds even with PHP accelerators), 2: scripts cached and prefix includes a hash based on the 'extList' string, 3: scripts cached to typo3conf/temp_CACHED_* (no hash included at all...)
-               'extList' => 'tsconfig_help,context_help,extra_page_cm_options,impexp,belog,aboutmodules,setup,opendocs,install,t3editor,felogin',                                              // String list: List of extensions which are enabled for this install. Use the Extension Manager (EM) to manage this!
+               'extList' => 'tsconfig_help,context_help,extra_page_cm_options,impexp,belog,aboutmodules,setup,opendocs,install,t3editor,felogin,fe_edit',                                              // String list: List of extensions which are enabled for this install. Use the Extension Manager (EM) to manage this!
                'extConf' => array(                                             // Config-options for extensions, stored as serialized arrays by extension-keys. Handled automatically by the EM.
 //                     '--key--' => array()
                ),
diff --git a/t3lib/exception/class.t3lib_exception_frontendedit.php b/t3lib/exception/class.t3lib_exception_frontendedit.php
new file mode 100644 (file)
index 0000000..74f2280
--- /dev/null
@@ -0,0 +1,45 @@
+<?php
+/***************************************************************
+*  Copyright notice
+*
+*  (c) 2008 Jeff Segars <jeff@webempoweredchurch.org>
+*  (c) 2008 David Slayback <dave@webempoweredchurch.org>
+*  All rights reserved
+*
+*  This script is part of the TYPO3 project. The TYPO3 project is
+*  free software; you can redistribute it and/or modify
+*  it under the terms of the GNU General Public License as published by
+*  the Free Software Foundation; either version 2 of the License, or
+*  (at your option) any later version.
+*
+*  The GNU General Public License can be found at
+*  http://www.gnu.org/copyleft/gpl.html.
+*  A copy is found in the textfile GPL.txt and important notices to the license
+*  from the author is found in LICENSE.txt distributed with these scripts.
+*
+*
+*  This script is distributed in the hope that it will be useful,
+*  but WITHOUT ANY WARRANTY; without even the implied warranty of
+*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*  GNU General Public License for more details.
+*
+*  This copyright notice MUST APPEAR in all copies of the script!
+***************************************************************/
+
+
+/**
+ * An "Invalid Frontend Edit Action" exception.
+ *
+ * @package TYPO33
+ * @subpackage t3lib
+ */
+class t3lib_exception_frontendedit extends Exception {
+
+}
+
+
+if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/exception/class.t3lib_exception_frontendedit.php']) {
+       include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/exception/class.t3lib_exception_frontendedit.php']);
+}
+
+?>
\ No newline at end of file
index 95fe569..ef9c8af 100755 (executable)
@@ -7224,183 +7224,22 @@ class tslib_cObj {
         * @return      string          The input content string with the editPanel appended. This function returns only an edit panel appended to the content string if a backend user is logged in (and has the correct permissions). Otherwise the content string is directly returned.
         * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=375&cHash=7d8915d508
         */
-       function editPanel($content, $conf, $currentRecord='', $dataArr=array())        {
-               global $TCA,$BE_USER;
-
-                       // If no backend user, return immediately
-               if (!$GLOBALS['TSFE']->beUserLogin)     { return $content; }
-
-                       // If a backend user is logged in, then go on...
-               if ($conf['newRecordFromTable'])        {
-                       $currentRecord = $conf['newRecordFromTable'].':NEW';
-                       $conf['allow']='new';
-               }
-
-               if (!$currentRecord)    $currentRecord=$this->currentRecord;
-               if (!count($dataArr))   $dataArr=$this->data;
-               list($table,$uid) = explode(':',$currentRecord);
-               $mayEdit=0;
-               $nPid=intval($conf['newRecordInPid']);  // Page ID for new records, 0 if not specified
-
-                       // If no access right to record languages, return immediately
-               if ($table === 'pages') {
-                       $lang = $GLOBALS['TSFE']->sys_language_uid;
-               } elseif ($table === 'tt_content')      {
-                       $lang = $GLOBALS['TSFE']->sys_language_content;
-               } elseif ($TCA[$table]['ctrl']['languageField'])        {
-                       $lang = $currentRecord[$TCA[$table]['ctrl']['languageField']];
-               } else {
-                       $lang = -1;
-               }
-               if (!$BE_USER->checkLanguageAccess($lang))      { return $content; }
-
-               if (!$conf['onlyCurrentPid'] || $dataArr['pid']==$GLOBALS['TSFE']->id)  {
-                               // Permissions:
-                       $types = t3lib_div::trimExplode(',',strtolower($conf['allow']),1);
-                       $allow = array_flip($types);
-
-                       $perms = $GLOBALS['BE_USER']->calcPerms($GLOBALS['TSFE']->page);
-                       if ($table=='pages')    {
-                               if (count($GLOBALS['TSFE']->config['rootLine'])==1)     {unset($allow['move']); unset($allow['hide']); unset($allow['delete']);}        // rootpage!
-                               if (!($perms&2))        {unset($allow['edit']);unset($allow['move']);unset($allow['hide']);}
-                               if (!($perms&4))        unset($allow['delete']);
-                               if (!($perms&8))        unset($allow['new']);
-                               if (count($allow))      $mayEdit=1;             // Can only display editbox if there are options in the menu
-                               $newUid = $uid;
-                       } else {
-                               $mayEdit = count($allow)&&($perms&16);
-                               if ($conf['newRecordFromTable'])        {
-                                       $newUid=$GLOBALS['TSFE']->id;
-                                       if ($nPid) $newUid=$nPid;
-                               } else {
-                                       $newUid = -1*$uid;
-                               }
-                       }
-               }
-
-               if ($GLOBALS['TSFE']->displayEditIcons && $table && $mayEdit)   {
-                       $GLOBALS['TSFE']->set_no_cache();               // Special content is about to be shown, so the cache must be disabled.
-                       $formName = 'TSFE_EDIT_FORM_'.substr($GLOBALS['TSFE']->uniqueHash(),0,4);
-                       $formTag = '<form name="'.$formName.'" action="'.htmlspecialchars(t3lib_div::getIndpEnv('REQUEST_URI')).'" method="post" enctype="'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'].'" onsubmit="return TBE_EDITOR.checkSubmit(1);" style="margin: 0 0 0 0;">';
-                       $sortField = $TCA[$table]['ctrl']['sortby'];
-                       $labelField = $TCA[$table]['ctrl']['label'];
-                       $hideField = $TCA[$table]['ctrl']['enablecolumns']['disabled'];
-                       $blackLine = $conf['line']?'<img src="clear.gif" width="1" height="'.intval($conf['line']).'" alt="" title="" /><br /><table border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="black" style="border: 0px;" summary=""><tr style="border: 0px;"><td style="border: 0px;"><img src="clear.gif" width="1" height="1" alt="" title="" /></td></tr></table><br />':'';
-
-                       $theCmd='';
-                       $TSFE_EDIT = t3lib_div::_POST('TSFE_EDIT');
-                       if (is_array($TSFE_EDIT) && $TSFE_EDIT['record']==$currentRecord && !$TSFE_EDIT['update_close'])        {
-                               $theCmd =$TSFE_EDIT['cmd'];
-                       }
-
-                       switch($theCmd) {
-                               case 'edit':
-                               case 'new':
-                                       $tceforms = t3lib_div::makeInstance('t3lib_TCEforms_FE');
-                                       $tceforms->prependFormFieldNames = 'TSFE_EDIT[data]';
-                                       $tceforms->prependFormFieldNames_file = 'TSFE_EDIT_file';
-                                       $tceforms->doSaveFieldName = 'TSFE_EDIT[doSave]';
-                                       $tceforms->formName = $formName;
-                                       $tceforms->backPath = TYPO3_mainDir;
-                                       $tceforms->setFancyDesign();
-                                       $tceforms->defStyle = 'font-family:Verdana;font-size:10px;';
-                                       $tceforms->edit_showFieldHelp = $GLOBALS['BE_USER']->uc['edit_showFieldHelp'];
-                                       $tceforms->helpTextFontTag='<font face="verdana,sans-serif" color="#333333" size="1">';
-
-                                       $trData = t3lib_div::makeInstance('t3lib_transferData');
-                                       $trData->addRawData = TRUE;
-                                       $trData->defVals = t3lib_div::_GP('defVals');           // Added without testing - should provide ability to submit default values in frontend editing, in-page.
-                                       $trData->fetchRecord($table,    ($theCmd=='new'?$newUid:$dataArr['uid']), ($theCmd=='new'?'new':'') );
-                                       reset($trData->regTableItems_data);
-                                       $processedDataArr = current($trData->regTableItems_data);
-                                       $processedDataArr['uid']=$theCmd=='new'?'NEW':$dataArr['uid'];
-                                       $processedDataArr['pid']=$theCmd=='new'?$newUid:$dataArr['pid'];
-
-                                       $panel='';
-                                       $buttons = '<input type="image" border="0" name="TSFE_EDIT[update]" src="'.$tceforms->backPath.'gfx/savedok.gif" hspace="2" width="21" height="16" title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.saveDoc',1).'" />';
-                                       $buttons.= '<input type="image" border="0" name="TSFE_EDIT[update_close]" src="'.$tceforms->backPath.'gfx/saveandclosedok.gif" hspace="2" width="21" height="16" title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.saveCloseDoc',1).'" />';
-                                       $buttons.= '<input type="image" border="0" name="TSFE_EDIT[cancel]" onclick="'.
-                                               htmlspecialchars('window.location.href=\''.t3lib_div::getIndpEnv('REQUEST_URI').'\';return false;').
-                                               '" src="'.$tceforms->backPath.'gfx/closedok.gif" hspace="2" width="21" height="16" title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.closeDoc',1).'" />';
-                                       $panel.=$tceforms->intoTemplate(array('ITEM'=>$buttons));               // Buttons top
-                                       $panel.=$tceforms->getMainFields($table,$processedDataArr);
-
-                                       $hiddenF="";
-                                       if ($theCmd=='new')     {
-                                               $hiddenF.='<input type="hidden" name="TSFE_EDIT[data]['.$table.'][NEW][pid]" value="'.$newUid.'" />';
-                                               if ($table=='pages')    $hiddenF.='<input type="hidden" name="TSFE_EDIT[data]['.$table.'][NEW][hidden]" value="0" />';          // If a new page is created in front-end, then show it by default!
-                                       } else {
-                                               $hiddenF.='<input type="hidden" name="TSFE_EDIT[record]" value="'.$currentRecord.'" />';
-                                               $hiddenF.='<input type="hidden" name="TSFE_EDIT[cmd]" value="edit" />';
-                                       }
-                                       $hiddenF.='<input type="hidden" name="TSFE_EDIT[doSave]" value="0" />';
-                                       $panel.=$tceforms->intoTemplate(array('ITEM'=>$buttons.$hiddenF));      // Buttons AND hidden fields bottom.
+       function editPanel($content, $conf, $currentRecord='', $dataArr=array()) {
 
-                                       $panel=$formTag.$tceforms->wrapTotal($panel,$dataArr,$table).'</form>'.($theCmd!='new'?$blackLine:'');
-                                       $finalOut = $tceforms->printNeededJSFunctions_top().($conf['edit.']['displayRecord']?$content:'').$panel.($theCmd=='new'?$blackLine:'').$tceforms->printNeededJSFunctions();
-                               break;
-                               default:
-                                       $panel = '';
-                                       if (isset($allow['toolbar']))           $panel.=$GLOBALS['BE_USER']->ext_makeToolBar().'<img src="clear.gif" width="2" height="1" alt="" title="" />';
-                                       if (isset($allow['edit']))              $panel.=$this->editPanelLinkWrap('<img src="'.TYPO3_mainDir.'gfx/edit2.gif" width="11" height="12" hspace="2" border="0" title="'.$BE_USER->extGetLL('p_editRecord').'" align="top" alt="" />',$formName,'edit',$dataArr['_LOCALIZED_UID'] ? $table.':'.$dataArr['_LOCALIZED_UID'] : $currentRecord);
-                                       if (isset($allow['move']) && $sortField && $BE_USER->workspace===0)     {       // Hiding in workspaces because implementation is incomplete
-                                               $panel.=$this->editPanelLinkWrap('<img src="'.TYPO3_mainDir.'gfx/button_up.gif" width="11" height="10" vspace="1" hspace="2" border="0" title="'.$BE_USER->extGetLL('p_moveUp').'" align="top" alt="" />',$formName,'up');
-                                               $panel.=$this->editPanelLinkWrap('<img src="'.TYPO3_mainDir.'gfx/button_down.gif" width="11" height="10" vspace="1" hspace="2" border="0" title="'.$BE_USER->extGetLL('p_moveDown').'" align="top" alt="" />',$formName,'down');
-                                       }
-                                       if (isset($allow['hide']) && $hideField && $BE_USER->workspace===0 && !$dataArr['_LOCALIZED_UID'])      {       // Hiding in workspaces because implementation is incomplete, Hiding for localizations because it is unknown what should be the function in that case
-                                               if ($dataArr[$hideField])       {
-                                                       $panel.=$this->editPanelLinkWrap('<img src="'.TYPO3_mainDir.'gfx/button_unhide.gif" width="11" height="10" vspace="1" hspace="2" border="0" title="'.$BE_USER->extGetLL('p_unhide').'" align="top" alt="" />',$formName,'unhide');
-                                               } else {
-                                                       $panel.=$this->editPanelLinkWrap('<img src="'.TYPO3_mainDir.'gfx/button_hide.gif" width="11" height="10" vspace="1" hspace="2" border="0" title="'.$BE_USER->extGetLL('p_hide').'" align="top" alt="" />',$formName,'hide','',$BE_USER->extGetLL('p_hideConfirm'));
-                                               }
-                                       }
-                                       if (isset($allow['new']))       {
-                                               if ($table=='pages')    {
-                                                       $panel.=$this->editPanelLinkWrap('<img src="'.TYPO3_mainDir.'gfx/new_page.gif" width="13" height="12" vspace="1" hspace="2" border="0" title="'.$BE_USER->extGetLL('p_newSubpage').'" align="top" alt="" />',$formName,'new',$currentRecord,'',$nPid);
-                                               } else {
-                                                       $panel.=$this->editPanelLinkWrap('<img src="'.TYPO3_mainDir.'gfx/new_record.gif" width="16" height="12" vspace="1" hspace="2" border="0" title="'.$BE_USER->extGetLL('p_newRecordAfter').'" align="top" alt="" />',$formName,'new',$currentRecord,'',$nPid);
-                                               }
-                                       }
-                                       if (isset($allow['delete']) && $BE_USER->workspace===0 && !$dataArr['_LOCALIZED_UID'])          {       // Hiding in workspaces because implementation is incomplete, Hiding for localizations because it is unknown what should be the function in that case
-                                               $panel.=$this->editPanelLinkWrap('<img src="'.TYPO3_mainDir.'gfx/delete_record.gif" width="12" height="12" vspace="1" hspace="2" border="0" title="'.$BE_USER->extGetLL('p_delete').'" align="top" alt="" />',$formName,'delete','',$BE_USER->extGetLL('p_deleteConfirm'));
-                                       }
+               if($GLOBALS['TSFE']->beUserLogin && ($GLOBALS['BE_USER']->frontendEdit instanceof t3lib_frontendedit)) {
+                       if(!$currentRecord) {
+                               $currentRecord = $this->currentRecord;
+                       }
 
-                                               //      Final
-                                       $labelTxt = $this->stdWrap($conf['label'],$conf['label.']);
-                                       $panel='
-
-                                                               <!-- BE_USER Edit Panel: -->
-                                                               '.$formTag.'
-                                                                       <input type="hidden" name="TSFE_EDIT[cmd]" value="" />
-                                                                       <input type="hidden" name="TSFE_EDIT[record]" value="'.$currentRecord.'" />
-                                                                       <table border="0" cellpadding="0" cellspacing="0" class="typo3-editPanel" summary="">
-                                                                               <tr>
-                                                                                       <td nowrap="nowrap" bgcolor="#ABBBB4" class="typo3-editPanel-controls">'.$panel.'</td>'.($labelTxt?'
-                                                                                       <td nowrap="nowrap" bgcolor="#F6F2E6" class="typo3-editPanel-label"><font face="verdana" size="1" color="black">&nbsp;'.sprintf($labelTxt,htmlspecialchars(t3lib_div::fixed_lgd($dataArr[$labelField],50))).'&nbsp;</font></td>':'').'
-                                                                               </tr>
-                                                                       </table>
-                                                               </form>';
-                                               // wrap the panel
-                                       if ($conf['innerWrap']) $panel = $this->wrap($panel,$conf['innerWrap']);
-                                       if ($conf['innerWrap.']) $panel = $this->stdWrap($panel,$conf['innerWrap.']);
-                                               // add black line:
-                                       $panel.=$blackLine;
-                                               // wrap the complete panel
-                                       if ($conf['outerWrap']) $panel = $this->wrap($panel,$conf['outerWrap']);
-                                       if ($conf['outerWrap.']) $panel = $this->stdWrap($panel,$conf['outerWrap.']);
-                                       if ($conf['printBeforeContent']) {
-                                               $finalOut = $panel . $content;
-                                       } else {
-                                               $finalOut = $content . $panel;
-                                       }
-                               break;
+                       if (!count($dataArr)) {
+                               $dataArr = $this->data;
                        }
 
-                       if ($conf['previewBorder']) $finalOut = $this->editPanelPreviewBorder($table,$dataArr,$finalOut,$conf['previewBorder'],$conf['previewBorder.']);
-                       return $finalOut;
-               } else {
-                       return $content;
+                               // Delegate rendering of the edit panel to the t3lib_frontendedit class.
+                       $content = $GLOBALS['BE_USER']->frontendEdit->displayEditPanel($content, $conf, $currentRecord, $dataArr);
                }
+
+               return $content;
        }
 
        /**
@@ -7415,171 +7254,24 @@ class tslib_cObj {
         * @param       string          Additional URL parameters for the link pointing to alt_doc.php
         * @return      string          The input content string, possibly with edit icons added (not necessarily in the end but just after the last string of normal content.
         */
-       function editIcons($content,$params, $conf=array(), $currentRecord='', $dataArr=array(),$addUrlParamStr='')     {
-               global $BE_USER;
-
-                       // If no backend user, return immediately
-               if (!$GLOBALS['TSFE']->beUserLogin)             {return $content;}
-
-                       // Check incoming params:
-               $rParts = explode(':',$currentRecord?$currentRecord:$this->currentRecord);
-
-               list($table,$fieldList)=t3lib_div::trimExplode(':',$params,1);
-               if (!$fieldList)        {
-                       $fieldList=$table;
-                       $table=$rParts[0];
-               } else {
-                       if ($table!=$rParts[0]) return $content;        // If the table is set as the first parameter, and does not match the table of the current record, then just return.
-               }
-
-                       // Check if allowed to edit content:
-               $mayEdit=0;
-               $dataArr=count($dataArr)?$dataArr:$this->data;  // If pages-record, should contain correct perms-field, if not, should contain correct pid value.
-
-               $editUid = $dataArr['_LOCALIZED_UID'] ? $dataArr['_LOCALIZED_UID'] : $rParts[1];
-
-               if ($table=='pages')    {
-                       $mayEdit = $BE_USER->isAdmin()||$BE_USER->doesUserHaveAccess($dataArr,2)?1:0;
-               } else {
-                       $mayEdit = $BE_USER->isAdmin()||$BE_USER->doesUserHaveAccess(t3lib_BEfunc::getRecord('pages',$dataArr['pid']),16)?1:0;
-               }
-
-                       // Check if allowed to edit language
-               if ($mayEdit)   {
-                       if ($table === 'pages') {
-                               $lang = $GLOBALS['TSFE']->sys_language_uid;
-                       } elseif ($table === 'tt_content')      {
-                               $lang = $GLOBALS['TSFE']->sys_language_content;
-                       } elseif ($TCA[$table]['ctrl']['languageField'])        {
-                               $lang = $currentRecord[$TCA[$table]['ctrl']['languageField']];
-                       } else {
-                               $lang = -1;
-                       }
-                       if (!$BE_USER->checkLanguageAccess($lang))      { $mayEdit = 0; }
-               }
-
-               if ($GLOBALS['TSFE']->displayFieldEditIcons && $table && $mayEdit && $fieldList)        {
-                       $GLOBALS['TSFE']->set_no_cache();               // Special content is about to be shown, so the cache must be disabled.
-                       $style = $conf['styleAttribute'] ? ' style="'.htmlspecialchars($conf['styleAttribute']).'"' : '';
-                       $iconTitle = $this->stdWrap($conf['iconTitle'],$conf['iconTitle.']);
-                       $iconImg = $conf['iconImg'] ? $conf['iconImg'] : '<img src="'.TYPO3_mainDir.'gfx/edit_fe.gif" width="11" height="12" border="0" align="top" title="'.t3lib_div::deHSCentities(htmlspecialchars($iconTitle)).'"'.$style.' class="frontEndEditIcons" alt="" />';
-                       $nV=t3lib_div::_GP('ADMCMD_view')?1:0;
-                       $adminURL = t3lib_div::getIndpEnv('TYPO3_SITE_URL').TYPO3_mainDir;
-                       $icon = $this->editPanelLinkWrap_doWrap($iconImg, $adminURL.'alt_doc.php?edit['.$rParts[0].']['.$editUid.']=edit&columnsOnly='.rawurlencode($fieldList).'&noView='.$nV.$addUrlParamStr,implode(':',$rParts));
-                       if ($conf['beforeLastTag']<0)   {
-                               $content=$icon.$content;
-                       } elseif ($conf['beforeLastTag']>0)     {
-                               $cBuf = rtrim($content);
-                               $securCount=30;
-                               while($securCount && substr($cBuf,-1)=='>' && substr($cBuf,-4)!='</a>') {
-                                       $cBuf = rtrim(ereg_replace('<[^<]*>$','',$cBuf));
-                                       $securCount--;
-                               }
-                               $content = strlen($cBuf)&&$securCount ? substr($content,0,strlen($cBuf)).$icon.substr($content,strlen($cBuf)) : $content=$icon.$content;
-                       } else {
-                               $content.=$icon;
+       function editIcons($content, $params, $conf=array(), $currentRecord='', $dataArr=array(), $addUrlParamStr='')   {
+               if($GLOBALS['TSFE']->beUserLogin && ($GLOBALS['BE_USER']->frontendEdit instanceof t3lib_frontendedit)) {
+                       if(!$currentRecord) {
+                               $currentRecord = $this->currentRecord;
                        }
-               }
-               return $content;
-       }
 
-       /**
-        * Helper function for editPanel() which wraps icons in the panel in a link with the action of the panel.
-        * The links are for some of them not simple hyperlinks but onclick-actions which submits a little form which the panel is wrapped in.
-        *
-        * @param       string          The string to wrap in a link, typ. and image used as button in the edit panel.
-        * @param       string          The name of the form wrapping the edit panel.
-        * @param       string          The command of the link. There is a predefined list available: edit, new, up, down etc.
-        * @param       string          The "table:uid" of the record being processed by the panel.
-        * @param       string          Text string with confirmation message; If set a confirm box will be displayed before carrying out the action (if Yes is pressed)
-        * @param       integer         "New pid" - for new records
-        * @return      string          A <a> tag wrapped string.
-        * @access private
-        * @see editPanel(), editIcons(), t3lib_tsfeBeUserAuth::extEditAction()
-        */
-       function editPanelLinkWrap($string,$formName,$cmd,$currentRecord='',$confirm='',$nPid='')       {
-               $eFONPage = $GLOBALS['BE_USER']->uc['TSFE_adminConfig']['edit_editFormsOnPage'] && $GLOBALS['BE_USER']->workspace===0;  // Editing forms on page only supported in Live workspace (because of incomplete implementation)
-               $nV=t3lib_div::_GP('ADMCMD_view')?1:0;
-               $adminURL = t3lib_div::getIndpEnv('TYPO3_SITE_URL').TYPO3_mainDir;
-
-               if ($cmd=='edit' && !$eFONPage) {
-                       $rParts = explode(':',$currentRecord);
-                       $out=$this->editPanelLinkWrap_doWrap($string,$adminURL.'alt_doc.php?edit['.$rParts[0].']['.$rParts[1].']=edit&noView='.$nV,$currentRecord);
-               } elseif ($cmd=='new' && !$eFONPage)    {
-                       $rParts = explode(':',$currentRecord);
-                       if ($rParts[0]=='pages')        {
-                               $out=$this->editPanelLinkWrap_doWrap($string,$adminURL.'db_new.php?id='.$rParts[1].'&pagesOnly=1',$currentRecord);
-                       } else {
-                               if (!intval($nPid))     {
-                                       $nPid = t3lib_div::testInt($rParts[1]) ? -$rParts[1] : $GLOBALS['TSFE']->id;
-                               }
-                               $out=$this->editPanelLinkWrap_doWrap($string,$adminURL.'alt_doc.php?edit['.$rParts[0].']['.$nPid.']=new&noView='.$nV,$currentRecord);
+                       if (!count($dataArr)) {
+                               $dataArr = $this->data;
                        }
-               } else {
-                       if ($confirm && $GLOBALS['BE_USER']->jsConfirmation(8)) {
-                               $cf1="if (confirm(".t3lib_div::quoteJSvalue($confirm, true).")){";                      // Gets htmlspecialchared later
-                               $cf2='}';
-                       } else {
-                               $cf1=$cf2='';
-                       }
-                       $out='<a href="#" onclick="'.
-                               htmlspecialchars($cf1.'document.'.$formName.'[\'TSFE_EDIT[cmd]\'].value=\''.$cmd.'\'; document.'.$formName.'.submit();'.$cf2.' return false;').
-                               '">'.$string.'</a>';
-               }
-               return $out;
-       }
 
-       /**
-        * Creates a link to a script (eg. typo3/alt_doc.php or typo3/db_new.php) which either opens in the current frame OR in a pop-up window.
-        *
-        * @param       string          The string to wrap in a link, typ. and image used as button in the edit panel.
-        * @param       string          The URL of the link. Should be absolute if supposed to work with <base> path set.
-        * @param       string          The "table:uid" of the record being processed by the panel.
-        * @return      string          A <a> tag wrapped string.
-        * @access private
-        * @see editPanelLinkWrap()
-        */
-       function editPanelLinkWrap_doWrap($string,$url,$currentRecord)  {
-               if ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['edit_editNoPopup'] || $GLOBALS['BE_USER']->extAdminConfig['module.']['edit.']['forceNoPopup']) {
-                       $retUrl = t3lib_div::getIndpEnv('REQUEST_URI');
-                       $rParts = explode(':',$currentRecord);
-                       if ($rParts[0]=='tt_content' && $this->parentRecordNumber>2)    {       // This parentRecordNumber is used to make sure that only elements 3- of ordinary content elements makes a 'anchor' jump down the page.
-                               $retUrl.='#'.$rParts[1];
-                       }
-                       return '<a href="'.htmlspecialchars($url.'&returnUrl='.rawurlencode($retUrl)).'" class="frontEndEditIconLinks">'.$string.'</a>';
-               } else {
-                       return '<a href="#" onclick="'.
-                               htmlspecialchars('vHWin=window.open(\''.$url.'&returnUrl=close.html\',\'FEquickEditWindow\',\''.($GLOBALS['BE_USER']->uc['edit_wideDocument']?'width=690,height=500':'width=540,height=400').',status=0,menubar=0,scrollbars=1,resizable=1\');vHWin.focus();return false;').
-                               '" class="frontEndEditIconLinks">'.$string.'</a>';
+                               // Delegate rendering of the edit panel to the t3lib_frontendedit class.
+                       $content = $GLOBALS['BE_USER']->frontendEdit->displayEditIcons($content, $params, $conf, $currentRecord, $dataArr, $addURLParamStr);
                }
-       }
 
-       /**
-        * Wraps the input content string in a table with a gray border if the table/row combination evaluates to being disabled/hidden.
-        * Used for marking previewed records in the frontend.
-        *
-        * @param       string          The table name
-        * @param       array           The data record from $table
-        * @param       string          The content string to wrap
-        * @param       integer         The thickness of the border
-        * @param       array           The array with TypoScript properties for the content object
-        * @return      string          The input string wrapped in a table with a border color of #cccccc and thickness = $thick
-        * @access private
-        * @see editPanel()
-        */
-       function editPanelPreviewBorder($table,$row,$content,$thick,$conf=array())      {
-               if ($this->isDisabled($table,$row))     {
-                       $thick = t3lib_div::intInRange($thick,1,100);
-                       $color = $conf['color'] ? $conf['color'] : '#cccccc';
-                       if ($conf['innerWrap']) $content = $this->wrap($content,$conf['innerWrap']);
-                       if ($conf['innerWrap.'])        $content = $this->stdWrap($content,$conf['innerWrap.']);
-                       $content = '<table class="typo3-editPanel-previewBorder" border="'.$thick.'" cellpadding="0" cellspacing="0" bordercolor="'.$color.'" width="100%" summary=""><tr><td>'.$content.'</td></tr></table>';
-                       if ($conf['outerWrap']) $content = $this->wrap($content,$conf['outerWrap']);
-                       if ($conf['outerWrap.'])        $content = $this->stdWrap($panel,$conf['outerWrap.']);
-               }
                return $content;
        }
 
+
        /**
         * Returns true if the input table/row would be hidden in the frontend (according nto the current time and simulate user group)
         *
index bd4d168..8682beb 100755 (executable)
@@ -761,23 +761,23 @@ require_once (PATH_t3lib.'class.t3lib_lock.php');
                if ($this->beUserLogin || $this->doWorkspacePreview())  {
 
                                // Backend user preview features:
-                       if ($this->beUserLogin) {
-                               $this->fePreview = $GLOBALS['BE_USER']->extGetFeAdminValue('preview') ? 1 : 0;
+                       if ($this->beUserLogin && ($GLOBALS['BE_USER']->frontendEdit instanceof t3lib_frontendedit)) {
+                               $this->fePreview = $GLOBALS['BE_USER']->frontendEdit->extGetFeAdminValue('preview') ? true : false;
 
                                        // If admin panel preview is enabled...
                                if ($this->fePreview)   {
                                        $fe_user_OLD_USERGROUP = $this->fe_user->user['usergroup'];
 
-                                       $this->showHiddenPage = $GLOBALS['BE_USER']->extGetFeAdminValue('preview','showHiddenPages');
-                                       $this->showHiddenRecords = $GLOBALS['BE_USER']->extGetFeAdminValue('preview','showHiddenRecords');
+                                       $this->showHiddenPage = $GLOBALS['BE_USER']->frontendEdit->extGetFeAdminValue('preview', 'showHiddenPages');
+                                       $this->showHiddenRecords = $GLOBALS['BE_USER']->frontendEdit->extGetFeAdminValue('preview', 'showHiddenRecords');
                                                // simulate date
-                                       $simTime = $GLOBALS['BE_USER']->extGetFeAdminValue('preview','simulateDate');
+                                       $simTime = $GLOBALS['BE_USER']->frontendEdit->extGetFeAdminValue('preview', 'simulateDate');
                                        if ($simTime)   {
                                                $GLOBALS['SIM_EXEC_TIME'] = $simTime;
                                                $GLOBALS['SIM_ACCESS_TIME'] = $simTime - ($simTime % 60);
                                        }
                                                // simulate user
-                                       $simUserGroup = $GLOBALS['BE_USER']->extGetFeAdminValue('preview','simulateUserGroup');
+                                       $simUserGroup = $GLOBALS['BE_USER']->frontendEdit->extGetFeAdminValue('preview', 'simulateUserGroup');
                                        $this->simUserGroup = $simUserGroup;
                                        if ($simUserGroup)      $this->fe_user->user['usergroup']=$simUserGroup;
                                        if (!$simUserGroup && !$simTime && !$this->showHiddenPage && !$this->showHiddenRecords) {
index ce9c03f..1435315 100755 (executable)
@@ -273,8 +273,8 @@ if ($_COOKIE['be_typo_user']) {             // If the backend cookie is set, we proceed and
                        $BE_USER->fetchGroupData();
                        $TSFE->beUserLogin = 1;
                }
-               if ($BE_USER->checkLockToIP() && $BE_USER->checkBackendAccessSettingsFromInitPhp())     {
-                       $BE_USER->extInitFeAdmin();
+               if ($BE_USER->checkLockToIP() && $BE_USER->checkBackendAccessSettingsFromInitPhp() && $BE_USER->user['uid']) {
+                       $BE_USER->initializeFrontendEdit();
                } else {        // Unset the user initialization.
                        $BE_USER='';
                        $TSFE->beUserLogin=0;
@@ -336,54 +336,12 @@ $TT->pull();
 // *****************************************
 // Frontend editing
 // *****************************************
-if ($TSFE->beUserLogin && $BE_USER->extAdmEnabled)     {
+if ($TSFE->beUserLogin && ($BE_USER->frontendEdit instanceof t3lib_frontendedit))      {
        require_once(t3lib_extMgm::extPath('lang').'lang.php');
        $LANG = t3lib_div::makeInstance('language');
        $LANG->init($BE_USER->uc['lang']);
 
-       $BE_USER->extSaveFeAdminConfig();
-
-               // Setting some values based on the admin panel
-       $TSFE->forceTemplateParsing = $BE_USER->extGetFeAdminValue('tsdebug', 'forceTemplateParsing');
-       $TSFE->displayEditIcons = $BE_USER->extGetFeAdminValue('edit', 'displayIcons');
-       $TSFE->displayFieldEditIcons = $BE_USER->extGetFeAdminValue('edit', 'displayFieldIcons');
-
-       if ($BE_USER->extGetFeAdminValue('tsdebug','displayQueries')) {
-               if ($GLOBALS['TYPO3_DB']->explainOutput == 0) {         // do not override if the value is already set in t3lib_db
-                               // Enable execution of EXPLAIN SELECT queries
-                       $GLOBALS['TYPO3_DB']->explainOutput = 3;
-               }
-       }
-
-       if (t3lib_div::_GP('ADMCMD_editIcons')) {
-               $TSFE->displayFieldEditIcons=1;
-               $BE_USER->uc['TSFE_adminConfig']['edit_editNoPopup']=1;
-       }
-       if (t3lib_div::_GP('ADMCMD_simUser'))   {
-               $BE_USER->uc['TSFE_adminConfig']['preview_simulateUserGroup']=intval(t3lib_div::_GP('ADMCMD_simUser'));
-               $BE_USER->ext_forcePreview=1;
-       }
-       if (t3lib_div::_GP('ADMCMD_simTime'))   {
-               $BE_USER->uc['TSFE_adminConfig']['preview_simulateDate']=intval(t3lib_div::_GP('ADMCMD_simTime'));
-               $BE_USER->ext_forcePreview=1;
-       }
-
-       // Include classes for editing IF editing module in Admin Panel is open
-       if (($BE_USER->extAdmModuleEnabled('edit') && $BE_USER->extIsAdmMenuOpen('edit')) || $TSFE->displayEditIcons == 1)      {
-               $TSFE->includeTCA();
-               if ($BE_USER->extIsEditAction())        {
-                       require_once (PATH_t3lib.'class.t3lib_tcemain.php');
-                       $BE_USER->extEditAction();
-               }
-               if ($BE_USER->extIsFormShown()) {
-                       require_once(PATH_t3lib.'class.t3lib_tceforms.php');
-                       require_once(PATH_t3lib.'class.t3lib_iconworks.php');
-                       require_once(PATH_t3lib.'class.t3lib_loaddbgroup.php');
-                       require_once(PATH_t3lib.'class.t3lib_transferdata.php');
-               }
-       }
-
-       if ($TSFE->forceTemplateParsing || $TSFE->displayEditIcons || $TSFE->displayFieldEditIcons)     { $TSFE->set_no_cache(); }
+       $BE_USER->frontendEdit->initConfigOptions();
 }
 
 
@@ -578,8 +536,8 @@ $TSFE->previewInfo();
 // ******************
 // Publishing static
 // ******************
-if (is_object($BE_USER))       {
-       if ($BE_USER->extAdmModuleEnabled('publish') && $BE_USER->extPublishList)       {
+if (is_object($BE_USER) && ($BE_USER->frontendEdit instanceof t3lib_frontendedit)) {
+       if ($BE_USER->frontendEdit->isAdminModuleEnabled('publish') && $BE_USER->frontendEdit->getExtPublishList()) {
                include_once(PATH_tslib.'publish.php');
        }
 }
@@ -606,16 +564,10 @@ echo $TSFE->beLoginLinkIPList();
 // *************
 // Admin panel
 // *************
-if (is_object($BE_USER)
-       && $TSFE->beUserLogin
-       && $TSFE->config['config']['admPanel']
-       && $BE_USER->extAdmEnabled
-//     && $BE_USER->extPageReadAccess($TSFE->page)     // This is already done, if there is a BE_USER object at this point!
-       && !$BE_USER->extAdminConfig['hide'])   {
-               echo $BE_USER->extPrintFeAdminDialog();
+if (is_object($BE_USER) && $TSFE->beUserLogin && ($BE_USER->frontendEdit instanceof t3lib_frontendedit)) {
+       echo $BE_USER->frontendEdit->displayAdmin();
 }
 
-
 // *************
 // Debugging Output
 // *************
index de302fa..59e61ff 100755 (executable)
@@ -58,7 +58,7 @@ if (!is_object($TSFE))        {die('You cannot execute this file directly. It\'s meant
        // Storing the TSFE object
 $temp_publish_TSFE = $TSFE;
 $TT->push('Publishing','');
-$temp_publish_pages = explode(',',$BE_USER->extPublishList);
+$temp_publish_pages = explode(',', $BE_USER->frontendEdit->getExtPublishList());
 $temp_publish_imagesTotal = array();
 $temp_publish_array = array(); // Collects the rendered pages.
 
diff --git a/typo3/sysext/fe_edit/ext_emconf.php b/typo3/sysext/fe_edit/ext_emconf.php
new file mode 100644 (file)
index 0000000..527d7b4
--- /dev/null
@@ -0,0 +1,48 @@
+<?php
+
+########################################################################
+# Extension Manager/Repository config file for ext: "fe_edit"
+#
+# Auto generated 06-11-2008 10:50
+#
+# Manual updates:
+# Only the data in the array - anything else is removed by next write.
+# "version" and "dependencies" must not be touched!
+########################################################################
+
+$EM_CONF[$_EXTKEY] = array(
+       'title' => 'Frontend Editing',
+       'description' => '',
+       'category' => 'fe',
+       'author' => 'Jeff Segars, David Slayback',
+       'author_email' => 'jeff@webempoweredchurch.org, dave@webempoweredchurch.org',
+       'shy' => '',
+       'dependencies' => '',
+       'conflicts' => '',
+       'priority' => '',
+       'module' => '',
+       'state' => 'beta',
+       'internal' => '',
+       'uploadfolder' => 0,
+       'createDirs' => '',
+       'modify_tables' => '',
+       'clearCacheOnLoad' => 0,
+       'lockType' => 'system',
+       'author_company' => 'Web-Empowered Church',
+       'version' => '0.1.0',
+       'constraints' => array(
+               'depends' => array(
+                       'typo3' => '4.3.0-0.0.0',
+                       'php' => '5.2.0-0.0.0',
+               ),
+               'conflicts' => array(
+               ),
+               'suggests' => array(
+               ),
+       ),
+       '_md5_values_when_last_written' => 'a:4:{s:12:"ext_icon.gif";s:4:"1bdc";s:17:"ext_localconf.php";s:4:"1aa5";s:35:"view/class.tx_feedit_adminpanel.php";s:4:"c85b";s:34:"view/class.tx_feedit_editpanel.php";s:4:"c635";}',
+       'suggests' => array(
+       ),
+);
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fe_edit/ext_icon.gif b/typo3/sysext/fe_edit/ext_icon.gif
new file mode 100755 (executable)
index 0000000..b993e8a
Binary files /dev/null and b/typo3/sysext/fe_edit/ext_icon.gif differ
diff --git a/typo3/sysext/fe_edit/ext_localconf.php b/typo3/sysext/fe_edit/ext_localconf.php
new file mode 100644 (file)
index 0000000..822754b
--- /dev/null
@@ -0,0 +1,8 @@
+<?php
+if (!defined ('TYPO3_MODE'))   die ('Access denied.');
+
+       // Register the admin panel and edit panel views.
+$TYPO3_CONF_VARS['SC_OPTIONS']['typo3/classes/class.frontendedit.php']['admin'] = 'EXT:fe_edit/view/class.tx_feedit_adminpanel.php:tx_feedit_adminpanel';
+$TYPO3_CONF_VARS['SC_OPTIONS']['typo3/classes/class.frontendedit.php']['edit'] = 'EXT:fe_edit/view/class.tx_feedit_editpanel.php:tx_feedit_editpanel';
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fe_edit/view/class.tx_feedit_adminpanel.php b/typo3/sysext/fe_edit/view/class.tx_feedit_adminpanel.php
new file mode 100644 (file)
index 0000000..cf3a6a9
--- /dev/null
@@ -0,0 +1,620 @@
+<?php
+/***************************************************************
+*  Copyright notice
+*
+*  (c) 2008 Jeff Segars <jeff@webempoweredchurch.org>
+*  (c) 2008 David Slayback <dave@webempoweredchurch.org>
+*  All rights reserved
+*
+*  This script is part of the TYPO3 project. The TYPO3 project is
+*  free software; you can redistribute it and/or modify
+*  it under the terms of the GNU General Public License as published by
+*  the Free Software Foundation; either version 2 of the License, or
+*  (at your option) any later version.
+*
+*  The GNU General Public License can be found at
+*  http://www.gnu.org/copyleft/gpl.html.
+*  A copy is found in the textfile GPL.txt and important notices to the license
+*  from the author is found in LICENSE.txt distributed with these scripts.
+*
+*
+*  This script is distributed in the hope that it will be useful,
+*  but WITHOUT ANY WARRANTY; without even the implied warranty of
+*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*  GNU General Public License for more details.
+*
+*  This copyright notice MUST APPEAR in all copies of the script!
+***************************************************************/
+
+/**
+ * View class for the admin panel in frontend editing.
+ *
+ * @author     Jeff Segars <jeff@webempoweredchurch.org>
+ * @author     David Slayback <dave@webempoweredchurch.org>
+ * @package TYPO3
+ * @subpackage fe_edit
+ */
+class tx_feedit_adminpanel {
+
+       /**
+        * Determines whether the update button should be shown.
+        *
+        * @var boolean
+        */
+       protected $extNeedUpdate = false;
+
+       /**
+        * Creates and returns the HTML code for the Admin Panel in the TSFE frontend.
+        *
+        * @return      string          HTML for the Admin Panel
+        */
+       public function display() {
+               $out='';
+               if ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_top']) {
+                       if ($GLOBALS['BE_USER']->frontendEdit->isAdminModuleEnabled('preview')) {
+                               $out .= $this->getPreviewModule();
+                       }
+                       if ($GLOBALS['BE_USER']->frontendEdit->isAdminModuleEnabled('cache')) {
+                               $out .= $this->getCacheModule();
+                       }
+                       if ($GLOBALS['BE_USER']->frontendEdit->isAdminModuleEnabled('publish')) {
+                               $out .= $this->getPublishModule();
+                       }
+                       if ($GLOBALS['BE_USER']->frontendEdit->isAdminModuleEnabled('edit')){
+                               $out .= $this->getEditModule();
+                       }
+                       if ($GLOBALS['BE_USER']->frontendEdit->isAdminModuleEnabled('tsdebug')) {
+                               $out .= $this->getTSDebugModule();
+                       }
+                       if ($GLOBALS['BE_USER']->frontendEdit->isAdminModuleEnabled('info')) {
+                               $out .= $this->getInfoModule();
+                       }
+               }
+
+               $row = '<img src="' . TYPO3_mainDir . 'gfx/ol/blank.gif" width="18" height="16" align="absmiddle" border="0" alt="" />';
+               $row .= '<img src="' . TYPO3_mainDir . 'gfx/ol/' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_top']?'minus':'plus') . 'bullet.gif" width="18" height="16" align="absmiddle" border="0" alt="" />';
+               $row .= '<strong>' . $this->extFw($this->extGetLL('adminOptions')) . '</strong>';
+               $row .= $this->extFw(': ' . $GLOBALS['BE_USER']->user['username']);
+
+               $header = '
+                       <tr class="typo3-adminPanel-hRow" style="background-color:#9ba1a8;">
+                               <td colspan="4" style="text-align:left; white-space:nowrap;">' .
+                                       $this->extItemLink('top',$row) . '
+                                       <img src="clear.gif" width="40" height="1" alt="" />
+                                       <input type="hidden" name="TSFE_ADMIN_PANEL[display_top]" value="' . $GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_top'] . '" />' . ($this->extNeedUpdate ? '<input type="submit" value="' . $this->extGetLL('update') . '" />' : '') . '</td>
+                       </tr>';
+
+               $query = !t3lib_div::_GET('id') ? ('<input type="hidden" name="id" value="' . $GLOBALS['TSFE']->id . '" />' . chr(10)) : '';
+                       // 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")
+               $query .= '<input type="hidden" name="TSFE_ADMIN_PANEL[DUMMY]" value="">';
+               foreach (t3lib_div::_GET() as $key => $value) {
+                       if ($key != 'TSFE_ADMIN_PANEL') {
+                               if (is_array($value)) {
+                                       $query .= $this->getHiddenFields($key, $value);
+                               } else {
+                                       $query .= '<input type="hidden" name="' . $key . '" value="' . htmlspecialchars($value) . '">' . chr(10);
+                               }
+                       }
+               }
+
+               $out = '
+<!--
+       ADMIN PANEL
+-->
+<a name="TSFE_ADMIN"></a>
+<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)">' .
+$query . '
+       <table border="0" cellpadding="0" cellspacing="0" class="typo3-adminPanel" style="background-color:#f6f2e6; border: 1px solid black; z-index:0; position:absolute;" summary="">' .
+               $header .
+               $out . '
+       </table>
+</form>';
+
+               if ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_top']) {
+                       $out .= '<script type="text/javascript" src="t3lib/jsfunc.evalfield.js"></script>';
+                       $out .= '
+                       <script type="text/javascript">
+                                       /*<![CDATA[*/
+                               var evalFunc = new evalFunc();
+                                       // TSFEtypo3FormFieldSet()
+                               function TSFEtypo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue) {    //
+                                       var theFObj = new evalFunc_dummy (evallist,is_in, checkbox, checkboxValue);
+                                       var theValue = document.TSFE_ADMIN_PANEL_FORM[theField].value;
+                                       if (checkbox && theValue==checkboxValue) {
+                                               document.TSFE_ADMIN_PANEL_FORM[theField+"_hr"].value="";
+                                               document.TSFE_ADMIN_PANEL_FORM[theField+"_cb"].checked = "";
+                                       } else {
+                                               document.TSFE_ADMIN_PANEL_FORM[theField+"_hr"].value = evalFunc.outputObjValue(theFObj, theValue);
+                                               document.TSFE_ADMIN_PANEL_FORM[theField+"_cb"].checked = "on";
+                                       }
+                               }
+                                       // TSFEtypo3FormFieldGet()
+                               function TSFEtypo3FormFieldGet(theField, evallist, is_in, checkbox, checkboxValue, checkbox_off) {      //
+                                       var theFObj = new evalFunc_dummy (evallist,is_in, checkbox, checkboxValue);
+                                       if (checkbox_off) {
+                                               document.TSFE_ADMIN_PANEL_FORM[theField].value=checkboxValue;
+                                       }else{
+                                               document.TSFE_ADMIN_PANEL_FORM[theField].value = evalFunc.evalObjValue(theFObj, document.TSFE_ADMIN_PANEL_FORM[theField+"_hr"].value);
+                                       }
+                                       TSFEtypo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue);
+                               }
+                                       /*]]>*/
+                       </script>
+                       <script language="javascript" type="text/javascript">' . $this->extJSCODE . '</script>';
+               }
+               return "\n\n\n\n" . $out . '<br />';
+       }
+
+       /**
+        * Fetches recursively all GET parameters as hidden fields.
+        * Called from display()
+        *
+        * @param       string          current key
+        * @param       mixed           current value
+        * @return      string          hidden fields
+        * @see display()
+        */
+       protected function getHiddenFields($key, &$val) {
+               $out = '';
+               foreach ($val as $k => $v) {
+                       if (is_array($v)) {
+                               $out .= $this->getHiddenFields($key . '[' . $k . ']', $v);
+                       } else {
+                               $out .= '<input type="hidden" name="' . $key . '[' . $k . ']" value="' . htmlspecialchars($v) . '">' . chr(10);
+                       }
+               }
+               return $out;
+       }
+
+       /*****************************************************
+        *
+        * Creating sections of the Admin Panel
+        *
+        ****************************************************/
+
+       /**
+        * Creates the content for the "preview" section ("module") of the Admin Panel
+        *
+        * @param       string          Optional start-value; The generated content is added to this variable.
+        * @return      string          HTML content for the section. Consists of a string with table-rows with four columns.
+        * @see display()
+        */
+       protected function getPreviewModule($out = '') {
+               $out .= $this->extGetHead('preview');
+               if ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_preview']) {
+                       $this->extNeedUpdate = true;
+                       $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"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['preview_showHiddenPages'] ? ' checked="checked"' : '') . ' />');
+                       $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"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['preview_showHiddenRecords'] ? ' checked="checked"' : '') . ' />');
+
+                               // Simulate date
+                       $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="' . $GLOBALS['BE_USER']->uc['TSFE_adminConfig']['preview_simulateDate'] . '" />');
+                       $this->extJSCODE .= 'TSFEtypo3FormFieldSet("TSFE_ADMIN_PANEL[preview_simulateDate]", "datetime", "", 1,0);';
+
+                               // Simulate fe_user:
+                       $options = '<option value="0">&nbsp;</option>';
+                       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
+                                               'fe_groups.uid, fe_groups.title',
+                                               'fe_groups,pages',
+                                               'pages.uid=fe_groups.pid AND pages.deleted=0 ' . t3lib_BEfunc::deleteClause('fe_groups') . ' AND ' . $GLOBALS['BE_USER']->getPagePermsClause(1)
+                                       );
+                       while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
+                               $options .= '<option value="' . $row['uid'] . '"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['preview_simulateUserGroup'] == $row['uid'] ? ' selected="selected"' : '') . '>' . htmlspecialchars('[' . $row['uid'] . '] ' . $row['title']) . '</option>';
+                       }
+                       $out .= $this->extGetItem('preview_simulateUserGroup', '<select name="TSFE_ADMIN_PANEL[preview_simulateUserGroup]">' . $options . '</select>');
+               }
+
+               return $out;
+       }
+
+       /**
+        * Creates the content for the "cache" section ("module") of the Admin Panel
+        *
+        * @param       string          Optional start-value; The generated content is added to this variable.
+        * @return      string          HTML content for the section. Consists of a string with table-rows with four columns.
+        * @see display()
+        */
+       protected function getCacheModule($out = '') {
+               $out.= $this->extGetHead('cache');
+               if ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_cache']) {
+                       $this->extNeedUpdate = true;
+                       $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"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['cache_noCache'] ? ' checked="checked"' : '') . ' />');
+                       $options = '';
+                       $options .= '<option value="0"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['cache_clearCacheLevels'] == 0 ? ' selected="selected"' : '') . '>' . $this->extGetLL('div_Levels_0') . '</option>';
+                       $options .= '<option value="1"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['cache_clearCacheLevels'] == 1 ? ' selected="selected"' : '') . '>' . $this->extGetLL('div_Levels_1') . '</option>';
+                       $options .= '<option value="2"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['cache_clearCacheLevels'] == 2 ? ' selected="selected"' : '') . '>' . $this->extGetLL('div_Levels_2') . '</option>';
+                       $out .= $this->extGetItem('cache_clearLevels', '<select name="TSFE_ADMIN_PANEL[cache_clearCacheLevels]">' . $options . '</select>' .
+                                       '<input type="hidden" name="TSFE_ADMIN_PANEL[cache_clearCacheId]" value="' . $GLOBALS['TSFE']->id . '" /><input type="submit" value="' . $this->extGetLL('update') . '" />');
+
+                               // Generating tree:
+                       $depth = $GLOBALS['BE_USER']->frontendEdit->extGetFeAdminValue('cache', 'clearCacheLevels');
+                       $outTable = '';
+                       $GLOBALS['BE_USER']->extPageInTreeInfo = array();
+                       $GLOBALS['BE_USER']->extPageInTreeInfo[] = array($GLOBALS['TSFE']->page['uid'], htmlspecialchars($GLOBALS['TSFE']->page['title']), $depth+1);
+                       $GLOBALS['BE_USER']->extGetTreeList($GLOBALS['TSFE']->id, $depth, 0, $GLOBALS['BE_USER']->getPagePermsClause(1));
+                       foreach ($GLOBALS['BE_USER']->extPageInTreeInfo as $row) {
+                               $outTable .= '
+                                       <tr>
+                                               <td style="white-space: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($GLOBALS['BE_USER']->extGetNumberOfCachedPages($row[0])) . '</td>
+                                       </tr>';
+                       }
+
+                       $outTable = '<br /><table border="0" cellpadding="0" cellspacing="0" summary="">' . $outTable . '</table>';
+                       $outTable .= '<input type="submit" name="TSFE_ADMIN_PANEL[action][clearCache]" value="' . $this->extGetLL('cache_doit') . '" />';
+
+                       $out .= $this->extGetItem('cache_cacheEntries', $outTable);
+               }
+
+               return $out;
+       }
+
+       /**
+        * Creates the content for the "publish" section ("module") of the Admin Panel
+        *
+        * @param       string          Optional start-value; The generated content is added to this variable.
+        * @return      string          HTML content for the section. Consists of a string with table-rows with four columns.
+        * @see display()
+        */
+       protected function getPublishModule($out = '') {
+               $out .= $this->extGetHead('publish');
+               if ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_publish']) {
+                       $this->extNeedUpdate = true;
+                       $options = '';
+                       $options .= '<option value="0"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['publish_levels'] == 0 ? ' selected="selected"' : '') . '>' . $this->extGetLL('div_Levels_0') . '</option>';
+                       $options .= '<option value="1"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['publish_levels'] == 1 ? ' selected="selected"' : '') . '>' . $this->extGetLL('div_Levels_1') . '</option>';
+                       $options .= '<option value="2"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['publish_levels'] == 2 ? ' selected="selected"' : '') . '>' . $this->extGetLL('div_Levels_2') . '</option>';
+                       $out .= $this->extGetItem('publish_levels', '<select name="TSFE_ADMIN_PANEL[publish_levels]">' . $options . '</select>' .
+                                       '<input type="hidden" name="TSFE_ADMIN_PANEL[publish_id]" value="' . $GLOBALS['TSFE']->id . '" />&nbsp;<input type="submit" value="' . $this->extGetLL('update') . '" />');
+
+                               // Generating tree:
+                       $depth = $GLOBALS['BE_USER']->frontendEdit->extGetFeAdminValue('publish', 'levels');
+                       $outTable = '';
+                       $GLOBALS['BE_USER']->extPageInTreeInfo = array();
+                       $GLOBALS['BE_USER']->extPageInTreeInfo[] = array($GLOBALS['TSFE']->page['uid'], htmlspecialchars($GLOBALS['TSFE']->page['title']), $depth+1);
+                       $GLOBALS['BE_USER']->extGetTreeList($GLOBALS['TSFE']->id, $depth, 0, $GLOBALS['BE_USER']->getPagePermsClause(1));
+                       foreach ($GLOBALS['BE_USER']->extPageInTreeInfo as $row) {
+                               $outTable.= '
+                                       <tr>
+                                               <td style="white-space: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>';
+                       }
+                       $outTable = '<br /><table border="0" cellpadding="0" cellspacing="0" summary="">' . $outTable . '</table>';
+                       $outTable .= '<input type="submit" name="TSFE_ADMIN_PANEL[action][publish]" value="' . $this->extGetLL('publish_doit') . '" />';
+
+                       $out .= $this->extGetItem('publish_tree', $outTable);
+               }
+
+               return $out;
+       }
+
+       /**
+        * Creates the content for the "edit" section ("module") of the Admin Panel
+        *
+        * @param       string          Optional start-value; The generated content is added to this variable.
+        * @return      string          HTML content for the section. Consists of a string with table-rows with four columns.
+        * @see display()
+        */
+       protected function getEditModule($out = '') {
+               $out .= $this->extGetHead('edit');
+               if ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_edit']) {
+
+                               // If another page module was specified, replace the default Page module with the new one
+                       $newPageModule = trim($GLOBALS['BE_USER']->getTSConfigVal('options.overridePageModule'));
+                       $pageModule = t3lib_BEfunc::isModuleSetInTBE_MODULES($newPageModule) ? $newPageModule : 'web_layout';
+
+                       $this->extNeedUpdate = true;
+                       $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"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['edit_displayFieldIcons'] ? ' checked="checked"' : '') . ' />');
+                       $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"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['edit_displayIcons'] ? ' checked="checked"' : '') . ' />');
+                       $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"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['edit_editFormsOnPage'] ? ' checked="checked"':'') . ' />');
+                       $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"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['edit_editNoPopup'] ? ' checked="checked"' : '') . ' />');
+                       $out .= $this->extGetItem('', $this->ext_makeToolBar());
+
+                       if (!t3lib_div::_GP('ADMCMD_view')) {
+                               $out .= $this->extGetItem('', '<a href="#" onclick="' .
+                                       htmlspecialchars('
+                                               if (parent.opener && parent.opener.top && parent.opener.top.TS) {
+                                                       parent.opener.top.fsMod.recentIds["web"]=' . intval($GLOBALS['TSFE']->page['uid']) . ';
+                                                       if (parent.opener.top.content && parent.opener.top.content.nav_frame && parent.opener.top.content.nav_frame.refresh_nav) {
+                                                               parent.opener.top.content.nav_frame.refresh_nav();
+                                                       }
+                                                       parent.opener.top.goToModule("' . $pageModule . '");
+                                                       parent.opener.top.focus();
+                                               } else {
+                                                       vHWin=window.open(\'' . TYPO3_mainDir.t3lib_BEfunc::getBackendScript() . '\',\'' . md5('Typo3Backend-' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']) . '\',\'status=1,menubar=1,scrollbars=1,resizable=1\');
+                                                       vHWin.focus();
+                                               }
+                                               return false;
+                                               ').
+                                       '">' . $this->extFw($this->extGetLL('edit_openAB')) . '</a>');
+                       }
+               }
+
+               return $out;
+       }
+
+       /**
+        * Creates the content for the "tsdebug" section ("module") of the Admin Panel
+        *
+        * @param       string          Optional start-value; The generated content is added to this variable.
+        * @return      string          HTML content for the section. Consists of a string with table-rows with four columns.
+        * @see display()
+        */
+       protected function getTSDebugModule($out = '') {
+               $out .= $this->extGetHead('tsdebug');
+               if ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_tsdebug']) {
+                       $this->extNeedUpdate = true;
+
+                       $out .= $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"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['tsdebug_tree'] ? ' checked="checked"' : '') . ' />');
+                       $out .= $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"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['tsdebug_displayTimes'] ? ' checked="checked"' : '') . ' />');
+                       $out .= $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"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['tsdebug_displayMessages'] ? ' checked="checked"':'') . ' />');
+                       $out .= $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"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['tsdebug_LR'] ? ' checked="checked"' : '') . ' />');
+                       $out .= $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"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['tsdebug_displayContent'] ? ' checked="checked"' : '') . ' />');
+                       $out .= $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"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['tsdebug_displayQueries'] ? ' checked="checked"' : '') . ' />');
+                       $out .= $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"' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['tsdebug_forceTemplateParsing'] ? ' checked="checked"' : '') . ' />');
+
+                       $GLOBALS['TT']->printConf['flag_tree'] = $GLOBALS['BE_USER']->frontendEdit->extGetFeAdminValue('tsdebug', 'tree');
+                       $GLOBALS['TT']->printConf['allTime'] = $GLOBALS['BE_USER']->frontendEdit->extGetFeAdminValue('tsdebug', 'displayTimes');
+                       $GLOBALS['TT']->printConf['flag_messages'] = $GLOBALS['BE_USER']->frontendEdit->extGetFeAdminValue('tsdebug', 'displayMessages');
+                       $GLOBALS['TT']->printConf['flag_content'] = $GLOBALS['BE_USER']->frontendEdit->extGetFeAdminValue('tsdebug', 'displayContent');
+                       $GLOBALS['TT']->printConf['flag_queries'] = $GLOBALS['BE_USER']->frontendEdit->extGetFeAdminValue('tsdebug', 'displayQueries');
+
+                       $out.= '
+                               <tr>
+                                       <td><img src="clear.gif" width="50" height="1" alt="" /></td>
+                                       <td colspan="3">' . $GLOBALS['TT']->printTSlog() . '</td>
+                               </tr>';
+               }
+
+               return $out;
+       }
+
+       /**
+        * Creates the content for the "info" section ("module") of the Admin Panel
+        *
+        * @param       string          Optional start-value; The generated content is added to this variable.
+        * @return      string          HTML content for the section. Consists of a string with table-rows with four columns.
+        * @see display()
+        */
+       protected function getInfoModule($out = '') {
+               $out .= $this->extGetHead('info');
+               if ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_info']) {
+                       $tableArr = array();
+
+                       if ($GLOBALS['BE_USER']->frontendEdit->extGetFeAdminValue('cache', 'noCache')) {
+                               $theBytes = 0;
+                               $count = 0;
+
+                               if (count($GLOBALS['TSFE']->imagesOnPage)) {
+                                       $tableArr[] = array('*Images on this page:*', '');
+                                       foreach ($GLOBALS['TSFE']->imagesOnPage as $file) {
+                                               $fs = @filesize($file);
+                                               $tableArr[] = array('&ndash; ' . $file, t3lib_div::formatSize($fs));
+                                               $theBytes+= $fs;
+                                               $count++;
+                                       }
+                               }
+                               $tableArr[] = array('', '');    // Add an empty line
+
+                               $tableArr[] = array('*Total number of images:*', $count);
+                               $tableArr[] = array('*Total image file sizes:*', t3lib_div::formatSize($theBytes));
+                               $tableArr[] = array('*Document size:*', t3lib_div::formatSize(strlen($GLOBALS['TSFE']->content)));
+                               $tableArr[] = array('*Total page load:*', t3lib_div::formatSize(strlen($GLOBALS['TSFE']->content)+$theBytes));
+                               $tableArr[] = array('', '');
+                       }
+
+                       $tableArr[] = array('id:', $GLOBALS['TSFE']->id);
+                       $tableArr[] = array('type:', $GLOBALS['TSFE']->type);
+                       $tableArr[] = array('gr_list:', $GLOBALS['TSFE']->gr_list);
+                       $tableArr[] = array('no_cache:', $GLOBALS['TSFE']->no_cache);
+                       $tableArr[] = array('fe_user, name:', $GLOBALS['TSFE']->fe_user->user['username']);
+                       $tableArr[] = array('fe_user, uid:', $GLOBALS['TSFE']->fe_user->user['uid']);
+                       $tableArr[] = array('', '');    // Add an empty line
+
+                               // parsetime:
+                       $tableArr[] = array('*Total parsetime:*', $GLOBALS['TSFE']->scriptParseTime . ' ms');
+
+                       $table = '';
+                       foreach ($tableArr as $arr) {
+                               if (strlen($arr[0])) {  // Put text wrapped by "*" between <strong> tags
+                                       $value1 = preg_replace('/^\*(.*)\*$/', '$1', $arr[0], -1, $count);
+                                       $value1 = ($count?'<strong>':'') . $this->extFw($value1) . ($count?'</strong>':'');
+                               } else {
+                                       $value1 = $this->extFw('&nbsp;');
+                               }
+
+                               $value2 = strlen($arr[1]) ? $arr[1] : '&nbsp;';
+                               $value2 = $this->extFw($value2);
+
+                               $table .= '
+                                       <tr>
+                                               <td style="text-align:left">' . $value1 . '</td>
+                                               <td style="text-align:right">' . $value2 . '</td>
+                                       </tr>';
+                       }
+
+                       $table = '<table border="0" cellpadding="0" cellspacing="0" summary="">' . $table . '</table>';
+
+                       $out .= '
+                               <tr>
+                                       <td><img src="clear.gif" width="50" height="1" alt="" /></td>
+                                       <td colspan="3">' . $table . '</td>
+                               </tr>';
+               }
+
+               return $out;
+       }
+
+       /*****************************************************
+        *
+        * Admin Panel Layout Helper functions
+        *
+        ****************************************************/
+
+       /**
+        * Returns a row (with colspan=4) which is a header for a section in the Admin Panel.
+        * 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
+        * See the functions get*Module
+        *
+        * @param       string          The suffix to the display_ label. Also selects the label from the LOCAL_LANG array.
+        * @return      string          HTML table row.
+        * @access private
+        * @see extGetItem()
+        */
+       protected function extGetHead($pre) {
+               $out = '<img src="' . TYPO3_mainDir . 'gfx/ol/blank.gif" width="18" height="16" align="absmiddle" border="0" alt="" />';
+               $out .= '<img src="' . TYPO3_mainDir . 'gfx/ol/' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_' . $pre] ? 'minus' : 'plus') . 'bullet.gif" width="18" height="16" align="absmiddle" border="0" alt="" />';
+               $out .= $this->extFw($this->extGetLL($pre));
+
+               $out = $this->extItemLink($pre,$out);
+               return '
+                               <tr class="typo3-adminPanel-itemHRow" style="background-color:#abbbb4;">
+                                       <td colspan="4" style="text-align:left; border-top:dashed 1px #007a8c; white-space:nowrap;">' . $out . '<input type="hidden" name="TSFE_ADMIN_PANEL[display_' . $pre . ']" value="' . $GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_' . $pre] . '" /></td>
+                               </tr>';
+       }
+
+       /**
+        * Wraps a string in a link which will open/close a certain part of the Admin Panel
+        *
+        * @param       string          The code for the display_ label/key
+        * @param       string          Input string
+        * @return      string          Linked input string
+        * @access private
+        * @see extGetHead()
+        */
+       protected function extItemLink($pre, $str) {
+               return '<a href="#" style="text-decoration:none;" onclick="' .
+                       htmlspecialchars('document.TSFE_ADMIN_PANEL_FORM[\'TSFE_ADMIN_PANEL[display_' . $pre . ']\'].value=' . ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['display_' . $pre] ? '0' : '1') . '; document.TSFE_ADMIN_PANEL_FORM.submit(); return false;') .
+                       '">' . $str . '</a>';
+       }
+
+       /**
+        * Returns a row (with 4 columns) for content in a section of the Admin Panel.
+        * It will take $pre as a key to a label to display and $element as the content to put into the forth cell.
+        *
+        * @param       string          Key to label
+        * @param       string          The HTML content for the forth table cell.
+        * @return      string          HTML table row.
+        * @access private
+        * @see extGetHead()
+        */
+       protected function extGetItem($pre, $element) {
+               $out = '
+                                       <tr class="typo3-adminPanel-itemRow">
+                                               <td><img src="clear.gif" width="50" height="1" alt="" /></td>
+                                               <td style="text-align:left; white-space:nowrap;">' . ($pre ? $this->extFw($this->extGetLL($pre)) : '&nbsp;') . '</td>
+                                               <td><img src="clear.gif" width="30" height="1" alt="" /></td>
+                                               <td style="text-align:left; white-space:nowrap;">' . $element . '</td>
+                                       </tr>';
+
+               return $out;
+       }
+
+       /**
+        * Wraps a string in a span-tag with black verdana font
+        *
+        * @param       string          The string to wrap
+        * @return      string
+        */
+       protected function extFw($str) {
+               return '<span style="font-family:Verdana,Arial,Helvetica,sans-serif; font-size:10px; color:black;">' . $str . '</span>';
+       }
+
+       /**
+        * Creates the tool bar links for the "edit" section of the Admin Panel.
+        *
+        * @return      string          A string containing images wrapped in <a>-tags linking them to proper functions.
+        */
+       public function ext_makeToolBar() {
+                       //  If mod.web_list.newContentWiz.overrideWithExtension is set, use that extension's create new content wizard instead:
+               $tmpTSc = t3lib_BEfunc::getModTSconfig($this->pageinfo['uid'],'mod.web_list');
+               $tmpTSc = $tmpTSc ['properties']['newContentWiz.']['overrideWithExtension'];
+               $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');
+
+               $perms = $GLOBALS['BE_USER']->calcPerms($GLOBALS['TSFE']->page);
+               $langAllowed = $GLOBALS['BE_USER']->checkLanguageAccess($GLOBALS['TSFE']->sys_language_uid);
+
+               $toolBar = '';
+               $id = $GLOBALS['TSFE']->id;
+               $toolBar .= '<a href="' . htmlspecialchars(TYPO3_mainDir . 'show_rechis.php?element=' . rawurlencode('pages:' . $id) . '&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))) . '#latest">' .
+                                       '<img src="' . TYPO3_mainDir . 'gfx/history2.gif" width="13" height="12" hspace="2" border="0" align="top" title="' . $this->extGetLL('edit_recordHistory') . '" alt="" /></a>';
+
+               if ($perms&16 && $langAllowed) {
+                       $params = '';
+                       if ($GLOBALS['TSFE']->sys_language_uid) {
+                               $params = '&sys_language_uid=' . $GLOBALS['TSFE']->sys_language_uid;
+                       }
+                       $toolBar .= '<a href="' . htmlspecialchars($newContentWizScriptPath . '?id=' . $id . $params . '&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))) . '">' .
+                                               '<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>';
+               }
+               if ($perms&2) {
+                       $toolBar .= '<a href="' . htmlspecialchars(TYPO3_mainDir . 'move_el.php?table=pages&uid=' . $id . '&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))) . '">' .
+                                       '<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>';
+               }
+               if ($perms&8) {
+                       $toolBar .= '<a href="' . htmlspecialchars(TYPO3_mainDir . 'db_new.php?id=' . $id . '&pagesOnly=1&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))) . '">' .
+                                       '<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>';
+               }
+               if ($perms&2) {
+                       $params = '&edit[pages][' . $id . ']=edit';
+                       $toolBar .= '<a href="' . htmlspecialchars(TYPO3_mainDir . 'alt_doc.php?' . $params . '&noView=1&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))) . '">' .
+                                       '<img src="' . TYPO3_mainDir . 'gfx/edit2.gif" width="11" height="12" hspace="2" border="0" align="top" title="' . $this->extGetLL('edit_editPageProperties') . '" alt="" /></a>';
+
+                       if ($GLOBALS['TSFE']->sys_language_uid && $langAllowed) {
+                               $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
+                                       'uid,pid,t3ver_state',  'pages_language_overlay',
+                                       'pid=' . intval($id) . ' AND sys_language_uid=' . $GLOBALS['TSFE']->sys_language_uid . $GLOBALS['TSFE']->sys_page->enableFields('pages_language_overlay'),
+                                       '', '', '1');
+                               $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
+                               $GLOBALS['TSFE']->sys_page->versionOL('pages_language_overlay',$row);
+                               if (is_array($row)) {
+                                       $params = '&edit[pages_language_overlay][' . $row['uid'] . ']=edit';
+                                       $toolBar .= '<a href="' . htmlspecialchars(TYPO3_mainDir . 'alt_doc.php?' . $params . '&noView=1&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))) . '">' .
+                                                       '<img src="' . TYPO3_mainDir . 'gfx/edit3.gif" width="11" height="12" hspace="2" border="0" align="top" title="' . $this->extGetLL('edit_editPageOverlay') . '" alt="" /></a>';
+                               }
+                       }
+               }
+               if ($GLOBALS['BE_USER']->check('modules', 'web_list')) {
+                       $toolBar .= '<a href="' . htmlspecialchars(TYPO3_mainDir . 'db_list.php?id=' . $id . '&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))) . '">' .
+                                       '<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>';
+               }
+
+               return $toolBar;
+       }
+
+       /**
+        * Returns the label for key, $key. If a translation for the language set in $GLOBALS['BE_USER']->uc['lang'] is found that is returned, otherwise the default value.
+        * 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
+        *
+        * @param       string          Key for a label in the $LOCAL_LANG array of "sysext/lang/locallang_tsfe.php"
+        * @return      string          The value for the $key
+        */
+       protected function extGetLL($key) {
+               global $LOCAL_LANG;
+               if (!is_array($LOCAL_LANG)) {
+                       $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_tsfe.php');
+                       if (!is_array($LOCAL_LANG)) {
+                               $LOCAL_LANG = array();
+                       }
+               }
+
+               $labelStr = htmlspecialchars($GLOBALS['LANG']->getLL($key));    // Label string in the default backend output charset.
+
+                       // Convert to utf-8, then to entities:
+               if ($GLOBALS['LANG']->charSet!='utf-8') {
+                       $labelStr = $GLOBALS['LANG']->csConvObj->utf8_encode($labelStr,$GLOBALS['LANG']->charSet);
+               }
+               $labelStr = $GLOBALS['LANG']->csConvObj->utf8_to_entities($labelStr);
+
+                       // Return the result:
+               return $labelStr;
+       }
+}
+
+if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/fe_edit/view/class.tx_feedit_adminpanel.php']) {
+       include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/fe_edit/view/class.tx_feedit_adminpanel.php']);
+}
+
+?>
diff --git a/typo3/sysext/fe_edit/view/class.tx_feedit_editpanel.php b/typo3/sysext/fe_edit/view/class.tx_feedit_editpanel.php
new file mode 100644 (file)
index 0000000..dc75391
--- /dev/null
@@ -0,0 +1,425 @@
+<?php
+/***************************************************************
+*  Copyright notice
+*
+*  (c) 2008 Jeff Segars <jeff@webempoweredchurch.org>
+*  (c) 2008 David Slayback <dave@webempoweredchurch.org>
+*  All rights reserved
+*
+*  This script is part of the TYPO3 project. The TYPO3 project is
+*  free software; you can redistribute it and/or modify
+*  it under the terms of the GNU General Public License as published by
+*  the Free Software Foundation; either version 2 of the License, or
+*  (at your option) any later version.
+*
+*  The GNU General Public License can be found at
+*  http://www.gnu.org/copyleft/gpl.html.
+*  A copy is found in the textfile GPL.txt and important notices to the license
+*  from the author is found in LICENSE.txt distributed with these scripts.
+*
+*
+*  This script is distributed in the hope that it will be useful,
+*  but WITHOUT ANY WARRANTY; without even the implied warranty of
+*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*  GNU General Public License for more details.
+*
+*  This copyright notice MUST APPEAR in all copies of the script!
+***************************************************************/
+
+/**
+ * View class for the edit panels in frontend editing.
+ *
+ * @author     Jeff Segars <jeff@webempoweredchurch.org>
+ * @author     David Slayback <dave@webempoweredchurch.org>
+ * @package TYPO3
+ * @subpackage fe_edit
+ */
+class tx_feedit_editpanel {
+
+       /**
+        * Local instance of tslib_cObj.
+        *
+        * @var tslib_cObj
+        */
+       protected $cObj;
+
+       /**
+        * Constructor for the edit panel. Creates a new cObject instance to be used in wrapping, etc.
+        *
+        * @return      void
+        */
+       public function __construct() {
+               require_once (PATH_tslib . '/class.tslib_content.php');
+               $this->cObj = t3lib_div::makeInstance('tslib_cObj');
+               $this->cObj->start(array());
+       }
+
+       /**
+        * Generates the "edit panels" which can be shown for a page or records on a page when the Admin Panel is enabled for a backend users surfing the frontend.
+        * With the "edit panel" the user will see buttons with links to editing, moving, hiding, deleting the element
+        * This function is used for the cObject EDITPANEL and the stdWrap property ".editPanel"
+        *
+        * @param       string          A content string containing the content related to the edit panel. For cObject "EDITPANEL" this is empty but not so for the stdWrap property. The edit panel is appended to this string and returned.
+        * @param       array           TypoScript configuration properties for the editPanel
+        * @param       string          The "table:uid" of the record being shown. If empty string then $this->currentRecord is used. For new records (set by $conf['newRecordFromTable']) it's auto-generated to "[tablename]:NEW"
+        * @param       array           Alternative data array to use. Default is $this->data
+        * @return      string          The input content string with the editPanel appended. This function returns only an edit panel appended to the content string if a backend user is logged in (and has the correct permissions). Otherwise the content string is directly returned.
+        * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=375&cHash=7d8915d508
+        */
+       public function editPanel($content, array $conf, $currentRecord='', array $dataArr=array(), $table='', $allow='', $newUID=0, array $hiddenFields=array()) {
+                       // Special content is about to be shown, so the cache must be disabled.
+               $GLOBALS['TSFE']->set_no_cache();
+               $formName = 'TSFE_EDIT_FORM_' . substr($GLOBALS['TSFE']->uniqueHash(), 0, 4);
+               $formTag = '<form name="' . $formName . '" id ="' . $formName . '" action="' . htmlspecialchars(t3lib_div::getIndpEnv('REQUEST_URI')) . '" method="post" enctype="' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'] . '" onsubmit="return TBE_EDITOR.checkSubmit(1);" style="margin: 0 0 0 0;">';
+               $sortField = $GLOBALS['TCA'][$table]['ctrl']['sortby'];
+               $labelField = $GLOBALS['TCA'][$table]['ctrl']['label'];
+               $hideField = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled'];
+               $blackLine = $conf['line'] ? '<img src="clear.gif" width="1" height="' . intval($conf['line']) . '" alt="" title="" /><br /><table border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="black" style="border: 0px;" summary=""><tr style="border: 0px;"><td style="border: 0px;"><img src="clear.gif" width="1" height="1" alt="" title="" /></td></tr></table><br />' : '';
+
+               $theCmd='';
+               $TSFE_EDIT = $GLOBALS['BE_USER']->frontendEdit->TSFE_EDIT;
+               if (is_array($TSFE_EDIT) && $TSFE_EDIT['record'] == $currentRecord && !$TSFE_EDIT['update_close']) {
+                       $theCmd =$TSFE_EDIT['cmd'];
+               }
+
+               switch($theCmd) {
+                       case 'edit':
+                       case 'new':
+                               $finalOut = $this->editContent($formTag, $formName, $theCmd, $newUID, $dataArr, $table, $currentRecord, $blackLine);
+                       break;
+                       default:
+                               $panel = '';
+                               if (isset($allow['toolbar'])) {
+                                       $adminClass = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/classes/class.frontendedit.php']['admin'];
+                                       $admin = &t3lib_div::getUserObj($adminClass);
+                                       $panel .= $admin->ext_makeToolBar() . '<img src="clear.gif" width="2" height="1" alt="" title="" />';
+                               }
+                               if (isset($allow['edit'])) {
+                                       $panel .= $this->editPanelLinkWrap('<img src="' . TYPO3_mainDir . 'gfx/edit2.gif" width="11" height="12" hspace="2" border="0" title="' . $GLOBALS['BE_USER']->extGetLL('p_editRecord').'" align="top" alt="" />', $formName, 'edit', $dataArr['_LOCALIZED_UID'] ? $table . ':' . $dataArr['_LOCALIZED_UID'] : $currentRecord);
+                               }
+                                       // Hiding in workspaces because implementation is incomplete
+                               if (isset($allow['move']) && $sortField && $GLOBALS['BE_USER']->workspace === 0) {
+                                       $panel .= $this->editPanelLinkWrap('<img src="' . TYPO3_mainDir . 'gfx/button_up.gif" width="11" height="10" vspace="1" hspace="2" border="0" title="' . $GLOBALS['BE_USER']->extGetLL('p_moveUp') . '" align="top" alt="" />', $formName, 'up');
+                                       $panel .= $this->editPanelLinkWrap('<img src="' . TYPO3_mainDir . 'gfx/button_down.gif" width="11" height="10" vspace="1" hspace="2" border="0" title="' . $GLOBALS['BE_USER']->extGetLL('p_moveDown') . '" align="top" alt="" />', $formName, 'down');
+                               }
+                                       // Hiding in workspaces because implementation is incomplete, Hiding for localizations because it is unknown what should be the function in that case
+                               if (isset($allow['hide']) && $hideField && $GLOBALS['BE_USER']->workspace === 0 && !$dataArr['_LOCALIZED_UID']) {
+                                       if ($dataArr[$hideField]) {
+                                               $panel .= $this->editPanelLinkWrap('<img src="' . TYPO3_mainDir . 'gfx/button_unhide.gif" width="11" height="10" vspace="1" hspace="2" border="0" title="' . $GLOBALS['BE_USER']->extGetLL('p_unhide') . '" align="top" alt="" />', $formName, 'unhide');
+                                       } else {
+                                               $panel .= $this->editPanelLinkWrap('<img src="' . TYPO3_mainDir . 'gfx/button_hide.gif" width="11" height="10" vspace="1" hspace="2" border="0" title="' . $GLOBALS['BE_USER']->extGetLL('p_hide') . '" align="top" alt="" />', $formName, 'hide', '', $GLOBALS['BE_USER']->extGetLL('p_hideConfirm'));
+                                       }
+                               }
+                               if (isset($allow['new'])) {
+                                       if ($table == 'pages') {
+                                               $panel .= $this->editPanelLinkWrap('<img src="' . TYPO3_mainDir . 'gfx/new_page.gif" width="13" height="12" vspace="1" hspace="2" border="0" title="' . $GLOBALS['BE_USER']->extGetLL('p_newSubpage') . '" align="top" alt="" />', $formName, 'new', $currentRecord, '', $nPid);
+                                       } else {
+                                               $panel .= $this->editPanelLinkWrap('<img src="' . TYPO3_mainDir . 'gfx/new_record.gif" width="16" height="12" vspace="1" hspace="2" border="0" title="' . $GLOBALS['BE_USER']->extGetLL('p_newRecordAfter') . '" align="top" alt="" />', $formName, 'new', $currentRecord, '', $nPid);
+                                       }
+                               }
+                                       // Hiding in workspaces because implementation is incomplete, Hiding for localizations because it is unknown what should be the function in that case
+                               if (isset($allow['delete']) && $GLOBALS['BE_USER']->workspace === 0 && !$dataArr['_LOCALIZED_UID']) {
+                                       $panel .= $this->editPanelLinkWrap('<img src="' . TYPO3_mainDir . 'gfx/delete_record.gif" width="12" height="12" vspace="1" hspace="2" border="0" title="' . $GLOBALS['BE_USER']->extGetLL('p_delete').'" align="top" alt="" />', $formName, 'delete', '', $GLOBALS['BE_USER']->extGetLL('p_deleteConfirm'));
+                               }
+                                       //      Final
+                               $labelTxt = $this->cObj->stdWrap($conf['label'],$conf['label.']);
+
+                               foreach((array) $hiddenFields as $name => $value) {
+                                       $hiddenFieldString .= '<input type="hidden" name="TSFE_EDIT[' . $name . ']" value="' . $value . '"/>' . chr(10);
+                               }
+
+                               $panel='
+
+                                                       <!-- BE_USER Edit Panel: -->
+                                                       ' . $formTag .
+                                                       $hiddenFieldString . '
+                                                               <input type="hidden" name="TSFE_EDIT[cmd]" value="" />
+                                                               <input type="hidden" name="TSFE_EDIT[record]" value="' . $currentRecord . '" />
+                                                               <table border="0" cellpadding="0" cellspacing="0" class="typo3-editPanel" summary="">
+                                                                       <tr>
+                                                                               <td nowrap="nowrap" bgcolor="#ABBBB4" class="typo3-editPanel-controls">' . $panel . '</td>' .
+                                                                               ($labelTxt ? '<td nowrap="nowrap" bgcolor="#F6F2E6" class="typo3-editPanel-label"><font face="verdana" size="1" color="black">&nbsp;' . sprintf($labelTxt, htmlspecialchars(t3lib_div::fixed_lgd($dataArr[$labelField], 50))) . '&nbsp;</font></td>' : '') . '
+                                                                       </tr>
+                                                               </table>
+                                                       </form>';
+                                       // wrap the panel
+                               if ($conf['innerWrap']) {
+                                       $panel = $this->cObj->wrap($panel, $conf['innerWrap']);
+                               }
+                               if ($conf['innerWrap.']) {
+                                       $panel = $this->cObj->stdWrap($panel, $conf['innerWrap.']);
+                               }
+
+                                       // add black line:
+                               $panel .= $blackLine;
+
+                                       // wrap the complete panel
+                               if ($conf['outerWrap']) {
+                                       $panel = $this->cObj->wrap($panel, $conf['outerWrap']);
+                               }
+                               if ($conf['outerWrap.']) {
+                                       $panel = $this->cObj->stdWrap($panel, $conf['outerWrap.']);
+                               }
+                               if ($conf['printBeforeContent']) {
+                                       $finalOut = $panel . $content;
+                               } else {
+                                       $finalOut = $content . $panel;
+                               }
+                       break;
+               }
+
+               if ($conf['previewBorder']) {
+                       if (!is_array($conf['previewBorder.'])) {
+                               $conf['previewBorder.'] = array();
+                       }
+                       $finalOut = $this->editPanelPreviewBorder($table, $dataArr, $finalOut, $conf['previewBorder'], $conf['previewBorder.']);
+               }
+
+               return $finalOut;
+       }
+
+       /**
+        * Adds an edit icon to the content string. The edit icon links to alt_doc.php with proper parameters for editing the table/fields of the context.
+        * This implements TYPO3 context sensitive editing facilities. Only backend users will have access (if properly configured as well).
+        *
+        * @param       string          The content to which the edit icons should be appended
+        * @param       string          The parameters defining which table and fields to edit. Syntax is [tablename]:[fieldname],[fieldname],[fieldname],... OR [fieldname],[fieldname],[fieldname],... (basically "[tablename]:" is optional, default table is the one of the "current record" used in the function). The fieldlist is sent as "&columnsOnly=" parameter to alt_doc.php
+        * @param       array           TypoScript properties for configuring the edit icons.
+        * @param       string          The "table:uid" of the record being shown. If empty string then $this->currentRecord is used. For new records (set by $conf['newRecordFromTable']) it's auto-generated to "[tablename]:NEW"
+        * @param       array           Alternative data array to use. Default is $this->data
+        * @param       string          Additional URL parameters for the link pointing to alt_doc.php
+        * @return      string          The input content string, possibly with edit icons added (not necessarily in the end but just after the last string of normal content.
+        */
+       public function editIcons($content, $params, array $conf=array(), $currentRecord='', array $dataArr=array(), $addUrlParamStr='', $table, $editUid, $fieldList) {
+                       // Special content is about to be shown, so the cache must be disabled.
+               $GLOBALS['TSFE']->set_no_cache();
+               $style = $conf['styleAttribute'] ? ' style="' . htmlspecialchars($conf['styleAttribute']) . '"' : '';
+               $iconTitle = $this->cObj->stdWrap($conf['iconTitle'], $conf['iconTitle.']);
+               $iconImg = $conf['iconImg'] ? $conf['iconImg'] : '<img src="' . TYPO3_mainDir . 'gfx/edit_fe.gif" width="11" height="12" border="0" align="top" title="' . t3lib_div::deHSCentities(htmlspecialchars($iconTitle)) . '"' . $style . ' class="frontEndEditIcons" alt="" />';
+               $nV=t3lib_div::_GP('ADMCMD_view') ? 1 : 0;
+               $adminURL = t3lib_div::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir;
+               $icon = $this->editPanelLinkWrap_doWrap($iconImg, $adminURL . 'alt_doc.php?edit[' . $table . '][' . $editUid . ']=edit&columnsOnly=' . rawurlencode($fieldList) . '&noView=' . $nV . $addUrlParamStr, $currentRecord);
+
+               if ($conf['beforeLastTag'] < 0) {
+                       $content = $icon . $content;
+               } elseif ($conf['beforeLastTag'] > 0) {
+                       $cBuf = rtrim($content);
+                       $securCount = 30;
+                       while($securCount && substr($cBuf, -1) == '>' && substr($cBuf, -4) != '</a>') {
+                               $cBuf = rtrim(ereg_replace('<[^<]*>$', '', $cBuf));
+                               $securCount--;
+                       }
+                       $content = (strlen($cBuf) && $securCount) ? substr($content, 0, strlen($cBuf)) . $icon . substr($content, strlen($cBuf)) : $content = $icon . $content;
+               } else {
+                       $content .= $icon;
+               }
+
+               return $content;
+       }
+
+       /**
+        * Helper function for editPanel() which wraps icons in the panel in a link with the action of the panel.
+        * The links are for some of them not simple hyperlinks but onclick-actions which submits a little form which the panel is wrapped in.
+        *
+        * @param       string          The string to wrap in a link, typ. and image used as button in the edit panel.
+        * @param       string          The name of the form wrapping the edit panel.
+        * @param       string          The command of the link. There is a predefined list available: edit, new, up, down etc.
+        * @param       string          The "table:uid" of the record being processed by the panel.
+        * @param       string          Text string with confirmation message; If set a confirm box will be displayed before carrying out the action (if Yes is pressed)
+        * @param       integer         "New pid" - for new records
+        * @return      string          A <a> tag wrapped string.
+        * @see editPanel(), editIcons(), t3lib_tsfeBeUserAuth::extEditAction()
+        */
+       protected function editPanelLinkWrap($string, $formName, $cmd, $currentRecord='', $confirm='', $nPid='')        {
+                       // Editing forms on page only supported in Live workspace (because of incomplete implementation)
+               $editFormsOnPage = $GLOBALS['BE_USER']->uc['TSFE_adminConfig']['edit_editFormsOnPage'] && $GLOBALS['BE_USER']->workspace === 0;
+               $nV=t3lib_div::_GP('ADMCMD_view') ? 1 : 0;
+               $adminURL = t3lib_div::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir;
+
+               if ($cmd == 'edit' && !$editFormsOnPage) {
+                       $rParts = explode(':', $currentRecord);
+                       $out = $this->editPanelLinkWrap_doWrap($string, $adminURL . 'alt_doc.php?edit[' . $rParts[0] . '][' . $rParts[1] . ']=edit&noView=' . $nV, $currentRecord);
+               } elseif ($cmd == 'new' && !$editFormsOnPage) {
+                       $rParts = explode(':', $currentRecord);
+                       if ($rParts[0] == 'pages') {
+                               $out = $this->editPanelLinkWrap_doWrap($string, $adminURL . 'db_new.php?id=' . $rParts[1] . '&pagesOnly=1', $currentRecord);
+                       } else {
+                               if (!intval($nPid)) {
+                                       $nPid = t3lib_div::testInt($rParts[1]) ? -$rParts[1] : $GLOBALS['TSFE']->id;
+                               }
+                               $out = $this->editPanelLinkWrap_doWrap($string, $adminURL . 'alt_doc.php?edit[' . $rParts[0] . '][' . $nPid . ']=new&noView=' . $nV, $currentRecord);
+                       }
+               } else {
+                       if ($confirm && $GLOBALS['BE_USER']->jsConfirmation(8)) {
+                                       // Gets htmlspecialchared later
+                               $cf1 = 'if (confirm(' . t3lib_div::quoteJSvalue($confirm, true) . ')) {';
+                               $cf2 = '}';
+                       } else {
+                               $cf1 = $cf2 = '';
+                       }
+                       $out = '<a href="#" onclick="' .
+                               htmlspecialchars($cf1 . 'document.' . $formName . '[\'TSFE_EDIT[cmd]\'].value=\'' . $cmd . '\'; document.' . $formName . '.submit();' . $cf2 . ' return false;') .
+                               '">' . $string . '</a>';
+               }
+
+               return $out;
+       }
+
+       /**
+        * Creates a link to a script (eg. typo3/alt_doc.php or typo3/db_new.php) which either opens in the current frame OR in a pop-up window.
+        *
+        * @param       string          The string to wrap in a link, typ. and image used as button in the edit panel.
+        * @param       string          The URL of the link. Should be absolute if supposed to work with <base> path set.
+        * @param       string          The "table:uid" of the record being processed by the panel.
+        * @return      string          A <a> tag wrapped string.
+        * @see editPanelLinkWrap()
+        */
+       protected function editPanelLinkWrap_doWrap($string, $url, $currentRecord)      {
+               if ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['edit_editNoPopup'] || $GLOBALS['BE_USER']->extAdminConfig['module.']['edit.']['forceNoPopup']) {
+                       $retUrl = t3lib_div::getIndpEnv('REQUEST_URI');
+                       $rParts = explode(':', $currentRecord);
+                               // This parentRecordNumber is used to make sure that only elements 3- of ordinary content elements makes a 'anchor' jump down the page.
+                       if ($rParts[0] == 'tt_content' && $this->parentRecordNumber > 2) {
+                               $retUrl .= '#' . $rParts[1];
+                       }
+                       return '<a href="' . htmlspecialchars($url . '&returnUrl=' . rawurlencode($retUrl)) . '" class="frontEndEditIconLinks">' . $string . '</a>';
+               } else {
+                       return '<a href="#" onclick="' .
+                               htmlspecialchars('vHWin=window.open(\'' . $url . '&returnUrl=close.html\',\'FEquickEditWindow\',\'' . ($GLOBALS['BE_USER']->uc['edit_wideDocument'] ? 'width=690,height=500' : 'width=540,height=400') . ',status=0,menubar=0,scrollbars=1,resizable=1\');vHWin.focus();return false;') .
+                               '" class="frontEndEditIconLinks">' . $string . '</a>';
+               }
+       }
+
+       /**
+        * Wraps the input content string in a table with a gray border if the table/row combination evaluates to being disabled/hidden.
+        * Used for marking previewed records in the frontend.
+        *
+        * @param       string          The table name
+        * @param       array           The data record from $table
+        * @param       string          The content string to wrap
+        * @param       integer         The thickness of the border
+        * @param       array           The array with TypoScript properties for the content object
+        * @return      string          The input string wrapped in a table with a border color of #cccccc and thickness = $thick
+        * @see editPanel()
+        */
+       protected function editPanelPreviewBorder($table, array $row, $content, $thick, array $conf = array()) {
+               if ($this->isDisabled($table, $row)) {
+                       $thick = t3lib_div::intInRange($thick, 1, 100);
+                       $color = $conf['color'] ? $conf['color'] : '#cccccc';
+                       if ($conf['innerWrap']) {
+                               $content = $this->wrap($content,$conf['innerWrap']);
+                       }
+                       if ($conf['innerWrap.']) {
+                               $content = $this->stdWrap($content,$conf['innerWrap.']);
+                       }
+                       $content = '<table class="typo3-editPanel-previewBorder" border="' . $thick . '" cellpadding="0" cellspacing="0" bordercolor="' . $color . '" width="100%" summary=""><tr><td>' . $content . '</td></tr></table>';
+                       if ($conf['outerWrap']) {
+                               $content = $this->wrap($content,$conf['outerWrap']);
+                       }
+                       if ($conf['outerWrap.']) {
+                               $content = $this->stdWrap($panel,$conf['outerWrap.']);
+                       }
+               }
+
+               return $content;
+       }
+
+       /**
+        * Returns true if the input table/row would be hidden in the frontend (according nto the current time and simulate user group)
+        *
+        * @param       string          The table name
+        * @param       array           The data record
+        * @return      boolean
+        * @see editPanelPreviewBorder()
+        */
+       protected function isDisabled($table, $row) {
+               if (($GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled'] && $row[$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled']]) ||
+                       ($GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['fe_group'] && $GLOBALS['TSFE']->simUserGroup && $row[$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['fe_group']] == $GLOBALS['TSFE']->simUserGroup) ||
+                       ($GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['starttime'] && $row[$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['starttime']] > time() ) ||
+                       ($GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['endtime'] && $row[$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['endtime']] && $row[$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['endtime']] < time())) {
+                       return true;
+               }
+       }
+
+       /**
+        * Returns the editing form for a content element.
+        *
+        * @param       string          Form tag
+        * @param       string          Form name
+        * @param       string          the command
+        * @param       integer         newUID
+        * @param       array           dataArray for element
+        * @param       string          Table name of element
+        * @param       string          Current record
+        * @param       string          Blackline
+        * @return      string
+        */
+       protected function editContent($formTag, $formName, $theCmd, $newUID, array $dataArray, $table, $currentRecord, $blackLine) {
+               $tceforms = t3lib_div::makeInstance('t3lib_TCEforms_FE');
+               $tceforms->prependFormFieldNames = 'TSFE_EDIT[data]';
+               $tceforms->prependFormFieldNames_file = 'TSFE_EDIT_file';
+               $tceforms->doSaveFieldName = 'TSFE_EDIT[doSave]';
+               $tceforms->formName = $formName;
+               $tceforms->backPath = TYPO3_mainDir;
+               $tceforms->setFancyDesign();
+               $tceforms->defStyle = 'font-family:Verdana;font-size:10px;';
+               $tceforms->edit_showFieldHelp = $GLOBALS['BE_USER']->uc['edit_showFieldHelp'];
+
+                       // Icon only mode for CSH destroys the layout for frontend editing so force full text mode instead.
+                       // @todo        Make sure the necessary Javascript and CSS are included so that CSH can work properly in all modes.
+               if($tceforms->edit_showFieldHelp == 'icon') {
+                       $tceforms->edit_showFieldHelp = 'text';
+               }
+
+               $tceforms->helpTextFontTag = '<font face="verdana,sans-serif" color="#333333" size="1">';
+
+               $trData = t3lib_div::makeInstance('t3lib_transferData');
+               $trData->addRawData = true;
+               $trData->lockRecords = 1;
+                       // Added without testing - should provide ability to submit default values in frontend editing, in-page.
+               $trData->defVals = t3lib_div::_GP('defVals');
+               $trData->fetchRecord($table, ($theCmd == 'new' ? $newUID : $dataArray['uid']), ($theCmd == 'new' ? 'new' : '') );
+               reset($trData->regTableItems_data);
+               $processedDataArr = current($trData->regTableItems_data);
+               $processedDataArr['uid'] = $theCmd == 'new' ? 'NEW' : $dataArray['uid'];
+               $processedDataArr['pid'] = $theCmd == 'new' ? $newUID : $dataArray['pid'];
+
+               $panel = '';
+               $buttons = '<input type="image" border="0" name="TSFE_EDIT[update]" src="' . $tceforms->backPath . 'gfx/savedok.gif" hspace="2" width="21" height="16" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.saveDoc', 1) . '" />';
+               $buttons .= '<input type="image" border="0" name="TSFE_EDIT[update_close]" src="' . $tceforms->backPath . 'gfx/saveandclosedok.gif" hspace="2" width="21" height="16" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.saveCloseDoc', 1) . '" />';
+               $buttons .= '<input type="image" border="0" name="TSFE_EDIT[cancel]" onclick="' .
+                       htmlspecialchars('window.location.href=\'' . t3lib_div::getIndpEnv('REQUEST_URI') . '\';return false;') .
+                       '" src="' . $tceforms->backPath . 'gfx/closedok.gif" hspace="2" width="21" height="16" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.closeDoc', 1) . '" />';
+                       // Buttons top
+               $panel .= $tceforms->intoTemplate(array('ITEM' => $buttons));
+               $panel .= $tceforms->getMainFields($table, $processedDataArr);
+
+               $hiddenF = "";
+               if ($theCmd == 'new') {
+                       $hiddenF .= '<input type="hidden" name="TSFE_EDIT[data][' . $table . '][NEW][pid]" value="' . $newUID . '" />';
+                       if ($table == 'pages') {
+                                       // If a new page is created in front-end, then show it by default!
+                               $hiddenF .= '<input type="hidden" name="TSFE_EDIT[data][' . $table . '][NEW][hidden]" value="0" />';
+                       } else {
+                               $hiddenF .= '<input type="hidden" name="TSFE_EDIT[record]" value="' . $currentRecord . '" />';
+                               $hiddenF .= '<input type="hidden" name="TSFE_EDIT[cmd]" value="edit" />';
+                       }
+               }
+               $hiddenF .= '<input type="hidden" name="TSFE_EDIT[doSave]" value="0" />';
+                       // Buttons AND hidden fields bottom.
+               $panel .= $tceforms->intoTemplate(array('ITEM' => $buttons . $hiddenF));
+
+               $panel = $formTag . $tceforms->wrapTotal($panel, $dataArray, $table) . '</form>' . ($theCmd != 'new' ? $blackLine : '');
+
+               $finalOut = $tceforms->printNeededJSFunctions_top() . ($conf['edit.']['displayRecord'] ? $content : '') . $panel . ($theCmd=='new' ? $blackLine : '') . $tceforms->printNeededJSFunctions();
+
+               return $finalOut;
+       }
+
+}
+
+if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/fe_edit/view/class.tx_feedit_editpanel.php']) {
+       include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/fe_edit/view/class.tx_feedit_editpanel.php']);
+}
+
+?>
\ No newline at end of file