예제 #1
0
 /**
  * MAIN function for page information of localization
  *
  * @return string Output HTML for the module.
  */
 public function main()
 {
     $theOutput = '<h1>' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:frontend/Resources/Private/Language/locallang_webinfo.xlf:lang_title')) . '</h1>';
     if ($this->pObj->id) {
         // Depth selector:
         $theOutput .= '<div class="form-inline form-inline-spaced">';
         $h_func = BackendUtility::getDropdownMenu($this->pObj->id, 'SET[depth]', $this->pObj->MOD_SETTINGS['depth'], $this->pObj->MOD_MENU['depth']);
         $h_func .= BackendUtility::getDropdownMenu($this->pObj->id, 'SET[lang]', $this->pObj->MOD_SETTINGS['lang'], $this->pObj->MOD_MENU['lang']);
         $theOutput .= $h_func;
         // Add CSH:
         $theOutput .= BackendUtility::cshItem('_MOD_web_info', 'lang', null, '<div class="form-group"><span class="btn btn-default btn-sm">|</span></div><br />');
         $theOutput .= '</div>';
         // Showing the tree:
         // Initialize starting point of page tree:
         $treeStartingPoint = (int) $this->pObj->id;
         $treeStartingRecord = BackendUtility::getRecordWSOL('pages', $treeStartingPoint);
         $depth = $this->pObj->MOD_SETTINGS['depth'];
         // Initialize tree object:
         $tree = GeneralUtility::makeInstance(PageTreeView::class);
         $tree->init('AND ' . $this->getBackendUser()->getPagePermsClause(1));
         $tree->addField('l18n_cfg');
         // Creating top icon; the current page
         $HTML = $this->iconFactory->getIconForRecord('pages', $treeStartingRecord, Icon::SIZE_SMALL)->render();
         $tree->tree[] = ['row' => $treeStartingRecord, 'HTML' => $HTML];
         // Create the tree from starting point:
         if ($depth) {
             $tree->getTree($treeStartingPoint, $depth, '');
         }
         // Render information table:
         $theOutput .= $this->renderL10nTable($tree);
     }
     return $theOutput;
 }
예제 #2
0
 /**
  * MAIN function for page information display
  *
  * @return string Output HTML for the module.
  */
 public function main()
 {
     $theOutput = $this->pObj->doc->header($this->getLanguageService()->sL('LLL:EXT:frontend/Resources/Private/Language/locallang_webinfo.xlf:page_title'));
     $dblist = GeneralUtility::makeInstance(PageLayoutView::class);
     $dblist->descrTable = '_MOD_web_info';
     $dblist->thumbs = 0;
     $dblist->script = BackendUtility::getModuleUrl('web_info');
     $dblist->showIcon = 0;
     $dblist->setLMargin = 0;
     $dblist->agePrefixes = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.minutesHoursDaysYears');
     $dblist->pI_showUser = 1;
     // PAGES:
     $this->pObj->MOD_SETTINGS['pages_levels'] = $this->pObj->MOD_SETTINGS['depth'];
     // ONLY for the sake of dblist module which uses this value.
     $h_func = BackendUtility::getDropdownMenu($this->pObj->id, 'SET[depth]', $this->pObj->MOD_SETTINGS['depth'], $this->pObj->MOD_MENU['depth']);
     $h_func .= BackendUtility::getDropdownMenu($this->pObj->id, 'SET[pages]', $this->pObj->MOD_SETTINGS['pages'], $this->pObj->MOD_MENU['pages']);
     $dblist->start($this->pObj->id, 'pages', 0);
     $dblist->generateList();
     // CSH
     $theOutput .= $this->pObj->doc->section('', BackendUtility::cshItem($dblist->descrTable, 'pagetree_overview', null, '|<br />') . '<div class="form-inline form-inline-spaced">' . $h_func . '</div>' . $dblist->HTMLcode, 0, 1);
     // Additional footer content
     $footerContentHook = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/web_info/class.tx_cms_webinfo.php']['drawFooterHook'];
     if (is_array($footerContentHook)) {
         foreach ($footerContentHook as $hook) {
             $params = array();
             $theOutput .= GeneralUtility::callUserFunction($hook, $params, $this);
         }
     }
     return $theOutput;
 }
