Exemplo n.º 1
0
 /**
  * @param $pageId
  * @param int $templateUid
  *
  * @return bool
  */
 protected function initializeTsParser($pageId, $templateUid = 0)
 {
     if (!$this->tsParserInitialized) {
         $this->tsParserInitialized = true;
         $this->tsParser = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\TypoScript\\ExtendedTemplateService');
         // Do not log time-performance information
         $this->tsParser->tt_track = 0;
         $this->tsParser->init();
         $this->tsParser->ext_localGfxPrefix = ExtensionManagementUtility::extPath('tstemplate');
         $this->tsParser->ext_localWebGfxPrefix = $GLOBALS['BACK_PATH'] . ExtensionManagementUtility::extRelPath('tstemplate');
         $this->tsParserTplRow = $this->tsParser->ext_getFirstTemplate($pageId, $templateUid);
         if (is_array($this->tsParserTplRow)) {
             /**
              * @var t3lib_pageSelect
              */
             $sysPageRepository = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository');
             $rootLine = $sysPageRepository->getRootLine($pageId);
             // This generates the constants/config + hierarchy info for the template.
             $this->tsParser->runThroughTemplates($rootLine, $templateUid);
             // The editable constants are returned in an array.
             $this->tsParserConstants = $this->tsParser->generateConfig_constants();
             // The returned constants are sorted in categories, that goes into the $tmpl->categories array
             $this->tsParser->ext_categorizeEditableConstants($this->tsParserConstants);
             $this->tsParser->ext_regObjectPositions($this->tsParserTplRow['constants']);
             // This array will contain key=[expanded constantname], value=linenumber in template. (after edit_divider, if any)
             return true;
         } else {
             return false;
         }
     }
     return true;
 }
Exemplo n.º 2
0
 /**
  * Render template menu
  *
  * @return string
  */
 public function templateMenu()
 {
     $this->templateService = GeneralUtility::makeInstance(ExtendedTemplateService::class);
     $this->templateService->init();
     $all = $this->templateService->ext_getAllTemplates($this->id);
     if (count($all) > 1) {
         $this->MOD_MENU['templatesOnPage'] = [];
         foreach ($all as $d) {
             $this->MOD_MENU['templatesOnPage'][$d['uid']] = $d['title'];
         }
     }
     $this->MOD_SETTINGS = BackendUtility::getModuleData($this->MOD_MENU, GeneralUtility::_GP('SET'), $this->MCONF['name'], $this->modMenu_type, $this->modMenu_dontValidateList, $this->modMenu_setDefaultList);
     return BackendUtility::getFuncMenu($this->id, 'SET[templatesOnPage]', $this->MOD_SETTINGS['templatesOnPage'], $this->MOD_MENU['templatesOnPage']);
 }
 /**
  * @param array $configuration
  * @return string
  */
 protected function encodeTypoScriptArray(array $configuration)
 {
     $configuration = $this->ensureDottedKeys($configuration);
     $typoScriptParser = new ExtendedTemplateService();
     $typoScriptParser->flattenSetup($configuration, 'backend_layout.', false);
     $string = '';
     foreach ($typoScriptParser->flatSetup as $name => $value) {
         $string .= $name . ' = ' . $value . LF;
     }
     return $string;
 }
