2 namespace TYPO3\CMS\Backend;
137 $this->type =
'perm';
139 if (!empty(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_modSettings.php'][
'writeDevLog'])) {
140 $this->writeDevLog =
true;
143 $this->writeDevLog =
true;
171 $this->storeList = array();
184 $this->storeList = array_merge($this->storeList,
$storeList);
185 if ($this->writeDevLog) {
200 foreach ($this->
getModule()->MOD_SETTINGS as $key => $value) {
201 if (preg_match(
'/^' .
$prefix .
'/', $key)) {
202 $this->storeList[$key] = $key;
205 unset($this->storeList[$this->prefix .
'_storedSettings']);
206 if ($this->writeDevLog) {
238 if (!is_array($sdArr)) {
240 }
elseif (!is_array($sdArr[
'data'])) {
242 }
elseif (!trim($sdArr[
'title'])) {
258 $storageData = array();
259 foreach ($this->storeList as $MS_key) {
260 $storageData[$MS_key] = $this->
getModule()->MOD_SETTINGS[$MS_key];
263 'title' => $data[
'title'],
264 'desc' => (
string)$data[
'desc'],
265 'data' => $storageData,
282 if ($this->storedSettings[$storeIndex]) {
283 foreach ($this->storeList as $k) {
284 $writeArray[$k] = $this->storedSettings[$storeIndex][
'data'][$k];
300 $storeIndex = $storeControl[
'STORE'];
302 $saveSettings =
false;
303 $writeArray = array();
304 if (is_array($storeControl)) {
305 if ($this->writeDevLog) {
309 if ($storeControl[
'LOAD'] && $storeIndex) {
310 $writeArray = $this->
getStoredData($storeIndex, $writeArray);
311 $saveSettings =
true;
312 $msg =
'\'' . $this->storedSettings[$storeIndex][
'title'] .
'\' preset loaded!
';
313 } elseif ($storeControl['SAVE
']) {
314 if (trim($storeControl['title
'])) {
315 // Get the data to store
316 $newEntry = $this->compileEntry($storeControl);
317 // Create an index for the storage array
319 $storeIndex = GeneralUtility::shortMD5($newEntry['title
']);
321 // Add data to the storage array
322 $this->storedSettings[$storeIndex] = $newEntry;
323 $saveSettings = true;
324 $msg = '\
'' . $newEntry[
'title'] .
'\' preset saved!
';
326 $msg = 'Please enter a name
for the preset!
';
328 } elseif ($storeControl['REMOVE
'] and $storeIndex) {
330 $msg = '\
'' . $this->storedSettings[$storeIndex][
'title'] .
'\' preset entry removed!
';
331 unset($this->storedSettings[$storeIndex]);
332 $saveSettings = true;
336 $this->writeStoredSetting($writeArray, $mconfName);
349 public function writeStoredSetting($writeArray = array(), $mconfName = '')
351 // Making sure, index 0 is not set
352 unset($this->storedSettings[0]);
353 $this->storedSettings = $this->cleanupStorageArray($this->storedSettings);
354 $writeArray[$this->prefix . '_storedSettings
'] = serialize($this->storedSettings);
355 $this->getModule()->MOD_SETTINGS = Utility\BackendUtility::getModuleData(
356 $this->getModule()->MOD_MENU,
358 $mconfName ?: $this->getModule()->MCONF['name
'],
361 if ($this->writeDevLog) {
362 GeneralUtility::devLog('Settings stored:
' . $this->msg, __CLASS__, 0);
366 /********************************
370 ********************************/
378 public function getStoreControl($showElements = 'load,
remove,save
', $useOwnForm = true)
380 $showElements = GeneralUtility::trimExplode(',
', $showElements, true);
381 $this->initStorage();
384 $opt[] = '<option value=
"0"> </option>
';
385 foreach ($this->storedSettings as $id => $v) {
386 $opt[] = '<option value=
"' . $id . '">
' . htmlspecialchars($v['title
']) . '</option>
';
388 $storedEntries = count($opt) > 1;
391 // LOAD, REMOVE, but also show selector so you can overwrite an entry with SAVE
392 if ($storedEntries && !empty($showElements)) {
394 $onChange = 'document.forms[
' . GeneralUtility::quoteJSvalue($this->formName) . '][\
'storeControl[title]\'].value= this.options[this.selectedIndex].value!=0 ? this.options[this.selectedIndex].text : \'\';';
396 <select name="storeControl[STORE]" onChange="' . htmlspecialchars($onChange) .
'">
401 if (in_array(
'load', $showElements)) {
403 <input class="btn btn-default" type="submit" name="storeControl[LOAD]" value="Load" /> ';
406 if (in_array(
'remove', $showElements)) {
408 <input class="btn btn-default" type="submit" name="storeControl[REMOVE]" value="Remove" /> ';
410 $codeTD[] =
'<td width="1%">Preset:</td>';
411 $codeTD[] =
'<td nowrap="nowrap">' . $code .
' </td>';
414 if (in_array(
'save', $showElements)) {
415 $onClick = !$storedEntries ?
'' :
'if (document.forms[' .
GeneralUtility::quoteJSvalue($this->formName) .
'][\'storeControl[STORE]\'].options[document.forms[' .
GeneralUtility::quoteJSvalue($this->formName) .
'][\'storeControl[STORE]\'].selectedIndex].value<0) return confirm(\'Are you sure you want to overwrite the existing entry?\');';
416 $code =
'<input name="storeControl[title]" value="" type="text" max="80" width="25"> ';
417 $code .=
'<input class="btn btn-default" type="submit" name="storeControl[SAVE]" value="Save" onClick="' . htmlspecialchars($onClick) .
'" />';
418 $codeTD[] =
'<td nowrap="nowrap">' . $code .
'</td>';
427 <table border="0" cellpadding="3" cellspacing="0" width="100%">
428 <tr class="bgColor4">
436 <div><strong>' . htmlspecialchars($this->msg) .
'</strong></div>';
438 if ($useOwnForm && trim($code)) {
440 <form action="' .
GeneralUtility::getIndpEnv(
'SCRIPT_NAME') .
'" method="post" name="' . $this->formName .
'" enctype="multipart/form-data">' . $code .
'</form>';