2 namespace TYPO3\CMS\Install\Controller\Action\Tool;
17 use TYPO3\CMS\Install\Controller\Action;
35 'syslogErrorReporting',
36 'belogErrorReporting',
46 if (isset($this->postValues[
'set'][
'write'])) {
47 $this->view->assign(
'configurationValuesSaved',
true);
48 $this->view->assign(
'savedConfigurationValueMessages', $this->updateLocalConfigurationValues());
54 return $this->view->render();
67 'EXT' =>
'Extension Installation',
69 'GFX' =>
'Image Processing',
70 'HTTP' =>
'Connection',
84 $typo3ConfVars = array_keys(
$GLOBALS[
'TYPO3_CONF_VARS']);
86 $commentArray = $this->getDefaultConfigArrayComments();
87 foreach ($typo3ConfVars as $sectionName) {
88 $data[$sectionName] = array();
90 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][$sectionName] as $key => $value) {
91 if (isset(
$GLOBALS[
'TYPO3_CONF_VARS_extensionAdded'][$sectionName][$key])) {
94 $potentialValue = str_replace(array(
'\' . LF . \
'',
'\' . LF . \
''), array(LF, LF), $value);
95 while (preg_match(
'/' . preg_quote(
$GLOBALS[
'TYPO3_CONF_VARS_extensionAdded'][$sectionName][$key],
'/') .
'$/', $potentialValue)) {
96 $potentialValue = preg_replace(
'/' . preg_quote(
$GLOBALS[
'TYPO3_CONF_VARS_extensionAdded'][$sectionName][$key],
'/') .
'$/',
'', $potentialValue);
98 $value = $potentialValue;
101 $description = trim($commentArray[$sectionName][$key]);
102 $isTextarea = (bool)preg_match(
'/^(<.*?>)?string \\(textarea\\)/i', $description);
103 $doNotRender = (bool)preg_match(
'/^(<.*?>)?string \\(exclude\\)/i', $description);
105 if (!is_array($value) && !$doNotRender && (!preg_match(
'/[' . LF . CR .
']/', $value) || $isTextarea)) {
107 $itemData[
'key'] = $key;
108 $itemData[
'description'] = $description;
110 $itemData[
'type'] =
'textarea';
111 $itemData[
'value'] = str_replace(array(
'\' . LF . \
'',
'\' . LF . \
''), array(LF, LF), $value);
112 }
elseif (preg_match(
'/^(<.*?>)?boolean/i', $description)) {
113 $itemData[
'type'] =
'checkbox';
114 $itemData[
'value'] = $value ?
'1' :
'0';
115 $itemData[
'checked'] = (bool)$value;
117 $itemData[
'type'] =
'input';
118 $itemData[
'value'] = $value;
122 if ($sectionName ===
'SYS' && in_array($key, $this->phpErrorCodesSettings)) {
123 $itemData[
'phpErrorCode'] =
true;
126 $data[$sectionName][] = $itemData;
138 protected function updateLocalConfigurationValues()
140 $statusObjects = array();
141 if (isset($this->postValues[
'values']) && is_array($this->postValues[
'values'])) {
142 $configurationPathValuePairs = array();
143 $commentArray = $this->getDefaultConfigArrayComments();
144 $formValues = $this->postValues[
'values'];
145 foreach ($formValues as $section => $valueArray) {
146 if (is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][$section])) {
147 foreach ($valueArray as $valueKey => $value) {
148 if (isset(
$GLOBALS[
'TYPO3_CONF_VARS'][$section][$valueKey])) {
149 $description = trim($commentArray[$section][$valueKey]);
150 if (preg_match(
'/^string \\(textarea\\)/i', $description)) {
152 $value = str_replace(CR,
'', $value);
154 $value = str_replace(LF,
'\' . LF . \
'', $value);
156 if (preg_match(
'/^boolean/i', $description)) {
160 if (
$GLOBALS[
'TYPO3_CONF_VARS'][$section][$valueKey] ===
false && $value ===
'0') {
162 }
elseif (
$GLOBALS[
'TYPO3_CONF_VARS'][$section][$valueKey] ===
true && $value ===
'1') {
167 if ((
string)
$GLOBALS[
'TYPO3_CONF_VARS'][$section][$valueKey] !== (
string)$value) {
168 $configurationPathValuePairs[$section .
'/' . $valueKey] = $value;
170 $status = $this->objectManager->get(\TYPO3\CMS\Install\Status\OkStatus::class);
171 $status->setTitle(
'$GLOBALS[\'TYPO3_CONF_VARS\'][\'' . $section .
'\'][\
'' . $valueKey .
'\']
');
172 $status->setMessage('New value =
' . $value);
173 $statusObjects[] = $status;
179 if (!empty($statusObjects)) {
181 $configurationManager = $this->objectManager->get(\TYPO3\CMS\Core\Configuration\ConfigurationManager::class);
182 $configurationManager->setLocalConfigurationValuesByPathValuePairs($configurationPathValuePairs);
185 return $statusObjects;
193 protected function getDefaultConfigArrayComments()
196 $configurationManager = $this->objectManager->get(\TYPO3\CMS\Core\Configuration\ConfigurationManager::class);
197 $string = GeneralUtility::getUrl($configurationManager->getDefaultConfigurationFileLocation());
199 $commentArray = array();
200 $lines = explode(LF, $string);
203 foreach ($lines as $lc) {
209 if (preg_match('/[
"\']([[:alnum:]_-]*)["\
'][[:space:]]*=>(.*)/i', $lc, $reg)) {
210 preg_match(
'/,[\\t\\s]*\\/\\/(.*)/i', $reg[2], $creg);
211 $theComment = trim($creg[1]);
212 if (substr(strtolower(trim($reg[2])), 0, 5) ==
'array' && $reg[1] === strtoupper($reg[1])) {
213 $mainKey = trim($reg[1]);
215 $commentArray[$mainKey][$reg[1]] = $theComment;
220 if ($lc ===
'return array(') {
224 return $commentArray;