Commit 29c445ec authored by Damjan's avatar Damjan
Browse files

[TASK] Use of fluid elements (f:form.select, f:form.save)

-Experimentng with fluid viewHelpers and actions

-Extbase file structure

-Adding ext_localconf.php

Related: forge.typo3.org/issues/31889
parent c64318ae
......@@ -27,6 +27,7 @@ namespace SGalinski\LFEditor\Controller;
***************************************************************/
//use SGalinski\DezShops\Domain\Model\Shop;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
/**
* Abstract Controller
......
<?php
namespace SGalinski\LFEditor\Controller;
/***************************************************************
* Copyright notice
*
* (c) sgalinski Internet Services (http://www.sgalinski.de)
*
* 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 3 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.
*
* 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!
***************************************************************/
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
/**
* Controller for general overview
*/
class MainController extends ActionController {
/**
* @param string $mainMenuSelection
* @param string $extensionSelection
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException
*/
public function mainMenuSelectAction($mainMenuSelection, $extensionSelection = NULL) {
$this->redirect($mainMenuSelection, NULL, NULL, array('extensionSelection' => $extensionSelection));
}
/**
* @param string $extensionSelection
*/
public function generalAction($extensionSelection = NULL) {
$this->view->assign('mainMenuSelection', 'general');
$this->view->assign('extensionSelection', $extensionSelection);
}
/**
* @param string $extensionSelection
*/
public function editFileAction($extensionSelection = NULL) {
debug($extensionSelection, 'extSelArg: ');
echo 'ExtSel: ' . $extensionSelection;
$this->view->assign('mainMenuSelection', 'editFile');
$this->view->assign('extensionSelection', $extensionSelection);
}
public function editFileSaveAction() {
$this->redirect('editFile');
}
}
?>
\ No newline at end of file
<?php
namespace SGalinski\LFeditor\ViewHelpers;
/***************************************************************
* Copyright notice
*
* (c) sgalinski Internet Services (http://www.sgalinski.de)
*
* 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 3 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.
*
* 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!
***************************************************************/
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Fluid\ViewHelpers\Be\AbstractBackendViewHelper;
/**
* Abstract view helper
*/
class AbstractViewHelper extends AbstractBackendViewHelper {
/**
* Returns an instance of the page renderer
*
* @return PageRenderer
*/
public function getPageRenderer() {
if (TYPO3_MODE === 'BE') {
$pageRenderer = $this->getDocInstance()->getPageRenderer();
} else {
/** @noinspection PhpUndefinedMethodInspection */
$pageRenderer = $GLOBALS['TSFE']->getPageRenderer();
}
return $pageRenderer;
}
/**
* Returns the base url of the site
*
* Note: Works only in frontend mode
*
* @return string
*/
public function getBaseUrl() {
if ($GLOBALS['TSFE']->absRefPrefix !== '') {
$baseUrl = $GLOBALS['TSFE']->absRefPrefix;
} else {
$baseUrl = $GLOBALS['TSFE']->baseUrl;
}
return $baseUrl;
}
}
?>
\ No newline at end of file
<?php
namespace SGalinski\LFEditor\ViewHelpers;
/***************************************************************
* Copyright notice
*
* (c) sgalinski Internet Services (http://www.sgalinski.de)
*
* 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 3 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.
*
* 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 helper to add custom css files
*
* Example:
* {namespace lfe=SGalinski\LFEditor\ViewHelpers}
* <lfe:addCssFile cssFile="{f:uri.resource(path: 'StyleSheets/Frontend.css')}" />
*/
class AddCssFileViewHelper extends AbstractViewHelper {
/**
* Adds a custom css file
*
* @param string $cssFile
* @return void
*/
public function render($cssFile) {
$cssFile = (TYPO3_MODE === 'FE' ? $this->getBaseUrl() : '') . $cssFile;
$this->getPageRenderer()->addCssFile($cssFile, 'stylesheet', 'all', '', FALSE);
}
}
?>
\ No newline at end of file
<?php
namespace SGalinski\LFEditor\ViewHelpers;
/***************************************************************
* Copyright notice
*
* (c) sgalinski Internet Services (http://www.sgalinski.de)
*
* 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 3 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.
*
* 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 helper to add custom javascript files
*
* Example:
* {namespace lfe=SGalinski\LFEditor\ViewHelpers}
* <lfe:addJavaScriptFile javaScriptFile="{f:uri.resource(path: 'Scripts/Frontend.js')}" />
*/
class AddJavaScriptFileViewHelper extends AbstractViewHelper {
/**
* Adds a custom javascript file
*
* @param string $javaScriptFile
* @return void
*/
public function render($javaScriptFile) {
$javaScriptFile = (TYPO3_MODE === 'FE' ? $this->getBaseUrl() : '') . $javaScriptFile;
$this->getPageRenderer()->addJsFile($javaScriptFile);
}
}
?>
\ No newline at end of file
<div>
This is Default layout. <br>
<f:form id="mainMenuForm" action="mainMenuSelect">
<f:form.select name="mainMenuSelection"
value="{mainMenuSelection}"
options="{ general: 'General select item', editFile: 'Edit file select item'}"
additionalAttributes="{onchange: 'document.getElementById(\'mainMenuForm\').submit();'}"
/>
<f:debug title="All available variables">{_all}</f:debug>
<br><br>
<f:render section="selectItems" />
</f:form>
<br><br>
<!--<f:link.action action="editFile">Edit file link</f:link.action>-->
<!--<br>-->
<!--<f:link.action action="general">General link</f:link.action>-->
<!--<br><br>-->
<f:render section="main" />
</div>
\ No newline at end of file
<f:layout name="Default" />
<f:section name="selectItems">
This is EditFile page. Select items section.
<f:form.select name="extensionSelection"
value="{extensionSelection}"
options="{ extension1: 'Test extension 1', extension2: 'Test extension 2'}"
additionalAttributes="{onchange: 'document.getElementById(\'mainMenuForm\').submit();'}"
/>
</f:section>
<f:section name="main">
This is EditFile page. Main section.
<f:form id="contentForm" action="editFileSave">
<f:form.submit value="Save" />
</f:form>
</f:section>
\ No newline at end of file
<f:layout name="Default" />
<f:section name="selectItems">
This is General page. Select items section.
</f:section>
<f:section name="main">
This is General page. Main section.
</f:section>
\ No newline at end of file
<?php
namespace SGalinski\LFEditor\Controller;
/***************************************************************
* Copyright notice
*
......@@ -26,14 +22,7 @@ namespace SGalinski\LFEditor\Controller;
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Domain\Model\Category;
/**
* Controller for the shop overview
*/
class GeneralController extends AbstractController {
function submitForm(formName) {
document.getElementById(formName).submit();
}
?>
\ No newline at end of file
<?php
$extensionPath = t3lib_extMgm::extPath('lfeditor');
return array(
'LFException' => $extensionPath . 'Classes/Exceptions/LFException.php',
'Typo3Lib' => $extensionPath . 'Classes/Util/Typo3Lib.php',
'SgLib' => $extensionPath . 'Classes/Util/SgLib.php',
'FileService' => $extensionPath . 'Classes/Service/FileService.php',
'FileBackupService' => $extensionPath . 'Classes/Service/FileBackupService.php',
'FileBaseService' => $extensionPath . 'Classes/Service/FileBaseService.php',
'FileBasePHPService' => $extensionPath . 'Classes/Service/FileBasePHPService.php',
'FileBaseXLFService' => $extensionPath . 'Classes/Service/FileBaseXLFService.php',
'FileBaseXMLService' => $extensionPath . 'Classes/Service/FileBaseXMLService.php',
'FileXllService' => $extensionPath . 'Classes/Service/FileXllService.php',
'FileXllPHPService' => $extensionPath . 'Classes/Service/FileXllPHPService.php',
'FileXllXMLService' => $extensionPath . 'Classes/Service/FileXllXMLService.php',
'Functions' => $extensionPath . 'Classes/Util/Functions.php',
);
?>
\ No newline at end of file
......@@ -33,7 +33,7 @@ $EM_CONF[$_EXTKEY] = array(
'conflicts' => '',
'priority' => '',
'loadOrder' => '',
'module' => 'mod1',
'module' => '',
'state' => 'stable',
'uploadfolder' => 0,
'createDirs' => '',
......
<?php
if (!defined('TYPO3_MODE')) {
die('Access denied.');
}
/** @noinspection PhpUndefinedVariableInspection */
$extPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('lfeditor');
?>
\ No newline at end of file
......@@ -11,7 +11,7 @@ if (TYPO3_MODE == 'BE') {
'LFEditor',
'',
[
'General' => 'index, selectExtension, selectLanguageFile, selectReferenceLanguage, save, reset',
'Main' => 'general, mainMenuSelect, editFile, editFileSave',
],
[
'access' => 'user,group',
......
......@@ -111,7 +111,7 @@ class tx_lfeditor_module1 extends t3lib_SCbase {
* @return void
*/
public function main() {
$this->doc = t3lib_div::makeInstance('template');
$this->doc = TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('template');
$this->doc->backPath = $GLOBALS['BACK_PATH'];
$this->doc->setModuleTemplate(t3lib_extMgm::extPath('lfeditor') . 'templates/main_mod1.html');
$this->doc->docType = 'xhtml_trans';
......@@ -1918,7 +1918,7 @@ class tx_lfeditor_module1 extends t3lib_SCbase {
try {
// generate extension and workspace list
$name = 'select.extensionAndWorkspace';
if (t3lib_div::compat_version('6.0')) {
if (TYPO3\CMS\Core\Utility\GeneralUtility::compat_version('6.0')) {
$name = 'select.extension';
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment