TYPO3 CMS  TYPO3_6-2
ContentRepository.php
Go to the documentation of this file.
1 <?php
3 
23 
31  public function getRecord() {
32  $record = FALSE;
33  $getPostVariables = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('P');
34  $table = (string) $getPostVariables['table'];
35  $recordId = (int)$getPostVariables['uid'];
36  $row = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord($table, $recordId);
37  if (is_array($row)) {
38  // strip off the leading "[Translate to XY]" text after localizing the original record
39  $languageField = $GLOBALS['TCA']['tt_content']['ctrl']['languageField'];
40  $transOrigPointerField = $GLOBALS['TCA']['tt_content']['ctrl']['transOrigPointerField'];
41  if ($row[$languageField] > 0 && $row[$transOrigPointerField] > 0) {
42  $bodytext = preg_replace('/^\[.*?\] /', '', $row['bodytext'], 1);
43  } else {
44  $bodytext = $row['bodytext'];
45  }
46 
48  $typoScriptParser = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\TypoScript\\Parser\\TypoScriptParser');
49  $typoScriptParser->parse($bodytext);
51  $record = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Form\\Domain\\Model\\Content');
52  $record->setUid($row['uid']);
53  $record->setPageId($row['pid']);
54  $record->setTyposcript($typoScriptParser->setup);
55  }
56  return $record;
57  }
58 
64  public function hasRecord() {
65  return $this->getRecord() !== FALSE;
66  }
67 
73  public function save() {
74  $json = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('configuration');
76  $success = FALSE;
78  $converter = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Form\\Domain\\Factory\\JsonToTypoScript');
79  $typoscript = $converter->convert($json);
80  if ($typoscript) {
81  // Make TCEmain object:
83  $tce = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler');
84  $tce->stripslashes_values = 0;
85  // Put content into the data array:
86  $data = array();
87  $data[$parameters['table']][$parameters['uid']][$parameters['field']] = $typoscript;
88  // Perform the update:
89  $tce->start($data, array());
90  $tce->process_datamap();
91  $success = TRUE;
92  }
93  return $success;
94  }
95 
101  public function getRecordAsJson() {
102  $json = FALSE;
103  $record = $this->getRecord();
104  if ($record) {
105  $typoscript = $record->getTyposcript();
107  $converter = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Form\\Utility\\TypoScriptToJsonConverter');
108  $json = $converter->convert($typoscript);
109  }
110  return $json;
111  }
112 
113 }
$parameters
Definition: FileDumpEID.php:15
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]