Esempio n. 1
0
 /**
  * Constructor
  */
 public function __construct()
 {
     // Set debug flag for BE development only
     $this->debug = (int) $GLOBALS['TYPO3_CONF_VARS']['BE']['debug'] === 1;
     // Initializes the backend modules structure for use later.
     $this->moduleLoader = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Module\\ModuleLoader');
     $this->moduleLoader->load($GLOBALS['TBE_MODULES']);
     $this->pageRenderer = $GLOBALS['TBE_TEMPLATE']->getPageRenderer();
     $this->pageRenderer->loadScriptaculous('builder,effects,controls,dragdrop');
     $this->pageRenderer->loadExtJS();
     $this->pageRenderer->loadJquery(NULL, NULL, \TYPO3\CMS\Core\Page\PageRenderer::JQUERY_NAMESPACE_DEFAULT_NOCONFLICT);
     $this->pageRenderer->enableExtJSQuickTips();
     $this->pageRenderer->addJsInlineCode('consoleOverrideWithDebugPanel', '//already done', FALSE);
     $this->pageRenderer->addExtDirectCode();
     // Add default BE javascript
     $this->js = '';
     $this->jsFiles = array('common' => 'sysext/backend/Resources/Public/JavaScript/common.js', 'locallang' => $this->getLocalLangFileName(), 'modernizr' => 'contrib/modernizr/modernizr.min.js', 'md5' => 'sysext/backend/Resources/Public/JavaScript/md5.js', 'toolbarmanager' => 'sysext/backend/Resources/Public/JavaScript/toolbarmanager.js', 'modulemenu' => 'sysext/backend/Resources/Public/JavaScript/modulemenu.js', 'evalfield' => 'sysext/backend/Resources/Public/JavaScript/jsfunc.evalfield.js', 'flashmessages' => 'sysext/backend/Resources/Public/JavaScript/flashmessages.js', 'tabclosemenu' => 'js/extjs/ux/ext.ux.tabclosemenu.js', 'notifications' => 'sysext/backend/Resources/Public/JavaScript/notifications.js', 'backend' => 'sysext/backend/Resources/Public/JavaScript/backend.js', 'loginrefresh' => 'sysext/backend/Resources/Public/JavaScript/loginrefresh.js', 'debugPanel' => 'js/extjs/debugPanel.js', 'viewport' => 'js/extjs/viewport.js', 'iframepanel' => 'sysext/backend/Resources/Public/JavaScript/iframepanel.js', 'backendcontentiframe' => 'js/extjs/backendcontentiframe.js', 'modulepanel' => 'js/extjs/modulepanel.js', 'viewportConfiguration' => 'js/extjs/viewportConfiguration.js', 'util' => 'sysext/backend/Resources/Public/JavaScript/util.js');
     if ($this->debug) {
         unset($this->jsFiles['loginrefresh']);
     }
     // Add default BE css
     $this->pageRenderer->addCssLibrary('contrib/normalize/normalize.css', 'stylesheet', 'all', '', TRUE, TRUE);
     $this->css = '';
     $this->cssFiles = array();
     $this->toolbarItems = array();
     $this->initializeCoreToolbarItems();
     $this->menuWidth = $this->menuWidthDefault;
     if (isset($GLOBALS['TBE_STYLES']['dims']['leftMenuFrameW']) && (int) $GLOBALS['TBE_STYLES']['dims']['leftMenuFrameW'] != (int) $this->menuWidth) {
         $this->menuWidth = (int) $GLOBALS['TBE_STYLES']['dims']['leftMenuFrameW'];
     }
     $this->executeHook('constructPostProcess');
 }
Esempio n. 2
0
 /**
  * Constructor
  */
 public function __construct()
 {
     // Set debug flag for BE development only
     $this->debug = intval($GLOBALS['TYPO3_CONF_VARS']['BE']['debug']) === 1;
     // Initializes the backend modules structure for use later.
     $this->moduleLoader = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Module\\ModuleLoader');
     $this->moduleLoader->load($GLOBALS['TBE_MODULES']);
     $this->moduleMenu = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\View\\ModuleMenuView');
     $this->pageRenderer = $GLOBALS['TBE_TEMPLATE']->getPageRenderer();
     $this->pageRenderer->loadScriptaculous('builder,effects,controls,dragdrop');
     $this->pageRenderer->loadExtJS();
     $this->pageRenderer->enableExtJSQuickTips();
     $this->pageRenderer->addJsInlineCode('consoleOverrideWithDebugPanel', '//already done', FALSE);
     $this->pageRenderer->addExtDirectCode();
     // Add default BE javascript
     $this->js = '';
     $this->jsFiles = array('common' => 'js/common.js', 'locallang' => $this->getLocalLangFileName(), 'modernizr' => 'contrib/modernizr/modernizr.min.js', 'swfupload' => 'contrib/swfupload/swfupload.js', 'swfupload.swfobject' => 'contrib/swfupload/plugins/swfupload.swfobject.js', 'swfupload.cookies' => 'contrib/swfupload/plugins/swfupload.cookies.js', 'swfupload.queue' => 'contrib/swfupload/plugins/swfupload.queue.js', 'md5' => 'md5.js', 'toolbarmanager' => 'js/toolbarmanager.js', 'modulemenu' => 'js/modulemenu.js', 'iecompatibility' => 'js/iecompatibility.js', 'flashupload' => 'js/flashupload.js', 'evalfield' => '../t3lib/jsfunc.evalfield.js', 'flashmessages' => '../t3lib/js/extjs/ux/flashmessages.js', 'tabclosemenu' => '../t3lib/js/extjs/ux/ext.ux.tabclosemenu.js', 'notifications' => '../t3lib/js/extjs/notifications.js', 'backend' => 'js/backend.js', 'loginrefresh' => 'js/loginrefresh.js', 'debugPanel' => 'js/extjs/debugPanel.js', 'viewport' => 'js/extjs/viewport.js', 'iframepanel' => 'js/extjs/iframepanel.js', 'backendcontentiframe' => 'js/extjs/backendcontentiframe.js', 'modulepanel' => 'js/extjs/modulepanel.js', 'viewportConfiguration' => 'js/extjs/viewportConfiguration.js', 'util' => '../t3lib/js/extjs/util.js');
     if ($this->debug) {
         unset($this->jsFiles['loginrefresh']);
     }
     // Add default BE css
     $this->css = '';
     $this->cssFiles = array();
     $this->toolbarItems = array();
     $this->initializeCoreToolbarItems();
     $this->menuWidth = $this->menuWidthDefault;
     if (isset($GLOBALS['TBE_STYLES']['dims']['leftMenuFrameW']) && (int) $GLOBALS['TBE_STYLES']['dims']['leftMenuFrameW'] != (int) $this->menuWidth) {
         $this->menuWidth = (int) $GLOBALS['TBE_STYLES']['dims']['leftMenuFrameW'];
     }
     $this->executeHook('constructPostProcess');
 }
