Skip to content

Commit

Permalink
coding cleanup, documentation, release of version 1.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Kephson committed Oct 29, 2017
1 parent 49ad7a6 commit 5d73994
Show file tree
Hide file tree
Showing 31 changed files with 187 additions and 121 deletions.
7 changes: 5 additions & 2 deletions Classes/Command/ExampleCommandController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@
namespace EHAERER\EhBootstrap\Command;

/**
* This file is part of the "news" Extension for TYPO3 CMS.
* This file is part of the "eh_bootstrap" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*/
use TYPO3\CMS\Extbase\Mvc\Controller\CommandController;
use \TYPO3\CMS\Extbase\Mvc\Controller\CommandController;
use \TYPO3\CMS\Core\Utility\GeneralUtility;
use \TYPO3\CMS\Core\Messaging\FlashMessage;

/**
* Example controller
* [Example-11]
*
*/
class ExampleCommandController extends CommandController
Expand All @@ -28,10 +29,12 @@ class ExampleCommandController extends CommandController
public function runCommand($required, $optional = false, $string = '')
{
$message = 'Required: ' . $required . ' | optional:' . $optional . ' | string:' . $string;
/* @var $messageOut \TYPO3\CMS\Core\Messaging\FlashMessage */
$messageOut = GeneralUtility::makeInstance(
\TYPO3\CMS\Core\Messaging\FlashMessage::class, $message, 'Field content', FlashMessage::OK, FALSE
);
// get backend message queue
/* @var $flashMessageService \TYPO3\CMS\Core\Messaging\FlashMessageService */
$flashMessageService = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessageService::class);
$flashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
// add message
Expand Down
15 changes: 8 additions & 7 deletions Classes/Controller/AbstractController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,9 @@
* This copyright notice MUST APPEAR in all copies of the script!
* ************************************************************* */

use \TYPO3\CMS\Core\Messaging\FlashMessage;
use \TYPO3\CMS\Core\Utility\GeneralUtility;
use \TYPO3\CMS\Core\Utility\DebugUtility;
use \TYPO3\CMS\Extbase\Utility\LocalizationUtility;
use \TYPO3\CMS\Extbase\Utility\DebuggerUtility;
use \TYPO3\CMS\Core\Utility\ExtensionManagementUtility;

/**
* AbstractController
* [Example-5]
*/
class AbstractController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController
{
Expand Down Expand Up @@ -67,11 +61,13 @@ public function __construct()
parent::__construct();

/* [Example-1] */
/* visit at the file ext_conf_template.txt to see all options */
$this->emSettings = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$this->extKey]);
}

/**
* action plugin
* Output of the extbase plugin in backend
*
* @return \string The rendered view.
*/
Expand All @@ -86,6 +82,9 @@ public function pluginAction()

/**
* action render
* loaded via AJAX to demonstrate the rendering via AJAX
* [Example-6]
* [Example-7]
*
* @return \string The rendered view.
*/
Expand All @@ -109,6 +108,8 @@ public function renderAction()