Exemplo n.º 4
0
 /**
  * Formatting the TypoScript code in $this->raw based on the data collected by $this->regHighLight in $this->highLightData
  *
  * @param mixed $lineNumDat If blank, linenumbers are NOT printed. If array then the first key is the linenumber offset to add to the internal counter.
  * @param bool $highlightBlockMode If set, then the highlighted output will be formatted in blocks based on the brace levels. prespace will be ignored and empty lines represented with a single no-break-space.
  * @return string HTML content
  * @access private
  * @see doSyntaxHighlight()
  */
 public function syntaxHighlight_print($lineNumDat, $highlightBlockMode)
 {
     // Registers all error messages in relation to their linenumber
     $errA = array();
     foreach ($this->errors as $err) {
         $errA[$err[2]][] = $err[0];
     }
     // Generates the syntax highlighted output:
     $lines = array();
     foreach ($this->raw as $rawP => $value) {
         $start = 0;
         $strlen = strlen($value);
         $lineC = '';
         if (is_array($this->highLightData[$rawP])) {
             foreach ($this->highLightData[$rawP] as $set) {
                 $len = $strlen - $start - $set[1];
                 if ($len > 0) {
                     $part = substr($value, $start, $len);
                     $start += $len;
                     $st = $this->highLightStyles[isset($this->highLightStyles[$set[0]]) ? $set[0] : 'default'];
                     if (!$highlightBlockMode || $set[0] !== 'prespace') {
                         $lineC .= $st[0] . htmlspecialchars($part) . $st[1];
                     }
                 } elseif ($len < 0) {
                     debug(array($len, $value, $rawP));
                 }
             }
         } else {
             debug(array($value));
         }
         if (strlen($value) > $start) {
             $lineC .= $this->highLightStyles['ignored'][0] . htmlspecialchars(substr($value, $start)) . $this->highLightStyles['ignored'][1];
         }
         if ($errA[$rawP]) {
             $lineC .= $this->highLightStyles['error'][0] . '<strong> - ERROR:</strong> ' . htmlspecialchars(implode(';', $errA[$rawP])) . $this->highLightStyles['error'][1];
         }
         if ($highlightBlockMode && $this->highLightData_bracelevel[$rawP]) {
             $lineC = str_pad('', $this->highLightData_bracelevel[$rawP] * 2, ' ', STR_PAD_LEFT) . '<span style="' . $this->highLightBlockStyles . ($this->highLightBlockStyles_basecolor ? 'background-color: ' . $this->modifyHTMLColorAll($this->highLightBlockStyles_basecolor, -$this->highLightData_bracelevel[$rawP] * 16) : '') . '">' . ($lineC !== '' ? $lineC : '&nbsp;') . '</span>';
         }
         if (is_array($lineNumDat)) {
             $lineNum = $rawP + $lineNumDat[0];
             if ($this->parentObject instanceof ExtendedTemplateService) {
                 $lineNum = $this->parentObject->ext_lnBreakPointWrap($lineNum, $lineNum);
             }
             $lineC = $this->highLightStyles['linenum'][0] . str_pad($lineNum, 4, ' ', STR_PAD_LEFT) . ':' . $this->highLightStyles['linenum'][1] . ' ' . $lineC;
         }
         $lines[] = $lineC;
     }
     return '<pre class="ts-hl">' . implode(LF, $lines) . '</pre>';
 }