Esempio n. 3
0
    /**
     * Main function of the module. Write the content to $this->content
     * If you chose "web" as main module, you will need to consider the $this->id parameter which will contain the uid-number of the page clicked in the page tree
     */
    function main()
    {
        global $BE_USER, $LANG, $BACK_PATH, $TCA_DESCR, $TCA, $CLIENT, $TYPO3_CONF_VARS;
        $PATH_TYPO3 = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . 'typo3/';
        if ($BE_USER->user["admin"]) {
            // Draw the header.
            $this->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance("template");
            $this->doc->backPath = $BACK_PATH;
            $this->pageRenderer = $this->doc->getPageRenderer();
            // Include Ext JS
            $this->pageRenderer->loadExtJS(true, true);
            $this->pageRenderer->enableExtJSQuickTips();
            $this->pageRenderer->enableExtJsDebug();
            $this->pageRenderer->addJsFile(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('caretaker') . 'res/js/tx.caretaker.js', 'text/javascript', FALSE, FALSE);
            $this->pageRenderer->addJsFile(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('caretaker') . 'res/js/tx.caretaker.NodeTree.js', 'text/javascript', FALSE, FALSE);
            //Add caretaker css
            $this->pageRenderer->addCssFile(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('caretaker') . 'res/css/tx.caretaker.nodetree.css', 'stylesheet', 'all', '', FALSE);
            // storage Pid
            $confArray = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['caretaker']);
            $storagePid = (int) $confArray['storagePid'];
            $this->pageRenderer->addJsInlineCode('Caretaker_Nodetree', '
			Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
			Ext.ns("tx.caretaker");
			Ext.onReady(function() {
				tx.caretaker.view = new Ext.Viewport({
					layout: "fit",
					items: {
						id: "cartaker-tree",
						xtype: "caretaker-nodetree",
						autoScroll: true,
						dataUrl: TYPO3.settings.ajaxUrls[\'tx_caretaker::treeloader\'],
						addUrl: "' . $PATH_TYPO3 . 'alt_doc.php?edit[###NODE_TYPE###][' . $storagePid . ']=new",
						editUrl: "' . $PATH_TYPO3 . 'alt_doc.php?edit[tx_caretaker_###NODE_TYPE###][###NODE_UID###]=edit",
						hideUrl: "' . $PATH_TYPO3 . 'tce_db.php?&data[tx_caretaker_###NODE_TYPE###][###NODE_UID###][hidden]=1",
						unhideUrl: "' . $PATH_TYPO3 . 'tce_db.php?&data[tx_caretaker_###NODE_TYPE###][###NODE_UID###][hidden]=0"
					}
				});

				tx_caretaker_updateTreeById = function( id ){
					tx_caretaker_tree = Ext.getCmp("cartaker-tree");
					tx_caretaker_tree.reloadTreePartial( id );
				}
			});
			');
            $this->content .= $this->doc->startPage($LANG->getLL("title"));
            $this->doc->form = '';
        } else {
            // If no access or if not admin
            $this->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\MediumDocumentTemplate');
            $this->doc->backPath = $BACK_PATH;
            $this->content .= $this->doc->startPage($LANG->getLL("title"));
            $this->content .= $this->doc->header($LANG->getLL("title"));
            $this->content .= $this->doc->spacer(5);
            $this->content .= $this->doc->spacer(10);
        }
    }
 /**
  * Initializes the controller before invoking an action method.
  *
  * @return void
  */
 protected function initializeAction()
 {
     $this->pageId = (int) GeneralUtility::_GP('id');
     $this->pageRenderer->addInlineLanguageLabelArray(array('title' => $this->languageService->getLL('title'), 'path' => $this->languageService->sL('LLL:EXT:lang/locallang_core.xml:labels.path'), 'table' => $this->languageService->sL('LLL:EXT:lang/locallang_core.xml:labels.table'), 'depth' => $this->languageService->sL('LLL:EXT:lang/locallang_mod_web_perm.xml:Depth'), 'depth_0' => $this->languageService->sL('LLL:EXT:lang/locallang_core.xml:labels.depth_0'), 'depth_1' => $this->languageService->sL('LLL:EXT:lang/locallang_core.xml:labels.depth_1'), 'depth_2' => $this->languageService->sL('LLL:EXT:lang/locallang_core.xml:labels.depth_2'), 'depth_3' => $this->languageService->sL('LLL:EXT:lang/locallang_core.xml:labels.depth_3'), 'depth_4' => $this->languageService->sL('LLL:EXT:lang/locallang_core.xml:labels.depth_4'), 'depth_infi' => $this->languageService->sL('LLL:EXT:lang/locallang_core.xml:labels.depth_infi')));
     $this->pageRenderer->addInlineLanguageLabelFile('EXT:typo3_forum/Resources/Private/Language/locallang_mod.xml');
     $this->pageRenderer->loadExtJS();
     $this->pageRenderer->enableExtJSQuickTips();
     $this->pageRenderer->addJsFile(ExtensionManagementUtility::extRelPath('lang') . 'res/js/be/typo3lang.js');
     $this->pageRenderer->addJsFile($this->backPath . 'js/extjs/ux/Ext.ux.FitToParent.js');
     $this->includeJavascriptFromPath('Resources/Public/Javascript/Backend/ExtJS/');
     $this->includeJavascriptFromPath('Resources/Public/Javascript/Backend/ForumIndex/');
     $this->includeCssFromPath('Resources/Public/Javascript/Backend/ExtJS/');
     $this->pageRenderer->addCssFile(ExtensionManagementUtility::extRelPath('typo3_forum') . 'Resources/Public/Stylesheets/typo3_forum-backend.css');
 }
Esempio n. 5
0
    /**
     * Constructor
     */
    public function __construct()
    {
        $this->backendModuleRepository = GeneralUtility::makeInstance(BackendModuleRepository::class);
        // Set debug flag for BE development only
        $this->debug = (int) $GLOBALS['TYPO3_CONF_VARS']['BE']['debug'] === 1;
        // Initializes the backend modules structure for use later.
        $this->moduleLoader = GeneralUtility::makeInstance(ModuleLoader::class);
        $this->moduleLoader->load($GLOBALS['TBE_MODULES']);
        $this->pageRenderer = $this->getDocumentTemplate()->getPageRenderer();
        $this->pageRenderer->loadExtJS();
        // included for the module menu JavaScript, please note that this is subject to change
        $this->pageRenderer->loadJquery();
        $this->pageRenderer->enableExtJSQuickTips();
        $this->pageRenderer->addJsInlineCode('consoleOverrideWithDebugPanel', '//already done', FALSE);
        $this->pageRenderer->addExtDirectCode();
        // Add default BE javascript
        $this->jsFiles = array('locallang' => $this->getLocalLangFileName(), 'md5' => 'sysext/backend/Resources/Public/JavaScript/md5.js', 'modulemenu' => 'sysext/backend/Resources/Public/JavaScript/modulemenu.js', 'evalfield' => 'sysext/backend/Resources/Public/JavaScript/jsfunc.evalfield.js', 'notifications' => 'sysext/backend/Resources/Public/JavaScript/notifications.js', 'backend' => 'sysext/backend/Resources/Public/JavaScript/backend.js', 'viewport' => 'sysext/backend/Resources/Public/JavaScript/extjs/viewport.js', 'iframepanel' => 'sysext/backend/Resources/Public/JavaScript/iframepanel.js', 'backendcontentiframe' => 'sysext/backend/Resources/Public/JavaScript/extjs/backendcontentiframe.js', 'viewportConfiguration' => 'sysext/backend/Resources/Public/JavaScript/extjs/viewportConfiguration.js');
        $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/LoginRefresh', 'function(LoginRefresh) {
			LoginRefresh.setLoginFramesetUrl(' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('login_frameset')) . ');
			LoginRefresh.setLogoutUrl(' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('logout')) . ');
		}');
        // load Utility class
        $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/Utility');
        // load Notification functionality
        $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/Notification');
        // load Modals
        $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/Modal');
        // load Legacy CSS Support
        $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/LegacyCssClasses');
        // load the storage API and fill the UC into the PersistentStorage, so no additional AJAX call is needed
        $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/Storage', 'function(Storage) {
			Storage.Persistent.load(' . json_encode($this->getBackendUser()->uc) . ');
		}');
        // load debug console
        $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/DebugConsole');
        $this->pageRenderer->addInlineSetting('ShowItem', 'moduleUrl', BackendUtility::getModuleUrl('show_item'));
        $this->css = '';
        $this->initializeToolbarItems();
        if (isset($GLOBALS['TBE_STYLES']['dims']['leftMenuFrameW'])) {
            $this->menuWidth = (int) $GLOBALS['TBE_STYLES']['dims']['leftMenuFrameW'];
        }
        $this->executeHook('constructPostProcess');
    }
 /**
  * Loads data in the HTML head section (e.g. JavaScript or stylesheet information).
  *
  * @return 	void
  */
 protected function loadHeaderData()
 {
     // Load CSS Stylesheets:
     $this->pageRenderer->addCssFile($this->relativePath . 'res/css/customExtJs.css');
     // Load Ext JS:
     $this->pageRenderer->loadExtJS();
     $this->pageRenderer->enableExtJSQuickTips();
     // Integrate dynamic JavaScript such as configuration or lables:
     $this->pageRenderer->addInlineSettingArray('Recycler', $this->getJavaScriptConfiguration());
     $this->pageRenderer->addInlineLanguageLabelArray($this->getJavaScriptLabels());
     // Load Recycler JavaScript:
     // Load Plugins
     $uxPath = $this->doc->backpath . 'js/extjs/ux/';
     $this->pageRenderer->addJsFile($uxPath . 'Ext.grid.RowExpander.js');
     $this->pageRenderer->addJsFile($uxPath . 'Ext.app.SearchField.js');
     $this->pageRenderer->addJsFile($uxPath . 'Ext.ux.FitToParent.js');
     // Load main script
     $this->pageRenderer->addJsFile($this->relativePath . 'res/js/t3_recycler.js');
 }
    /**
     * Draws the RTE as an iframe
     *
     * @param 	object		Reference to parent object, which is an instance of the TCEforms.
     * @param 	string		The table name
     * @param 	string		The field name
     * @param 	array		The current row from which field is being rendered
     * @param 	array		Array of standard content for rendering form fields from TCEforms. See TCEforms for details on this. Includes for instance the value and the form field name, java script actions and more.
     * @param 	array		"special" configuration - what is found at position 4 in the types configuration of a field from record, parsed into an array.
     * @param 	array		Configuration for RTEs; A mix between TSconfig and otherwise. Contains configuration for display, which buttons are enabled, additional transformation information etc.
     * @param 	string		Record "type" field value.
     * @param 	string		Relative path for images/links in RTE; this is used when the RTE edits content from static files where the path of such media has to be transformed forth and back!
     * @param 	integer		PID value of record (true parent page id)
     * @return 	string		HTML code for RTE!
     * @todo Define visibility
     */
    public function drawRTE(&$parentObject, $table, $field, $row, $PA, $specConf, $thisConfig, $RTEtypeVal, $RTErelPath, $thePidValue)
    {
        global $TSFE, $TYPO3_CONF_VARS, $TYPO3_DB;
        $this->TCEform = $parentObject;
        $this->client = $this->clientInfo();
        $this->typoVersion = \TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version);
        /* =======================================
         * INIT THE EDITOR-SETTINGS
         * =======================================
         */
        // Get the path to this extension:
        $this->extHttpPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath($this->ID);
        // Get the site URL
        $this->siteURL = $GLOBALS['TSFE']->absRefPrefix ?: '';
        // Get the host URL
        $this->hostURL = '';
        // Element ID + pid
        $this->elementId = $PA['itemFormElName'];
        $this->elementParts[0] = $table;
        $this->elementParts[1] = $row['uid'];
        $this->tscPID = $thePidValue;
        $this->thePid = $thePidValue;
        // Record "type" field value:
        $this->typeVal = $RTEtypeVal;
        // TCA "type" value for record
        // RTE configuration
        $pageTSConfig = $TSFE->getPagesTSconfig();
        if (is_array($pageTSConfig) && is_array($pageTSConfig['RTE.'])) {
            $this->RTEsetup = $pageTSConfig['RTE.'];
        }
        if (is_array($thisConfig) && !empty($thisConfig)) {
            $this->thisConfig = $thisConfig;
        } elseif (is_array($this->RTEsetup['default.']) && is_array($this->RTEsetup['default.']['FE.'])) {
            $this->thisConfig = $this->RTEsetup['default.']['FE.'];
        }
        // Special configuration (line) and default extras:
        $this->specConf = $specConf;
        if ($this->thisConfig['forceHTTPS']) {
            $this->extHttpPath = preg_replace('/^(http|https)/', 'https', $this->extHttpPath);
            $this->siteURL = preg_replace('/^(http|https)/', 'https', $this->siteURL);
            $this->hostURL = preg_replace('/^(http|https)/', 'https', $this->hostURL);
        }
        // Register RTE windows:
        $this->TCEform->RTEwindows[] = $PA['itemFormElName'];
        $textAreaId = preg_replace('/[^a-zA-Z0-9_:.-]/', '_', $PA['itemFormElName']);
        $textAreaId = htmlspecialchars(preg_replace('/^[^a-zA-Z]/', 'x', $textAreaId)) . '_' . strval($this->TCEform->RTEcounter);
        /* =======================================
         * LANGUAGES & CHARACTER SETS
         * =======================================
         */
        // Language
        $TSFE->initLLvars();
        $this->language = $TSFE->lang;
        $this->LOCAL_LANG = \TYPO3\CMS\Core\Utility\GeneralUtility::readLLfile('EXT:' . $this->ID . '/locallang.xml', $this->language);
        if ($this->language == 'default' || !$this->language) {
            $this->language = 'en';
        }
        $this->contentLanguageUid = max($row['sys_language_uid'], 0);
        if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('static_info_tables')) {
            if ($this->contentLanguageUid) {
                $tableA = 'sys_language';
                $tableB = 'static_languages';
                $languagesUidsList = $this->contentLanguageUid;
                $selectFields = $tableA . '.uid,' . $tableB . '.lg_iso_2,' . $tableB . '.lg_country_iso_2,' . $tableB . '.lg_typo3';
                $tableAB = $tableA . ' LEFT JOIN ' . $tableB . ' ON ' . $tableA . '.static_lang_isocode=' . $tableB . '.uid';
                $whereClause = $tableA . '.uid IN (' . $languagesUidsList . ') ';
                $whereClause .= \TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields($tableA);
                $whereClause .= \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($tableA);
                $res = $TYPO3_DB->exec_SELECTquery($selectFields, $tableAB, $whereClause);
                while ($languageRow = $TYPO3_DB->sql_fetch_assoc($res)) {
                    $this->contentISOLanguage = strtolower(trim($languageRow['lg_iso_2']) . (trim($languageRow['lg_country_iso_2']) ? '_' . trim($languageRow['lg_country_iso_2']) : ''));
                    $this->contentTypo3Language = strtolower(trim($languageRow['lg_typo3']));
                }
            } else {
                $this->contentISOLanguage = $GLOBALS['TSFE']->sys_language_isocode ?: 'en';
                $selectFields = 'lg_iso_2, lg_typo3';
                $tableAB = 'static_languages';
                $whereClause = 'lg_iso_2 = ' . $TYPO3_DB->fullQuoteStr(strtoupper($this->contentISOLanguage), $tableAB);
                $res = $TYPO3_DB->exec_SELECTquery($selectFields, $tableAB, $whereClause);
                while ($languageRow = $TYPO3_DB->sql_fetch_assoc($res)) {
                    $this->contentTypo3Language = strtolower(trim($languageRow['lg_typo3']));
                }
            }
        }
        $this->contentISOLanguage = $this->contentISOLanguage ?: ($GLOBALS['TSFE']->sys_language_isocode ?: 'en');
        $this->contentTypo3Language = $this->contentTypo3Language ?: $GLOBALS['TSFE']->lang;
        if ($this->contentTypo3Language == 'default') {
            $this->contentTypo3Language = 'en';
        }
        // Character set
        $this->charset = $TSFE->renderCharset;
        $this->OutputCharset = $TSFE->metaCharset ?: $TSFE->renderCharset;
        // Set the charset of the content
        $this->contentCharset = $TSFE->csConvObj->charSetArray[$this->contentTypo3Language];
        $this->contentCharset = $this->contentCharset ?: 'utf-8';
        $this->contentCharset = trim($TSFE->config['config']['metaCharset']) ?: $this->contentCharset;
        /* =======================================
         * TOOLBAR CONFIGURATION
         * =======================================
         */
        $this->initializeToolbarConfiguration();
        /* =======================================
         * SET STYLES
         * =======================================
         */
        $width = 610;
        if (isset($this->thisConfig['RTEWidthOverride'])) {
            if (strstr($this->thisConfig['RTEWidthOverride'], '%')) {
                if ($this->client['browser'] != 'msie') {
                    $width = (int) $this->thisConfig['RTEWidthOverride'] > 0 ? $this->thisConfig['RTEWidthOverride'] : '100%';
                }
            } else {
                $width = (int) $this->thisConfig['RTEWidthOverride'] > 0 ? (int) $this->thisConfig['RTEWidthOverride'] : $width;
            }
        }
        $RTEWidth = strstr($width, '%') ? $width : $width . 'px';
        $editorWrapWidth = strstr($width, '%') ? $width : $width + 2 . 'px';
        $height = 380;
        $RTEHeightOverride = (int) $this->thisConfig['RTEHeightOverride'];
        $height = $RTEHeightOverride > 0 ? $RTEHeightOverride : $height;
        $RTEHeight = $height . 'px';
        $editorWrapHeight = $height + 2 . 'px';
        $this->RTEWrapStyle = $this->RTEWrapStyle ?: ($this->RTEdivStyle ?: 'height:' . $editorWrapHeight . '; width:' . $editorWrapWidth . ';');
        $this->RTEdivStyle = $this->RTEdivStyle ?: 'position:relative; left:0px; top:0px; height:' . $RTEHeight . '; width:' . $RTEWidth . '; border: 1px solid black;';
        /* =======================================
         * LOAD JS, CSS and more
         * =======================================
         */
        $this->getPageRenderer();
        // Register RTE in JS
        $this->TCEform->additionalJS_post[] = $this->wrapCDATA($this->registerRTEinJS($this->TCEform->RTEcounter, '', '', '', $textAreaId));
        // Set the save option for the RTE:
        $this->TCEform->additionalJS_submit[] = $this->setSaveRTE($this->TCEform->RTEcounter, $this->TCEform->formName, $textAreaId);
        // Loading ExtJs JavaScript files and inline code, if not configured in TS setup
        if (!is_array($GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtJs.'])) {
            $this->pageRenderer->loadExtJs();
            $this->pageRenderer->enableExtJSQuickTips();
        }
        $this->pageRenderer->addJsFile($this->getFullFileName('typo3/js/extjs/ux/ext.resizable.js'));
        $this->pageRenderer->addJsFile('sysext/backend/Resources/Public/JavaScript/notifications.js');
        // Preloading the pageStyle and including RTE skin stylesheets
        $this->addPageStyle();
        $this->pageRenderer->addCssFile($this->siteURL . 'typo3/contrib/extjs/resources/css/ext-all-notheme.css');
        $this->pageRenderer->addCssFile($this->siteURL . 'typo3/sysext/t3skin/extjs/xtheme-t3skin.css');
        $this->addSkin();
        $this->pageRenderer->addCssFile($this->siteURL . 'typo3/js/extjs/ux/resize.css');
        // Add RTE JavaScript
        $this->addRteJsFiles($this->TCEform->RTEcounter);
        $this->pageRenderer->addJsFile($this->buildJSMainLangFile($this->TCEform->RTEcounter));
        $this->pageRenderer->addJsInlineCode('HTMLArea-init', $this->getRteInitJsCode(), TRUE);
        /* =======================================
         * DRAW THE EDITOR
         * =======================================
         */
        // Transform value:
        $value = $this->transformContent('rte', $PA['itemFormElValue'], $table, $field, $row, $specConf, $thisConfig, $RTErelPath, $thePidValue);
        // Further content transformation by registered plugins
        foreach ($this->registeredPlugins as $pluginId => $plugin) {
            if ($this->isPluginEnabled($pluginId) && method_exists($plugin, 'transformContent')) {
                $value = $plugin->transformContent($value);
            }
        }
        // draw the textarea
        $item = $this->triggerField($PA['itemFormElName']) . '
			<div id="pleasewait' . $textAreaId . '" class="pleasewait" style="display: block;" >' . $TSFE->csConvObj->conv($TSFE->getLLL('Please wait', $this->LOCAL_LANG), $this->charset, $TSFE->renderCharset) . '</div>
			<div id="editorWrap' . $textAreaId . '" class="editorWrap" style="visibility: hidden; ' . htmlspecialchars($this->RTEWrapStyle) . '">
			<textarea id="RTEarea' . $textAreaId . '" name="' . htmlspecialchars($PA['itemFormElName']) . '" rows="0" cols="0" style="' . htmlspecialchars($this->RTEdivStyle) . '">' . \TYPO3\CMS\Core\Utility\GeneralUtility::formatForTextarea($value) . '</textarea>
			</div>' . LF;
        return $item;
    }
