TYPO3 CMS  TYPO3_6-2
ConfigurationView.php
Go to the documentation of this file.
1 <?php
3 
20 
27 
31  public $MCONF = array();
32 
36  public $MOD_MENU = array();
37 
41  public $MOD_SETTINGS = array();
42 
49  public $doc;
50 
54  public $include_once = array();
55 
59  public $content;
60 
66  protected $blindedConfigurationOptions = array(
67  'TYPO3_CONF_VARS' => array(
68  'DB' => array(
69  'database' => '******',
70  'host' => '******',
71  'password' => '******',
72  'port' => '******',
73  'socket' => '******',
74  'username' => '******'
75  ),
76  'SYS' => array(
77  'encryptionKey' => '******'
78  )
79  )
80  );
81 
85  public function __construct() {
86  $GLOBALS['LANG']->includeLLFile('EXT:lowlevel/config/locallang.xlf');
87  $GLOBALS['BE_USER']->modAccess($GLOBALS['MCONF'], 1);
88  }
89 
96  public function init() {
97  global $BACK_PATH;
98  $this->MCONF = $GLOBALS['MCONF'];
99  $this->menuConfig();
100  $this->doc = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
101  $this->doc->backPath = $BACK_PATH;
102  $this->doc->setModuleTemplate('EXT:lowlevel/Resources/Private/Templates/config.html');
103  $this->doc->form = '<form action="" method="post">';
104  }
105 
112  public function menuConfig() {
113  global $TYPO3_CONF_VARS;
114  // MENU-ITEMS:
115  // If array, then it's a selector box menu
116  // If empty string it's just a variable, that'll be saved.
117  // Values NOT in this array will not be saved in the settings-array for the module.
118  $this->MOD_MENU = array(
119  'function' => array(
120  0 => $GLOBALS['LANG']->getLL('typo3ConfVars', TRUE),
121  1 => $GLOBALS['LANG']->getLL('tca', TRUE),
122  2 => $GLOBALS['LANG']->getLL('tcaDescr', TRUE),
123  3 => $GLOBALS['LANG']->getLL('loadedExt', TRUE),
124  4 => $GLOBALS['LANG']->getLL('t3services', TRUE),
125  5 => $GLOBALS['LANG']->getLL('tbemodules', TRUE),
126  6 => $GLOBALS['LANG']->getLL('tbemodulesext', TRUE),
127  7 => $GLOBALS['LANG']->getLL('tbeStyles', TRUE),
128  8 => $GLOBALS['LANG']->getLL('beUser', TRUE),
129  9 => $GLOBALS['LANG']->getLL('usersettings', TRUE)
130  ),
131  'regexsearch' => '',
132  'fixedLgd' => ''
133  );
134  // CLEANSE SETTINGS
135  $this->MOD_SETTINGS = BackendUtility::getModuleData($this->MOD_MENU, GeneralUtility::_GP('SET'), $this->MCONF['name']);
136  }
137 
144  public function main() {
145  $arrayBrowser = GeneralUtility::makeInstance('TYPO3\\CMS\\Lowlevel\\Utility\\ArrayBrowser');
146  $label = $this->MOD_MENU['function'][$this->MOD_SETTINGS['function']];
147  $search_field = GeneralUtility::_GP('search_field');
148  $this->content = $this->doc->header($GLOBALS['LANG']->getLL('configuration', TRUE));
149  $this->content .= '<h2>' . $label . '</h2>';
150 
151  $this->content .= '<div id="lowlevel-config">
152  <label for="search_field">' . $GLOBALS['LANG']->getLL('enterSearchPhrase', TRUE) . '</label>
153  <input type="text" id="search_field" name="search_field" value="' . htmlspecialchars($search_field) . '"' . $GLOBALS['TBE_TEMPLATE']->formWidth(20) . ' />
154  <input type="submit" name="search" id="search" value="' . $GLOBALS['LANG']->getLL('search', TRUE) . '" />';
155  $this->content .= BackendUtility::getFuncCheck(0, 'SET[regexsearch]', $this->MOD_SETTINGS['regexsearch'], '', '', 'id="checkRegexsearch"') . '<label for="checkRegexsearch">' . $GLOBALS['LANG']->getLL('useRegExp', TRUE) . '</label>';
156  $this->content .= BackendUtility::getFuncCheck(0, 'SET[fixedLgd]', $this->MOD_SETTINGS['fixedLgd'], '', '', 'id="checkFixedLgd"') . '<label for="checkFixedLgd">' . $GLOBALS['LANG']->getLL('cropLines', TRUE) . '</label>
157  </div>';
158  $this->content .= $this->doc->spacer(5);
159  switch ($this->MOD_SETTINGS['function']) {
160  case 0:
161  $theVar = $GLOBALS['TYPO3_CONF_VARS'];
163  $arrayBrowser->varName = '$TYPO3_CONF_VARS';
164  break;
165  case 1:
166  $theVar = $GLOBALS['TCA'];
168  $arrayBrowser->varName = '$TCA';
169  break;
170  case 2:
171  $theVar = $GLOBALS['TCA_DESCR'];
173  $arrayBrowser->varName = '$TCA_DESCR';
174  break;
175  case 3:
176  $theVar = $GLOBALS['TYPO3_LOADED_EXT'];
178  $arrayBrowser->varName = '$TYPO3_LOADED_EXT';
179  break;
180  case 4:
181  $theVar = $GLOBALS['T3_SERVICES'];
183  $arrayBrowser->varName = '$T3_SERVICES';
184  break;
185  case 5:
186  $theVar = $GLOBALS['TBE_MODULES'];
188  $arrayBrowser->varName = '$TBE_MODULES';
189  break;
190  case 6:
191  $theVar = $GLOBALS['TBE_MODULES_EXT'];
193  $arrayBrowser->varName = '$TBE_MODULES_EXT';
194  break;
195  case 7:
196  $theVar = $GLOBALS['TBE_STYLES'];
198  $arrayBrowser->varName = '$TBE_STYLES';
199  break;
200  case 8:
201  $theVar = $GLOBALS['BE_USER']->uc;
203  $arrayBrowser->varName = '$BE_USER->uc';
204  break;
205  case 9:
206  $theVar = $GLOBALS['TYPO3_USER_SETTINGS'];
208  $arrayBrowser->varName = '$TYPO3_USER_SETTINGS';
209  break;
210  default:
211  $theVar = array();
212  }
213  // Update node:
214  $update = 0;
215  $node = GeneralUtility::_GET('node');
216  // If any plus-signs were clicked, it's registred.
217  if (is_array($node)) {
218  $this->MOD_SETTINGS['node_' . $this->MOD_SETTINGS['function']] = $arrayBrowser->depthKeys($node, $this->MOD_SETTINGS['node_' . $this->MOD_SETTINGS['function']]);
219  $update = 1;
220  }
221  if ($update) {
222  $GLOBALS['BE_USER']->pushModuleData($this->MCONF['name'], $this->MOD_SETTINGS);
223  }
224  $arrayBrowser->depthKeys = $this->MOD_SETTINGS['node_' . $this->MOD_SETTINGS['function']];
225  $arrayBrowser->regexMode = $this->MOD_SETTINGS['regexsearch'];
226  $arrayBrowser->fixedLgd = $this->MOD_SETTINGS['fixedLgd'];
227  $arrayBrowser->searchKeysToo = TRUE;
228 
229  // If any POST-vars are send, update the condition array
230  if (GeneralUtility::_POST('search') && trim($search_field)) {
231  $arrayBrowser->depthKeys = $arrayBrowser->getSearchKeys($theVar, '', $search_field, array());
232  }
233  // mask sensitive information
234  $varName = trim($arrayBrowser->varName, '$');
235  if (isset($this->blindedConfigurationOptions[$varName])) {
236  ArrayUtility::mergeRecursiveWithOverrule($theVar, $this->blindedConfigurationOptions[$varName]);
237  }
238  $tree = $arrayBrowser->tree($theVar, '', '');
239  $this->content .= $this->doc->sectionEnd();
240  // Variable name:
241  if (GeneralUtility::_GP('varname')) {
242  $line = GeneralUtility::_GP('_') ? GeneralUtility::_GP('_') : GeneralUtility::_GP('varname');
243  // Write the line to extTables.php
244  if (GeneralUtility::_GP('writetoexttables')) {
245  // change value to $GLOBALS
246  $length = strpos($line, '[');
247  $var = substr($line, 0, $length);
248  $changedLine = '$GLOBALS[\'' . substr($line, 1, ($length - 1)) . '\']' . substr($line, $length);
249  // load current extTables.php
250  $extTables = GeneralUtility::getUrl(PATH_typo3conf . TYPO3_extTableDef_script);
251  if ($var === '$TCA') {
252  // check if we are editing the TCA
253  preg_match_all('/\\[\'([^\']+)\'\\]/', $line, $parts);
254  }
255  // insert line in extTables.php
256  $extTables = preg_replace('/<\\?php|\\?>/is', '', $extTables);
257  $extTables = '<?php' . (empty($extTables) ? LF : '') . $extTables . $changedLine . LF . '?>';
258  $success = GeneralUtility::writeFile(PATH_typo3conf . TYPO3_extTableDef_script, $extTables);
259  if ($success) {
260  // show flash message
261  $flashMessage = GeneralUtility::makeInstance(
262  'TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
263  '',
264  sprintf(
265  $GLOBALS['LANG']->getLL('writeMessage', TRUE),
266  TYPO3_extTableDef_script,
267  '<br />',
268  '<strong>' . nl2br(htmlspecialchars($changedLine)) . '</strong>'
269  ),
270  \TYPO3\CMS\Core\Messaging\FlashMessage::OK
271  );
272  } else {
273  // Error: show flash message
274  $flashMessage = GeneralUtility::makeInstance(
275  'TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
276  '',
277  sprintf($GLOBALS['LANG']->getLL('writeMessageFailed', TRUE), TYPO3_extTableDef_script),
278  \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR
279  );
280  }
281  $this->content .= $flashMessage->render();
282  }
283  $this->content .= '<div id="lowlevel-config-var">
284  <strong>' . $GLOBALS['LANG']->getLL('variable', TRUE) . '</strong><br />
285  <input type="text" name="_" value="' . trim(htmlspecialchars($line)) . '" size="120" /><br/>';
286  if (TYPO3_extTableDef_script !== '' && ($this->MOD_SETTINGS['function'] === '1' || $this->MOD_SETTINGS['function'] === '4')) {
287  // write only for $TCA and TBE_STYLES if TYPO3_extTableDef_script is defined
288  $this->content .= '<br /><input type="submit" name="writetoexttables" value="' . $GLOBALS['LANG']->getLL('writeValue', TRUE) . '" /></div>';
289  } else {
290  $this->content .= $GLOBALS['LANG']->getLL('copyPaste', TRUE) . LF . '</div>';
291  }
292  }
293  $this->content .= '<div class="nowrap">' . $tree . '</div>';
294 
295  // Setting up the buttons and markers for docheader
296  $docHeaderButtons = $this->getButtons();
297  $markers = array(
298  'CSH' => $docHeaderButtons['csh'],
299  'FUNC_MENU' => $this->getFuncMenu(),
300  'CONTENT' => $this->content
301  );
302  // Build the <body> for the module
303  $this->content = $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
304  // Renders the module page
305  $this->content = $this->doc->render('Configuration', $this->content);
306  }
307 
314  public function printContent() {
315  echo $this->content;
316  }
317 
323  protected function getButtons() {
324  $buttons = array(
325  'csh' => '',
326  'shortcut' => ''
327  );
328  // Shortcut
329  if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
330  $buttons['shortcut'] = $this->doc->makeShortcutIcon('', 'function', $this->MCONF['name']);
331  }
332  return $buttons;
333  }
334 
340  protected function getFuncMenu() {
341  $funcMenu = BackendUtility::getFuncMenu(0, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']);
342  return $funcMenu;
343  }
344 
345 }
static mergeRecursiveWithOverrule(array &$original, array $overrule, $addKeys=TRUE, $includeEmptyValues=TRUE, $enableUnsetFeature=TRUE)
$TYPO3_CONF_VARS['SYS']['contentTable']
static getFuncCheck($mainParams, $elementName, $currentValue, $script='', $addParams='', $tagParams='')
static writeFile($file, $content, $changePermissions=FALSE)
$TCA['tx_irretutorial_1ncsv_hotel']
$BACK_PATH
Definition: conf.php:3
static getModuleData($MOD_MENU, $CHANGED_SETTINGS, $modName, $type='', $dontValidateList='', $setDefaultList='')
static getFuncMenu($mainParams, $elementName, $currentValue, $menuItems, $script='', $addparams='')
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]