';
64 |
65 | $commonJavascriptCalls = $PA['fieldChangeFunc']['TBE_EDITOR_fieldChanged'] . $PA['fieldChangeFunc']['typo3form.fieldGet'] . ' return false;';
66 | // Create the + button
67 | $onClick = "document." . $PA['formName'] . "['" . $PA['itemName'] . "'].value++; " . $commonJavascriptCalls;
68 | $output .= '
+';
69 | // Create the - button
70 | $onClick = "document." . $PA['formName'] . "['" . $PA['itemName'] . "'].value--; " . $commonJavascriptCalls;
71 | $output .= '
-';
72 | $output .= '
';
73 | return $output;
74 | }
75 |
76 | /**
77 | * This method creates custom titles for the records of the tx_examples_haiku table
78 | *
79 | * @param array $parameters Parameters used to identify the current record
80 | * @param object $parentObject Calling object
81 | * @return void
82 | */
83 | public function haikuTitle(&$parameters, $parentObject) {
84 | $record = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord($parameters['table'], $parameters['row']['uid']);
85 | $newTitle = $record['title'];
86 | $newTitle .= ' (' . substr(strip_tags($record['poem']), 0, 10) . '...)';
87 | $parameters['title'] = $newTitle;
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/ext_localconf.php:
--------------------------------------------------------------------------------
1 | TYPO3 API overview > PHP Class Extension > Which classes? > Example - Adding a small feature in the interface
6 | $GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects']['TYPO3\\CMS\\Backend\\Controller\\NewRecordController'] = array(
7 | 'className' => 'Documentation\\Examples\\Xclass\\NewRecordController'
8 | );
9 |
10 | // Define custom permission options
11 | // USAGE: Core APIs > TYPO3 API overview > Various examples > Custom permission
12 | $GLOBALS['TYPO3_CONF_VARS']['BE']['customPermOptions'] = array(
13 | 'tx_examples_cat1' => array(
14 | 'header' => 'LLL:EXT:examples/Resources/Private/Language/locallang.xlf:permissions_header',
15 | 'items' => array(
16 | 'key1' => array(
17 | 'LLL:EXT:examples/Resources/Private/Language/locallang.xlf:permissions_option1',
18 | 'EXT:t3skin/icons/gfx/savedok.gif',
19 | 'LLL:EXT:examples/Resources/Private/Language/locallang.xlf:permissions_option1_description',
20 | ),
21 | 'key2' => array('LLL:EXT:examples/Resources/Private/Language/locallang.xlf:permissions_option2'),
22 | 'key3' => array('LLL:EXT:examples/Resources/Private/Language/locallang.xlf:permissions_option3'),
23 | )
24 | )
25 | );
26 |
27 | $GLOBALS['TYPO3_CONF_VARS']['LOG']['Documentation']['Examples']['Controller']['writerConfiguration'][\TYPO3\CMS\Core\Log\LogLevel::DEBUG] = $GLOBALS['TYPO3_CONF_VARS']['LOG']['writerConfiguration'][\TYPO3\CMS\Core\Log\LogLevel::DEBUG];
28 | // Add example configuration for the logging API
29 | $GLOBALS['TYPO3_CONF_VARS']['LOG']['Documentation']['Examples']['Controller']['writerConfiguration'][\TYPO3\CMS\Core\Log\LogLevel::WARNING] = array(
30 | // configuration for WARNING severity, including all
31 | // levels with higher severity (ERROR, CRITICAL, EMERGENCY)
32 | // add a SyslogWriter
33 | 'TYPO3\\CMS\\Core\\Log\\Writer\\SyslogWriter' => array(),
34 | );
35 | $GLOBALS['TYPO3_CONF_VARS']['LOG']['Documentation']['Examples']['Controller']['processorConfiguration'] = array(
36 | // configuration for ERROR level log entries
37 | \TYPO3\CMS\Core\Log\LogLevel::ERROR => array(
38 | // add a MemoryUsageProcessor
39 | 'TYPO3\\CMS\\Core\\Log\\Processor\\MemoryUsageProcessor' => array(
40 | 'formatSize' => TRUE
41 | )
42 | )
43 | );
44 |
45 | // Register ExtDirect method
46 | \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::registerExtDirectComponent(
47 | 'TYPO3.Examples.ExtDirect',
48 | \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY, 'Classes/ExtDirect/Server.php:Tx_Examples_ExtDirect_Server')
49 | );
50 |
51 | /*
52 | // Register a class for manipulating the page rendering process
53 | // (used in TYPO3 Viewport manipulation demonstration)
54 | // NOTE: even though the code itself works, it breaks the TYPO3 backend
55 | // This code should be revisited at some point, but this requires solid ExtJS knowledge
56 | $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_pagerenderer.php']['render-preProcess'][] =
57 | 'EXT:' . $_EXTKEY . '/Classes/Utilities/Viewport.php:Tx_Examples_Utilities_Viewport->renderPreProcess';
58 | */
59 |
60 | \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPItoST43(
61 | $_EXTKEY,
62 | 'pierror/class.tx_examples_pierror.php',
63 | '_pierror',
64 | 'list_type',
65 | 1
66 | );
67 | \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPItoST43(
68 | $_EXTKEY,
69 | 'pihtml/class.tx_examples_pihtml.php',
70 | '_pihtml',
71 | 'list_type',
72 | 1
73 | );
74 |
75 | // Register the collections plugin
76 | \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
77 | 'Documentation.' . $_EXTKEY,
78 | 'Collections',
79 | array(
80 | 'Collection' => 'index',
81 | )
82 | );
83 |
84 | // Add custom translations overriding default labels
85 | $GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride']['EXT:cms/locallang_tca.xlf'][] = 'EXT:examples/Resources/Private/Language/custom.xlf';
86 | $GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride']['de']['EXT:cms/locallang_tca.xlf'][] = 'EXT:examples/Resources/Private/Language/de.custom.xlf';
87 |
88 | // Register custom RTE transformation
89 | $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_parsehtml_proc.php']['transformation']['tx_examples_transformation'] = 'Documentation\Examples\Service\RteTransformation';
90 |
91 | // Add necessary TSconfig to active custom RTE transformation
92 | \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig(
93 | 'RTE.default.proc.usertrans.tx_examples_transformation.addHrulerInRTE = 1
94 | RTE.config.tx_examples_haiku.poem.proc.overruleMode = tx_examples_transformation,ts_css'
95 | );
96 |
--------------------------------------------------------------------------------
/Classes/Controller/DefaultController.php:
--------------------------------------------------------------------------------
1 |
21 | * @package TYPO3
22 | * @subpackage tx_examples
23 | */
24 | class DefaultController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {
25 |
26 | /**
27 | * Renders the list of all possible flash messages
28 | *
29 | * @return void
30 | */
31 | public function flashAction() {
32 | // Issue one of each type of flash messages
33 | $this->addFlashMessage(
34 | 'This is a notice message',
35 | 'Notification',
36 | \TYPO3\CMS\Core\Messaging\FlashMessage::NOTICE
37 | );
38 | $this->addFlashMessage(
39 | 'This is an information message',
40 | 'Information',
41 | \TYPO3\CMS\Core\Messaging\FlashMessage::INFO
42 | );
43 | $this->addFlashMessage(
44 | 'This is a success message',
45 | 'Hooray!',
46 | \TYPO3\CMS\Core\Messaging\FlashMessage::OK
47 | );
48 | $this->addFlashMessage(
49 | 'This is a warning message',
50 | 'Watch out',
51 | \TYPO3\CMS\Core\Messaging\FlashMessage::WARNING
52 | );
53 | $this->addFlashMessage(
54 | '
55 |