TYPO3  7.6
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
BaseScriptClass Class Reference
Inheritance diagram for BaseScriptClass:
ModuleController PageFunctionsController ImportExportController InfoModuleController ConfigurationView DatabaseIntegrityView SchedulerModuleController TaskModuleController TypoScriptTemplateModuleController VersionModuleController

Public Member Functions

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

Public Attributes

 $MCONF = array()
 
 $id
 
 $CMD
 
 $perms_clause
 
 $MOD_MENU
 
 $MOD_SETTINGS = array()
 
 $modTSconfig
 
 $modMenu_type = ''
 
 $modMenu_dontValidateList = ''
 
 $modMenu_setDefaultList = ''
 
 $extClassConf
 
 $content = ''
 
 $doc
 
 $extObj
 

Protected Member Functions

 getLanguageService ()
 
 getBackendUser ()
 
 getDatabaseConnection ()
 
 getPageRenderer ()
 

Protected Attributes

 $pageRenderer = null
 

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 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 with a main() and printContent() function:

namespace Vendor;

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

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 = ::makeInstance(::class); TYPICALLY THE INTERNAL VAR, $this->backPath is set like this: $this->backPath = $this->doc->backPath = $GLOBALS['BACK_PATH']; ... AND OF COURSE A LOT OF OTHER THINGS GOES ON - LIKE PUTTING CONTENT INTO $this->content $this->content=''; } PRINT CONTENT - DONE AS THE LAST THING public function printContent() { echo $this->content; }

MAKE INSTANCE OF THE SCRIPT CLASS AND CALL init() $GLOBALS['SOBE'] = ::makeInstance(::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(); FINALLY THE printContent() FUNCTION WILL OUTPUT THE ACCUMULATED CONTENT $GLOBALS['SOBE']->printContent();

Definition at line 76 of file BaseScriptClass.php.

Member Function Documentation

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.

Returns
void
See Also
handleExternalFunctionValue(), ::insertModuleFunction(), $extObj

Definition at line 298 of file BaseScriptClass.php.

References GeneralUtility\_GP(), BackendUtility\getModuleData(), and GeneralUtility\makeInstance().

Referenced by PageFunctionsController\mainAction(), InfoModuleController\mainAction(), and TypoScriptTemplateModuleController\mainAction().

checkSubExtObj ( )

Calls the checkExtObj function in sub module if present.

Returns
void

Definition at line 313 of file BaseScriptClass.php.

Referenced by PageFunctionsController\mainAction(), and InfoModuleController\mainAction().

extObjContent ( )

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

Returns
void

Definition at line 340 of file BaseScriptClass.php.

References AbstractMessage\ERROR, BaseScriptClass\getLanguageService(), and GeneralUtility\makeInstance().

Referenced by InfoModuleController\main(), and PageFunctionsController\main().

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. example call in the header function: $this->pObj->doc->JScode = $this->pObj->doc->wrapScriptTags(' ...

Returns
void

Definition at line 328 of file BaseScriptClass.php.

getBackendUser ( )
protected

Returns the Backend User

Returns
BackendUserAuthentication

Definition at line 371 of file BaseScriptClass.php.

References $GLOBALS.

Referenced by TypoScriptTemplateModuleController\init(), BaseScriptClass\init(), and BaseScriptClass\mergeExternalItems().

getDatabaseConnection ( )
protected
Returns
DatabaseConnection

Definition at line 379 of file BaseScriptClass.php.

References $GLOBALS.

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$menuKeyMenu key, eg. "function" for the function menu. See $this->MOD_MENU
string$valueOptionally 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 281 of file BaseScriptClass.php.

References $GLOBALS.

Referenced by BaseScriptClass\handleExternalFunctionValue().

getLanguageService ( )
protected
getPageRenderer ( )
protected
handleExternalFunctionValue (   $MM_key = 'function',
  $MS_value = null 
)

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

Parameters
string$MM_keyThe 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_valueThe 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)
Returns
void
See Also
getExternalItemConfig(), init()

Definition at line 263 of file BaseScriptClass.php.

References BaseScriptClass\getExternalItemConfig().

Referenced by BaseScriptClass\init().

init ( )

Initializes the backend module by setting internal variables, initializing the menu.

Returns
void
See Also
menuConfig()

Definition at line 202 of file BaseScriptClass.php.

References $GLOBALS, GeneralUtility\_GP(), BaseScriptClass\getBackendUser(), BaseScriptClass\handleExternalFunctionValue(), and BaseScriptClass\menuConfig().

Referenced by PageFunctionsController\mainAction(), InfoModuleController\mainAction(), and VersionModuleController\mainAction().

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 ::getModuleData()) so it contains only valid values. It's also updated with any SET[] values submitted. Also loads the modTSconfig internal variable.

Returns
void
See Also
init(), $MOD_MENU, $MOD_SETTINGS, ::getModuleData(), mergeExternalItems()

Definition at line 223 of file BaseScriptClass.php.

References GeneralUtility\_GP(), BackendUtility\getModTSconfig(), BackendUtility\getModuleData(), BaseScriptClass\mergeExternalItems(), and BackendUtility\unsetMenuItems().

Referenced by BaseScriptClass\init().

mergeExternalItems (   $modName,
  $menuKey,
  $menuArr 
)

Merges menu items from global array $TBE_MODULES_EXT

Parameters
string$modNameModule name for which to find value
string$menuKeyMenu key, eg. 'function' for the function menu.
array$menuArrThe part of a MOD_MENU array to work on.
Returns
array Modified array part. private
See Also
::insertModuleFunction(), menuConfig()

Definition at line 242 of file BaseScriptClass.php.

References $GLOBALS, BaseScriptClass\getBackendUser(), BaseScriptClass\getLanguageService(), and GeneralUtility\inList().

Referenced by TaskModuleController\menuConfig(), and BaseScriptClass\menuConfig().

Member Data Documentation

$CMD

Definition at line 100 of file BaseScriptClass.php.

$content = ''
$doc

Definition at line 181 of file BaseScriptClass.php.

$extClassConf

Definition at line 169 of file BaseScriptClass.php.

$extObj

Definition at line 189 of file BaseScriptClass.php.

$id

Definition at line 92 of file BaseScriptClass.php.

Referenced by TaskModuleController\renderListMenu().

$MCONF = array()

Definition at line 84 of file BaseScriptClass.php.

$MOD_MENU
Initial value:
= array(
'function' => array()
)

Definition at line 116 of file BaseScriptClass.php.

$MOD_SETTINGS = array()

Definition at line 126 of file BaseScriptClass.php.

$modMenu_dontValidateList = ''

Definition at line 152 of file BaseScriptClass.php.

$modMenu_setDefaultList = ''

Definition at line 161 of file BaseScriptClass.php.

$modMenu_type = ''

Definition at line 143 of file BaseScriptClass.php.

$modTSconfig

Definition at line 134 of file BaseScriptClass.php.

$pageRenderer = null
protected
$perms_clause

Definition at line 108 of file BaseScriptClass.php.