TYPO3 CMS  TYPO3_7-6
TYPO3\CMS\Backend\ModuleSettings Class Reference

Public Member Functions

 __construct ()
 
 init ($prefix='', $storeList='')
 
 setSessionType ($type='ses')
 
 setStoreList ($storeList)
 
 addToStoreList ($storeList)
 
 addToStoreListFromPrefix ($prefix='')
 
 initStorage ()
 
 cleanupStorageArray ($storedSettings)
 
 compileEntry ($data)
 
 getStoredData ($storeIndex, $writeArray=[])
 
 processStoreControl ($mconfName='')
 
 writeStoredSetting ($writeArray=[], $mconfName='')
 
 getStoreControl ($showElements='load, remove, save', $useOwnForm=true)
 
 processEntry ($storageArr)
 

Public Attributes

 $type = 'perm'
 
 $prefix = ''
 
 $storeList = []
 
 $storedSettings = []
 
 $msg = ''
 
 $formName = 'storeControl'
 
 $writeDevLog = false
 

Protected Member Functions

 getModule ()
 

Detailed Description

Manage storing and restoring of $this->getModule()->MOD_SETTINGS settings. Provides a presets box for BE modules.

usage inside of BaseScriptClass class

....

$this->MOD_MENU = array( 'function' => array('xxx'), 'tx_someext_storedSettings' => '',

....

function main() { // reStore settings $store = ::makeInstance(::class); $store->init('tx_someext'); $store->setStoreList('tx_someext'); $store->processStoreControl();

// show control panel $this->content .= '

Settings

' . '

' . $store->getStoreControl() . '

';

Format of saved settings

$this->getModule()->MOD_SETTINGS[$this->prefix . '_storedSettings'] = serialize( array ( 'any id' => array( 'title' => 'title for saved settings', 'desc' => 'description text, not mandatory', 'data' => array(), // data from MOD_SETTINGS 'user' => NULL, // can be used for extra data used by the application to identify this entry 'tstamp' => 12345, // $GLOBALS['EXEC_TIME'] ), 'another id' => ... )

Deprecated:
since TYPO3 CMS 7, will be removed with TYPO3 CMS 8.

Definition at line 60 of file ModuleSettings.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Backend\ModuleSettings::__construct ( )

Default constructor

Definition at line 121 of file ModuleSettings.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\deprecationLog().

Member Function Documentation

◆ addToStoreList()

TYPO3\CMS\Backend\ModuleSettings::addToStoreList (   $storeList)

Add MOD_SETTINGS keys to the current list

Parameters
array | string$storeListAdd names of keys of the MOD_SETTING array which should be stored
Returns
void

Definition at line 181 of file ModuleSettings.php.

References TYPO3\CMS\Backend\ModuleSettings\$storeList, TYPO3\CMS\Core\Utility\GeneralUtility\devLog(), and TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode().

Referenced by TYPO3\CMS\Backend\ModuleSettings\setStoreList().

◆ addToStoreListFromPrefix()

TYPO3\CMS\Backend\ModuleSettings::addToStoreListFromPrefix (   $prefix = '')

Add names of keys of the MOD_SETTING array by a prefix

Parameters
string$prefixPrefix of MOD_SETTING array keys that should be stored
Returns
void

Definition at line 196 of file ModuleSettings.php.

References TYPO3\CMS\Backend\ModuleSettings\$prefix, TYPO3\CMS\Core\Utility\GeneralUtility\devLog(), and TYPO3\CMS\Backend\ModuleSettings\getModule().

◆ cleanupStorageArray()

TYPO3\CMS\Backend\ModuleSettings::cleanupStorageArray (   $storedSettings)

Remove corrupted data entries from the stored settings array

Parameters
array$storedSettingsThe stored settings
Returns
array Cleaned up stored settings

Definition at line 233 of file ModuleSettings.php.

References TYPO3\CMS\Backend\ModuleSettings\$storedSettings.

Referenced by TYPO3\CMS\Backend\ModuleSettings\initStorage().

◆ compileEntry()

TYPO3\CMS\Backend\ModuleSettings::compileEntry (   $data)

Creates an entry for the stored settings array Collects data from MOD_SETTINGS selected by the storeList

Parameters
array$dataShould work with data from _GP('storeControl'). This is ['title']: Title for the entry. ['desc']: A description text. Currently not used by this class
Returns
array Entry for the stored settings array

Definition at line 256 of file ModuleSettings.php.

References $GLOBALS, TYPO3\CMS\Backend\ModuleSettings\getModule(), and TYPO3\CMS\Backend\ModuleSettings\processEntry().

◆ getModule()

TYPO3\CMS\Backend\ModuleSettings::getModule ( )
protected

◆ getStoreControl()

TYPO3\CMS\Backend\ModuleSettings::getStoreControl (   $showElements = 'load,
remove  ,
save'  ,
  $useOwnForm = true 
)

Returns the storage control box

Parameters
string$showElementsList of elemetns which should be shown: load,remove,save
bool$useOwnFormIf set the box is wrapped with own form tag
Returns
string HTML code

Definition at line 378 of file ModuleSettings.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\getIndpEnv(), and TYPO3\CMS\Core\Utility\GeneralUtility\quoteJSvalue().

◆ getStoredData()

TYPO3\CMS\Backend\ModuleSettings::getStoredData (   $storeIndex,
  $writeArray = [] 
)

Copies the stored data from entry $index to $writeArray which can be used to set MOD_SETTINGS

Parameters
mixed$storeIndexThe entry key
array$writeArrayPreset data array. Will be overwritten by copied values.
Returns
array Data array

Definition at line 280 of file ModuleSettings.php.

Referenced by TYPO3\CMS\Backend\ModuleSettings\processStoreControl().

◆ init()

TYPO3\CMS\Backend\ModuleSettings::init (   $prefix = '',
  $storeList = '' 
)

Initializes the object

Parameters
string$prefixPrefix of MOD_SETTING array keys that should be stored
array | string$storeListAdditional names of keys of the MOD_SETTING array which should be stored (array or comma list)
Returns
void

Definition at line 133 of file ModuleSettings.php.

References $GLOBALS, TYPO3\CMS\Backend\ModuleSettings\$prefix, TYPO3\CMS\Backend\ModuleSettings\$storeList, and TYPO3\CMS\Backend\ModuleSettings\setStoreList().

◆ initStorage()

TYPO3\CMS\Backend\ModuleSettings::initStorage ( )

Get the stored settings from MOD_SETTINGS and set them in $this->storedSettings

Returns
void

Definition at line 221 of file ModuleSettings.php.

References TYPO3\CMS\Backend\ModuleSettings\$storedSettings, TYPO3\CMS\Backend\ModuleSettings\cleanupStorageArray(), and TYPO3\CMS\Backend\ModuleSettings\getModule().

Referenced by TYPO3\CMS\Backend\ModuleSettings\processStoreControl().

◆ processEntry()

TYPO3\CMS\Backend\ModuleSettings::processEntry (   $storageArr)

Processing entry for the stored settings array Can be overwritten by extended class

Parameters
array$storageArrEntry for the stored settings array
Returns
array Entry for the stored settings array

Definition at line 457 of file ModuleSettings.php.

Referenced by TYPO3\CMS\Backend\ModuleSettings\compileEntry().

◆ processStoreControl()

TYPO3\CMS\Backend\ModuleSettings::processStoreControl (   $mconfName = '')

Processing of the storage command LOAD, SAVE, REMOVE

Parameters
string$mconfNameName of the module to store the settings for. Default: $this->getModule()->MCONF['name'] (current module)
Returns
string Storage message. Also set in $this->msg

Definition at line 296 of file ModuleSettings.php.

References TYPO3\CMS\Backend\ModuleSettings\$msg, TYPO3\CMS\Core\Utility\GeneralUtility\_GP(), TYPO3\CMS\Core\Utility\GeneralUtility\arrayToLogString(), TYPO3\CMS\Core\Utility\GeneralUtility\devLog(), TYPO3\CMS\Backend\ModuleSettings\getStoredData(), and TYPO3\CMS\Backend\ModuleSettings\initStorage().

◆ setSessionType()

TYPO3\CMS\Backend\ModuleSettings::setSessionType (   $type = 'ses')

Set session type to 'ses' which will store the settings data not permanently.

Parameters
string$typeDefault is 'ses'
Returns
void

Definition at line 153 of file ModuleSettings.php.

References TYPO3\CMS\Backend\ModuleSettings\$type.

◆ setStoreList()

TYPO3\CMS\Backend\ModuleSettings::setStoreList (   $storeList)

Set MOD_SETTINGS keys which should be stored

Parameters
array | string$storeListAdd names of keys of the MOD_SETTING array which should be stored
Returns
void

Definition at line 169 of file ModuleSettings.php.

References TYPO3\CMS\Backend\ModuleSettings\$storeList, and TYPO3\CMS\Backend\ModuleSettings\addToStoreList().

Referenced by TYPO3\CMS\Backend\ModuleSettings\init().

◆ writeStoredSetting()

TYPO3\CMS\Backend\ModuleSettings::writeStoredSetting (   $writeArray = [],
  $mconfName = '' 
)

Write the current storage array and update MOD_SETTINGS

Parameters
array$writeArrayArray of settings which should be overwrite current MOD_SETTINGS
string$mconfNameName of the module to store the settings for. Default: $this->getModule()->MCONF['name'] (current module)
Returns
void

Definition at line 349 of file ModuleSettings.php.

Member Data Documentation

◆ $formName

TYPO3\CMS\Backend\ModuleSettings::$formName = 'storeControl'

Definition at line 103 of file ModuleSettings.php.

◆ $msg

TYPO3\CMS\Backend\ModuleSettings::$msg = ''

◆ $prefix

TYPO3\CMS\Backend\ModuleSettings::$prefix = ''

◆ $storedSettings

TYPO3\CMS\Backend\ModuleSettings::$storedSettings = []

◆ $storeList

TYPO3\CMS\Backend\ModuleSettings::$storeList = []

◆ $type

TYPO3\CMS\Backend\ModuleSettings::$type = 'perm'

Definition at line 68 of file ModuleSettings.php.

Referenced by TYPO3\CMS\Backend\ModuleSettings\setSessionType().

◆ $writeDevLog

TYPO3\CMS\Backend\ModuleSettings::$writeDevLog = false

Definition at line 110 of file ModuleSettings.php.