/**
     * Main
     *
     * @return string
     */
    public function main()
    {
        $lang = $this->getLanguageService();
        $POST = GeneralUtility::_POST();
        $documentTemplate = $this->getDocumentTemplate();
        // 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);
        $tplRow = $this->getTemplateRow();
        // initialize
        $theOutput = '';
        if ($existTemplate) {
            $content = ' ' . IconUtility::getSpriteIconForRecord('sys_template', $tplRow) . ' <strong>' . $this->pObj->linkWrapTemplateTitle($tplRow['title'], $bType == 'setup' ? 'config' : 'constants') . '</strong>' . htmlspecialchars(trim($tplRow['sitetitle']) ? ' (' . $tplRow['sitetitle'] . ')' : '');
            $theOutput .= $this->pObj->doc->section($lang->getLL('currentTemplate'), $content);
            if ($manyTemplatesMenu) {
                $theOutput .= $this->pObj->doc->section('', $manyTemplatesMenu);
            }
            $theOutput .= $this->pObj->doc->spacer(10);
            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') . '<br />' . $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, htmlspecialchars($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, htmlspecialchars($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, htmlspecialchars($pline), $lang->getLL('objectCleared'));
                            $this->addFlashMessage($objectClearedMessage);
                            $line .= LF . $pline;
                        }
                    }
                }
                if ($line) {
                    $saveId = $tplRow['_ORIG_uid'] ? $tplRow['_ORIG_uid'] : $tplRow['uid'];
                    // Set the data to be saved
                    $recData = array();
                    $field = $bType == 'setup' ? 'config' : 'constants';
                    $recData['sys_template'][$saveId][$field] = $tplRow[$field] . $line;
                    // Create new  tce-object
                    $tce = GeneralUtility::makeInstance(DataHandler::class);
                    $tce->stripslashes_values = FALSE;
                    // Initialize
                    $tce->start($recData, array());
                    // 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');
        $templateService = $this->getExtendedTemplateService();
        $update = 0;
        if (is_array($tsbr)) {
            // If any plus-signs were clicked, it's registred.
            $this->pObj->MOD_SETTINGS['tsbrowser_depthKeys_' . $bType] = $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);
        }
        $templateService->matchAlternative = $this->pObj->MOD_SETTINGS['tsbrowser_conditions'];
        $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.
        $templateService->constantMode = $this->pObj->MOD_SETTINGS['ts_browser_const'];
        if ($this->pObj->sObj && $templateService->constantMode) {
            $templateService->constantMode = 'untouched';
        }
        $templateService->regexMode = $this->pObj->MOD_SETTINGS['ts_browser_regexsearch'];
        $templateService->fixedLgd = $this->pObj->MOD_SETTINGS['ts_browser_fixedLgd'];
        $templateService->linkObjects = TRUE;
        $templateService->ext_regLinenumbers = TRUE;
        $templateService->ext_regComments = $this->pObj->MOD_SETTINGS['ts_browser_showComments'];
        $templateService->bType = $bType;
        if ($this->pObj->MOD_SETTINGS['ts_browser_type'] == 'const') {
            $templateService->ext_constants_BRP = (int) GeneralUtility::_GP('breakPointLN');
        } else {
            $templateService->ext_config_BRP = (int) GeneralUtility::_GP('breakPointLN');
        }
        $templateService->generateConfig();
        if ($bType == 'setup') {
            $theSetup = $templateService->setup;
        } else {
            $theSetup = $templateService->setup_constants;
        }
        // EDIT A VALUE:
        if ($this->pObj->sObj) {
            list($theSetup, $theSetupValue) = $templateService->ext_getSetup($theSetup, $this->pObj->sObj ? $this->pObj->sObj : '');
            if ($existTemplate) {
                // Value
                $out = '';
                $out .= htmlspecialchars($this->pObj->sObj) . ' =<br />';
                $out .= '<input type="text" name="data[' . htmlspecialchars($this->pObj->sObj) . '][value]" value="' . htmlspecialchars($theSetupValue) . '"' . $documentTemplate->formWidth(40) . ' />';
                $out .= '<input class="btn btn-default" type="submit" name="update_value" value="' . $lang->getLL('updateButton') . '" />';
                $theOutput .= $this->pObj->doc->section($lang->getLL('editProperty'), $out, 0, 0);
                // Property
                $out = '<span class="text-nowrap">' . htmlspecialchars($this->pObj->sObj) . '.';
                $out .= '<input type="text" name="data[' . htmlspecialchars($this->pObj->sObj) . '][name]"' . $documentTemplate->formWidth(20) . ' /> = </span><br />';
                $out .= '<input type="text" name="data[' . htmlspecialchars($this->pObj->sObj) . '][propertyValue]"' . $documentTemplate->formWidth(40) . ' />';
                $out .= '<input class="btn btn-default" type="submit" name="add_property" value="' . $lang->getLL('addButton') . '" />';
                $theOutput .= $this->pObj->doc->spacer(20);
                $theOutput .= $this->pObj->doc->section($lang->getLL('addProperty'), $out, 0, 0);
                // clear
                $out = htmlspecialchars($this->pObj->sObj) . ' <strong>' . $lang->csConvObj->conv_case($lang->charSet, $lang->getLL('clear'), 'toUpper') . '</strong> &nbsp;&nbsp;';
                $out .= '<input type="checkbox" name="data[' . htmlspecialchars($this->pObj->sObj) . '][clearValue]" value="1" />';
                $out .= '<input class="btn btn-default" type="submit" name="clear_object" value="' . $lang->getLL('clearButton') . '" />';
                $theOutput .= $this->pObj->doc->spacer(20);
                $theOutput .= $this->pObj->doc->section($lang->getLL('clearObject'), $out, 0, 0);
                $theOutput .= $this->pObj->doc->spacer(10);
            } else {
                $noTemplateMessage = GeneralUtility::makeInstance(FlashMessage::class, $lang->getLL('noCurrentTemplate'), $lang->getLL('edit'), FlashMessage::ERROR);
                $this->addFlashMessage($noTemplateMessage);
                $theOutput .= htmlspecialchars($this->pObj->sObj) . ' = <strong>' . htmlspecialchars($theSetupValue) . '</strong>';
                $theOutput .= $this->pObj->doc->spacer(10);
            }
            // Links:
            $out = '';
            $urlParameters = array('id' => $this->pObj->id);
            $aHref = BackendUtility::getModuleUrl('web_ts', $urlParameters);
            if (!$this->pObj->MOD_SETTINGS['ts_browser_TLKeys_' . $bType][$this->pObj->sObj]) {
                if (!empty($theSetup)) {
                    $out = '<a href="' . htmlspecialchars($aHref . '&addKey[' . rawurlencode($this->pObj->sObj) . ']=1&SET[ts_browser_toplevel_' . $bType . ']=' . rawurlencode($this->pObj->sObj)) . '">';
                    $out .= sprintf($lang->getLL('addKey'), htmlspecialchars($this->pObj->sObj));
                }
            } else {
                $out = '<a href="' . htmlspecialchars($aHref . '&addKey[' . rawurlencode($this->pObj->sObj) . ']=0&SET[ts_browser_toplevel_' . $bType . ']=0') . '">';
                $out .= sprintf($lang->getLL('removeKey'), htmlspecialchars($this->pObj->sObj));
            }
            if ($out) {
                $theOutput .= $this->pObj->doc->divider(5);
                $theOutput .= $this->pObj->doc->section('', $out);
            }
            // back
            $out = $lang->getLL('back');
            $out = '<a href="' . htmlspecialchars($aHref) . '"><strong>' . $out . '</strong></a>';
            $theOutput .= $this->pObj->doc->divider(5);
            $theOutput .= $this->pObj->doc->section('', $out);
        } else {
            $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
                $templateService->tsbrowser_depthKeys = $templateService->ext_getSearchKeys($theSetup, '', GeneralUtility::_POST('search_field'), array());
            }
            $theOutput .= '
				<div class="tsob-menu">
					<div class="form-inline">';
            if (is_array($this->pObj->MOD_MENU['ts_browser_type']) && count($this->pObj->MOD_MENU['ts_browser_type']) > 1) {
                $theOutput .= '
						<div class="form-group">
							<label class="control-label">' . $lang->getLL('browse') . '</label>' . BackendUtility::getFuncMenu($this->pObj->id, 'SET[ts_browser_type]', $bType, $this->pObj->MOD_MENU['ts_browser_type']) . '
						</div>';
            }
            if (is_array($this->pObj->MOD_MENU['ts_browser_toplevel_' . $bType]) && count($this->pObj->MOD_MENU['ts_browser_toplevel_' . $bType]) > 1) {
                $theOutput .= '
						<div class="form-group">
							<label class="control-label" for="ts_browser_toplevel_' . $bType . '">' . $lang->getLL('objectList') . '</label> ' . BackendUtility::getFuncMenu($this->pObj->id, 'SET[ts_browser_toplevel_' . $bType . ']', $this->pObj->MOD_SETTINGS['ts_browser_toplevel_' . $bType], $this->pObj->MOD_MENU['ts_browser_toplevel_' . $bType]) . '
						</div>';
            }
            $theOutput .= '
						<div class="form-group">
							<label class="control-label" for="search_field">' . $lang->getLL('search') . '</label>
							<input class="form-control" type="search" name="search_field" id="search_field" value="' . htmlspecialchars($POST['search_field']) . '"' . $documentTemplate->formWidth(20) . '/>
						</div>
						<input class="btn btn-default tsob-search-submit" type="submit" name="search" value="' . $lang->sL('LLL:EXT:lang/locallang_common.xlf:search') . '" />
					</div>
					<div class="checkbox">
						<label for="checkTs_browser_regexsearch">
							' . BackendUtility::getFuncCheck($this->pObj->id, 'SET[ts_browser_regexsearch]', $this->pObj->MOD_SETTINGS['ts_browser_regexsearch'], '', '', 'id="checkTs_browser_regexsearch"') . $lang->getLL('regExp') . '
						</label>
					</div>
				</div>';
            $theKey = $this->pObj->MOD_SETTINGS['ts_browser_toplevel_' . $bType];
            if (!$theKey || !str_replace('-', '', $theKey)) {
                $theKey = '';
            }
            list($theSetup, $theSetupValue) = $templateService->ext_getSetup($theSetup, $this->pObj->MOD_SETTINGS['ts_browser_toplevel_' . $bType] ? $this->pObj->MOD_SETTINGS['ts_browser_toplevel_' . $bType] : '');
            $tree = $templateService->ext_getObjTree($theSetup, $theKey, '', '', $theSetupValue, $this->pObj->MOD_SETTINGS['ts_browser_alphaSort']);
            $tree = $templateService->substituteCMarkers($tree);
            $urlParameters = array('id' => $this->pObj->id);
            $aHref = BackendUtility::getModuleUrl('web_ts', $urlParameters);
            // Parser Errors:
            $pEkey = $bType == 'setup' ? 'config' : 'constants';
            if (!empty($templateService->parserErrors[$pEkey])) {
                $errMsg = array();
                foreach ($templateService->parserErrors[$pEkey] as $inf) {
                    $errorLink = ' <a href="' . htmlspecialchars($aHref . '&SET[function]=TYPO3\\CMS\\Tstemplate\\Controller\\TemplateAnalyzerModuleFunctionController&template=all&SET[ts_analyzer_checkLinenum]=1#line-' . $inf[2]) . '">' . $lang->getLL('errorShowDetails') . '</a>';
                    $errMsg[] = $inf[1] . ': &nbsp; &nbsp;' . $inf[0] . $errorLink;
                }
                $theOutput .= $this->pObj->doc->spacer(10);
                $title = $lang->getLL('errorsWarnings');
                $message = '<p>' . implode($errMsg, '<br />') . '</p>';
                $view = GeneralUtility::makeInstance(StandaloneView::class);
                $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName('EXT:tstemplate/Resources/Private/Templates/InfoBox.html'));
                $view->assignMultiple(array('title' => $title, 'message' => $message, 'state' => InfoboxViewHelper::STATE_WARNING));
                $theOutput .= $view->render();
            }
            if (isset($this->pObj->MOD_SETTINGS['ts_browser_TLKeys_' . $bType][$theKey])) {
                $remove = '<a href="' . htmlspecialchars($aHref . '&addKey[' . $theKey . ']=0&SET[ts_browser_toplevel_' . $bType . ']=0') . '">' . $lang->getLL('removeKey') . '</a>';
            } else {
                $remove = '';
            }
            $label = $theKey ? $theKey : ($bType == 'setup' ? $lang->csConvObj->conv_case($lang->charSet, $lang->getLL('setupRoot'), 'toUpper') : $lang->csConvObj->conv_case($lang->charSet, $lang->getLL('constantRoot'), 'toUpper'));
            $theOutput .= $this->pObj->doc->sectionEnd();
            $theOutput .= '<div class="panel panel-space panel-default">';
            $theOutput .= '<div class="panel-heading">';
            $theOutput .= '<strong>' . $label . ' ' . $remove . '</strong>';
            $theOutput .= '</div>';
            $theOutput .= '<div class="panel-body">' . $tree . '</div>';
            $theOutput .= '</div>';
            // second row options
            $menu = '<div class="tsob-menu-row2">';
            $menu .= '<div class="checkbox"><label for="checkTs_browser_showComments">' . BackendUtility::getFuncCheck($this->pObj->id, 'SET[ts_browser_showComments]', $this->pObj->MOD_SETTINGS['ts_browser_showComments'], '', '', 'id="checkTs_browser_showComments"');
            $menu .= $lang->getLL('displayComments') . '</label></div>';
            $menu .= '<div class="checkbox"><label for="checkTs_browser_alphaSort">' . BackendUtility::getFuncCheck($this->pObj->id, 'SET[ts_browser_alphaSort]', $this->pObj->MOD_SETTINGS['ts_browser_alphaSort'], '', '', 'id="checkTs_browser_alphaSort"');
            $menu .= $lang->getLL('sortAlphabetically') . '</label></div>';
            $menu .= '<div class="checkbox"><label for="checkTs_browser_fixedLgd">' . BackendUtility::getFuncCheck($this->pObj->id, 'SET[ts_browser_fixedLgd]', $this->pObj->MOD_SETTINGS['ts_browser_fixedLgd'], '', '', 'id="checkTs_browser_fixedLgd"');
            $menu .= $lang->getLL('cropLines') . '</label></div>';
            if ($bType == 'setup' && !$this->pObj->MOD_SETTINGS['ts_browser_fixedLgd']) {
                $menu .= '<br /><br /><label>' . $lang->getLL('displayConstants') . '</label>';
                $menu .= BackendUtility::getFuncMenu($this->pObj->id, 'SET[ts_browser_const]', $this->pObj->MOD_SETTINGS['ts_browser_const'], $this->pObj->MOD_MENU['ts_browser_const']);
            }
            $menu .= '</div>';
            $theOutput .= $this->pObj->doc->section($lang->getLL('displayOptions'), '<span class="text-nowrap">' . $menu . '</span>', 0, 1);
            // Conditions:
            if (is_array($templateService->sections) && !empty($templateService->sections)) {
                $theOutput .= $this->pObj->doc->section($lang->getLL('conditions'), '', 0, 1);
                $out = '';
                foreach ($templateService->sections as $key => $val) {
                    $out .= '<div class="checkbox"><label for="check' . $key . '">';
                    $out .= '<input class="checkbox" type="checkbox" name="conditions[' . $key . ']" id="check' . $key . '" value="' . htmlspecialchars($val) . '"' . ($this->pObj->MOD_SETTINGS['tsbrowser_conditions'][$key] ? ' checked' : '') . ' />' . $templateService->substituteCMarkers(htmlspecialchars($val));
                    $out .= '</label></div>';
                }
                $theOutput .= '<div class="tsob-menu-row2">' . $out . '</div><input class="btn btn-default" type="submit" name="Submit" value="' . $lang->getLL('setConditions') . '" />';
            }
            // Ending section:
            $theOutput .= $this->pObj->doc->sectionEnd();
        }
        return $theOutput;
    }
 /**
  * Main
  *
  * @return string
  */
 public function main()
 {
     $lang = $this->getLanguageService();
     $lang->includeLLFile('EXT:tstemplate/Resources/Private/Language/locallang_ceditor.xlf');
     $theOutput = '';
     // 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) {
         $templateService = $this->getExtendedTemplateService();
         $tplRow = $this->getTemplateRow();
         $theConstants = $this->getConstants();
         $this->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Tstemplate/ConstantEditor');
         $saveId = $tplRow['_ORIG_uid'] ? $tplRow['_ORIG_uid'] : $tplRow['uid'];
         // Update template ?
         if (GeneralUtility::_POST('_savedok')) {
             $templateService->changed = 0;
             $templateService->ext_procesInput(GeneralUtility::_POST(), array(), $theConstants, $tplRow);
             if ($templateService->changed) {
                 // Set the data to be saved
                 $recData = array();
                 $recData['sys_template'][$saveId]['constants'] = implode($templateService->raw, LF);
                 // Create new  tce-object
                 $tce = GeneralUtility::makeInstance(DataHandler::class);
                 $tce->stripslashes_values = false;
                 $tce->start($recData, array());
                 $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);
                 // re-read the constants as they have changed
                 $templateService = $this->getExtendedTemplateService();
                 $tplRow = $this->getTemplateRow();
                 $theConstants = $this->getConstants();
             }
         }
         // 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'] = $templateService->ext_getCategoryLabelArray();
         $this->pObj->MOD_SETTINGS = BackendUtility::getModuleData($this->pObj->MOD_MENU, GeneralUtility::_GP('SET'), $this->pObj->MCONF['name']);
         // Resetting the menu (stop)
         $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
         $content = $iconFactory->getIconForRecord('sys_template', $tplRow, Icon::SIZE_SMALL)->render() . '<strong>' . $this->pObj->linkWrapTemplateTitle($tplRow['title'], 'constants') . '</strong>' . (trim($tplRow['sitetitle']) ? htmlspecialchars(' (' . $tplRow['sitetitle'] . ')') : '');
         $theOutput .= $this->pObj->doc->section($lang->getLL('editConstants', true), $content, false, true);
         if ($manyTemplatesMenu) {
             $theOutput .= $this->pObj->doc->section('', $manyTemplatesMenu);
         }
         $theOutput .= '<div style="padding-top: 10px;"></div>';
         if (!empty($this->pObj->MOD_MENU['constant_editor_cat'])) {
             $menu = '<div class="form-inline form-inline-spaced">';
             $menu .= BackendUtility::getDropdownMenu($this->pObj->id, 'SET[constant_editor_cat]', $this->pObj->MOD_SETTINGS['constant_editor_cat'], $this->pObj->MOD_MENU['constant_editor_cat']);
             $menu .= '</div>';
             $theOutput .= $this->pObj->doc->section($lang->getLL('category', true), '<span class="text-nowrap">' . $menu . '</span>', false);
         } else {
             $theOutput .= $this->pObj->doc->section($lang->getLL('noConstants', true), $lang->getLL('noConstantsDescription', true), false, false, 1);
         }
         $theOutput .= '<div style="padding-top: 15px;"></div>';
         // Category and constant editor config:
         $category = $this->pObj->MOD_SETTINGS['constant_editor_cat'];
         $templateService->ext_getTSCE_config($category);
         $printFields = trim($templateService->ext_printFields($theConstants, $category));
         if ($printFields) {
             $theOutput .= $this->pObj->doc->section('', $printFields);
         }
         $BE_USER_modOptions = BackendUtility::getModTSconfig(0, 'mod.' . $this->pObj->MCONF['name']);
         if ($BE_USER_modOptions['properties']['constantEditor.']['example'] != 'top') {
             $theOutput = $this->displayExample($theOutput);
         }
     } else {
         $theOutput .= $this->pObj->noTemplate(1);
     }
     return $theOutput;
 }
 /**
  * The main processing method if this class
  *
  * @return string Information of the template status or the taken actions as HTML string
  */
 public function main()
 {
     $lang = $this->getLanguageService();
     $lang->includeLLFile('EXT:tstemplate/Resources/Private/Language/locallang_info.xlf');
     $this->pObj->MOD_MENU['includeTypoScriptFileContent'] = true;
     $e = $this->pObj->e;
     // 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);
     $tplRow = $GLOBALS['tplRow'];
     $saveId = 0;
     if ($existTemplate) {
         $saveId = $tplRow['_ORIG_uid'] ? $tplRow['_ORIG_uid'] : $tplRow['uid'];
     }
     // Create extension template
     $newId = $this->pObj->createTemplate($this->pObj->id, $saveId);
     if ($newId) {
         // Switch to new template
         $urlParameters = ['id' => $this->pObj->id, 'SET[templatesOnPage]' => $newId];
         $url = BackendUtility::getModuleUrl('web_ts', $urlParameters);
         HttpUtility::redirect($url);
     }
     $tce = null;
     $theOutput = '';
     if ($existTemplate) {
         // Update template ?
         $POST = GeneralUtility::_POST();
         if (isset($POST['_savedok']) || isset($POST['_saveandclosedok'])) {
             // Set the data to be saved
             $recData = array();
             $alternativeFileName = array();
             if (is_array($POST['data'])) {
                 foreach ($POST['data'] as $field => $val) {
                     switch ($field) {
                         case 'constants':
                         case 'config':
                             $recData['sys_template'][$saveId][$field] = $val;
                             break;
                     }
                 }
             }
             if (!empty($recData)) {
                 $recData['sys_template'][$saveId] = $this->processTemplateRowBeforeSaving($recData['sys_template'][$saveId]);
                 // Create new  tce-object
                 $tce = GeneralUtility::makeInstance(DataHandler::class);
                 $tce->alternativeFileName = $alternativeFileName;
                 // Initialize
                 $tce->start($recData, array());
                 // 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');
                 // tce were processed successfully
                 $this->tce_processed = true;
                 // re-read the template ...
                 $this->initialize_editor($this->pObj->id, $template_uid);
                 $tplRow = $GLOBALS['tplRow'];
                 // reload template menu
                 $manyTemplatesMenu = $this->pObj->templateMenu();
             }
         }
         // Hook post updating template/TCE processing
         if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postTCEProcessingHook'])) {
             $postTCEProcessingHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postTCEProcessingHook'];
             if (is_array($postTCEProcessingHook)) {
                 $hookParameters = array('POST' => $POST, 'tce' => $tce);
                 foreach ($postTCEProcessingHook as $hookFunction) {
                     GeneralUtility::callUserFunction($hookFunction, $hookParameters, $this);
                 }
             }
         }
         $content = '<a href="#" class="t3-js-clickmenutrigger" data-table="sys_template" data-uid="' . $tplRow['uid'] . '" data-listframe="1">' . $this->iconFactory->getIconForRecord('sys_template', $tplRow, Icon::SIZE_SMALL)->render() . '</a><strong>' . htmlspecialchars($tplRow['title']) . '</strong>' . (trim($tplRow['sitetitle']) ? htmlspecialchars(' (' . $tplRow['sitetitle'] . ')') : '');
         $theOutput .= '<h2>' . $lang->getLL('templateInformation', true) . '</h2><div>' . $content . '</div>';
         if ($manyTemplatesMenu) {
             $theOutput .= '<div>' . $manyTemplatesMenu . '</div>';
         }
         $theOutput .= '<div style="padding-top: 10px;"></div>';
         $numberOfRows = 35;
         // If abort pressed, nothing should be edited:
         if (isset($POST['_saveandclosedok'])) {
             unset($e);
         }
         if (isset($e['constants'])) {
             $outCode = '<textarea name="data[constants]" rows="' . $numberOfRows . '" wrap="off" class="text-monospace enable-tab" style="width:98%;height:70%" class="text-monospace">' . htmlspecialchars($tplRow['constants']) . '</textarea>';
             $outCode .= '<input type="hidden" name="e[constants]" value="1">';
             // Display "Include TypoScript file content?" checkbox
             $outCode .= '<div class="checkbox"><label for="checkIncludeTypoScriptFileContent">' . BackendUtility::getFuncCheck($this->pObj->id, 'SET[includeTypoScriptFileContent]', $this->pObj->MOD_SETTINGS['includeTypoScriptFileContent'], '', '&e[constants]=1', 'id="checkIncludeTypoScriptFileContent"');
             $outCode .= $lang->getLL('includeTypoScriptFileContent') . '</label></div><br />';
             $theOutput .= '<div style="padding-top: 15px;"></div>';
             $theOutput .= '<h3>' . $lang->getLL('constants', true) . '</h3>';
             $theOutput .= $outCode;
         }
         if (isset($e['config'])) {
             $outCode = '<textarea name="data[config]" rows="' . $numberOfRows . '" wrap="off" class="text-monospace enable-tab" style="width:98%;height:70%" class="text-monospace">' . htmlspecialchars($tplRow['config']) . '</textarea>';
             $outCode .= '<input type="hidden" name="e[config]" value="1">';
             // Display "Include TypoScript file content?" checkbox
             $outCode .= '<div class="checkbox"><label for="checkIncludeTypoScriptFileContent">' . BackendUtility::getFuncCheck($this->pObj->id, 'SET[includeTypoScriptFileContent]', $this->pObj->MOD_SETTINGS['includeTypoScriptFileContent'], '', '&e[config]=1', 'id="checkIncludeTypoScriptFileContent"');
             $outCode .= $lang->getLL('includeTypoScriptFileContent') . '</label></div><br />';
             $theOutput .= '<div style="padding-top: 15px;"></div>';
             $theOutput .= '<h3>' . $lang->getLL('setup', true) . '</h3>';
             $theOutput .= $outCode;
         }
         // Processing:
         $outCode = '';
         $outCode .= $this->tableRow($lang->getLL('title'), htmlspecialchars($tplRow['title']), 'title', $tplRow['uid']);
         $outCode .= $this->tableRow($lang->getLL('sitetitle'), htmlspecialchars($tplRow['sitetitle']), 'sitetitle', $tplRow['uid']);
         $outCode .= $this->tableRow($lang->getLL('description'), nl2br(htmlspecialchars($tplRow['description'])), 'description', $tplRow['uid']);
         $outCode .= $this->tableRow($lang->getLL('constants'), sprintf($lang->getLL('editToView'), trim($tplRow['constants']) ? count(explode(LF, $tplRow['constants'])) : 0), 'constants', $tplRow['uid']);
         $outCode .= $this->tableRow($lang->getLL('setup'), sprintf($lang->getLL('editToView'), trim($tplRow['config']) ? count(explode(LF, $tplRow['config'])) : 0), 'config', $tplRow['uid']);
         $outCode = '<div class="table-fit"><table class="table table-striped table-hover">' . $outCode . '</table></div>';
         // Edit all icon:
         $urlParameters = ['edit' => ['sys_template' => [$tplRow['uid'] => 'edit']], 'createExtension' => 0, 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')];
         $url = BackendUtility::getModuleUrl('record_edit', $urlParameters);
         $title = $lang->getLL('editTemplateRecord', true);
         $icon = $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render();
         $outCode .= '<br /><a class="btn btn-default" href="' . htmlspecialchars($url) . '"><strong>' . $icon . '&nbsp;' . $title . '</strong></a>';
         $theOutput .= '<div>' . $outCode . '</div>';
         // hook	after compiling the output
         if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postOutputProcessingHook'])) {
             $postOutputProcessingHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postOutputProcessingHook'];
             if (is_array($postOutputProcessingHook)) {
                 $hookParameters = array('theOutput' => &$theOutput, 'POST' => $POST, 'e' => $e, 'tplRow' => $tplRow, 'numberOfRows' => $numberOfRows);
                 foreach ($postOutputProcessingHook as $hookFunction) {
                     GeneralUtility::callUserFunction($hookFunction, $hookParameters, $this);
                 }
             }
         }
     } else {
         $theOutput .= $this->pObj->noTemplate(1);
     }
     return $theOutput;
 }
