‪TYPO3CMS  9.5
TYPO3\CMS\Backend\Module\BaseScriptClass Class Reference

Public Member Functions

 __construct ()
 
 init ()
 
 menuConfig ()
 
array mergeExternalItems ($modName, $menuKey, $menuArr)
 
 handleExternalFunctionValue ($MM_key='function', $MS_value=null)
 
mixed getExternalItemConfig ($modName, $menuKey, $value='')
 
 checkExtObj ()
 
 checkSubExtObj ()
 
 extObjHeader ()
 
 extObjContent ()
 
string getExtObjContent ()
 

Public Attributes

array $MCONF = array( )
 
int $id
 
mixed $CMD
 
string $perms_clause
 
array $MOD_MENU
 
array $MOD_SETTINGS = array( )
 
array $modTSconfig
 
string $modMenu_type = ''
 
string $modMenu_dontValidateList = ''
 
string $modMenu_setDefaultList = ''
 
array $extClassConf
 
string $content = ''
 
TYPO3 CMS Backend Template DocumentTemplate $doc
 
AbstractFunctionModule $extObj
 

Protected Member Functions

LanguageService getLanguageService ()
 
BackendUserAuthentication getBackendUser ()
 
PageRenderer getPageRenderer ()
 

Protected Attributes

PageRenderer $pageRenderer
 

Detailed Description

Parent class for 'ScriptClasses' in backend modules.

EXAMPLE PROTOTYPE

As for examples there are lots of them if you search for classes which extends \TYPO3\CMS\Backend\Module\BaseScriptClass However you can see a prototype example of how a module might use this class in an index.php file typically hosting a backend module.

NOTICE: This example only outlines the basic structure of how this class is used. You should consult the documentation and other real-world examples for some actual things to do when building modules.

TYPICAL SETUP OF A BACKEND MODULE:

PrototypeController EXTENDS THE CLASS \TYPO3\CMS\Backend\Module\BaseScriptClass with a main() function:

namespace Vendor\Prototype\Controller;

class PrototypeController extends \TYPO3\CMS\Backend\Module\BaseScriptClass { public function __construct() { $this->getLanguageService()->includeLLFile('EXT:prototype/Resources/Private/Language/locallang.xlf'); $this->getBackendUser()->modAccess($GLOBALS['MCONF']); } }

MAIN FUNCTION - HERE YOU CREATE THE MODULE CONTENT IN $this->content public function main() { TYPICALLY THE INTERNAL VAR, $this->doc is instantiated like this: $this->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Template\DocumentTemplate::class); ... AND OF COURSE A LOT OF OTHER THINGS GOES ON - LIKE PUTTING CONTENT INTO $this->content $this->content=''; }

MAKE INSTANCE OF THE SCRIPT CLASS AND CALL init() $GLOBALS['SOBE'] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\Vendor\Prototype\Controller\PrototypeController::class); $GLOBALS['SOBE']->init();

THEN WE WILL CHECK IF THERE IS A 'SUBMODULE' REGISTERED TO BE INITIALIZED AS WELL: $GLOBALS['SOBE']->checkExtObj();

THEN WE CALL THE main() METHOD AND THIS SHOULD SPARK THE CREATION OF THE MODULE OUTPUT. $GLOBALS['SOBE']->main();

Deprecated:
‪since TYPO3 v9, will be removed in TYPO3 v10.0

Definition at line 71 of file BaseScriptClass.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Backend\Module\BaseScriptClass::__construct ( )

Constructor deprecates the class

Definition at line 179 of file BaseScriptClass.php.

Member Function Documentation

◆ checkExtObj()

TYPO3\CMS\Backend\Module\BaseScriptClass::checkExtObj ( )

Creates an instance of the class found in $this->extClassConf['name'] in $this->extObj if any (this should hold three keys, "name", "path" and "title" if a "Function menu module" tries to connect...) This value in extClassConf might be set by an extension (in an ext_tables/ext_localconf file) which thus "connects" to a module. The array $this->extClassConf is set in handleExternalFunctionValue() based on the value of MOD_SETTINGS[function] If an instance is created it is initiated with $this passed as value and $this->extClassConf as second argument. Further the $this->MOD_SETTING is cleaned up again after calling the init function.

See also
handleExternalFunctionValue(), \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::insertModuleFunction(), $extObj

Definition at line 290 of file BaseScriptClass.php.

References TYPO3\CMS\Backend\Utility\BackendUtility\getModuleData().

◆ checkSubExtObj()

TYPO3\CMS\Backend\Module\BaseScriptClass::checkSubExtObj ( )

Calls the checkExtObj function in sub module if present.

Definition at line 303 of file BaseScriptClass.php.

◆ extObjContent()

TYPO3\CMS\Backend\Module\BaseScriptClass::extObjContent ( )

Calls the 'main' function inside the "Function menu module" if present

Definition at line 324 of file BaseScriptClass.php.

References TYPO3\CMS\Core\Messaging\AbstractMessage\ERROR, and TYPO3\CMS\Backend\Module\BaseScriptClass\getLanguageService().

Referenced by TYPO3\CMS\Backend\Module\BaseScriptClass\getExtObjContent().