Exemplo n.º 5
0
 /**
  * Main
  *
  * @return string
  */
 public function main()
 {
     $lang = $this->getLanguageService();
     $POST = GeneralUtility::_POST();
     // Checking for more than one template an if, set a menu...
     $manyTemplatesMenu = $this->pObj->templateMenu();
     $template_uid = 0;
     if ($manyTemplatesMenu) {
         $template_uid = $this->pObj->MOD_SETTINGS['templatesOnPage'];
     }
     $bType = $this->pObj->MOD_SETTINGS['ts_browser_type'];
     $existTemplate = $this->initialize_editor($this->pObj->id, $template_uid);
     // initialize
     $assigns = [];
     $assigns['LLPrefix'] = 'LLL:' . $this->localLanguageFilePath . ':';
     $assigns['existTemplate'] = $existTemplate;
     $assigns['tsBrowserType'] = $this->pObj->MOD_SETTINGS['ts_browser_type'];
     if ($existTemplate) {
         $assigns['templateRecord'] = $this->templateRow;
         $assigns['linkWrapTemplateTitle'] = $this->pObj->linkWrapTemplateTitle($this->templateRow['title'], $bType == 'setup' ? 'config' : 'constants');
         $assigns['manyTemplatesMenu'] = $manyTemplatesMenu;
         if ($POST['add_property'] || $POST['update_value'] || $POST['clear_object']) {
             // add property
             $line = '';
             if (is_array($POST['data'])) {
                 $name = key($POST['data']);
                 if ($POST['data'][$name]['name'] !== '') {
                     // Workaround for this special case: User adds a key and submits by pressing the return key. The form however will use "add_property" which is the name of the first submit button in this form.
                     unset($POST['update_value']);
                     $POST['add_property'] = 'Add';
                 }
                 if ($POST['add_property']) {
                     $property = trim($POST['data'][$name]['name']);
                     if (preg_replace('/[^a-zA-Z0-9_\\.]*/', '', $property) != $property) {
                         $badPropertyMessage = GeneralUtility::makeInstance(FlashMessage::class, $lang->getLL('noSpaces') . $lang->getLL('nothingUpdated'), $lang->getLL('badProperty'), FlashMessage::ERROR);
                         $this->addFlashMessage($badPropertyMessage);
                     } else {
                         $pline = $name . '.' . $property . ' = ' . trim($POST['data'][$name]['propertyValue']);
                         $propertyAddedMessage = GeneralUtility::makeInstance(FlashMessage::class, $pline, $lang->getLL('propertyAdded'));
                         $this->addFlashMessage($propertyAddedMessage);
                         $line .= LF . $pline;
                     }
                 } elseif ($POST['update_value']) {
                     $pline = $name . ' = ' . trim($POST['data'][$name]['value']);
                     $updatedMessage = GeneralUtility::makeInstance(FlashMessage::class, $pline, $lang->getLL('valueUpdated'));
                     $this->addFlashMessage($updatedMessage);
                     $line .= LF . $pline;
                 } elseif ($POST['clear_object']) {
                     if ($POST['data'][$name]['clearValue']) {
                         $pline = $name . ' >';
                         $objectClearedMessage = GeneralUtility::makeInstance(FlashMessage::class, $pline, $lang->getLL('objectCleared'));
                         $this->addFlashMessage($objectClearedMessage);
                         $line .= LF . $pline;
                     }
                 }
             }
             if ($line) {
                 $saveId = $this->templateRow['_ORIG_uid'] ?: $this->templateRow['uid'];
                 // Set the data to be saved
                 $recData = [];
                 $field = $bType == 'setup' ? 'config' : 'constants';
                 $recData['sys_template'][$saveId][$field] = $this->templateRow[$field] . $line;
                 // Create new  tce-object
                 $tce = GeneralUtility::makeInstance(DataHandler::class);
                 // Initialize
                 $tce->start($recData, []);
                 // Saved the stuff
                 $tce->process_datamap();
                 // Clear the cache (note: currently only admin-users can clear the cache in tce_main.php)
                 $tce->clear_cacheCmd('all');
                 // re-read the template ...
                 $this->initialize_editor($this->pObj->id, $template_uid);
             }
         }
     }
     $tsbr = GeneralUtility::_GET('tsbr');
     $update = 0;
     if (is_array($tsbr)) {
         // If any plus-signs were clicked, it's registred.
         $this->pObj->MOD_SETTINGS['tsbrowser_depthKeys_' . $bType] = $this->templateService->ext_depthKeys($tsbr, $this->pObj->MOD_SETTINGS['tsbrowser_depthKeys_' . $bType]);
         $update = 1;
     }
     if ($POST['Submit']) {
         // If any POST-vars are send, update the condition array
         $this->pObj->MOD_SETTINGS['tsbrowser_conditions'] = $POST['conditions'];
         $update = 1;
     }
     if ($update) {
         $this->getBackendUserAuthentication()->pushModuleData($this->pObj->MCONF['name'], $this->pObj->MOD_SETTINGS);
     }
     $this->templateService->matchAlternative = $this->pObj->MOD_SETTINGS['tsbrowser_conditions'];
     $this->templateService->matchAlternative[] = 'dummydummydummydummydummydummydummydummydummydummydummy';
     // This is just here to make sure that at least one element is in the array so that the tsparser actually uses this array to match.
     $this->templateService->constantMode = $this->pObj->MOD_SETTINGS['ts_browser_const'];
     if ($this->pObj->sObj && $this->templateService->constantMode) {
         $this->templateService->constantMode = 'untouched';
     }
     $this->templateService->regexMode = $this->pObj->MOD_SETTINGS['ts_browser_regexsearch'];
     $this->templateService->fixedLgd = $this->pObj->MOD_SETTINGS['ts_browser_fixedLgd'];
     $this->templateService->linkObjects = true;
     $this->templateService->ext_regLinenumbers = true;
     $this->templateService->ext_regComments = $this->pObj->MOD_SETTINGS['ts_browser_showComments'];
     $this->templateService->bType = $bType;
     if ($this->pObj->MOD_SETTINGS['ts_browser_type'] == 'const') {
         $this->templateService->ext_constants_BRP = (int) GeneralUtility::_GP('breakPointLN');
     } else {
         $this->templateService->ext_config_BRP = (int) GeneralUtility::_GP('breakPointLN');
     }
     $this->templateService->generateConfig();
     if ($bType == 'setup') {
         $theSetup = $this->templateService->setup;
     } else {
         $theSetup = $this->templateService->setup_constants;
     }
     // EDIT A VALUE:
     $assigns['typoScriptPath'] = $this->pObj->sObj;
     if ($this->pObj->sObj) {
         list($theSetup, $theSetupValue) = $this->templateService->ext_getSetup($theSetup, $this->pObj->sObj ? $this->pObj->sObj : '');
         $assigns['theSetupValue'] = $theSetupValue;
         if ($existTemplate === false) {
             $noTemplateMessage = GeneralUtility::makeInstance(FlashMessage::class, $lang->getLL('noCurrentTemplate'), $lang->getLL('edit'), FlashMessage::ERROR);
             $this->addFlashMessage($noTemplateMessage);
         }
         // Links:
         $urlParameters = ['id' => $this->pObj->id];
         $aHref = BackendUtility::getModuleUrl('web_ts', $urlParameters);
         $assigns['moduleUrl'] = BackendUtility::getModuleUrl('web_ts', $urlParameters);
         $assigns['isNotInTopLevelKeyList'] = !isset($this->pObj->MOD_SETTINGS['ts_browser_TLKeys_' . $bType][$this->pObj->sObj]);
         $assigns['hasProperties'] = !empty($theSetup);
         if (!$this->pObj->MOD_SETTINGS['ts_browser_TLKeys_' . $bType][$this->pObj->sObj]) {
             if (!empty($theSetup)) {
                 $assigns['moduleUrlObjectListAction'] = $aHref . '&addKey[' . rawurlencode($this->pObj->sObj) . ']=1&SET[ts_browser_toplevel_' . $bType . ']=' . rawurlencode($this->pObj->sObj);
             }
         } else {
             $assigns['moduleUrlObjectListAction'] = $aHref . '&addKey[' . rawurlencode($this->pObj->sObj) . ']=0&SET[ts_browser_toplevel_' . $bType . ']=0';
         }
     } else {
         $this->templateService->tsbrowser_depthKeys = $this->pObj->MOD_SETTINGS['tsbrowser_depthKeys_' . $bType];
         if (GeneralUtility::_POST('search') && GeneralUtility::_POST('search_field')) {
             // If any POST-vars are send, update the condition array
             $searchString = GeneralUtility::_POST('search_field');
             try {
                 $this->templateService->tsbrowser_depthKeys = $this->templateService->ext_getSearchKeys($theSetup, '', $searchString, []);
             } catch (Exception $e) {
                 $this->addFlashMessage(GeneralUtility::makeInstance(FlashMessage::class, sprintf($lang->getLL('error.' . $e->getCode()), $searchString), '', FlashMessage::ERROR));
             }
         }
         $assigns['hasTsBrowserTypes'] = is_array($this->pObj->MOD_MENU['ts_browser_type']) && count($this->pObj->MOD_MENU['ts_browser_type']) > 1;
         if (is_array($this->pObj->MOD_MENU['ts_browser_type']) && count($this->pObj->MOD_MENU['ts_browser_type']) > 1) {
             $assigns['browserTypeDropdownMenu'] = BackendUtility::getDropdownMenu($this->pObj->id, 'SET[ts_browser_type]', $bType, $this->pObj->MOD_MENU['ts_browser_type']);
         }
         $assigns['hasTopLevelInObjectList'] = is_array($this->pObj->MOD_MENU['ts_browser_toplevel_' . $bType]) && count($this->pObj->MOD_MENU['ts_browser_toplevel_' . $bType]) > 1;
         if (is_array($this->pObj->MOD_MENU['ts_browser_toplevel_' . $bType]) && count($this->pObj->MOD_MENU['ts_browser_toplevel_' . $bType]) > 1) {
             $assigns['objectListDropdownMenu'] = BackendUtility::getDropdownMenu($this->pObj->id, 'SET[ts_browser_toplevel_' . $bType . ']', $this->pObj->MOD_SETTINGS['ts_browser_toplevel_' . $bType], $this->pObj->MOD_MENU['ts_browser_toplevel_' . $bType]);
         }
         $assigns['regexSearchCheckbox'] = BackendUtility::getFuncCheck($this->pObj->id, 'SET[ts_browser_regexsearch]', $this->pObj->MOD_SETTINGS['ts_browser_regexsearch'], '', '', 'id="checkTs_browser_regexsearch"');
         $assigns['postSearchField'] = $POST['search_field'];
         $theKey = $this->pObj->MOD_SETTINGS['ts_browser_toplevel_' . $bType];
         if (!$theKey || !str_replace('-', '', $theKey)) {
             $theKey = '';
         }
         list($theSetup, $theSetupValue) = $this->templateService->ext_getSetup($theSetup, $this->pObj->MOD_SETTINGS['ts_browser_toplevel_' . $bType] ? $this->pObj->MOD_SETTINGS['ts_browser_toplevel_' . $bType] : '');
         $tree = $this->templateService->ext_getObjTree($theSetup, $theKey, '', '', $theSetupValue, $this->pObj->MOD_SETTINGS['ts_browser_alphaSort']);
         $tree = $this->templateService->substituteCMarkers($tree);
         $urlParameters = ['id' => $this->pObj->id];
         $aHref = BackendUtility::getModuleUrl('web_ts', $urlParameters);
         // Parser Errors:
         $pEkey = $bType == 'setup' ? 'config' : 'constants';
         $assigns['hasParseErrors'] = !empty($this->templateService->parserErrors[$pEkey]);
         if (!empty($this->templateService->parserErrors[$pEkey])) {
             $assigns['showErrorDetailsUri'] = $aHref . '&SET[function]=TYPO3\\CMS\\Tstemplate\\Controller\\TemplateAnalyzerModuleFunctionController&template=all&SET[ts_analyzer_checkLinenum]=1#line-';
             $assigns['parseErrors'] = $this->templateService->parserErrors[$pEkey];
         }
         if (isset($this->pObj->MOD_SETTINGS['ts_browser_TLKeys_' . $bType][$theKey])) {
             $assigns['moduleUrlRemoveFromObjectList'] = $aHref . '&addKey[' . $theKey . ']=0&SET[ts_browser_toplevel_' . $bType . ']=0';
         }
         $assigns['hasKeySelected'] = $theKey !== '';
         if ($theKey) {
             $assigns['treeLabel'] = $theKey;
         } else {
             $assigns['rootLLKey'] = $bType === 'setup' ? 'setupRoot' : 'constantRoot';
         }
         $assigns['tsTree'] = $tree;
         // second row options
         $assigns['isSetupAndCropLinesDisabled'] = $bType == 'setup' && !$this->pObj->MOD_SETTINGS['ts_browser_fixedLgd'];
         $assigns['checkBoxShowComments'] = BackendUtility::getFuncCheck($this->pObj->id, 'SET[ts_browser_showComments]', $this->pObj->MOD_SETTINGS['ts_browser_showComments'], '', '', 'id="checkTs_browser_showComments"');
         $assigns['checkBoxAlphaSort'] = BackendUtility::getFuncCheck($this->pObj->id, 'SET[ts_browser_alphaSort]', $this->pObj->MOD_SETTINGS['ts_browser_alphaSort'], '', '', 'id="checkTs_browser_alphaSort"');
         $assigns['checkBoxCropLines'] = BackendUtility::getFuncCheck($this->pObj->id, 'SET[ts_browser_fixedLgd]', $this->pObj->MOD_SETTINGS['ts_browser_fixedLgd'], '', '', 'id="checkTs_browser_fixedLgd"');
         if ($bType == 'setup' && !$this->pObj->MOD_SETTINGS['ts_browser_fixedLgd']) {
             $assigns['dropdownDisplayConstants'] = BackendUtility::getDropdownMenu($this->pObj->id, 'SET[ts_browser_const]', $this->pObj->MOD_SETTINGS['ts_browser_const'], $this->pObj->MOD_MENU['ts_browser_const']);
         }
         // Conditions:
         $assigns['hasConditions'] = is_array($this->templateService->sections) && !empty($this->templateService->sections);
         if (is_array($this->templateService->sections) && !empty($this->templateService->sections)) {
             $tsConditions = [];
             foreach ($this->templateService->sections as $key => $val) {
                 $tsConditions[] = ['key' => $key, 'value' => $val, 'label' => $this->templateService->substituteCMarkers(htmlspecialchars($val)), 'isSet' => $this->pObj->MOD_SETTINGS['tsbrowser_conditions'][$key] ? true : false];
             }
             $assigns['tsConditions'] = $tsConditions;
         }
         // Ending section displayoptions
     }
     $view = GeneralUtility::makeInstance(StandaloneView::class);
     $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName('EXT:tstemplate/Resources/Private/Templates/TemplateObjectBrowserModuleFunction.html'));
     $view->assignMultiple($assigns);
     return $view->render();
 }