Esempio n. 8
0
    /**
     * Draws the RTE as an iframe
     *
     * @param FormEngine $_ Reference to parent object, which is an instance of the TCEforms. Obsolete DUMMY object only!
     * @param string $table The table name
     * @param string $field The field name
     * @param array $row The current row from which field is being rendered
     * @param array $PA Array of standard content for rendering form fields from TCEforms. See TCEforms for details on this. Includes for instance the value and the form field name, java script actions and more.
     * @param array $specConf "special" configuration - what is found at position 4 in the types configuration of a field from record, parsed into an array.
     * @param array $thisConfig Configuration for RTEs; A mix between TSconfig and otherwise. Contains configuration for display, which buttons are enabled, additional transformation information etc.
     * @param string $RTEtypeVal Record "type" field value.
     * @param string $RTErelPath Relative path for images/links in RTE; this is used when the RTE edits content from static files where the path of such media has to be transformed forth and back!
     * @param int $thePidValue PID value of record (true parent page id)
     * @param array $globalOptions Global options like 'readonly' for all elements. This is a hack until RTE is an own type
     * @param array $resultArray Initialized final result array that is returned later filled with content. This is a hack until RTE is an own type
     * @param string $validatationDataAttribute the validation data attribute.
     * @return string HTML code for RTE!
     */
    public function drawRTE($_, $table, $field, $row, $PA, $specConf, $thisConfig, $RTEtypeVal, $RTErelPath, $thePidValue, $globalOptions, $resultArray, $validatationDataAttribute = '')
    {
        $languageService = $this->getLanguageService();
        $backendUser = $this->getBackendUserAuthentication();
        $database = $this->getDatabaseConnection();
        $this->globalOptions = $globalOptions;
        $languageService->includeLLFile('EXT:rtehtmlarea/locallang.xlf');
        $this->client = $this->clientInfo();
        $this->typoVersion = \TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version);
        $this->userUid = 'BE_' . $GLOBALS['BE_USER']->user['uid'];
        // Draw real RTE
        /* =======================================
         * INIT THE EDITOR-SETTINGS
         * =======================================
         */
        // Get the path to this extension:
        $this->extHttpPath = ExtensionManagementUtility::extRelPath('rtehtmlarea');
        // Get the site URL
        $this->siteURL = GeneralUtility::getIndpEnv('TYPO3_SITE_URL');
        // Get the host URL
        $this->hostURL = $this->siteURL . TYPO3_mainDir;
        // Element ID + pid
        $this->elementId = $PA['itemFormElName'];
        // Form element name
        $this->elementParts = explode('][', preg_replace('/\\]$/', '', preg_replace('/^(TSFE_EDIT\\[data\\]\\[|data\\[)/', '', $this->elementId)));
        // Find the page PIDs:
        list($this->tscPID, $this->thePid) = BackendUtility::getTSCpid(trim($this->elementParts[0]), trim($this->elementParts[1]), $thePidValue);
        // Record "types" field value:
        $this->typeVal = $RTEtypeVal;
        // TCA "types" value for record
        // Find "thisConfig" for record/editor:
        unset($this->RTEsetup);
        $this->RTEsetup = $backendUser->getTSConfig('RTE', BackendUtility::getPagesTSconfig($this->tscPID));
        $this->thisConfig = $thisConfig;
        // Special configuration and default extras:
        $this->specConf = $specConf;
        if ($this->thisConfig['forceHTTPS']) {
            $this->extHttpPath = preg_replace('/^(http|https)/', 'https', $this->extHttpPath);
            $this->siteURL = preg_replace('/^(http|https)/', 'https', $this->siteURL);
            $this->hostURL = preg_replace('/^(http|https)/', 'https', $this->hostURL);
        }
        // Register RTE windows
        $textAreaId = preg_replace('/[^a-zA-Z0-9_:.-]/', '_', $PA['itemFormElName']);
        $textAreaId = htmlspecialchars(preg_replace('/^[^a-zA-Z]/', 'x', $textAreaId));
        /* =======================================
         * LANGUAGES & CHARACTER SETS
         * =======================================
         */
        // Languages: interface and content
        $this->language = $GLOBALS['LANG']->lang;
        if ($this->language === 'default' || !$this->language) {
            $this->language = 'en';
        }
        $this->contentLanguageUid = max($row['sys_language_uid'], 0);
        if ($this->contentLanguageUid) {
            $this->contentISOLanguage = $this->language;
            if (ExtensionManagementUtility::isLoaded('static_info_tables')) {
                $tableA = 'sys_language';
                $tableB = 'static_languages';
                $selectFields = $tableA . '.uid,' . $tableB . '.lg_iso_2,' . $tableB . '.lg_country_iso_2';
                $tableAB = $tableA . ' LEFT JOIN ' . $tableB . ' ON ' . $tableA . '.static_lang_isocode=' . $tableB . '.uid';
                $whereClause = $tableA . '.uid = ' . intval($this->contentLanguageUid);
                $whereClause .= BackendUtility::BEenableFields($tableA);
                $whereClause .= BackendUtility::deleteClause($tableA);
                $res = $database->exec_SELECTquery($selectFields, $tableAB, $whereClause);
                while ($languageRow = $database->sql_fetch_assoc($res)) {
                    $this->contentISOLanguage = strtolower(trim($languageRow['lg_iso_2']) . (trim($languageRow['lg_country_iso_2']) ? '_' . trim($languageRow['lg_country_iso_2']) : ''));
                }
            }
        } else {
            $this->contentISOLanguage = trim($this->thisConfig['defaultContentLanguage']) ?: 'en';
            $languageCodeParts = explode('_', $this->contentISOLanguage);
            $this->contentISOLanguage = strtolower($languageCodeParts[0]) . ($languageCodeParts[1] ? '_' . strtoupper($languageCodeParts[1]) : '');
            // Find the configured language in the list of localization locales
            /** @var $locales \TYPO3\CMS\Core\Localization\Locales */
            $locales = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Localization\Locales::class);
            // If not found, default to 'en'
            if (!in_array($this->contentISOLanguage, $locales->getLocales())) {
                $this->contentISOLanguage = 'en';
            }
        }
        // Create content laguage service
        $this->contentLanguageService = GeneralUtility::makeInstance(\TYPO3\CMS\Lang\LanguageService::class);
        $this->contentTypo3Language = $this->contentISOLanguage === 'en' ? 'default' : $this->contentISOLanguage;
        $this->contentLanguageService->init($this->contentTypo3Language);
        /* =======================================
         * TOOLBAR CONFIGURATION
         * =======================================
         */
        $this->initializeToolbarConfiguration();
        /* =======================================
         * SET STYLES
         * =======================================
         */
        // Check if wizard_rte called this for fullscreen edtition
        if (GeneralUtility::_GP('M') === 'wizard_rte') {
            $this->fullScreen = TRUE;
            $RTEWidth = '100%';
            $RTEHeight = '100%';
            $RTEPaddingRight = '0';
            $editorWrapWidth = '100%';
        } else {
            $options = $GLOBALS['BE_USER']->userTS['options.'];
            $RTEWidth = 530 + (isset($options['RTELargeWidthIncrement']) ? (int) $options['RTELargeWidthIncrement'] : 150);
            /** @var InlineStackProcessor  $inlineStackProcessor */
            $inlineStackProcessor = GeneralUtility::makeInstance(InlineStackProcessor::class);
            $inlineStackProcessor->initializeByGivenStructure($globalOptions['inlineStructure']);
            $inlineStructureDepth = $inlineStackProcessor->getStructureDepth();
            $RTEWidth -= $inlineStructureDepth > 0 ? ($inlineStructureDepth + 1) * 12 : 0;
            $RTEWidthOverride = is_object($GLOBALS['BE_USER']) && isset($GLOBALS['BE_USER']->uc['rteWidth']) && trim($GLOBALS['BE_USER']->uc['rteWidth']) ? trim($GLOBALS['BE_USER']->uc['rteWidth']) : trim($this->thisConfig['RTEWidthOverride']);
            if ($RTEWidthOverride) {
                if (strstr($RTEWidthOverride, '%')) {
                    if ($this->client['browser'] != 'msie') {
                        $RTEWidth = (int) $RTEWidthOverride > 0 ? $RTEWidthOverride : '100%';
                    }
                } else {
                    $RTEWidth = (int) $RTEWidthOverride > 0 ? (int) $RTEWidthOverride : $RTEWidth;
                }
            }
            $RTEWidth = strstr($RTEWidth, '%') ? $RTEWidth : $RTEWidth . 'px';
            $RTEHeight = 380 + (isset($options['RTELargeHeightIncrement']) ? (int) $options['RTELargeHeightIncrement'] : 0);
            $RTEHeightOverride = is_object($GLOBALS['BE_USER']) && isset($GLOBALS['BE_USER']->uc['rteHeight']) && (int) $GLOBALS['BE_USER']->uc['rteHeight'] ? (int) $GLOBALS['BE_USER']->uc['rteHeight'] : (int) $this->thisConfig['RTEHeightOverride'];
            $RTEHeight = $RTEHeightOverride > 0 ? $RTEHeightOverride : $RTEHeight;
            $RTEPaddingRight = '2px';
            $editorWrapWidth = '99%';
        }
        $editorWrapHeight = '100%';
        $this->RTEdivStyle = 'position:relative; left:0px; top:0px; height:' . $RTEHeight . 'px; width:' . $RTEWidth . '; border: 1px solid black; padding: 2px ' . $RTEPaddingRight . ' 2px 2px;';
        /* =======================================
         * LOAD CSS AND JAVASCRIPT
         * =======================================
         */
        $this->pageRenderer = $GLOBALS['SOBE']->doc->getPageRenderer();
        // Preloading the pageStyle and including RTE skin stylesheets
        $resultArray = $this->addPageStyle($resultArray);
        $resultArray = $this->addSkin($resultArray);
        // Register RTE in JS
        $resultArray['additionalJavaScriptPost'][] = $this->registerRTEinJS(NULL, $table, $row['uid'], $field, $textAreaId);
        // Set the save option for the RTE
        $resultArray['additionalJavaScriptSubmit'][] = $this->setSaveRTE(NULL, 'editform', $textAreaId, $PA['itemFormElName']);
        // Loading ExtJs inline code
        $this->pageRenderer->enableExtJSQuickTips();
        // Add TYPO3 notifications JavaScript
        $this->pageRenderer->addJsFile('sysext/backend/Resources/Public/JavaScript/notifications.js');
        // Add RTE JavaScript
        $this->addRteJsFiles();
        $this->pageRenderer->addJsFile($this->createJavaScriptLanguageLabelsFromFiles());
        $this->pageRenderer->addJsInlineCode('HTMLArea-init', $this->getRteInitJsCode(), TRUE);
        /* =======================================
         * DRAW THE EDITOR
         * =======================================
         */
        // Transform value:
        $value = $this->transformContent('rte', $PA['itemFormElValue'], $table, $field, $row, $specConf, $thisConfig, $RTErelPath, $thePidValue);
        // Further content transformation by registered plugins
        foreach ($this->registeredPlugins as $pluginId => $plugin) {
            if ($this->isPluginEnabled($pluginId) && method_exists($plugin, 'transformContent')) {
                $value = $plugin->transformContent($value);
            }
        }
        // Draw the textarea
        $item = $this->triggerField($PA['itemFormElName']) . '
			<div id="pleasewait' . $textAreaId . '" class="pleasewait" style="display: block;" >' . $languageService->getLL('Please wait') . '</div>
			<div id="editorWrap' . $textAreaId . '" class="editorWrap" style="visibility: hidden; width:' . $editorWrapWidth . '; height:' . $editorWrapHeight . ';">
			<textarea id="RTEarea' . $textAreaId . '" ' . $validatationDataAttribute . ' name="' . htmlspecialchars($PA['itemFormElName']) . '" rows="0" cols="0" style="' . htmlspecialchars($this->RTEdivStyle, ENT_COMPAT, 'UTF-8', FALSE) . '">' . GeneralUtility::formatForTextarea($value) . '</textarea>
			</div>' . LF;
        $resultArray['html'] = $item;
        return $resultArray;
    }