◆ extObjHeader()

TYPO3\CMS\Backend\Module\BaseScriptClass::extObjHeader ( )

Calls the 'header' function inside the "Function menu module" if present. A header function might be needed to add JavaScript or other stuff in the head. This can't be done in the main function because the head is already written.

Definition at line 314 of file BaseScriptClass.php.

◆ getBackendUser()

BackendUserAuthentication TYPO3\CMS\Backend\Module\BaseScriptClass::getBackendUser ( )
protected

Returns the Backend User

Returns
‪BackendUserAuthentication

Definition at line 374 of file BaseScriptClass.php.

References $GLOBALS.

Referenced by TYPO3\CMS\Backend\Module\BaseScriptClass\init(), and TYPO3\CMS\Backend\Module\BaseScriptClass\mergeExternalItems().

◆ getExternalItemConfig()

mixed TYPO3\CMS\Backend\Module\BaseScriptClass::getExternalItemConfig (   $modName,
  $menuKey,
  $value = '' 
)

Returns configuration values from the global variable $TBE_MODULES_EXT for the module given. For example if the module is named "web_info" and the "function" key ($menuKey) of MOD_SETTINGS is "stat" ($value) then you will have the values of $TBE_MODULES_EXT['webinfo']['MOD_MENU']['function']['stat'] returned.

Parameters
string$modNameModule name
string$menuKey‪Menu key, eg. "function" for the function menu. See $this->MOD_MENU
string$value‪Optionally the value-key to fetch from the array that would otherwise have been returned if this value was not set. Look source...
Returns
‪mixed The value from the TBE_MODULES_EXT array.
See also
handleExternalFunctionValue()

Definition at line 274 of file BaseScriptClass.php.

References $GLOBALS.

Referenced by TYPO3\CMS\Backend\Module\BaseScriptClass\handleExternalFunctionValue().

◆ getExtObjContent()

string TYPO3\CMS\Backend\Module\BaseScriptClass::getExtObjContent ( )

Return the content of the 'main' function inside the "Function menu module" if present

Returns
‪string

Definition at line 351 of file BaseScriptClass.php.

References TYPO3\CMS\Backend\Module\BaseScriptClass\$content, and TYPO3\CMS\Backend\Module\BaseScriptClass\extObjContent().

◆ getLanguageService()

LanguageService TYPO3\CMS\Backend\Module\BaseScriptClass::getLanguageService ( )
protected

Returns the Language Service

Returns
‪LanguageService

Definition at line 365 of file BaseScriptClass.php.

References $GLOBALS.

Referenced by TYPO3\CMS\Backend\Module\BaseScriptClass\extObjContent(), and TYPO3\CMS\Backend\Module\BaseScriptClass\mergeExternalItems().

◆ getPageRenderer()

PageRenderer TYPO3\CMS\Backend\Module\BaseScriptClass::getPageRenderer ( )
protected
Returns
‪PageRenderer

Definition at line 382 of file BaseScriptClass.php.

References TYPO3\CMS\Backend\Module\BaseScriptClass\$pageRenderer.

◆ handleExternalFunctionValue()

TYPO3\CMS\Backend\Module\BaseScriptClass::handleExternalFunctionValue (   $MM_key = 'function',
  $MS_value = null 
)

Loads $this->extClassConf with the configuration for the CURRENT function of the menu.

Parameters
string$MM_key‪The key to MOD_MENU for which to fetch configuration. 'function' is default since it is first and foremost used to get information per "extension object" (I think that is what its called)
string$MS_value‪The value-key to fetch from the config array. If NULL (default) MOD_SETTINGS[$MM_key] will be used. This is useful if you want to force another function than the one defined in MOD_SETTINGS[function]. Call this in init() function of your Script Class: handleExternalFunctionValue('function', $forcedSubModKey)
See also
getExternalItemConfig(), init()

Definition at line 256 of file BaseScriptClass.php.

References TYPO3\CMS\Backend\Module\BaseScriptClass\getExternalItemConfig().

Referenced by TYPO3\CMS\Backend\Module\BaseScriptClass\init().

◆ init()

◆ menuConfig()

TYPO3\CMS\Backend\Module\BaseScriptClass::menuConfig ( )

Initializes the internal MOD_MENU array setting and unsetting items based on various conditions. It also merges in external menu items from the global array TBE_MODULES_EXT (see mergeExternalItems()) Then MOD_SETTINGS array is cleaned up (see \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleData()) so it contains only valid values. It's also updated with any SET[] values submitted. Also loads the modTSconfig internal variable.

See also
init(), $MOD_MENU, $MOD_SETTINGS, \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleData(), mergeExternalItems()

Definition at line 212 of file BaseScriptClass.php.

References TYPO3\CMS\Backend\Utility\BackendUtility\getModuleData(), TYPO3\CMS\Backend\Utility\BackendUtility\getPagesTSconfig(), and TYPO3\CMS\Backend\Module\BaseScriptClass\mergeExternalItems().

Referenced by TYPO3\CMS\Backend\Module\BaseScriptClass\init().

◆ mergeExternalItems()