Exemplo n.º 6
0
 /**
  * Main
  *
  * @return string
  */
 public function main()
 {
     // Initializes the module. Done in this function because we may need to re-initialize if data is submitted!
     // Checking for more than one template an if, set a menu...
     $assigns = [];
     $template_uid = 0;
     $assigns['manyTemplatesMenu'] = $this->pObj->templateMenu();
     $assigns['LLPrefix'] = 'LLL:' . $this->localLanguageFilePath . ':';
     if ($assigns['manyTemplatesMenu']) {
         $template_uid = $this->pObj->MOD_SETTINGS['templatesOnPage'];
     }
     $assigns['existTemplate'] = $this->initialize_editor($this->pObj->id, $template_uid);
     if ($assigns['existTemplate']) {
         $assigns['siteTitle'] = trim($this->templateRow['sitetitle']);
         $assigns['templateRecord'] = $this->templateRow;
         $assigns['linkWrappedTemplateTitle'] = $this->pObj->linkWrapTemplateTitle($this->templateRow['title']);
     }
     $this->templateService->clearList_const_temp = array_flip($this->templateService->clearList_const);
     $this->templateService->clearList_setup_temp = array_flip($this->templateService->clearList_setup);
     $pointer = count($this->templateService->hierarchyInfo);
     $hierarchyInfo = $this->templateService->ext_process_hierarchyInfo([], $pointer);
     $assigns['hierarchy'] = implode(array_reverse($this->templateService->ext_getTemplateHierarchyArr($hierarchyInfo, '', [], 1)), '');
     $urlParameters = ['id' => $this->pObj->id, 'template' => 'all'];
     $assigns['moduleLink'] = BackendUtility::getModuleUrl('web_ts', $urlParameters);
     $assigns['template'] = $template = GeneralUtility::_GET('template');
     $addParams = $template ? '&template=' . $template : '';
     $assigns['checkboxes'] = ['ts_analyzer_checkLinenum' => ['id' => 'checkTs_analyzer_checkLinenum', 'll' => 'lineNumbers'], 'ts_analyzer_checkSyntax' => ['id' => 'checkTs_analyzer_checkSyntax', 'll' => 'syntaxHighlight']];
     if (!$this->pObj->MOD_SETTINGS['ts_analyzer_checkSyntax']) {
         $assigns['checkboxes']['ts_analyzer_checkComments'] = ['id' => 'checkTs_analyzer_checkComments', 'll' => 'comments'];
         $assigns['checkboxes']['ts_analyzer_checkCrop'] = ['id' => 'checkTs_analyzer_checkCrop', 'll' => 'cropLines'];
     }
     foreach ($assigns['checkboxes'] as $key => $conf) {
         $assigns['checkboxes'][$key]['label'] = BackendUtility::getFuncCheck($this->pObj->id, 'SET[' . $key . ']', $this->pObj->MOD_SETTINGS[$key], '', $addParams, 'id="' . $conf['id'] . '"');
     }
     if ($template) {
         $this->templateService->ext_lineNumberOffset = 0;
         $this->templateService->ext_lineNumberOffset_mode = 'const';
         $assigns['constants'] = [];
         foreach ($this->templateService->constants as $key => $val) {
             $currentTemplateId = $this->templateService->hierarchyInfo[$key]['templateID'];
             if ($currentTemplateId == $template || $template === 'all') {
                 $assigns['constants'][] = ['title' => $this->templateService->hierarchyInfo[$key]['title'], 'content' => $this->templateService->ext_outputTS([$val], $this->pObj->MOD_SETTINGS['ts_analyzer_checkLinenum'], $this->pObj->MOD_SETTINGS['ts_analyzer_checkComments'], $this->pObj->MOD_SETTINGS['ts_analyzer_checkCrop'], $this->pObj->MOD_SETTINGS['ts_analyzer_checkSyntax'], 0)];
                 if ($template !== 'all') {
                     break;
                 }
             }
             $this->templateService->ext_lineNumberOffset += count(explode(LF, $val)) + 1;
         }
         // Output Setup
         $this->templateService->ext_lineNumberOffset = 0;
         $this->templateService->ext_lineNumberOffset_mode = 'setup';
         $assigns['setups'] = [];
         foreach ($this->templateService->config as $key => $val) {
             $currentTemplateId = $this->templateService->hierarchyInfo[$key]['templateID'];
             if ($currentTemplateId == $template || $template === 'all') {
                 $assigns['setups'][] = ['title' => $this->templateService->hierarchyInfo[$key]['title'], 'content' => $this->templateService->ext_outputTS([$val], $this->pObj->MOD_SETTINGS['ts_analyzer_checkLinenum'], $this->pObj->MOD_SETTINGS['ts_analyzer_checkComments'], $this->pObj->MOD_SETTINGS['ts_analyzer_checkCrop'], $this->pObj->MOD_SETTINGS['ts_analyzer_checkSyntax'], 0)];
                 if ($template !== 'all') {
                     break;
                 }
             }
             $this->templateService->ext_lineNumberOffset += count(explode(LF, $val)) + 1;
         }
     }
     $view = GeneralUtility::makeInstance(StandaloneView::class);
     $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName('EXT:tstemplate/Resources/Private/Templates/TemplateAnalyzerModuleFunction.html'));
     $view->assignMultiple($assigns);
     return $view->render();
 }
