TYPO3 CMS  TYPO3_6-2
AllConfiguration.php
Go to the documentation of this file.
1 <?php
3 
19 
24 
32  protected $phpErrorCodesSettings = array(
33  'errorHandlerErrors',
34  'exceptionalErrors',
35  'syslogErrorReporting',
36  'belogErrorReporting',
37  );
38 
44  protected function executeAction() {
45  if (isset($this->postValues['set']['write'])) {
46  $this->view->assign('configurationValuesSaved', TRUE);
47  $this->view->assign('savedConfigurationValueMessages', $this->updateLocalConfigurationValues());
48  } else {
49  $this->view->assign('data', $this->setUpConfigurationData());
50  }
51 
52  return $this->view->render();
53  }
54 
60  protected function setUpConfigurationData() {
61  $data = array();
62  $typo3ConfVars = array_keys($GLOBALS['TYPO3_CONF_VARS']);
63  sort($typo3ConfVars);
64  $commentArray = $this->getDefaultConfigArrayComments();
65  foreach ($typo3ConfVars as $sectionName) {
66  $data[$sectionName] = array();
67 
68  foreach ($GLOBALS['TYPO3_CONF_VARS'][$sectionName] as $key => $value) {
69  if (isset($GLOBALS['TYPO3_CONF_VARS_extensionAdded'][$sectionName][$key])) {
70  // Don't allow editing stuff which is added by extensions
71  // Make sure we fix potentially duplicated entries from older setups
72  $potentialValue = str_replace(array('\'.chr(10).\'', '\' . LF . \''), array(LF, LF), $value);
73  while (preg_match('/' . preg_quote($GLOBALS['TYPO3_CONF_VARS_extensionAdded'][$sectionName][$key], '/') . '$/', '', $potentialValue)) {
74  $potentialValue = preg_replace('/' . preg_quote($GLOBALS['TYPO3_CONF_VARS_extensionAdded'][$sectionName][$key], '/') . '$/', '', $potentialValue);
75  }
76  $value = $potentialValue;
77  }
78 
79  $description = trim($commentArray[$sectionName][$key]);
80  $isTextarea = preg_match('/^(<.*?>)?string \\(textarea\\)/i', $description) ? TRUE : FALSE;
81  $doNotRender = preg_match('/^(<.*?>)?string \\(exclude\\)/i', $description) ? TRUE : FALSE;
82 
83  if (!is_array($value) && !$doNotRender && (!preg_match('/[' . LF . CR . ']/', $value) || $isTextarea)) {
84  $itemData = array();
85  $itemData['key'] = $key;
86  $itemData['description'] = $description;
87  if ($isTextarea) {
88  $itemData['type'] = 'textarea';
89  $itemData['value'] = str_replace(array('\'.chr(10).\'', '\' . LF . \''), array(LF, LF), $value);
90  } elseif (preg_match('/^(<.*?>)?boolean/i', $description)) {
91  $itemData['type'] = 'checkbox';
92  $itemData['value'] = $value ? '1' : '0';
93  $itemData['checked'] = (boolean)$value;
94  } else {
95  $itemData['type'] = 'input';
96  $itemData['value'] = $value;
97  }
98 
99  // Check if the setting is a PHP error code, will trigger a view helper in fluid
100  if ($sectionName === 'SYS' && in_array($key, $this->phpErrorCodesSettings)) {
101  $itemData['phpErrorCode'] = TRUE;
102  }
103 
104  $data[$sectionName][] = $itemData;
105  }
106  }
107  }
108  return $data;
109  }
110 
116  protected function updateLocalConfigurationValues() {
117  $statusObjects = array();
118  if (isset($this->postValues['values']) && is_array($this->postValues['values'])) {
119  $configurationPathValuePairs = array();
120  $commentArray = $this->getDefaultConfigArrayComments();
121  $formValues = $this->postValues['values'];
122  foreach ($formValues as $section => $valueArray) {
123  if (is_array($GLOBALS['TYPO3_CONF_VARS'][$section])) {
124  foreach ($valueArray as $valueKey => $value) {
125  if (isset($GLOBALS['TYPO3_CONF_VARS'][$section][$valueKey])) {
126  $description = trim($commentArray[$section][$valueKey]);
127  if (preg_match('/^string \\(textarea\\)/i', $description)) {
128  // Force Unix linebreaks in textareas
129  $value = str_replace(CR, '', $value);
130  // Preserve linebreaks
131  $value = str_replace(LF, '\' . LF . \'', $value);
132  }
133  if (preg_match('/^boolean/i', $description)) {
134  // When submitting settings in the Install Tool, values that default to "FALSE" or "TRUE"
135  // in EXT:core/Configuration/DefaultConfiguration.php will be sent as "0" resp. "1".
136  // Therefore, reset the values to their boolean equivalent.
137  if ($GLOBALS['TYPO3_CONF_VARS'][$section][$valueKey] === FALSE && $value === '0') {
138  $value = FALSE;
139  } elseif ($GLOBALS['TYPO3_CONF_VARS'][$section][$valueKey] === TRUE && $value === '1') {
140  $value = TRUE;
141  }
142  }
143  // Save if value changed
144  if ((string)$GLOBALS['TYPO3_CONF_VARS'][$section][$valueKey] !== (string)$value) {
145  $configurationPathValuePairs[$section . '/' . $valueKey] = $value;
147  $status = $this->objectManager->get('TYPO3\\CMS\\Install\\Status\\OkStatus');
148  $status->setTitle('$TYPO3_CONF_VARS[\'' . $section . '\'][\'' . $valueKey . '\']');
149  $status->setMessage('New value = ' . $value);
150  $statusObjects[] = $status;
151  }
152  }
153  }
154  }
155  }
156  if (count($statusObjects)) {
158  $configurationManager = $this->objectManager->get('TYPO3\\CMS\\Core\\Configuration\\ConfigurationManager');
159  $configurationManager->setLocalConfigurationValuesByPathValuePairs($configurationPathValuePairs);
160  }
161  }
162  return $statusObjects;
163  }
164 
170  protected function getDefaultConfigArrayComments() {
172  $configurationManager = $this->objectManager->get('TYPO3\\CMS\\Core\\Configuration\\ConfigurationManager');
173  $string = GeneralUtility::getUrl($configurationManager->getDefaultConfigurationFileLocation());
174 
175  $commentArray = array();
176  $lines = explode(LF, $string);
177  $in = 0;
178  $mainKey = '';
179  foreach ($lines as $lc) {
180  $lc = trim($lc);
181  if ($in) {
182  if ($lc === ');') {
183  $in = 0;
184  } else {
185  if (preg_match('/["\']([[:alnum:]_-]*)["\'][[:space:]]*=>(.*)/i', $lc, $reg)) {
186  preg_match('/,[\\t\\s]*\\/\\/(.*)/i', $reg[2], $creg);
187  $theComment = trim($creg[1]);
188  if (substr(strtolower(trim($reg[2])), 0, 5) == 'array' && $reg[1] === strtoupper($reg[1])) {
189  $mainKey = trim($reg[1]);
190  } elseif ($mainKey) {
191  $commentArray[$mainKey][$reg[1]] = $theComment;
192  }
193  }
194  }
195  }
196  if ($lc === 'return array(') {
197  $in = 1;
198  }
199  }
200  return $commentArray;
201  }
202 }
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]