TYPO3  7.6
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
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=array())
 
 processStoreControl ($mconfName= '')
 
 writeStoredSetting ($writeArray=array(), $mconfName= '')
 
 getStoreControl ($showElements= 'load, remove, save', $useOwnForm=true)
 
 processEntry ($storageArr)
 

Public Attributes

 $type = 'perm'
 
 $prefix = ''
 
 $storeList = array()
 
 $storedSettings = array()
 
 $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 ( )

Default constructor

Definition at line 121 of file ModuleSettings.php.

References GeneralUtility\deprecationLog().

Member Function Documentation

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 ModuleSettings\$storeList, GeneralUtility\devLog(), and GeneralUtility\trimExplode().

Referenced by ModuleSettings\setStoreList().

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 ModuleSettings\$prefix, GeneralUtility\devLog(), and ModuleSettings\getModule().

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 ModuleSettings\$storedSettings, and elseif.

Referenced by ModuleSettings\initStorage().

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, ModuleSettings\getModule(), and ModuleSettings\processEntry().

getModule ( )
protected
Returns
BaseScriptClass

Definition at line 465 of file ModuleSettings.php.

References $GLOBALS.

Referenced by ModuleSettings\addToStoreListFromPrefix(), ModuleSettings\compileEntry(), and ModuleSettings\initStorage().

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.

getStoredData (   $storeIndex,
  $writeArray = array() 
)

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 ModuleSettings\processStoreControl().

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, ModuleSettings\$prefix, ModuleSettings\$storeList, and ModuleSettings\setStoreList().

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 ModuleSettings\$storedSettings, ModuleSettings\cleanupStorageArray(), and ModuleSettings\getModule().

Referenced by ModuleSettings\processStoreControl().

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 ModuleSettings\compileEntry().

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 ModuleSettings\$msg, GeneralUtility\_GP(), GeneralUtility\arrayToLogString(), GeneralUtility\devLog(), ModuleSettings\getStoredData(), and ModuleSettings\initStorage().

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 ModuleSettings\$type.

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 ModuleSettings\$storeList, and ModuleSettings\addToStoreList().

Referenced by ModuleSettings\init().

writeStoredSetting (   $writeArray = array(),
  $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 = 'storeControl'

Definition at line 103 of file ModuleSettings.php.

$msg = ''

Definition at line 96 of file ModuleSettings.php.

Referenced by ModuleSettings\processStoreControl().

$prefix = ''
$storedSettings = array()
$storeList = array()
$type = 'perm'

Definition at line 68 of file ModuleSettings.php.

Referenced by ModuleSettings\setSessionType().

$writeDevLog = false

Definition at line 110 of file ModuleSettings.php.