/**
* action module
* used for the backend module
* [Example-9]
*
* @return \string The rendered view. For the backend module
*/
Expand Down
76 changes: 42 additions & 34 deletions Classes/Eid/ExtbaseDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,18 @@
* This copyright notice MUST APPEAR in all copies of the script!
*
*
* [Example-6]
* Usage of this script:
*
* - Copy this script in your Extension Dir in the Folder Classes
* - Set the Vendor and Extension Name in Line 82 + 83
* - Include the next line in the ext_localconf.php, change the ext name!
* - $TYPO3_CONF_VARS['FE']['eID_include']['myExtAjaxDispatcher'] = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('myExtension').'Classes/Eid/EidDispatcher.php';
*
* tested with TYPO3 7.6
* tested with TYPO3 7.6 and 8.7
*
* Use for Ajax Calls in your jQuery Code:
* Usage for AJAX calls in your jQuery Code:
* see example file Resources/Public/JavaScript/main.js
*
* $('.jqAjax').click(function(e) {
* var uid = $(this).find('.uid').html();
Expand Down Expand Up @@ -64,9 +66,9 @@
* }
* });
* ************************************************************* */
/**
* Gets the Ajax Call Parameters
*/
/* * **********************************
* Gets the AJAX Call Parameters
* ********************************* */
$ajax = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('request');
/**
* Set Vendor and Extension Name
Expand All @@ -92,56 +94,62 @@

global $TYPO3_CONF_VARS;

$GLOBALS['TSFE'] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::class, $TYPO3_CONF_VARS, $pid, 0);
/* @var $GLOBALS['TSFE'] \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController */
$GLOBALS['TSFE'] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::class, $TYPO3_CONF_VARS, $pid, 0);
\TYPO3\CMS\Frontend\Utility\EidUtility::initLanguage();
//init TCA to load content elements
//\TYPO3\CMS\Frontend\Utility\EidUtility::initTCA();
// Get FE User Information
$GLOBALS['TSFE']->initFEuser();
// get backend user information
$GLOBALS['TSFE']->initializeBackendUser();
//init TCA to load content elements
// init TCA to load content elements
\TYPO3\CMS\Frontend\Utility\EidUtility::initTCA();
// Important: no Cache for Ajax stuff
// disable Cache for AJAX calls
$GLOBALS['TSFE']->set_no_cache();
//$GLOBALS['TSFE']->checkAlternativCoreMethods();
// Provides ways to bypass the '?id=[xxx]&type=[xx]' format
$GLOBALS['TSFE']->checkAlternativeIdMethods();
// Determines the id and evaluates any preview settings
$GLOBALS['TSFE']->determineId();
// Initialize the TypoScript template parser
$GLOBALS['TSFE']->initTemplate();
// Checks if config-array exists already but if not, gets it
$GLOBALS['TSFE']->getConfigArray();
//\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($GLOBALS['TSFE']); die();
//\TYPO3\CMS\Core\Core\Bootstrap::getInstance();
//\TYPO3\CMS\Core\Core\Bootstrap::getInstance()->loadConfigurationAndInitialize();

$GLOBALS['TSFE']->cObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer');
/* @var $GLOBALS['TSFE']->cObj \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer */
$GLOBALS['TSFE']->cObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class);
// Setting the language key that will be used by the current page
$GLOBALS['TSFE']->settingLanguage();
// Setting locale for frontend rendering
$GLOBALS['TSFE']->settingLocale();
/**
* @var $objectManager \TYPO3\CMS\Extbase\Object\ObjectManager
*/
$objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Extbase\Object\ObjectManager');
/**
* Initialize Extbase bootstap
*/
$bootstrapConf['extensionName'] = $ajax['extensionName'];
$bootstrapConf['pluginName'] = $ajax['pluginName'];
$bootstrap = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Extbase\Core\Bootstrap');
/* @var $objectManager \TYPO3\CMS\Extbase\Object\ObjectManager */
$objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
/* * *********************************
* Initialize the Extbase bootstap
* ******************************** */
$bootstrapConf = [
'extensionName' => $ajax['extensionName'],
'pluginName' => $ajax['pluginName'],
];
/* @var $bootstrap \TYPO3\CMS\Extbase\Core\Bootstrap */
$bootstrap = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Core\Bootstrap::class);
$bootstrap->initialize($bootstrapConf);
$bootstrap->cObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer');
//\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
/**
/* @var $bootstrap->cObj \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer */
$bootstrap->cObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class);
/* * *****$bootstrap*************
* Build the request
*/
$request = $objectManager->get('TYPO3\CMS\Extbase\Mvc\Request');
* ***************** */
/* @var $request \TYPO3\CMS\Extbase\Mvc\Request */
$request = $objectManager->get(\TYPO3\CMS\Extbase\Mvc\Request::class);
$request->setControllerVendorName($ajax['vendor']);
$request->setcontrollerExtensionName($ajax['extensionName']);
$request->setPluginName($ajax['pluginName']);
$request->setControllerName($ajax['controller']);
$request->setControllerActionName($ajax['action']);
$request->setArguments($ajax['arguments']);
$request->setFormat("html"); // set to use html file as template -> default is txt
$response = $objectManager->get('TYPO3\CMS\Extbase\Mvc\ResponseInterface');
$dispatcher = $objectManager->get('TYPO3\CMS\Extbase\Mvc\Dispatcher');
// set to use html file as template -> default is txt file
$request->setFormat("html");
/* @var $response \TYPO3\CMS\Extbase\Mvc\ResponseInterface */
$response = $objectManager->get(\TYPO3\CMS\Extbase\Mvc\ResponseInterface::class);
/* @var $dispatcher \TYPO3\CMS\Extbase\Mvc\Dispatcher */
$dispatcher = $objectManager->get(\TYPO3\CMS\Extbase\Mvc\Dispatcher::class);
$dispatcher->dispatch($request, $response);
echo $response->getContent();
//die();
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