예제 #3
0
 /**
  * MAIN function for page information display
  *
  * @return string Output HTML for the module.
  */
 public function main()
 {
     $theOutput = '<h1>' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:frontend/Resources/Private/Language/locallang_webinfo.xlf:page_title')) . '</h1>';
     $dblist = GeneralUtility::makeInstance(PageLayoutView::class);
     $dblist->descrTable = '_MOD_web_info';
     $dblist->thumbs = 0;
     $dblist->script = BackendUtility::getModuleUrl('web_info');
     $dblist->showIcon = 0;
     $dblist->setLMargin = 0;
     $dblist->agePrefixes = $GLOBALS['LANG']->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.minutesHoursDaysYears');
     $dblist->pI_showUser = 1;
     switch ((int) $this->pObj->MOD_SETTINGS['pages']) {
         case 1:
             $dblist->fieldArray = ['title', 'uid'] + array_keys($this->cleanTableNames());
             break;
         case 2:
             $dblist->fieldArray = ['title', 'uid', 'lastUpdated', 'newUntil', 'no_cache', 'cache_timeout', 'php_tree_stop', 'TSconfig', 'is_siteroot', 'fe_login_mode'];
             break;
         default:
             $dblist->fieldArray = ['title', 'uid', 'alias', 'starttime', 'endtime', 'fe_group', 'target', 'url', 'shortcut', 'shortcut_mode'];
     }
     // PAGES:
     $this->pObj->MOD_SETTINGS['pages_levels'] = $this->pObj->MOD_SETTINGS['depth'];
     // ONLY for the sake of dblist module which uses this value.
     $h_func = BackendUtility::getDropdownMenu($this->pObj->id, 'SET[depth]', $this->pObj->MOD_SETTINGS['depth'], $this->pObj->MOD_MENU['depth']);
     $h_func .= BackendUtility::getDropdownMenu($this->pObj->id, 'SET[pages]', $this->pObj->MOD_SETTINGS['pages'], $this->pObj->MOD_MENU['pages']);
     $dblist->start($this->pObj->id, 'pages', 0);
     $dblist->generateList();
     // CSH
     $theOutput .= '<div>';
     $theOutput .= BackendUtility::cshItem($dblist->descrTable, 'pagetree_overview', null, '<span class="btn btn-default btn-sm">|</span><br />') . '<div class="form-inline form-inline-spaced">' . $h_func . '</div>' . $dblist->HTMLcode;
     $theOutput .= '</div>';
     // Additional footer content
     $footerContentHook = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/web_info/class.tx_cms_webinfo.php']['drawFooterHook'];
     if (is_array($footerContentHook)) {
         foreach ($footerContentHook as $hook) {
             $params = [];
             $theOutput .= GeneralUtility::callUserFunction($hook, $params, $this);
         }
     }
     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;
 }
 /**
  * Main function of class
  *
  * @return string HTML output
  */
 public function main()
 {
     $pageId = (int) GeneralUtility::_GP('id');
     if ($pageId === 0) {
         $this->view->assign('pageZero', 1);
         $this->view->assign('overviewOfPagesUsingTSConfig', $this->getOverviewOfPagesUsingTSConfig());
     } else {
         if ($this->pObj->MOD_SETTINGS['tsconf_parts'] == 99) {
             $TSparts = BackendUtility::getPagesTSconfig($this->pObj->id, null, true);
             $lines = array();
             $pUids = array();
             foreach ($TSparts as $k => $v) {
                 if ($k != 'uid_0') {
                     $line = array();
                     if ($k == 'defaultPageTSconfig') {
                         $line['defaultPageTSconfig'] = 1;
                     } else {
                         $pUids[] = substr($k, 4);
                         $row = BackendUtility::getRecordWSOL('pages', substr($k, 4));
                         $icon = $this->iconFactory->getIconForRecord('pages', $row, Icon::SIZE_SMALL);
                         $editIdList = substr($k, 4);
                         $urlParameters = ['edit' => ['pages' => [$editIdList => 'edit']], 'columnsOnly' => 'TSconfig', 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')];
                         $line['editIcon'] = BackendUtility::getModuleUrl('record_edit', $urlParameters);
                         $line['editTitle'] = 'editTSconfig';
                         $line['title'] = BackendUtility::wrapClickMenuOnIcon($icon, 'pages', $row['uid']) . ' ' . htmlspecialchars(BackendUtility::getRecordTitle('pages', $row));
                     }
                     $tsparser = GeneralUtility::makeInstance(\TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::class);
                     $tsparser->lineNumberOffset = 0;
                     $line['content'] = $tsparser->doSyntaxHighlight(trim($v) . LF);
                     $lines[] = $line;
                 }
             }
             if (!empty($pUids)) {
                 $urlParameters = ['edit' => ['pages' => [implode(',', $pUids) => 'edit']], 'columnsOnly' => 'TSconfig', 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')];
                 $url = BackendUtility::getModuleUrl('record_edit', $urlParameters);
                 $editIcon = htmlspecialchars($url);
                 $editTitle = 'editTSconfig_all';
             } else {
                 $editIcon = '';
                 $editTitle = '';
             }
             $this->view->assign('tsconfParts99', 1);
             $this->view->assign('csh', BackendUtility::cshItem('_MOD_web_info', 'tsconfig_edit', null, '|'));
             $this->view->assign('lines', $lines);
             $this->view->assign('editIcon', $editIcon);
             $this->view->assign('editTitle', $editTitle);
         } else {
             $this->view->assign('tsconfParts99', 0);
             // Defined global here!
             $tmpl = GeneralUtility::makeInstance(\TYPO3\CMS\Core\TypoScript\ExtendedTemplateService::class);
             // Do not log time-performance information
             $tmpl->tt_track = 0;
             $tmpl->fixedLgd = 0;
             $tmpl->linkObjects = 0;
             $tmpl->bType = '';
             $tmpl->ext_expandAllNotes = 1;
             $tmpl->ext_noPMicons = 1;
             $beUser = $this->getBackendUser();
             switch ($this->pObj->MOD_SETTINGS['tsconf_parts']) {
                 case '1':
                     $modTSconfig = BackendUtility::getModTSconfig($this->pObj->id, 'mod');
                     break;
                 case '1a':
                     $modTSconfig = $beUser->getTSConfig('mod.web_layout', BackendUtility::getPagesTSconfig($this->pObj->id));
                     break;
                 case '1b':
                     $modTSconfig = $beUser->getTSConfig('mod.web_view', BackendUtility::getPagesTSconfig($this->pObj->id));
                     break;
                 case '1c':
                     $modTSconfig = $beUser->getTSConfig('mod.web_modules', BackendUtility::getPagesTSconfig($this->pObj->id));
                     break;
                 case '1d':
                     $modTSconfig = $beUser->getTSConfig('mod.web_list', BackendUtility::getPagesTSconfig($this->pObj->id));
                     break;
                 case '1e':
                     $modTSconfig = $beUser->getTSConfig('mod.web_info', BackendUtility::getPagesTSconfig($this->pObj->id));
                     break;
                 case '1f':
                     $modTSconfig = $beUser->getTSConfig('mod.web_func', BackendUtility::getPagesTSconfig($this->pObj->id));
                     break;
                 case '1g':
                     $modTSconfig = $beUser->getTSConfig('mod.web_ts', BackendUtility::getPagesTSconfig($this->pObj->id));
                     break;
                 case '2':
                     $modTSconfig = $beUser->getTSConfig('RTE', BackendUtility::getPagesTSconfig($this->pObj->id));
                     break;
                 case '5':
                     $modTSconfig = $beUser->getTSConfig('TCEFORM', BackendUtility::getPagesTSconfig($this->pObj->id));
                     break;
                 case '6':
                     $modTSconfig = $beUser->getTSConfig('TCEMAIN', BackendUtility::getPagesTSconfig($this->pObj->id));
                     break;
                 case '3':
                     $modTSconfig = $beUser->getTSConfig('TSFE', BackendUtility::getPagesTSconfig($this->pObj->id));
                     break;
                 case '4':
                     $modTSconfig = $beUser->getTSConfig('user', BackendUtility::getPagesTSconfig($this->pObj->id));
                     break;
                 default:
                     $modTSconfig['properties'] = BackendUtility::getPagesTSconfig($this->pObj->id);
             }
             $modTSconfig = $modTSconfig['properties'];
             if (!is_array($modTSconfig)) {
                 $modTSconfig = array();
             }
             $this->view->assign('csh', BackendUtility::cshItem('_MOD_web_info', 'tsconfig_hierarchy', null, '|'));
             $this->view->assign('tree', $tmpl->ext_getObjTree($modTSconfig, '', '', '', '', $this->pObj->MOD_SETTINGS['tsconf_alphaSort']));
         }
         $this->view->assign('alphaSort', BackendUtility::getFuncCheck($this->pObj->id, 'SET[tsconf_alphaSort]', $this->pObj->MOD_SETTINGS['tsconf_alphaSort'], '', '', 'id="checkTsconf_alphaSort"'));
         $this->view->assign('dropdownMenu', BackendUtility::getDropdownMenu($this->pObj->id, 'SET[tsconf_parts]', $this->pObj->MOD_SETTINGS['tsconf_parts'], $this->pObj->MOD_MENU['tsconf_parts']));
     }
     return $this->view->render();
 }
예제 #6
0
 /**
  * Search (Full / Advanced)
  *
  * @return void
  */
 public function func_search()
 {
     $lang = $this->getLanguageService();
     $searchMode = $this->MOD_SETTINGS['search'];
     $fullsearch = GeneralUtility::makeInstance(QueryView::class);
     $fullsearch->setFormName($this->formName);
     $submenu = '<div class="form-inline form-inline-spaced">';
     $submenu .= BackendUtility::getDropdownMenu(0, 'SET[search]', $searchMode, $this->MOD_MENU['search']);
     if ($this->MOD_SETTINGS['search'] == 'query') {
         $submenu .= BackendUtility::getDropdownMenu(0, 'SET[search_query_makeQuery]', $this->MOD_SETTINGS['search_query_makeQuery'], $this->MOD_MENU['search_query_makeQuery']) . '<br />';
     }
     $submenu .= '</div>';
     if ($this->MOD_SETTINGS['search'] == 'query') {
         $submenu .= '<div class="checkbox"><label for="checkSearch_query_smallparts">' . BackendUtility::getFuncCheck($GLOBALS['SOBE']->id, 'SET[search_query_smallparts]', $this->MOD_SETTINGS['search_query_smallparts'], '', '', 'id="checkSearch_query_smallparts"') . $lang->getLL('showSQL') . '</label></div>';
         $submenu .= '<div class="checkbox"><label for="checkSearch_result_labels">' . BackendUtility::getFuncCheck($GLOBALS['SOBE']->id, 'SET[search_result_labels]', $this->MOD_SETTINGS['search_result_labels'], '', '', 'id="checkSearch_result_labels"') . $lang->getLL('useFormattedStrings') . '</label></div>';
         $submenu .= '<div class="checkbox"><label for="checkLabels_noprefix">' . BackendUtility::getFuncCheck($GLOBALS['SOBE']->id, 'SET[labels_noprefix]', $this->MOD_SETTINGS['labels_noprefix'], '', '', 'id="checkLabels_noprefix"') . $lang->getLL('dontUseOrigValues') . '</label></div>';
         $submenu .= '<div class="checkbox"><label for="checkOptions_sortlabel">' . BackendUtility::getFuncCheck($GLOBALS['SOBE']->id, 'SET[options_sortlabel]', $this->MOD_SETTINGS['options_sortlabel'], '', '', 'id="checkOptions_sortlabel"') . $lang->getLL('sortOptions') . '</label></div>';
         $submenu .= '<div class="checkbox"><label for="checkShow_deleted">' . BackendUtility::getFuncCheck($GLOBALS['SOBE']->id, 'SET[show_deleted]', $this->MOD_SETTINGS['show_deleted'], '', '', 'id="checkShow_deleted"') . $lang->getLL('showDeleted') . '</label></div>';
     }
     $this->view->assign('submenu', $submenu);
     $this->view->assign('searchMode', $searchMode);
     switch ($searchMode) {
         case 'query':
             $this->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Lowlevel/QueryGenerator');
             $this->view->assign('queryMaker', $fullsearch->queryMaker());
             break;
         case 'raw':
         default:
             $this->view->assign('searchOptions', $fullsearch->form());
             $this->view->assign('results', $fullsearch->search());
     }
 }
    /**
     * Main
     *
     * @return string
     */
    public function main()
    {
        $lang = $this->getLanguageService();
        $POST = GeneralUtility::_POST();
        $documentTemplate = $this->getDocumentTemplate();
        /** @var CharsetConverter $charsetConverter */
        $charsetConverter = GeneralUtility::makeInstance(CharsetConverter::class);
        // 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) {
            $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
            $content = ' ' . $iconFactory->getIconForRecord('sys_template', $tplRow, Icon::SIZE_SMALL)->render() . ' <strong>' . $this->pObj->linkWrapTemplateTitle($tplRow['title'], $bType == 'setup' ? 'config' : 'constants') . '</strong>' . (trim($tplRow['sitetitle']) ? htmlspecialchars(' (' . $tplRow['sitetitle'] . ')') : '');
            $theOutput .= '<h3>' . $lang->getLL('currentTemplate', true) . '</h3>';
            $theOutput .= '<div>';
            $theOutput .= $content;
            $theOutput .= '</div>';
            if ($manyTemplatesMenu) {
                $theOutput .= $manyTemplatesMenu;
            }
            $theOutput .= '<div style="padding-top: 10px;"></div>';
            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 = $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);
                    // 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) {
                // Inline Form Area Begin
                $theOutput .= '<div class="form-inline form-inline-spaced">';
                // Value
                $out = '';
                $out .= '<div class="form-group">';
                $out .= '	<label>' . htmlspecialchars($this->pObj->sObj) . ' =' . '</label>';
                $out .= '	<input class="form-control" 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') . '" />';
                $out .= '</div>';
                $theOutput .= '<h3>' . $lang->getLL('editProperty', true) . '</h3>';
                $theOutput .= $out;
                // Property
                $out = '<div class="form-group">';
                $out .= '	<label>' . htmlspecialchars($this->pObj->sObj) . '.';
                $out .= '		<input class="form-control" type="text" name="data[' . htmlspecialchars($this->pObj->sObj) . '][name]"' . $documentTemplate->formWidth(20) . ' /> = ';
                $out .= '	</label>';
                $out .= '	<input class="form-control" 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') . '" />';
                $out .= '</div>';
                $theOutput .= '<div style="padding-top: 20px;"></div>';
                $theOutput .= '<h3>' . $lang->getLL('addProperty', true) . '</h3>';
                $theOutput .= $out;
                // clear
                $out = '<div class="form-group">';
                $out .= '	<div class="checkbox">';
                $out .= '		<label>';
                $out .= '			' . htmlspecialchars($this->pObj->sObj) . ' ' . $charsetConverter->conv_case('utf-8', $lang->getLL('clear'), 'toUpper');
                $out .= '			<input type="checkbox" name="data[' . htmlspecialchars($this->pObj->sObj) . '][clearValue]" value="1" />';
                $out .= '		</label>';
                $out .= '		<input class="btn btn-default" type="submit" name="clear_object" value="' . $lang->getLL('clearButton') . '" />';
                $out .= '	</div>';
                $out .= '</div>';
                $theOutput .= '<div style="padding-top: 20px;"></div>';
                $theOutput .= '<h3>' . $lang->getLL('clearObject', true) . '</h3>';
                $theOutput .= $out;
                $theOutput .= '<div style="padding-top: 10px;"></div>';
                // Inline Form Area End
                $theOutput .= '</div>';
            } 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 .= '<div style="padding-top: 10px;"></div>';
            }
            // 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 .= '<div><hr style="margin-top: 5px; margin-bottom: 5px;" />' . $out . '</div>';
            }
            // back
            $out = $lang->getLL('back');
            $out = '<a href="' . htmlspecialchars($aHref) . '" class="btn btn-default"><strong><i class="fa fa-chevron-left"></i>&nbsp;' . $out . '</strong></a>';
            $theOutput .= '<div><hr style="margin-top: 5px; margin-bottom: 5px;" />' . $out . '</div>';
        } 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
                $searchString = GeneralUtility::_POST('search_field');
                try {
                    $templateService->tsbrowser_depthKeys = $templateService->ext_getSearchKeys($theSetup, '', $searchString, array());
                } catch (Exception $e) {
                    $this->addFlashMessage(GeneralUtility::makeInstance(FlashMessage::class, sprintf($lang->getLL('error.' . $e->getCode()), $searchString), '', FlashMessage::ERROR));
                }
            }
            $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::getDropdownMenu($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::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]) . '
						</div>';
            }
            $this->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Tstemplate/TypoScriptObjectBrowser');
            $theOutput .= '
						<div class="form-group">
							<label class="control-label" for="search_field">' . $lang->getLL('search') . '</label>
							<div class="form-group"><input class="form-control" type="search" name="search_field" id="search_field" value="' . htmlspecialchars($POST['search_field']) . '" /></div>
						</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]) . '" class="text-warning">' . $lang->getLL('errorShowDetails') . '</a>';
                    $errMsg[] = $lang->getLL('severity.' . $inf[1]) . ':&nbsp;' . $inf[0] . $errorLink;
                }
                $theOutput .= '<div style="padding-top: 10px;"></div>';
                $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 = '';
            }
            if ($theKey) {
                $label = $theKey;
            } else {
                $label = $charsetConverter->conv_case('utf-8', $lang->getLL($bType === 'setup' ? 'setupRoot' : 'constantRoot'), 'toUpper');
            }
            $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="typo3-listOptions">';
            $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 .= '<div class="form"><label>' . $lang->getLL('displayConstants') . '</label>';
                $menu .= BackendUtility::getDropdownMenu($this->pObj->id, 'SET[ts_browser_const]', $this->pObj->MOD_SETTINGS['ts_browser_const'], $this->pObj->MOD_MENU['ts_browser_const']);
                $menu .= '</div>';
            }
            $menu .= '</div>';
            //start section displayoptions
            $theOutput .= '<div>';
            $theOutput .= '<h2>' . $lang->getLL('displayOptions', true) . '</h2>';
            $theOutput .= $menu;
            // Conditions:
            if (is_array($templateService->sections) && !empty($templateService->sections)) {
                $theOutput .= '<h2>' . $lang->getLL('conditions', true) . '</h2>';
                $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="typo3-listOptions">' . $out . '</div><input class="btn btn-default" type="submit" name="Submit" value="' . $lang->getLL('setConditions') . '" />';
            }
            // Ending section displayoptions
            $theOutput .= '</div>';
        }
        return $theOutput;
    }