Exemplo n.º 7
0
 /**
  * Main
  *
  * @return string
  */
 public function main()
 {
     $assigns = [];
     $assigns['LLPrefix'] = 'LLL:EXT:tstemplate/Resources/Private/Language/locallang_ceditor.xlf:';
     // Create extension template
     $this->pObj->createTemplate($this->pObj->id);
     // Checking for more than one template an if, set a menu...
     $manyTemplatesMenu = $this->pObj->templateMenu();
     $template_uid = 0;
     if ($manyTemplatesMenu) {
         $template_uid = $this->pObj->MOD_SETTINGS['templatesOnPage'];
     }
     // initialize
     $existTemplate = $this->initialize_editor($this->pObj->id, $template_uid);
     if ($existTemplate) {
         $assigns['siteTitle'] = trim($this->templateRow['sitetitle']);
         $assigns['templateRecord'] = $this->templateRow;
         if ($manyTemplatesMenu) {
             $assigns['manyTemplatesMenu'] = $manyTemplatesMenu;
         }
         $this->getPageRenderer();
         $saveId = $this->templateRow['_ORIG_uid'] ?: $this->templateRow['uid'];
         // Update template ?
         if (GeneralUtility::_POST('_savedok')) {
             $this->templateService->changed = 0;
             $this->templateService->ext_procesInput(GeneralUtility::_POST(), [], $this->constants, $this->templateRow);
             if ($this->templateService->changed) {
                 // Set the data to be saved
                 $recData = [];
                 $recData['sys_template'][$saveId]['constants'] = implode($this->templateService->raw, LF);
                 // Create new  tce-object
                 $tce = GeneralUtility::makeInstance(DataHandler::class);
                 $tce->start($recData, []);
                 $tce->process_datamap();
                 // Clear the cache (note: currently only admin-users can clear the cache in tce_main.php)
                 $tce->clear_cacheCmd('all');
                 // re-read the template ...
                 // re-read the constants as they have changed
                 $this->initialize_editor($this->pObj->id, $template_uid);
             }
         }
         // Resetting the menu (start). I wonder if this in any way is a violation of the menu-system. Haven't checked. But need to do it here, because the menu is dependent on the categories available.
         $this->pObj->MOD_MENU['constant_editor_cat'] = $this->templateService->ext_getCategoryLabelArray();
         $this->pObj->MOD_SETTINGS = BackendUtility::getModuleData($this->pObj->MOD_MENU, GeneralUtility::_GP('SET'), $this->pObj->MCONF['name']);
         // Resetting the menu (stop)
         $assigns['title'] = $this->pObj->linkWrapTemplateTitle($this->templateRow['title'], 'constants');
         if (!empty($this->pObj->MOD_MENU['constant_editor_cat'])) {
             $assigns['constantsMenu'] = BackendUtility::getDropdownMenu($this->pObj->id, 'SET[constant_editor_cat]', $this->pObj->MOD_SETTINGS['constant_editor_cat'], $this->pObj->MOD_MENU['constant_editor_cat']);
         }
         // Category and constant editor config:
         $category = $this->pObj->MOD_SETTINGS['constant_editor_cat'];
         $this->templateService->ext_getTSCE_config($category);
         $printFields = trim($this->templateService->ext_printFields($this->constants, $category));
         foreach ($this->templateService->getInlineJavaScript() as $name => $inlineJavaScript) {
             $this->pageRenderer->addJsInlineCode($name, $inlineJavaScript);
         }
         if ($printFields) {
             $assigns['printFields'] = $printFields;
         }
         $BE_USER_modOptions = BackendUtility::getModTSconfig(0, 'mod.' . $this->pObj->MCONF['name']);
         if ($BE_USER_modOptions['properties']['constantEditor.']['example'] != 'top') {
             $assigns['helpConfig'] = $this->getHelpConfig();
         }
         // Rendering of the output via fluid
         $view = GeneralUtility::makeInstance(StandaloneView::class);
         $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName('EXT:tstemplate/Resources/Private/Templates/ConstantEditor.html'));
         $view->assignMultiple($assigns);
         $theOutput = $view->render();
     } else {
         $theOutput = $this->pObj->noTemplate(1);
     }
     return $theOutput;
 }