Esempio n. 9
0
    /**
     * Main function of the module. Write the content to $this->content
     * If you chose "web" as main module, you will need to consider the $this->id parameter which will contain the uid-number of the page clicked in the page tree
     *
     * @return void
     */
    function main()
    {
        global $BE_USER, $LANG, $BACK_PATH, $TCA_DESCR, $TCA, $CLIENT, $TYPO3_CONF_VARS;
        $PATH_TYPO3 = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . 'typo3/';
        if ($BE_USER->user["admin"]) {
            // find node
            $node_repository = tx_caretaker_NodeRepository::getInstance();
            $node = $node_repository->id2node($this->node_id, true);
            if (!$node) {
                $node = $node_repository->getRootNode();
            }
            // Draw the header.
            $this->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
            $this->doc->backPath = $BACK_PATH;
            $this->pageRenderer = $this->doc->getPageRenderer();
            // Include Ext JS
            $this->pageRenderer->loadExtJS();
            $this->pageRenderer->enableExtJSQuickTips();
            $this->pageRenderer->addJsFile($BACK_PATH . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('caretaker') . 'res/js/tx.caretaker.js');
            $panels = array();
            foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['caretaker']['extJsBackendPanels'] as $extJsBackendPanel) {
                // register JS
                foreach ($extJsBackendPanel['jsIncludes'] as $jsInclude) {
                    $filename = $BACK_PATH . '../' . str_replace(PATH_site, '', \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($jsInclude));
                    $this->pageRenderer->addJsFile($filename);
                }
                // register CSS
                foreach ($extJsBackendPanel['cssIncludes'] as $cssInclude) {
                    $filename = $BACK_PATH . '../' . str_replace(PATH_site, '', \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($cssInclude));
                    $this->pageRenderer->addCssFile($filename);
                }
                // add ExtJs Panel
                $panels[$extJsBackendPanel['id']] = $extJsBackendPanel['xtype'];
            }
            $this->pageRenderer->addJsFile($BACK_PATH . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('caretaker') . 'res/js/tx.caretaker.NodeToolbar.js');
            // Enable debug mode for Ext JS
            $this->pageRenderer->enableExtJsDebug();
            // storage Pid
            $confArray = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['caretaker']);
            $storagePid = (int) $confArray['storagePid'];
            //Add caretaker css
            $this->pageRenderer->addCssFile($BACK_PATH . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('caretaker') . 'res/css/tx.caretaker.overview.css');
            $pluginItems = array();
            foreach ($panels as $id => $xtype) {
                $pluginItems[] = '{ id: "' . $id . '", xtype: "' . $xtype . '" , back_path: back_path , node_id: node_id }';
            }
            $this->pageRenderer->addJsInlineCode('Caretaker_Overview', '
				Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
				Ext.namespace("tx","tx.caretaker");

				Ext.QuickTips.init();

				Ext.onReady( function() {

					var back_path   = "' . $this->doc->backPath . '";
					var back_url    = "' . urlencode(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL')) . '";
					var path_typo3  = "' . \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . 'typo3/";
					var	add_url     = "' . $PATH_TYPO3 . 'alt_doc.php?edit[###NODE_TYPE###][' . $storagePid . ']=new";
					var node_id     = "' . $node->getCaretakerNodeId() . '";
					var node_type   = "' . strtolower($node->getType()) . '";
					var node_hidden = "' . $node->getHidden() . '";
					var node_uid    = "' . $node->getUid() . '";
					var node_title  = "' . htmlspecialchars($node->getTitle() ? $node->getTitle() : '[no title]') . '( ' . ($node->getTypeDescription() ? htmlspecialchars($node->getTypeDescription()) : $node->getType()) . ' )" ;
					var node_state  = "' . $node->getTestResult()->getState() . '" ;
					var node_state_info  = "' . $node->getTestResult()->getStateInfo() . '" ;

					tx.caretaker.view = new Ext.Viewport({
						layout: "fit",
						items: {
								xtype    : "panel",
								id       : "node",
								autoScroll: true,
								title    : node_title,
								iconCls  : "icon-caretaker-type-" + node_type,
								tbar     : {
									xtype: "caretaker-nodetoolbar",
									back_path: back_path,
									path_typo3: path_typo3,
									back_url: back_url,
									add_url :add_url,
									node_id: node_id,
									node_type: node_type,
									node_uid: node_uid,
									node_hidden: node_hidden,
									node_state: node_state,
									node_state_info: node_state_info
								},
								items    : [
									{
										xtype    : "panel",
										padding  : "10",
										layout   : "fit",
										id       : "caretaker-panels",
										items    : [
											' . implode(chr(10) . ',', $pluginItems) . chr(10) . '
										]
									}
								],
						}
					 });
				});
			');
            $this->content .= $this->doc->startPage($LANG->getLL("title"));
            $this->doc->form = '';
        } else {
            // If no access or if not admin
            $this->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\MediumDocumentTemplate');
            $this->doc->backPath = $BACK_PATH;
            $this->content .= $this->doc->startPage($LANG->getLL("title"));
            $this->content .= $this->doc->header($LANG->getLL("title"));
            $this->content .= $this->doc->spacer(5);
            $this->content .= $this->doc->spacer(10);
        }
    }