Project

General

Profile

Actions

Feature #66620

closed

FE Edit viewhelper

Added by Philipp Wrann about 9 years ago. Updated about 7 years ago.

Status:
Closed
Priority:
Could have
Assignee:
-
Category:
Frontend
Target version:
-
Start date:
2015-04-28
Due date:
% Done:

0%

Estimated time:
PHP Version:
5.5
Tags:
Complexity:
Sprint Focus:

Description

I wrote a viewhelper for fe edit, it would be nice to have some kind of this functionallity in the core.
I dont know the typo3 coding guidelines and didnt work with gerrit before, so i thought i share those lines here.

Also i didnt know how to get the raw query result from the persistence manager to avoid the query...

<?php

namespace TYPO3\CMS\Feedit\ViewHelpers;

use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Database\DatabaseConnection;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;

/**
 * @author Philipp Wrann <philippwrann@gmail.com>
 * @package TYPO3.CMS
 * @subpackage Feedit
 */
class EditPanelViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper {

    /**
     * @var ContentObjectRenderer
     */
    protected static $contentObjectRenderer = NULL;

    /**
     * @var \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface
     * @inject
     */
    protected $configurationManager;

    /**
     * @param \TYPO3\CMS\Extbase\DomainObject\AbstractEntity $for
     * @return string
     */
    public function render(AbstractEntity $for) {
        if ($GLOBALS['TSFE']->beUserLogin) {
            $settings = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK,$this->controllerContext->getRequest()->getControllerExtensionName());
            $config = $settings['admPanel'];
            $table = $settings['persistence']['classes'][get_class($for)]['mapping']['tableName'];
            $currentRecord = $table.':'.$for->getUid();
            $dataArray = $this->getDatabase()->exec_SELECTgetSingleRow('*',$table,'uid='.$for->getUid());
            return self::getContentObjectRenderer()->editPanel('', $config, $currentRecord, $dataArray);
        }
    }

    /**
     * @return ContentObjectRenderer
     */
    protected static function getContentObjectRenderer() {
        if (self::$contentObjectRenderer === NULL) {
            self::$contentObjectRenderer = GeneralUtility::makeInstance(ContentObjectRenderer::class); 
        }
        return self::$contentObjectRenderer;
    }

    /**
     * @return DatabaseConnection
     */
    protected function getDatabase() {
        return $GLOBALS['TYPO3_DB'];
    }

}

So basically you have to add the admPanel configuration to your extensions typoscript and place this viewHelper:
<feedit:editPanel for="{yourEntity}"/>

It is very limited that way but would be a start :)


Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Feature #79633: Integrate next generation of Frontend Editing based on CKEditorRejectedBenni Mack2017-02-10

Actions
Actions

Also available in: Atom PDF