array TYPO3\CMS\Backend\Module\BaseScriptClass::mergeExternalItems (   $modName,
  $menuKey,
  $menuArr 
)

Merges menu items from global array $TBE_MODULES_EXT

Parameters
string$modNameModule name for which to find value
string$menuKey‪Menu key, eg. 'function' for the function menu.
array$menuArr‪The part of a MOD_MENU array to work on.
Returns
‪array Modified array part.
See also
‪\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::insertModuleFunction(), menuConfig()

Definition at line 236 of file BaseScriptClass.php.

References $GLOBALS, TYPO3\CMS\Backend\Module\BaseScriptClass\getBackendUser(), TYPO3\CMS\Backend\Module\BaseScriptClass\getLanguageService(), and TYPO3\CMS\Core\Localization\LanguageService\sL().

Referenced by TYPO3\CMS\Backend\Module\BaseScriptClass\menuConfig().

Member Data Documentation

◆ $CMD

mixed TYPO3\CMS\Backend\Module\BaseScriptClass::$CMD

The value of GET/POST var, 'CMD'

See also
init()

Definition at line 92 of file BaseScriptClass.php.

◆ $content

string TYPO3\CMS\Backend\Module\BaseScriptClass::$content = ''

Generally used for accumulating the output content of backend modules

Definition at line 159 of file BaseScriptClass.php.

Referenced by TYPO3\CMS\Backend\Module\BaseScriptClass\getExtObjContent().

◆ $doc

TYPO3 CMS Backend Template DocumentTemplate TYPO3\CMS\Backend\Module\BaseScriptClass::$doc

Definition at line 163 of file BaseScriptClass.php.

◆ $extClassConf

array TYPO3\CMS\Backend\Module\BaseScriptClass::$extClassConf

Contains module configuration parts from TBE_MODULES_EXT if found

See also
handleExternalFunctionValue()

Definition at line 153 of file BaseScriptClass.php.

◆ $extObj

AbstractFunctionModule TYPO3\CMS\Backend\Module\BaseScriptClass::$extObj

May contain an instance of a 'Function menu module' which connects to this backend module.

See also
checkExtObj()

Definition at line 170 of file BaseScriptClass.php.

◆ $id

int TYPO3\CMS\Backend\Module\BaseScriptClass::$id

The integer value of the GET/POST var, 'id'. Used for submodules to the 'Web' module (page id)

See also
init()

Definition at line 85 of file BaseScriptClass.php.

◆ $MCONF

array TYPO3\CMS\Backend\Module\BaseScriptClass::$MCONF = array( )

Loaded with the global array $MCONF which holds some module configuration from the conf.php file of backend modules.

See also
init()

Definition at line 78 of file BaseScriptClass.php.

◆ $MOD_MENU

array TYPO3\CMS\Backend\Module\BaseScriptClass::$MOD_MENU
Initial value:
= array(
'function' => []
)

The module menu items array. Each key represents a key for which values can range between the items in the array of that key.

See also
init()

Definition at line 106 of file BaseScriptClass.php.

◆ $MOD_SETTINGS

array TYPO3\CMS\Backend\Module\BaseScriptClass::$MOD_SETTINGS = array( )

Current settings for the keys of the MOD_MENU array

See also
$MOD_MENU

Definition at line 115 of file BaseScriptClass.php.

◆ $modMenu_dontValidateList

string TYPO3\CMS\Backend\Module\BaseScriptClass::$modMenu_dontValidateList = ''

dontValidateList can be used to list variables that should not be checked if their value is found in the MOD_MENU array. Used for dynamically generated menus. Can be set from extension classes of this class before the init() function is called.

See also
menuConfig(), \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleData()

Definition at line 138 of file BaseScriptClass.php.

◆ $modMenu_setDefaultList

string TYPO3\CMS\Backend\Module\BaseScriptClass::$modMenu_setDefaultList = ''

List of default values from $MOD_MENU to set in the output array (only if the values from MOD_MENU are not arrays) Can be set from extension classes of this class before the init() function is called.

See also
menuConfig(), \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleData()

Definition at line 146 of file BaseScriptClass.php.

◆ $modMenu_type

string TYPO3\CMS\Backend\Module\BaseScriptClass::$modMenu_type = ''

If type is 'ses' then the data is stored as session-lasting data. This means that it'll be wiped out the next time the user logs in. Can be set from extension classes of this class before the init() function is called.

See also
menuConfig(), \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleData()

Definition at line 130 of file BaseScriptClass.php.

◆ $modTSconfig

array TYPO3\CMS\Backend\Module\BaseScriptClass::$modTSconfig

Module TSconfig based on PAGE TSconfig / USER TSconfig

See also
menuConfig()

Definition at line 122 of file BaseScriptClass.php.

◆ $pageRenderer

PageRenderer TYPO3\CMS\Backend\Module\BaseScriptClass::$pageRenderer
protected

◆ $perms_clause

string TYPO3\CMS\Backend\Module\BaseScriptClass::$perms_clause

A WHERE clause for selection records from the pages table based on read-permissions of the current backend user.

See also
init()

Definition at line 99 of file BaseScriptClass.php.