TYPO3 API  SVNRelease
class.t3lib_frontendedit.php
Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003  *  Copyright notice
00004  *
00005  *  (c) 2008-2011 Jeff Segars <jeff@webempoweredchurch.org>
00006  *  (c) 2008-2011 David Slayback <dave@webempoweredchurch.org>
00007  *  All rights reserved
00008  *
00009  *  This script is part of the TYPO3 project. The TYPO3 project is
00010  *  free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version.
00014  *
00015  *  The GNU General Public License can be found at
00016  *  http://www.gnu.org/copyleft/gpl.html.
00017  *  A copy is found in the textfile GPL.txt and important notices to the license
00018  *  from the author is found in LICENSE.txt distributed with these scripts.
00019  *
00020  *
00021  *  This script is distributed in the hope that it will be useful,
00022  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00023  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00024  *  GNU General Public License for more details.
00025  *
00026  *  This copyright notice MUST APPEAR in all copies of the script!
00027  ***************************************************************/
00028 /**
00029  * Controller class for frontend editing.
00030  *
00031  * $Id: class.t3lib_frontendedit.php 10317 2011-01-26 00:56:49Z baschny $
00032  *
00033  * @author  Jeff Segars <jeff@webempoweredchurch.org>
00034  * @author  David Slayback <dave@webempoweredchurch.org>
00035  * @package TYPO3
00036  * @subpackage t3lib
00037  */
00038 class t3lib_frontendedit {
00039     /**
00040      * GET/POST parameters for the FE editing.
00041      * Accessed as $GLOBALS['BE_USER']->frontendEdit->TSFE_EDIT, thus public
00042      *
00043      * @var array
00044      */
00045     public $TSFE_EDIT;
00046 
00047     /**
00048      * TCEmain object.
00049      *
00050      * @var t3lib_tcemain
00051      */
00052     protected $tce;
00053 
00054     /**
00055      * Initializes configuration options.
00056      *
00057      * @return  void
00058      */
00059     public function initConfigOptions() {
00060         $this->TSFE_EDIT = t3lib_div::_GP('TSFE_EDIT');
00061 
00062             // Include classes for editing IF editing module in Admin Panel is open
00063         if ($GLOBALS['BE_USER']->isFrontendEditingActive()) {
00064             $GLOBALS['TSFE']->includeTCA();
00065             if ($this->isEditAction()) {
00066                 $this->editAction();
00067             }
00068         }
00069     }
00070 
00071     /**
00072      * 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.
00073      * With the "edit panel" the user will see buttons with links to editing, moving, hiding, deleting the element
00074      * This function is used for the cObject EDITPANEL and the stdWrap property ".editPanel"
00075      *
00076      * @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.
00077      * @param   array       TypoScript configuration properties for the editPanel
00078      * @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"
00079      * @param   array       Alternative data array to use. Default is $this->data
00080      * @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.
00081      */
00082     public function displayEditPanel($content, array $conf, $currentRecord, array $dataArray) {
00083         if ($conf['newRecordFromTable']) {
00084             $currentRecord = $conf['newRecordFromTable'] . ':NEW';
00085             $conf['allow'] = 'new';
00086             $checkEditAccessInternals = FALSE;
00087         } else {
00088             $checkEditAccessInternals = TRUE;
00089         }
00090 
00091         list($table, $uid) = explode(':', $currentRecord);
00092 
00093             // Page ID for new records, 0 if not specified
00094         $newRecordPid = intval($conf['newRecordInPid']);
00095         if (!$conf['onlyCurrentPid'] || $dataArray['pid'] == $GLOBALS['TSFE']->id) {
00096             if ($table == 'pages') {
00097                 $newUid = $uid;
00098             } else {
00099                 if ($conf['newRecordFromTable']) {
00100                     $newUid = $GLOBALS['TSFE']->id;
00101                     if ($newRecordPid) {
00102                         $newUid = $newRecordPid;
00103                     }
00104                 } else {
00105                     $newUid = -1 * $uid;
00106                 }
00107             }
00108         }
00109 
00110         if ($GLOBALS['TSFE']->displayEditIcons && $table && $this->allowedToEdit($table, $dataArray, $conf, $checkEditAccessInternals) && $this->allowedToEditLanguage($table, $dataArray)) {
00111             $editClass = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/classes/class.frontendedit.php']['edit'];
00112             if ($editClass) {
00113                 $edit = t3lib_div::getUserObj($editClass, FALSE);
00114                 if (is_object($edit)) {
00115                     $allowedActions = $this->getAllowedEditActions($table, $conf, $dataArray['pid']);
00116                     $content = $edit->editPanel($content, $conf, $currentRecord, $dataArray, $table, $allowedActions, $newUid, $this->getHiddenFields($dataArray));
00117                 }
00118             }
00119         }
00120 
00121         return $content;
00122     }
00123 
00124     /**
00125      * 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.
00126      * This implements TYPO3 context sensitive editing facilities. Only backend users will have access (if properly configured as well).
00127      *
00128      * @param   string      The content to which the edit icons should be appended
00129      * @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
00130      * @param   array       TypoScript properties for configuring the edit icons.
00131      * @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"
00132      * @param   array       Alternative data array to use. Default is $this->data
00133      * @param   string      Additional URL parameters for the link pointing to alt_doc.php
00134      * @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.
00135      */
00136 
00137     public function displayEditIcons($content, $params, array $conf = array(), $currentRecord = '', array $dataArray = array(), $addUrlParamStr = '') {
00138             // Check incoming params:
00139         list($currentRecordTable, $currentRecordUID) = explode(':', $currentRecord);
00140         list($fieldList, $table) = array_reverse(t3lib_div::trimExplode(':', $params, 1)); // Reverse the array because table is optional
00141         if (!$table) {
00142             $table = $currentRecordTable;
00143         } elseif ($table != $currentRecordTable) {
00144             return $content; // If the table is set as the first parameter, and does not match the table of the current record, then just return.
00145         }
00146 
00147         $editUid = $dataArray['_LOCALIZED_UID'] ? $dataArray['_LOCALIZED_UID'] : $currentRecordUID;
00148 
00149             // Edit icons imply that the editing action is generally allowed, assuming page and content element permissions permit it.
00150         if (!array_key_exists('allow', $conf)) {
00151             $conf['allow'] = 'edit';
00152         }
00153 
00154         if ($GLOBALS['TSFE']->displayFieldEditIcons && $table && $this->allowedToEdit($table, $dataArray, $conf) && $fieldList && $this->allowedToEditLanguage($table, $dataArray)) {
00155             $editClass = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/classes/class.frontendedit.php']['edit'];
00156             if ($editClass) {
00157                 $edit = t3lib_div::getUserObj($editClass);
00158                 if (is_object($edit)) {
00159                     $content = $edit->editIcons($content, $params, $conf, $currentRecord, $dataArray, $addUrlParamStr, $table, $editUid, $fieldList);
00160                 }
00161             }
00162         }
00163 
00164         return $content;
00165     }
00166 
00167     /*****************************************************
00168      *
00169      * Frontend Editing
00170      *
00171      ****************************************************/
00172 
00173     /**
00174      * Returns true if an edit-action is sent from the Admin Panel
00175      *
00176      * @return  boolean
00177      * @see index_ts.php
00178      */
00179     public function isEditAction() {
00180         if (is_array($this->TSFE_EDIT)) {
00181             if ($this->TSFE_EDIT['cancel']) {
00182                 unset($this->TSFE_EDIT['cmd']);
00183             } else {
00184                 $cmd = (string) $this->TSFE_EDIT['cmd'];
00185                 if (($cmd != 'edit' || (is_array($this->TSFE_EDIT['data']) && ($this->TSFE_EDIT['doSave'] || $this->TSFE_EDIT['update'] || $this->TSFE_EDIT['update_close']))) && $cmd != 'new') {
00186                         // $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 sent because of .keepGoing flag.
00187                     return TRUE;
00188                 }
00189             }
00190         }
00191         return FALSE;
00192     }
00193 
00194     /**
00195      * Returns true if an edit form is shown on the page.
00196      * Used from index_ts.php where a true return-value will result in classes etc. being included.
00197      *
00198      * @return  boolean
00199      * @see index_ts.php
00200      */
00201     public function isEditFormShown() {
00202         if (is_array($this->TSFE_EDIT)) {
00203             $cmd = (string) $this->TSFE_EDIT['cmd'];
00204             if ($cmd == 'edit' || $cmd == 'new') {
00205                 return TRUE;
00206             }
00207         }
00208     }
00209 
00210     /**
00211      * Management of the on-page frontend editing forms and edit panels.
00212      * Basically taking in the data and commands and passes them on to the proper classes as they should be.
00213      *
00214      * @return  void
00215      * @throws UnexpectedValueException if TSFE_EDIT[cmd] is not a valid command
00216      * @see index_ts.php
00217      */
00218     public function editAction() {
00219             // Commands:
00220         list($table, $uid) = explode(':', $this->TSFE_EDIT['record']);
00221         $uid = intval($uid);
00222         $cmd = $this->TSFE_EDIT['cmd'];
00223 
00224             // Look for some TSFE_EDIT data that indicates we should save.
00225         if (($this->TSFE_EDIT['doSave'] || $this->TSFE_EDIT['update'] || $this->TSFE_EDIT['update_close']) && is_array($this->TSFE_EDIT['data'])) {
00226             $cmd = 'save';
00227         }
00228 
00229         if (($cmd == 'save') || ($cmd && $table && $uid && isset($GLOBALS['TCA'][$table]))) {
00230                 // Hook for defining custom editing actions. Naming is incorrect, but preserves compatibility.
00231             if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['extEditAction'])) {
00232                 $_params = array();
00233                 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['extEditAction'] as $_funcRef) {
00234                     t3lib_div::callUserFunction($_funcRef, $_params, $this);
00235                 }
00236             }
00237 
00238                 // Perform the requested editing command.
00239             $cmdAction = 'do' . ucwords($cmd);
00240             if (is_callable(array($this, $cmdAction))) {
00241                 $this->$cmdAction($table, $uid);
00242             } else {
00243                 throw new UnexpectedValueException(
00244                     'The specified frontend edit command (' . $cmd . ') is not valid.',
00245                     1225818120
00246                 );
00247             }
00248         }
00249     }
00250 
00251     /**
00252      * Hides a specific record.
00253      *
00254      * @param   string      The table name for the record to hide.
00255      * @param   integer     The UID for the record to hide.
00256      * @return  void
00257      */
00258     public function doHide($table, $uid) {
00259         $hideField = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled'];
00260         if ($hideField) {
00261             $recData = array();
00262             $recData[$table][$uid][$hideField] = 1;
00263 
00264             $this->initializeTceMain();
00265             $this->tce->start($recData, array());
00266             $this->tce->process_datamap();
00267         }
00268     }
00269 
00270     /**
00271      * Unhides (shows) a specific record.
00272      *
00273      * @param   string      The table name for the record to unhide.
00274      * @param   integer     The UID for the record to unhide.
00275      * @return  void
00276      */
00277     public function doUnhide($table, $uid) {
00278         $hideField = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled'];
00279         if ($hideField) {
00280             $recData = array();
00281             $recData[$table][$uid][$hideField] = 0;
00282 
00283             $this->initializeTceMain();
00284             $this->tce->start($recData, array());
00285             $this->tce->process_datamap();
00286         }
00287     }
00288 
00289     /**
00290      * Moves a record up.
00291      *
00292      * @param   string      The table name for the record to move.
00293      * @param   integer     The UID for the record to hide.
00294      * @return  void
00295      */
00296     public function doUp($table, $uid) {
00297         $this->move($table, $uid, 'up');
00298     }
00299 
00300     /**
00301      * Moves a record down.
00302      *
00303      * @param   string      The table name for the record to move.
00304      * @param   integer     The UID for the record to move.
00305      * @return  void
00306      */
00307     public function doDown($table, $uid) {
00308         $this->move($table, $uid, 'down');
00309     }
00310 
00311     /**
00312      * Moves a record after a given element. Used for drag.
00313      *
00314      * @param   string      The table name for the record to move.
00315      * @param   integer     The UID for the record to move.
00316      * @return  void
00317      */
00318     public function doMoveAfter($table, $uid) {
00319         $afterUID = $GLOBALS['BE_USER']->frontendEdit->TSFE_EDIT['moveAfter'];
00320         $this->move($table, $uid, '', $afterUID);
00321     }
00322 
00323     /**
00324      * Moves a record
00325      *
00326      * @param   string      The table name for the record to move.
00327      * @param   integer     The UID for the record to move.
00328      * @param   string      The direction to move, either 'up' or 'down'.
00329      * @param   integer     The UID of record to move after. This is specified for dragging only.
00330      * @return  void
00331      */
00332     protected function move($table, $uid, $direction = '', $afterUID = 0) {
00333         $cmdData = array();
00334         $sortField = $GLOBALS['TCA'][$table]['ctrl']['sortby'];
00335         if ($sortField) {
00336                 // Get self:
00337             $fields = array_unique(t3lib_div::trimExplode(',', $GLOBALS['TCA'][$table]['ctrl']['copyAfterDuplFields'] . ',uid,pid,' . $sortField, TRUE));
00338             $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(implode(',', $fields), $table, 'uid=' . $uid);
00339             if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00340                     // record before or after
00341                 if (($GLOBALS['BE_USER']->adminPanel instanceOf tslib_AdminPanel) && ($GLOBALS['BE_USER']->adminPanel->extGetFeAdminValue('preview'))) {
00342                     $ignore = array('starttime' => 1, 'endtime' => 1, 'disabled' => 1, 'fe_group' => 1);
00343                 }
00344                 $copyAfterFieldsQuery = '';
00345                 if ($GLOBALS['TCA'][$table]['ctrl']['copyAfterDuplFields']) {
00346                     $cAFields = t3lib_div::trimExplode(',', $GLOBALS['TCA'][$table]['ctrl']['copyAfterDuplFields'], TRUE);
00347                     foreach ($cAFields as $fieldName) {
00348                         $copyAfterFieldsQuery .= ' AND ' . $fieldName . '="' . $row[$fieldName] . '"';
00349                     }
00350                 }
00351                 if (!empty($direction)) {
00352                     if ($direction == 'up') {
00353                         $operator = '<';
00354                         $order = 'DESC';
00355                     } else {
00356                         $operator = '>';
00357                         $order = 'ASC';
00358                     }
00359                     $sortCheck = ' AND ' . $sortField . $operator . intval($row[$sortField]);
00360                 }
00361                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
00362                     'uid,pid',
00363                     $table,
00364                         'pid=' . intval($row['pid']) .
00365                                 $sortCheck .
00366                                 $copyAfterFieldsQuery .
00367                                 $GLOBALS['TSFE']->sys_page->enableFields($table, '', $ignore),
00368                     '',
00369                         $sortField . ' ' . $order,
00370                     '2'
00371                 );
00372                 if ($row2 = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00373                     if ($afterUID) {
00374                         $cmdData[$table][$uid]['move'] = -$afterUID;
00375                     }
00376                     elseif ($direction == 'down') {
00377                         $cmdData[$table][$uid]['move'] = -$row2['uid'];
00378                     }
00379                     elseif ($row3 = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { // Must take the second record above...
00380                         $cmdData[$table][$uid]['move'] = -$row3['uid'];
00381                     }
00382                     else { // ... and if that does not exist, use pid
00383                         $cmdData[$table][$uid]['move'] = $row['pid'];
00384                     }
00385                 } elseif ($direction == 'up') {
00386                     $cmdData[$table][$uid]['move'] = $row['pid'];
00387                 }
00388             }
00389             if (!empty($cmdData)) {
00390                 $this->initializeTceMain();
00391                 $this->tce->start(array(), $cmdData);
00392                 $this->tce->process_cmdmap();
00393             }
00394         }
00395     }
00396 
00397     /**
00398      * Deletes a specific record.
00399      *
00400      * @param   string      The table name for the record to delete.
00401      * @param   integer     The UID for the record to delete.
00402      * @return  void
00403      */
00404     public function doDelete($table, $uid) {
00405         $cmdData[$table][$uid]['delete'] = 1;
00406         if (count($cmdData)) {
00407             $this->initializeTceMain();
00408             $this->tce->start(array(), $cmdData);
00409             $this->tce->process_cmdmap();
00410         }
00411     }
00412 
00413     /**
00414      * Saves a record based on its data array.
00415      *
00416      * @param   string      The table name for the record to save.
00417      * @param   integer     The UID for the record to save.
00418      * @return  void
00419      */
00420     public function doSave($table, $uid) {
00421         $data = $this->TSFE_EDIT['data'];
00422 
00423         if (!empty($data)) {
00424             $this->initializeTceMain();
00425             $this->tce->start($data, array());
00426             $this->tce->process_uploads($_FILES);
00427             $this->tce->process_datamap();
00428 
00429                 // Save the new UID back into TSFE_EDIT
00430             $newUID = $this->tce->substNEWwithIDs['NEW'];
00431             if ($newUID) {
00432                 $GLOBALS['BE_USER']->frontendEdit->TSFE_EDIT['newUID'] = $newUID;
00433             }
00434         }
00435     }
00436 
00437     /**
00438      * Saves a record based on its data array and closes it.
00439      *
00440      * @param   string      The table name for the record to save.
00441      * @param   integer     The UID for the record to save.
00442      * @return  void
00443      * @note    This method is only a wrapper for doSave() but is needed so
00444      *          that frontend editing views can handle "save" differently from
00445      *          "save and close".
00446      *          Example: When editing a page record, "save" reloads the same
00447      *          editing form.  "Save and close" reloads the entire page at
00448      *          the appropriate URL.
00449      */
00450     public function doSaveAndClose($table, $uid) {
00451         $this->doSave($table, $uid);
00452     }
00453 
00454 
00455     /**
00456      * Stub for closing a record. No real functionality needed since content
00457      * element rendering will take care of everything.
00458      *
00459      * @param   string      The table name for the record to close.
00460      * @param   integer     The UID for the record to close.
00461      * @return  void
00462      */
00463     public function doClose($table, $uid) {
00464         // Do nothing.
00465     }
00466 
00467     /**
00468      * Checks whether the user has access to edit the language for the
00469      * requested record.
00470      *
00471      * @param   string      The name of the table.
00472      * @param   array       The record.
00473      * @return  boolean
00474      */
00475     protected function allowedToEditLanguage($table, array $currentRecord) {
00476             // If no access right to record languages, return immediately
00477         if ($table === 'pages') {
00478             $lang = $GLOBALS['TSFE']->sys_language_uid;
00479         } elseif ($table === 'tt_content') {
00480             $lang = $GLOBALS['TSFE']->sys_language_content;
00481         } elseif ($GLOBALS['TCA'][$table]['ctrl']['languageField']) {
00482             $lang = $currentRecord[$GLOBALS['TCA'][$table]['ctrl']['languageField']];
00483         } else {
00484             $lang = -1;
00485         }
00486 
00487         if ($GLOBALS['BE_USER']->checkLanguageAccess($lang)) {
00488             $languageAccess = TRUE;
00489         } else {
00490             $languageAccess = FALSE;
00491         }
00492 
00493         return $languageAccess;
00494     }
00495 
00496     /**
00497      * Checks whether the user is allowed to edit the requested table.
00498      *
00499      * @param   string  The name of the table.
00500      * @param   array   The data array.
00501      * @param   array   The configuration array for the edit panel.
00502      * @param   boolean Boolean indicating whether recordEditAccessInternals should not be checked. Defaults
00503      *                   to true but doesn't makes sense when creating new records on a page.
00504      * @return  boolean
00505      */
00506     protected function allowedToEdit($table, array $dataArray, array $conf, $checkEditAccessInternals = TRUE) {
00507 
00508             // Unless permissions specifically allow it, editing is not allowed.
00509         $mayEdit = FALSE;
00510 
00511         if ($checkEditAccessInternals) {
00512             $editAccessInternals = $GLOBALS['BE_USER']->recordEditAccessInternals($table, $dataArray, FALSE, FALSE);
00513         } else {
00514             $editAccessInternals = TRUE;
00515         }
00516 
00517         if ($editAccessInternals) {
00518             if ($table == 'pages') {
00519                     // 2 = permission to edit the page
00520                 if ($GLOBALS['BE_USER']->isAdmin() || $GLOBALS['BE_USER']->doesUserHaveAccess($dataArray, 2)) {
00521                     $mayEdit = TRUE;
00522                 }
00523             } else {
00524                     // 16 = permission to edit content on the page
00525                 if ($GLOBALS['BE_USER']->isAdmin() || $GLOBALS['BE_USER']->doesUserHaveAccess(t3lib_BEfunc::getRecord('pages', $dataArray['pid']), 16)) {
00526                     $mayEdit = TRUE;
00527                 }
00528             }
00529 
00530             if (!$conf['onlyCurrentPid'] || ($dataArray['pid'] == $GLOBALS['TSFE']->id)) {
00531                     // Permissions:
00532                 $types = t3lib_div::trimExplode(',', t3lib_div::strtolower($conf['allow']), 1);
00533                 $allow = array_flip($types);
00534 
00535                 $perms = $GLOBALS['BE_USER']->calcPerms($GLOBALS['TSFE']->page);
00536                 if ($table == 'pages') {
00537                     $allow = $this->getAllowedEditActions($table, $conf, $dataArray['pid'], $allow);
00538 
00539                         // Can only display editbox if there are options in the menu
00540                     if (count($allow)) {
00541                         $mayEdit = TRUE;
00542                     }
00543                 } else {
00544                     $mayEdit = count($allow) && ($perms & 16);
00545                 }
00546             }
00547         }
00548 
00549         return $mayEdit;
00550     }
00551 
00552     /**
00553      * Takes an array of generally allowed actions and filters that list based on page and content permissions.
00554      *
00555      * @param   string  The name of the table.
00556      * @param   array   The configuration array.
00557      * @param   integer The PID where editing will occur.
00558      * @param   string  Comma-separated list of actions that are allowed in general.
00559      * @return  array
00560      */
00561     protected function getAllowedEditActions($table, array $conf, $pid, $allow = '') {
00562 
00563         if (!$allow) {
00564             $types = t3lib_div::trimExplode(',', t3lib_div::strtolower($conf['allow']), TRUE);
00565             $allow = array_flip($types);
00566         }
00567 
00568         if (!$conf['onlyCurrentPid'] || $pid == $GLOBALS['TSFE']->id) {
00569                 // Permissions:
00570             $types = t3lib_div::trimExplode(',', t3lib_div::strtolower($conf['allow']), TRUE);
00571             $allow = array_flip($types);
00572 
00573             $perms = $GLOBALS['BE_USER']->calcPerms($GLOBALS['TSFE']->page);
00574             if ($table == 'pages') {
00575                     // rootpage!
00576                 if (count($GLOBALS['TSFE']->config['rootLine']) == 1) {
00577                     unset($allow['move']);
00578                     unset($allow['hide']);
00579                     unset($allow['delete']);
00580                 }
00581                 if (!($perms & 2)) {
00582                     unset($allow['edit']);
00583                     unset($allow['move']);
00584                     unset($allow['hide']);
00585                 }
00586                 if (!($perms & 4)) {
00587                     unset($allow['delete']);
00588                 }
00589                 if (!($perms & 8)) {
00590                     unset($allow['new']);
00591                 }
00592             }
00593         }
00594 
00595         return $allow;
00596     }
00597 
00598     /**
00599      * Adds any extra Javascript includes needed for Front-end editing
00600      *
00601      * @param   none
00602      * @return  string
00603      */
00604     public function getJavascriptIncludes() {
00605             // No extra JS includes needed
00606         return '';
00607     }
00608 
00609     /**
00610      * Gets the hidden fields (array key=field name, value=field value) to be used in the edit panel for a particular content element.
00611      * In the normal case, no hidden fields are needed but special controllers such as TemplaVoila need to track flexform pointers, etc.
00612      *
00613      * @param   array   The data array for a specific content element.
00614      * @return  array
00615      */
00616     public function getHiddenFields(array $dataArray) {
00617             // No special hidden fields needed.
00618         return array();
00619     }
00620 
00621     /**
00622      * Initializes t3lib_TCEmain since it is used on modification actions.
00623      *
00624      * @return  void
00625      */
00626     protected function initializeTceMain() {
00627         if (!isset($this->tce)) {
00628             $this->tce = t3lib_div::makeInstance('t3lib_TCEmain');
00629             $this->tce->stripslashes_values = 0;
00630         }
00631     }
00632 }
00633 
00634 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_frontendedit.php'])) {
00635     include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_frontendedit.php']);
00636 }
00637 
00638 ?>