/**
* Contains a preview rendering for the page module of CType="eh_bs_01"
* [Example-4]
*/
class NewContentElementPreviewRenderer implements PageLayoutViewDrawItemHookInterface
{
Expand Down Expand Up @@ -66,6 +67,7 @@ public function preProcess(
*/
protected function renderFluidStandAlone($templatePath = 'Abstract/PluginPreview.html')
{
/* @var $view \TYPO3\CMS\Fluid\View\StandaloneView */
$view = GeneralUtility::makeInstance(\TYPO3\CMS\Fluid\View\StandaloneView::class);
$view->getRequest()->setControllerExtensionName($this->extKey); // path the extension name to get translation work
$view->setPartialRootPaths(array(100 => ExtensionManagementUtility::extPath($this->extKey) . 'Resources/Private/Partials/'));
Expand Down
9 changes: 5 additions & 4 deletions Classes/Task/Example.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,20 @@
use \TYPO3\CMS\Core\Utility\GeneralUtility;

/**
* [Example-10]
* task class which executes only another class
* see: http://docs.typo3.org/typo3cms/extensions/scheduler/latest/DevelopersGuide/CreatingTasks/Index.html
*/
class Example extends \TYPO3\CMS\Scheduler\Task\AbstractTask
{
/*

/**
* executed by scheduler
*/

public function execute()
{

// initialize task class
// initialize task class via make instance because it's easier to add/update the fields later
/* @var $exampleTask \EHAERER\EhBootstrap\Task\ExampleTask */
$exampleTask = GeneralUtility::makeInstance(\EHAERER\EhBootstrap\Task\ExampleTask::class);
return $exampleTask->run($this->link, $this->translang);
}
Expand Down
9 changes: 8 additions & 1 deletion Classes/Task/ExampleTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
use \TYPO3\CMS\Core\Utility\GeneralUtility;
use \TYPO3\CMS\Core\Messaging\FlashMessage;

/**
* [Example-10]
* task class which will be instantiated by the default scheduler class
* see: http://docs.typo3.org/typo3cms/extensions/scheduler/latest/DevelopersGuide/CreatingTasks/Index.html
*/
class ExampleTask
{

Expand All @@ -47,12 +52,14 @@ class ExampleTask
*/
public function run($link, $transLang)
{
/* @var $messageOut \TYPO3\CMS\Core\Messaging\FlashMessage */
$messageOut = GeneralUtility::makeInstance(
\TYPO3\CMS\Core\Messaging\FlashMessage::class, 'Configured link: ' . $link . ' | Configured language: ' . $transLang, 'Field content', FlashMessage::OK, FALSE
);
// get backend message queue
/* @var $flashMessageService \TYPO3\CMS\Core\Messaging\FlashMessageService */
$flashMessageService = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessageService::class);
$flashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
$flashMessageQueue = $flashMessageService->getMessageQueueByIdentifier('ehBoostrap.task.default');
// add message
$flashMessageQueue->enqueue($messageOut);

Expand Down
9 changes: 8 additions & 1 deletion Classes/Task/ExampleTaskFields.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
use \TYPO3\CMS\Core\Utility\GeneralUtility;
use \TYPO3\CMS\Core\Utility\DebugUtility;

/**
* [Example-10]
* additional task class to add custom fields in the scheduler
* @see https://docs.typo3.org/typo3cms/extensions/scheduler/DevelopersGuide/CreatingTasks/Index.html
*/
class ExampleTaskFields implements \TYPO3\CMS\Scheduler\AdditionalFieldProviderInterface
{

Expand Down Expand Up @@ -120,12 +125,14 @@ public function validateAdditionalFields(array &$submittedData, \TYPO3\CMS\Sched

if (!empty($errors)) {
foreach ($message as $m) {
/* @var $messageOut \TYPO3\CMS\Core\Messaging\FlashMessage */
$messageOut = GeneralUtility::makeInstance(
\TYPO3\CMS\Core\Messaging\FlashMessage::class, $m['body'], $m['head'], FlashMessage::ERROR, FALSE
);
// get backend message queue
/* @var $flashMessageService \TYPO3\CMS\Core\Messaging\FlashMessageService */
$flashMessageService = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessageService::class);
$flashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
$flashMessageQueue = $flashMessageService->getMessageQueueByIdentifier('ehBoostrap.task.default');
// add message
$flashMessageQueue->enqueue($messageOut);
}
Expand Down
1 change: 1 addition & 0 deletions Classes/ViewHelpers/FlashMessagesViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

/**
* Display core flash messages
* [Example-13]
*
* @package EHAERER\EhBootstrap\ViewHelpers
*/
Expand Down
2 changes: 1 addition & 1 deletion Configuration/TCA/Overrides/sys_template.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
/* add TypoScript
/* add TypoScript files
* @see https://docs.typo3.org/typo3cms/extensions/fluid_styled_content/7.6/AddingYourOwnContentElements/Index.html
*/
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile(
Expand Down
3 changes: 2 additions & 1 deletion Configuration/TCA/Overrides/tt_content.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
/* TCA config
/* TCA config for the content element
* [Example-4]
* @see https://docs.typo3.org/typo3cms/extensions/fluid_styled_content/7.6/AddingYourOwnContentElements/Index.html
*/
// add the new CType
Expand Down
4 changes: 4 additions & 0 deletions Configuration/TypoScript/constants.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
################################
# Constants for extbase plugin
# [Example-5]
################################
plugin.tx_ehbootstrap {
view {
# cat=powermail_main/file; type=string; label= Path to template root (FE)
Expand Down
11 changes: 8 additions & 3 deletions Configuration/TypoScript/setup.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
##################
# Frontend Plugin
##################
################################
# Setup for extbase plugin
# [Example-5]
################################
plugin.tx_ehbootstrap {
# Templates for Fluid
view {
Expand All @@ -26,6 +27,7 @@ plugin.tx_ehbootstrap {

##################
# Content elements
# [Example-4]
##################
tt_content.eh_bs_01 = COA
tt_content.eh_bs_01 {
Expand All @@ -37,6 +39,9 @@ tt_content.eh_bs_01 {
}
}

##########################
# Include a basic js file
##########################
page {
includeJSFooterlibs {
eh_bootstrap = EXT:eh_bootstrap/Resources/Public/JavaScript/main.js
Expand Down
6 changes: 6 additions & 0 deletions Documentation/ChangeLog/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
ChangeLog
=========

2017-10-29 Ephraim Härer <[email protected]>

* updated coding with more annotations and links for documentation
* release of version 1.0.4


2017-09-10 Ephraim Härer <[email protected]>

* improved compatibility with TYPO3 8
Expand Down
13 changes: 2 additions & 11 deletions Documentation/Developer/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,5 @@ could be accessed inside of the class.
$this->emSettings = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$this->extKey]);
}
or some other language:

.. code-block:: javascript
:linenos:
:emphasize-lines: 2-4
$(document).ready(
function () {
doStuff();
}
);
You should also read the documentation on https://docs.typo3.org/typo3cms/CoreApiReference/ExtensionArchitecture/ConfigurationOptions/Index.html
and the information on https://docs.typo3.org/typo3cms/TyposcriptSyntaxReference/TypoScriptTemplates/TheConstantEditor/Index.html#constant-editor.
Loading

0 comments on commit 5d73994

Please sign in to comment.