Beispiel #4
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();
 }
    /**
     * Main
     *
     * @return string
     */
    public function main()
    {
        $theOutput = '';
        // 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...
        $manyTemplatesMenu = $this->pObj->templateMenu();
        $template_uid = 0;
        if ($manyTemplatesMenu) {
            $template_uid = $this->pObj->MOD_SETTINGS['templatesOnPage'];
        }
        $existTemplate = $this->initialize_editor($this->pObj->id, $template_uid);
        // initialize
        $lang = $this->getLanguageService();
        if ($existTemplate) {
            $siteTitle = trim($GLOBALS['tplRow']['sitetitle']);
            $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
            $theOutput .= $this->pObj->doc->section($lang->getLL('currentTemplate', true), $iconFactory->getIconForRecord('sys_template', $GLOBALS['tplRow'], Icon::SIZE_SMALL)->render() . '<strong>' . $this->pObj->linkWrapTemplateTitle($GLOBALS['tplRow']['title']) . '</strong>' . htmlspecialchars($siteTitle ? ' (' . $siteTitle . ')' : ''));
        }
        if ($manyTemplatesMenu) {
            $theOutput .= $this->pObj->doc->section('', $manyTemplatesMenu);
        }
        $templateService = $this->getExtendedTemplateService();
        $templateService->clearList_const_temp = array_flip($templateService->clearList_const);
        $templateService->clearList_setup_temp = array_flip($templateService->clearList_setup);
        $pointer = count($templateService->hierarchyInfo);
        $hierarchyInfo = $templateService->ext_process_hierarchyInfo(array(), $pointer);
        $head = '<thead><tr>';
        $head .= '<th>' . $lang->getLL('title', true) . '</th>';
        $head .= '<th>' . $lang->getLL('rootlevel', true) . '</th>';
        $head .= '<th>' . $lang->getLL('clearSetup', true) . '</th>';
        $head .= '<th>' . $lang->getLL('clearConstants', true) . '</th>';
        $head .= '<th>' . $lang->getLL('pid', true) . '</th>';
        $head .= '<th>' . $lang->getLL('rootline', true) . '</th>';
        $head .= '<th>' . $lang->getLL('nextLevel', true) . '</th>';
        $head .= '</tr></thead>';
        $hierar = implode(array_reverse($templateService->ext_getTemplateHierarchyArr($hierarchyInfo, '', array(), 1)), '');
        $hierar = '<div class="table-fit"><table class="table table-striped table-hover" id="ts-analyzer">' . $head . $hierar . '</table></div>';
        $theOutput .= $this->pObj->doc->spacer(5);
        $theOutput .= $this->pObj->doc->section($lang->getLL('templateHierarchy', true), $hierar, 0, 1);
        $urlParameters = array('id' => $GLOBALS['SOBE']->id, 'template' => 'all');
        $aHref = BackendUtility::getModuleUrl('web_ts', $urlParameters);
        $completeLink = '<p><a href="' . htmlspecialchars($aHref) . '" class="btn btn-default">' . $lang->getLL('viewCompleteTS', true) . '</a></p>';
        $theOutput .= $this->pObj->doc->spacer(5);
        $theOutput .= $this->pObj->doc->section($lang->getLL('completeTS', true), $completeLink, 0, 1);
        $theOutput .= $this->pObj->doc->spacer(15);
        // Output options
        $theOutput .= $this->pObj->doc->section($lang->getLL('displayOptions', true), '', false, true);
        $template = GeneralUtility::_GET('template');
        $addParams = $template ? '&template=' . $template : '';
        $theOutput .= '<div class="tst-analyzer-options">' . '<div class="checkbox"><label for="checkTs_analyzer_checkLinenum">' . BackendUtility::getFuncCheck($this->pObj->id, 'SET[ts_analyzer_checkLinenum]', $this->pObj->MOD_SETTINGS['ts_analyzer_checkLinenum'], '', $addParams, 'id="checkTs_analyzer_checkLinenum"') . $lang->getLL('lineNumbers', true) . '</label></div>' . '<div class="checkbox"><label for="checkTs_analyzer_checkSyntax">' . BackendUtility::getFuncCheck($this->pObj->id, 'SET[ts_analyzer_checkSyntax]', $this->pObj->MOD_SETTINGS['ts_analyzer_checkSyntax'], '', $addParams, 'id="checkTs_analyzer_checkSyntax"') . $lang->getLL('syntaxHighlight', true) . '</label> ' . '</label></div>';
        if (!$this->pObj->MOD_SETTINGS['ts_analyzer_checkSyntax']) {
            $theOutput .= '<div class="checkbox"><label for="checkTs_analyzer_checkComments">' . BackendUtility::getFuncCheck($this->pObj->id, 'SET[ts_analyzer_checkComments]', $this->pObj->MOD_SETTINGS['ts_analyzer_checkComments'], '', $addParams, 'id="checkTs_analyzer_checkComments"') . $lang->getLL('comments', true) . '</label></div>' . '<div class="checkbox"><label for="checkTs_analyzer_checkCrop">' . BackendUtility::getFuncCheck($this->pObj->id, 'SET[ts_analyzer_checkCrop]', $this->pObj->MOD_SETTINGS['ts_analyzer_checkCrop'], '', $addParams, 'id="checkTs_analyzer_checkCrop"') . $lang->getLL('cropLines', true) . '</label></div>';
        }
        $theOutput .= '</div>';
        $theOutput .= $this->pObj->doc->spacer(25);
        if ($template) {
            // Output Constants
            $theOutput .= $this->pObj->doc->section($lang->getLL('constants', true), '', 0, 1);
            $theOutput .= $this->pObj->doc->sectionEnd();
            $templateService->ext_lineNumberOffset = 0;
            $templateService->ext_lineNumberOffset_mode = 'const';
            foreach ($templateService->constants as $key => $val) {
                $currentTemplateId = $templateService->hierarchyInfo[$key]['templateID'];
                if ($currentTemplateId == $template || $template === 'all') {
                    $theOutput .= '
						<h3>' . htmlspecialchars($templateService->hierarchyInfo[$key]['title']) . '</h3>
						<div class="nowrap">' . $templateService->ext_outputTS(array($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) . '</div>
					';
                    if ($template !== 'all') {
                        break;
                    }
                }
                $templateService->ext_lineNumberOffset += count(explode(LF, $val)) + 1;
            }
            // Output Setup
            $theOutput .= $this->pObj->doc->spacer(15);
            $theOutput .= $this->pObj->doc->section($lang->getLL('setup', true), '', 0, 1);
            $theOutput .= $this->pObj->doc->sectionEnd();
            $templateService->ext_lineNumberOffset = 0;
            $templateService->ext_lineNumberOffset_mode = 'setup';
            foreach ($templateService->config as $key => $val) {
                $currentTemplateId = $templateService->hierarchyInfo[$key]['templateID'];
                if ($currentTemplateId == $template || $template == 'all') {
                    $theOutput .= '
						<h3>' . htmlspecialchars($templateService->hierarchyInfo[$key]['title']) . '</h3>
						<div class="nowrap">' . $templateService->ext_outputTS(array($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) . '</div>
					';
                    if ($template !== 'all') {
                        break;
                    }
                }
                $templateService->ext_lineNumberOffset += count(explode(LF, $val)) + 1;
            }
        }
        return $theOutput;
    }
Beispiel #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();
 }
Beispiel #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;
 }