예제 #8
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 function of class
     *
     * @return string HTML output
     */
    public function main()
    {
        if ((int) GeneralUtility::_GP('id') === 0) {
            $lang = $this->getLanguageService();
            return '<div class="nowrap"><div class="table-fit"><table class="table table-striped table-hover" id="tsconfig-overview">' . '<thead>' . '<tr>' . '<th>' . $lang->getLL('pagetitle') . '</th>' . '<th>' . $lang->getLL('included_tsconfig_files') . '</th>' . '<th>' . $lang->getLL('written_tsconfig_lines') . '</th>' . '</tr>' . '</thead>' . '<tbody>' . implode('', $this->getOverviewOfPagesUsingTSConfig()) . '</tbody>' . '</table></div>';
        } else {
            $menu = '<div class="form-inline form-inline-spaced">';
            $menu .= BackendUtility::getDropdownMenu($this->pObj->id, 'SET[tsconf_parts]', $this->pObj->MOD_SETTINGS['tsconf_parts'], $this->pObj->MOD_MENU['tsconf_parts']);
            $menu .= '<div class="checkbox"><label for="checkTsconf_alphaSort">' . BackendUtility::getFuncCheck($this->pObj->id, 'SET[tsconf_alphaSort]', $this->pObj->MOD_SETTINGS['tsconf_alphaSort'], '', '', 'id="checkTsconf_alphaSort"') . ' ' . $this->getLanguageService()->getLL('sort_alphabetic', true) . '</label></div>';
            $menu .= '</div>';
            $theOutput = '<h1>' . htmlspecialchars($this->getLanguageService()->getLL('tsconf_title')) . '</h1>';
            if ($this->pObj->MOD_SETTINGS['tsconf_parts'] == 99) {
                $TSparts = BackendUtility::getPagesTSconfig($this->pObj->id, null, true);
                $lines = array();
                $pUids = array();
                foreach ($TSparts as $k => $v) {
                    if ($k != 'uid_0') {
                        if ($k == 'defaultPageTSconfig') {
                            $pTitle = '<strong>' . $this->getLanguageService()->getLL('editTSconfig_default', true) . '</strong>';
                            $editIcon = '';
                        } else {
                            $pUids[] = substr($k, 4);
                            $row = BackendUtility::getRecordWSOL('pages', substr($k, 4));
                            $icon = $this->iconFactory->getIconForRecord('pages', $row, Icon::SIZE_SMALL);
                            $pTitle = BackendUtility::wrapClickMenuOnIcon($icon, 'pages', $row['uid']) . ' ' . htmlspecialchars(BackendUtility::getRecordTitle('pages', $row));
                            $editIdList = substr($k, 4);
                            $urlParameters = ['edit' => ['pages' => [$editIdList => 'edit']], 'columnsOnly' => 'TSconfig', 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')];
                            $url = BackendUtility::getModuleUrl('record_edit', $urlParameters);
                            $editIcon = '<a href="' . htmlspecialchars($url) . '" title="' . $this->getLanguageService()->getLL('editTSconfig', true) . '">' . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() . '</a>';
                        }
                        $TScontent = nl2br(htmlspecialchars(trim($v) . LF));
                        $tsparser = GeneralUtility::makeInstance(\TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::class);
                        $tsparser->lineNumberOffset = 0;
                        $TScontent = $tsparser->doSyntaxHighlight(trim($v) . LF);
                        $lines[] = '
							<tr><td nowrap="nowrap" class="bgColor5">' . $pTitle . '</td></tr>
							<tr><td nowrap="nowrap" class="bgColor4">' . $TScontent . $editIcon . '</td></tr>
							<tr><td>&nbsp;</td></tr>
						';
                    }
                }
                if (!empty($pUids)) {
                    $urlParameters = ['edit' => ['pages' => [implode(',', $pUids) => 'edit']], 'columnsOnly' => 'TSconfig', 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')];
                    $url = BackendUtility::getModuleUrl('record_edit', $urlParameters);
                    $editIcon = '<a href="' . htmlspecialchars($url) . '" title="' . $this->getLanguageService()->getLL('editTSconfig_all', true) . '">' . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() . '<strong>' . $this->getLanguageService()->getLL('editTSconfig_all', true) . '</strong>' . '</a>';
                } else {
                    $editIcon = '';
                }
                $theOutput .= '<div>';
                $theOutput .= BackendUtility::cshItem('_MOD_web_info', 'tsconfig_edit', null, '<span class="btn btn-default btn-sm">|</span>') . $menu . '
						<!-- Edit fields: -->
						<table border="0" cellpadding="0" cellspacing="1">' . implode('', $lines) . '</table><br />' . $editIcon;
                $theOutput .= '</div>';
            } else {
                // Defined global here!
                $tmpl = GeneralUtility::makeInstance(\TYPO3\CMS\Core\TypoScript\ExtendedTemplateService::class);
                // Do not log time-performance information
                $tmpl->tt_track = 0;
                $tmpl->fixedLgd = 0;
                $tmpl->linkObjects = 0;
                $tmpl->bType = '';
                $tmpl->ext_expandAllNotes = 1;
                $tmpl->ext_noPMicons = 1;
                $beUser = $this->getBackendUser();
                switch ($this->pObj->MOD_SETTINGS['tsconf_parts']) {
                    case '1':
                        $modTSconfig = BackendUtility::getModTSconfig($this->pObj->id, 'mod');
                        break;
                    case '1a':
                        $modTSconfig = $beUser->getTSConfig('mod.web_layout', BackendUtility::getPagesTSconfig($this->pObj->id));
                        break;
                    case '1b':
                        $modTSconfig = $beUser->getTSConfig('mod.web_view', BackendUtility::getPagesTSconfig($this->pObj->id));
                        break;
                    case '1c':
                        $modTSconfig = $beUser->getTSConfig('mod.web_modules', BackendUtility::getPagesTSconfig($this->pObj->id));
                        break;
                    case '1d':
                        $modTSconfig = $beUser->getTSConfig('mod.web_list', BackendUtility::getPagesTSconfig($this->pObj->id));
                        break;
                    case '1e':
                        $modTSconfig = $beUser->getTSConfig('mod.web_info', BackendUtility::getPagesTSconfig($this->pObj->id));
                        break;
                    case '1f':
                        $modTSconfig = $beUser->getTSConfig('mod.web_func', BackendUtility::getPagesTSconfig($this->pObj->id));
                        break;
                    case '1g':
                        $modTSconfig = $beUser->getTSConfig('mod.web_ts', BackendUtility::getPagesTSconfig($this->pObj->id));
                        break;
                    case '2':
                        $modTSconfig = $beUser->getTSConfig('RTE', BackendUtility::getPagesTSconfig($this->pObj->id));
                        break;
                    case '5':
                        $modTSconfig = $beUser->getTSConfig('TCEFORM', BackendUtility::getPagesTSconfig($this->pObj->id));
                        break;
                    case '6':
                        $modTSconfig = $beUser->getTSConfig('TCEMAIN', BackendUtility::getPagesTSconfig($this->pObj->id));
                        break;
                    case '3':
                        $modTSconfig = $beUser->getTSConfig('TSFE', BackendUtility::getPagesTSconfig($this->pObj->id));
                        break;
                    case '4':
                        $modTSconfig = $beUser->getTSConfig('user', BackendUtility::getPagesTSconfig($this->pObj->id));
                        break;
                    default:
                        $modTSconfig['properties'] = BackendUtility::getPagesTSconfig($this->pObj->id);
                }
                $modTSconfig = $modTSconfig['properties'];
                if (!is_array($modTSconfig)) {
                    $modTSconfig = array();
                }
                $csh = BackendUtility::cshItem('_MOD_web_info', 'tsconfig_hierarchy', null, '<span class="btn btn-default btn-sm">|</span>');
                $tree = $tmpl->ext_getObjTree($modTSconfig, '', '', '', '', $this->pObj->MOD_SETTINGS['tsconf_alphaSort']);
                $theOutput .= '<div>';
                $theOutput .= $csh . $menu . '<div class="nowrap">' . $tree . '</div>';
                $theOutput .= '</div>';
            }
        }
        return $theOutput;
    }
예제 #10
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;
 }