Conditions | 15 |
Paths | 5120 |
Total Lines | 105 |
Code Lines | 63 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
194 | protected function JSbottom() |
||
195 | { |
||
196 | $pageRenderer = $this->getPageRenderer(); |
||
197 | /** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */ |
||
198 | $uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class); |
||
199 | |||
200 | // @todo: this is messy here - "additional hidden fields" should be handled elsewhere |
||
201 | $html = implode(LF, $this->hiddenFieldAccum); |
||
202 | $pageRenderer->addJsFile('EXT:backend/Resources/Public/JavaScript/md5.js'); |
||
203 | // load the main module for FormEngine with all important JS functions |
||
204 | $this->requireJsModules['TYPO3/CMS/Backend/FormEngine'] = 'function(FormEngine) { |
||
205 | FormEngine.initialize( |
||
206 | ' . GeneralUtility::quoteJSvalue((string)$uriBuilder->buildUriFromRoute('wizard_element_browser')) . ', |
||
207 | ' . ($GLOBALS['TYPO3_CONF_VARS']['SYS']['USdateFormat'] ? '1' : '0') . ' |
||
208 | ); |
||
209 | }'; |
||
210 | $this->requireJsModules['TYPO3/CMS/Backend/FormEngineReview'] = null; |
||
211 | |||
212 | foreach ($this->requireJsModules as $moduleName => $callbacks) { |
||
213 | if (!is_array($callbacks)) { |
||
214 | $callbacks = [$callbacks]; |
||
215 | } |
||
216 | foreach ($callbacks as $callback) { |
||
217 | $pageRenderer->loadRequireJsModule($moduleName, $callback); |
||
218 | } |
||
219 | } |
||
220 | $pageRenderer->loadJquery(); |
||
221 | $beUserAuth = $this->getBackendUserAuthentication(); |
||
222 | |||
223 | // define the window size of the element browser etc. |
||
224 | $popupWindowWidth = 800; |
||
225 | $popupWindowHeight = 600; |
||
226 | $popupWindowSize = trim($beUserAuth->getTSConfigVal('options.popupWindowSize')); |
||
227 | if (!empty($popupWindowSize)) { |
||
228 | list($popupWindowWidth, $popupWindowHeight) = GeneralUtility::intExplode('x', $popupWindowSize); |
||
229 | } |
||
230 | |||
231 | // define the window size of the popups within the RTE |
||
232 | $rtePopupWindowSize = trim($beUserAuth->getTSConfigVal('options.rte.popupWindowSize')); |
||
233 | if (!empty($rtePopupWindowSize)) { |
||
234 | list($rtePopupWindowWidth, $rtePopupWindowHeight) = GeneralUtility::trimExplode('x', $rtePopupWindowSize); |
||
235 | } |
||
236 | $rtePopupWindowWidth = !empty($rtePopupWindowWidth) ? (int)$rtePopupWindowWidth : ($popupWindowWidth); |
||
237 | $rtePopupWindowHeight = !empty($rtePopupWindowHeight) ? (int)$rtePopupWindowHeight : ($popupWindowHeight); |
||
238 | |||
239 | // Make textareas resizable and flexible ("autogrow" in height) |
||
240 | $textareaSettings = [ |
||
241 | 'autosize' => (bool)$beUserAuth->uc['resizeTextareas_Flexible'], |
||
242 | 'RTEPopupWindow' => [ |
||
243 | 'width' => $rtePopupWindowWidth, |
||
244 | 'height' => $rtePopupWindowHeight |
||
245 | ] |
||
246 | ]; |
||
247 | $pageRenderer->addInlineSettingArray('Textarea', $textareaSettings); |
||
248 | |||
249 | $popupSettings = [ |
||
250 | 'PopupWindow' => [ |
||
251 | 'width' => $popupWindowWidth, |
||
252 | 'height' => $popupWindowHeight |
||
253 | ] |
||
254 | ]; |
||
255 | $pageRenderer->addInlineSettingArray('Popup', $popupSettings); |
||
256 | |||
257 | $pageRenderer->addJsFile('EXT:backend/Resources/Public/JavaScript/jsfunc.tbe_editor.js'); |
||
258 | // Needed for FormEngine manipulation (date picker) |
||
259 | $dateFormat = ($GLOBALS['TYPO3_CONF_VARS']['SYS']['USdateFormat'] ? ['MM-DD-YYYY', 'HH:mm MM-DD-YYYY'] : ['DD-MM-YYYY', 'HH:mm DD-MM-YYYY']); |
||
260 | $pageRenderer->addInlineSetting('DateTimePicker', 'DateFormat', $dateFormat); |
||
|
|||
261 | |||
262 | $pageRenderer->loadRequireJsModule('TYPO3/CMS/Filelist/FileListLocalisation'); |
||
263 | |||
264 | $pageRenderer->addInlineLanguageLabelFile('EXT:lang/Resources/Private/Language/locallang_core.xlf', 'file_upload'); |
||
265 | if (!empty($this->additionalInlineLanguageLabelFiles)) { |
||
266 | foreach ($this->additionalInlineLanguageLabelFiles as $additionalInlineLanguageLabelFile) { |
||
267 | $pageRenderer->addInlineLanguageLabelFile($additionalInlineLanguageLabelFile); |
||
268 | } |
||
269 | } |
||
270 | // We want to load jQuery-ui inside our js. Enable this using requirejs. |
||
271 | $pageRenderer->addJsFile('EXT:backend/Resources/Public/JavaScript/jsfunc.inline.js'); |
||
272 | |||
273 | // todo: change these things in JS |
||
274 | $pageRenderer->addInlineLanguageLabelArray([ |
||
275 | 'FormEngine.noRecordTitle' => 'LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.no_title', |
||
276 | 'FormEngine.fieldsChanged' => 'LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.fieldsChanged', |
||
277 | 'FormEngine.fieldsMissing' => 'LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.fieldsMissing', |
||
278 | 'FormEngine.maxItemsAllowed' => 'LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.maxItemsAllowed', |
||
279 | 'FormEngine.refreshRequiredTitle' => 'LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:mess.refreshRequired.title', |
||
280 | 'FormEngine.refreshRequiredContent' => 'LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:mess.refreshRequired.content', |
||
281 | 'FormEngine.remainingCharacters' => 'LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.remainingCharacters', |
||
282 | ], true); |
||
283 | |||
284 | $out = LF . 'TBE_EDITOR.doSaveFieldName = "' . ($this->doSaveFieldName ? addslashes($this->doSaveFieldName) : '') . '";'; |
||
285 | |||
286 | // Add JS required for inline fields |
||
287 | if (!empty($this->inlineData)) { |
||
288 | $out .= LF . 'inline.addToDataArray(' . json_encode($this->inlineData) . ');'; |
||
289 | } |
||
290 | // $this->additionalJS_submit: |
||
291 | if ($this->additionalJavaScriptSubmit) { |
||
292 | $additionalJS_submit = implode('', $this->additionalJavaScriptSubmit); |
||
293 | $additionalJS_submit = str_replace([CR, LF], '', $additionalJS_submit); |
||
294 | $out .= 'TBE_EDITOR.addActionChecks("submit", "' . addslashes($additionalJS_submit) . '");'; |
||
295 | } |
||
296 | $out .= LF . implode(LF, $this->additionalJavaScriptPost); |
||
297 | |||
298 | return $html . LF . TAB . GeneralUtility::wrapJS($out); |
||
299 | } |
||
322 |