Esempio n. 1
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);
        }
    }
 /**
  * Load the assets (JavaScript, CSS) for this Vidi module.
  *
  * @return void
  * @api
  */
 public function render()
 {
     /** @var \Fab\Vidi\Module\ModuleLoader $moduleLoader */
     $moduleLoader = $this->objectManager->get('Fab\\Vidi\\Module\\ModuleLoader');
     foreach ($moduleLoader->getAdditionalStyleSheetFiles() as $addCssFile) {
         $fileNameAndPath = $this->resolvePath($addCssFile);
         $this->pageRenderer->addCssFile($fileNameAndPath);
     }
     foreach ($moduleLoader->getAdditionalJavaScriptFiles() as $addJsFile) {
         $fileNameAndPath = $this->resolvePath($addJsFile);
         $this->pageRenderer->addJsFile($fileNameAndPath);
     }
 }
 /**
  * test add JS file
  */
 public function testAddJsFile()
 {
     $expectedRegExp = '#<script src="fileadmin/test\\.(js|\\d+\\.js|js\\?\\d+)" type="text/javascript"></script>#';
     $this->fixture->addJsFile('fileadmin/test.js');
     $out = $this->fixture->render();
     $this->assertRegExp($expectedRegExp, $out);
 }
 /**
  * Wrapper for t3lib_PageRenderer->addJsFile. Excludes $jsFile from concatenation on TYPO3 4.6+.
  *
  * @param string $jsFile
  * @return void
  */
 protected function addJsFileToPageRenderer($jsFile)
 {
     if (version_compare(TYPO3_version, '4.6', '>=')) {
         $this->pageRenderer->addJsFile($jsFile, 'text/javascript', true, false, '', true);
     } else {
         $this->pageRenderer->addJsFile($jsFile);
     }
 }
Esempio n. 5
0
 /**
  * Add a JS File to the header
  * 
  * @param string $file
  * @param string $type
  * @param boolean $compress
  * @param boolean $forceOnTop
  * @param string $allWrap
  * @param string $position
  * @return void
  */
 public function addJSFile($file, $position = 'footer', $type = 'text/javascript', $compress = true, $forceOnTop = false, $allWrap = '')
 {
     $filePath = GeneralUtility::isFirstPartOfStr(strtolower($file), 'http') ? $file : $this->fileSystemDiv->getFileRelFileName($file);
     if ($position === 'footer') {
         $this->pageRenderer->addJsFooterFile($filePath, $type, $compress, $forceOnTop, $allWrap);
     } else {
         $this->pageRenderer->addJsFile($filePath, $type, $compress, $forceOnTop, $allWrap);
     }
 }
 /**
  * @param $path
  */
 protected function includeJavascriptFromPath($path)
 {
     $resourcePath = ExtensionManagementUtility::extRelPath('typo3_forum') . $path;
     $absResourcePath = ExtensionManagementUtility::extPath('typo3_forum') . $path;
     $jsFiles = glob($absResourcePath . '*.js');
     foreach ($jsFiles as $jsFile) {
         $jsFile = str_replace($absResourcePath, $resourcePath, $jsFile);
         $this->pageRenderer->addJsFile($jsFile, 'text/javascript', FALSE);
     }
 }
 /**
  * Render the URI to the resource. The filename is used from child content.
  *
  * @param string $file The relative path of the resource (relative to Public resource directory of the extension).
  */
 public function render($file = NULL)
 {
     if (!$this->arguments['extensionName']) {
         $this->arguments['extensionName'] = $this->controllerContext->getRequest()->getControllerExtensionName();
     }
     $uri = 'EXT:' . GeneralUtility::camelCaseToLowerCaseUnderscored($this->arguments['extensionName']) . $this->getResourcesPathAndFilename($file);
     $uri = GeneralUtility::getFileAbsFileName($uri);
     $uri = substr($uri, strlen(PATH_site));
     switch ($this->arguments['where']) {
         case 'footer':
             $this->pageRenderer->addJsFooterFile($uri, $this->arguments['type'], $this->arguments['compress'], $this->arguments['forceOnTop'], $this->arguments['allWrap'], $this->arguments['excludeFromConcatenation']);
             break;
         case 'footerLibs':
             $this->pageRenderer->addJsFooterLibrary($this->arguments['key'], $uri, $this->arguments['type'], $this->arguments['compress'], $this->arguments['forceOnTop'], $this->arguments['allWrap'], $this->arguments['excludeFromConcatenation']);
             break;
         default:
             $this->pageRenderer->addJsFile($uri, $this->arguments['type'], $this->arguments['compress'], $this->arguments['forceOnTop'], $this->arguments['allWrap'], $this->arguments['excludeFromConcatenation']);
             break;
     }
 }
Esempio n. 8
0
 /**
  * Load the necessarry javascript
  *
  * This will only be done when the referenced record is available
  *
  * @return void
  */
 protected function loadJavascript()
 {
     $compress = TRUE;
     $javascriptFiles = array('Initialize.js', 'Ux/Ext.ux.merge.js', 'Ux/Ext.ux.isemptyobject.js', 'Ux/Ext.ux.spinner.js', 'Ux/Ext.ux.form.spinnerfield.js', 'Ux/Ext.ux.form.textfieldsubmit.js', 'Ux/Ext.ux.grid.CheckColumn.js', 'Ux/Ext.ux.grid.SingleSelectCheckColumn.js', 'Ux/Ext.ux.grid.ItemDeleter.js', 'Helpers/History.js', 'Helpers/Element.js', 'Elements/ButtonGroup.js', 'Elements/Container.js', 'Elements/Elements.js', 'Elements/Dummy.js', 'Elements/Basic/Button.js', 'Elements/Basic/Checkbox.js', 'Elements/Basic/Fieldset.js', 'Elements/Basic/Fileupload.js', 'Elements/Basic/Form.js', 'Elements/Basic/Hidden.js', 'Elements/Basic/Password.js', 'Elements/Basic/Radio.js', 'Elements/Basic/Reset.js', 'Elements/Basic/Select.js', 'Elements/Basic/Submit.js', 'Elements/Basic/Textarea.js', 'Elements/Basic/Textline.js', 'Elements/Predefined/Email.js', 'Elements/Predefined/CheckboxGroup.js', 'Elements/Predefined/Name.js', 'Elements/Predefined/RadioGroup.js', 'Elements/Content/Header.js', 'Elements/Content/Textblock.js', 'Viewport.js', 'Viewport/Left.js', 'Viewport/Right.js', 'Viewport/Left/Elements.js', 'Viewport/Left/Elements/ButtonGroup.js', 'Viewport/Left/Elements/Basic.js', 'Viewport/Left/Elements/Predefined.js', 'Viewport/Left/Elements/Content.js', 'Viewport/Left/Options.js', 'Viewport/Left/Options/Dummy.js', 'Viewport/Left/Options/Panel.js', 'Viewport/Left/Options/Forms/Attributes.js', 'Viewport/Left/Options/Forms/Label.js', 'Viewport/Left/Options/Forms/Legend.js', 'Viewport/Left/Options/Forms/Options.js', 'Viewport/Left/Options/Forms/Various.js', 'Viewport/Left/Options/Forms/Filters.js', 'Viewport/Left/Options/Forms/Filters/Filter.js', 'Viewport/Left/Options/Forms/Filters/Dummy.js', 'Viewport/Left/Options/Forms/Filters/Alphabetic.js', 'Viewport/Left/Options/Forms/Filters/Alphanumeric.js', 'Viewport/Left/Options/Forms/Filters/Currency.js', 'Viewport/Left/Options/Forms/Filters/Digit.js', 'Viewport/Left/Options/Forms/Filters/Integer.js', 'Viewport/Left/Options/Forms/Filters/LowerCase.js', 'Viewport/Left/Options/Forms/Filters/RegExp.js', 'Viewport/Left/Options/Forms/Filters/RemoveXSS.js', 'Viewport/Left/Options/Forms/Filters/StripNewLines.js', 'Viewport/Left/Options/Forms/Filters/TitleCase.js', 'Viewport/Left/Options/Forms/Filters/Trim.js', 'Viewport/Left/Options/Forms/Filters/UpperCase.js', 'Viewport/Left/Options/Forms/Validation.js', 'Viewport/Left/Options/Forms/Validation/Rule.js', 'Viewport/Left/Options/Forms/Validation/Dummy.js', 'Viewport/Left/Options/Forms/Validation/Alphabetic.js', 'Viewport/Left/Options/Forms/Validation/Alphanumeric.js', 'Viewport/Left/Options/Forms/Validation/Between.js', 'Viewport/Left/Options/Forms/Validation/Date.js', 'Viewport/Left/Options/Forms/Validation/Digit.js', 'Viewport/Left/Options/Forms/Validation/Email.js', 'Viewport/Left/Options/Forms/Validation/Equals.js', 'Viewport/Left/Options/Forms/Validation/FileAllowedTypes.js', 'Viewport/Left/Options/Forms/Validation/FileMaximumSize.js', 'Viewport/Left/Options/Forms/Validation/FileMinimumSize.js', 'Viewport/Left/Options/Forms/Validation/Float.js', 'Viewport/Left/Options/Forms/Validation/GreaterThan.js', 'Viewport/Left/Options/Forms/Validation/InArray.js', 'Viewport/Left/Options/Forms/Validation/Integer.js', 'Viewport/Left/Options/Forms/Validation/Ip.js', 'Viewport/Left/Options/Forms/Validation/Length.js', 'Viewport/Left/Options/Forms/Validation/LessThan.js', 'Viewport/Left/Options/Forms/Validation/RegExp.js', 'Viewport/Left/Options/Forms/Validation/Required.js', 'Viewport/Left/Options/Forms/Validation/Uri.js', 'Viewport/Left/Form.js', 'Viewport/Left/Form/Behaviour.js', 'Viewport/Left/Form/Attributes.js', 'Viewport/Left/Form/Prefix.js', 'Viewport/Left/Form/PostProcessor.js', 'Viewport/Left/Form/PostProcessors/PostProcessor.js', 'Viewport/Left/Form/PostProcessors/Dummy.js', 'Viewport/Left/Form/PostProcessors/Mail.js', 'Viewport/Left/Form/PostProcessors/Redirect.js');
     // Load ExtJS
     $this->pageRenderer->loadExtJS();
     // Load the wizards javascript
     $baseUrl = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('form') . 'Resources/Public/JavaScript/Wizard/';
     foreach ($javascriptFiles as $javascriptFile) {
         $this->pageRenderer->addJsFile($baseUrl . $javascriptFile, 'text/javascript', $compress, FALSE);
     }
 }
 /**
  * @param PageRenderer $pageRenderer
  */
 public function getPageRenderer(PageRenderer $pageRenderer)
 {
     $loginSecurityLevel = trim($GLOBALS['TYPO3_CONF_VARS']['BE']['loginSecurityLevel']) ?: 'normal';
     if ($loginSecurityLevel === 'rsa') {
         $javascriptPath = '../' . ExtensionManagementUtility::siteRelPath('rsaauth') . 'Resources/Public/JavaScript/';
         $files = array('jsbn/jsbn.js', 'jsbn/prng4.js', 'jsbn/rng.js', 'jsbn/rsa.js', 'jsbn/base64.js');
         foreach ($files as $file) {
             $pageRenderer->addJsFile($javascriptPath . $file);
         }
         $pageRenderer->loadRequireJsModule('TYPO3/CMS/Rsaauth/BackendLoginFormRsaEncryption');
     }
 }
 /**
  * Render start page with \TYPO3\CMS\Backend\Template\DocumentTemplate and pageTitle
  *
  * @param string $pageTitle title tag of the module. Not required by default, as BE modules are shown in a frame
  * @param bool $loadExtJs specifies whether to load ExtJS library. Defaults to FALSE
  * @param bool $loadExtJsTheme whether to load ExtJS "grey" theme. Defaults to FALSE
  * @param bool $enableExtJsDebug if TRUE, debug version of ExtJS is loaded. Use this for development only
  * @param bool $loadJQuery whether to load jQuery library. Defaults to FALSE
  * @param array $includeCssFiles List of custom CSS file to be loaded
  * @param array $includeJsFiles List of custom JavaScript file to be loaded
  * @param array $addJsInlineLabels Custom labels to add to JavaScript inline labels
  * @param array $includeRequireJsModules List of RequireJS modules to be loaded
  * @param string $jQueryNamespace Store the jQuery object in a specific namespace
  * @return void
  */
 public function render($pageTitle = '', $loadExtJs = false, $loadExtJsTheme = true, $enableExtJsDebug = false, $loadJQuery = false, $includeCssFiles = null, $includeJsFiles = null, $addJsInlineLabels = null, $includeRequireJsModules = null, $jQueryNamespace = null)
 {
     if ($pageTitle) {
         $this->pageRenderer->setTitle($pageTitle);
     }
     if ($loadExtJs) {
         $this->pageRenderer->loadExtJS(true, $loadExtJsTheme);
         if ($enableExtJsDebug) {
             $this->pageRenderer->enableExtJsDebug();
         }
     }
     if ($loadJQuery) {
         $jQueryNamespace = $jQueryNamespace ?: PageRenderer::JQUERY_NAMESPACE_DEFAULT;
         $this->pageRenderer->loadJquery(null, null, $jQueryNamespace);
     }
     // Include custom CSS and JS files
     if (is_array($includeCssFiles) && count($includeCssFiles) > 0) {
         foreach ($includeCssFiles as $addCssFile) {
             $this->pageRenderer->addCssFile($addCssFile);
         }
     }
     if (is_array($includeJsFiles) && count($includeJsFiles) > 0) {
         foreach ($includeJsFiles as $addJsFile) {
             $this->pageRenderer->addJsFile($addJsFile);
         }
     }
     if (is_array($includeRequireJsModules) && count($includeRequireJsModules) > 0) {
         foreach ($includeRequireJsModules as $addRequireJsFile) {
             $this->pageRenderer->loadRequireJsModule($addRequireJsFile);
         }
     }
     // Add inline language labels
     if (is_array($addJsInlineLabels) && count($addJsInlineLabels) > 0) {
         $extensionKey = $this->controllerContext->getRequest()->getControllerExtensionKey();
         foreach ($addJsInlineLabels as $key) {
             $label = LocalizationUtility::translate($key, $extensionKey);
             $this->pageRenderer->addInlineLanguageLabel($key, $label);
         }
     }
 }
Esempio n. 11
0
 /**
  * Shows all versions of a specific extension
  *
  * @return void
  */
 public function showAllVersionsAction()
 {
     $this->pageRenderer->addJsFile($this->backPath . '../t3lib/js/extjs/notifications.js');
     $extensions = array();
     $extensionKey = '';
     if ($this->request->hasArgument('allVersions') && $this->request->getArgument('allVersions') == 1 && $this->request->hasArgument('extensionKey') && is_string($this->request->getArgument('extensionKey'))) {
         $extensionKey = $this->request->getArgument('extensionKey');
         $extensions = $this->extensionRepository->findByExtensionKeyOrderedByVersion($extensionKey);
     } else {
         $this->redirect('ter');
     }
     $this->view->assign('extensions', $extensions)->assign('extensionKey', $extensionKey);
 }
Esempio n. 12
0
 /**
  * Loads the css and javascript files of all registered navigation widgets
  *
  * @return void
  */
 protected function loadResourcesForRegisteredNavigationComponents()
 {
     if (!is_array($GLOBALS['TBE_MODULES']['_navigationComponents'])) {
         return;
     }
     $loadedComponents = array();
     foreach ($GLOBALS['TBE_MODULES']['_navigationComponents'] as $module => $info) {
         if (in_array($info['componentId'], $loadedComponents)) {
             continue;
         }
         $loadedComponents[] = $info['componentId'];
         $component = strtolower(substr($info['componentId'], strrpos($info['componentId'], '-') + 1));
         $componentDirectory = 'components/' . $component . '/';
         if ($info['isCoreComponent']) {
             $absoluteComponentPath = PATH_site . 'typo3/sysext/backend/Resources/Public/JavaScript/extjs/' . $componentDirectory;
             $relativeComponentPath = '../' . str_replace(PATH_site, '', $absoluteComponentPath);
         } else {
             $absoluteComponentPath = ExtensionManagementUtility::extPath($info['extKey']) . $componentDirectory;
             $relativeComponentPath = ExtensionManagementUtility::extRelPath($info['extKey']) . $componentDirectory;
         }
         $cssFiles = GeneralUtility::getFilesInDir($absoluteComponentPath . 'css/', 'css');
         if (file_exists($absoluteComponentPath . 'css/loadorder.txt')) {
             // Don't allow inclusion outside directory
             $loadOrder = str_replace('../', '', GeneralUtility::getUrl($absoluteComponentPath . 'css/loadorder.txt'));
             $cssFilesOrdered = GeneralUtility::trimExplode(LF, $loadOrder, true);
             $cssFiles = array_merge($cssFilesOrdered, $cssFiles);
         }
         foreach ($cssFiles as $cssFile) {
             $this->pageRenderer->addCssFile($relativeComponentPath . 'css/' . $cssFile);
         }
         $jsFiles = GeneralUtility::getFilesInDir($absoluteComponentPath . 'javascript/', 'js');
         if (file_exists($absoluteComponentPath . 'javascript/loadorder.txt')) {
             // Don't allow inclusion outside directory
             $loadOrder = str_replace('../', '', GeneralUtility::getUrl($absoluteComponentPath . 'javascript/loadorder.txt'));
             $jsFilesOrdered = GeneralUtility::trimExplode(LF, $loadOrder, true);
             $jsFiles = array_merge($jsFilesOrdered, $jsFiles);
         }
         foreach ($jsFiles as $jsFile) {
             $this->pageRenderer->addJsFile($relativeComponentPath . 'javascript/' . $jsFile);
         }
         $this->pageRenderer->addInlineSetting('RecordHistory', 'moduleUrl', BackendUtility::getModuleUrl('record_history'));
         $this->pageRenderer->addInlineSetting('NewRecord', 'moduleUrl', BackendUtility::getModuleUrl('db_new'));
         $this->pageRenderer->addInlineSetting('FormEngine', 'moduleUrl', BackendUtility::getModuleUrl('record_edit'));
     }
 }
 /**
  * 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');
 }
Esempio n. 14
0
 /**
  * Loads the css and javascript files of all registered navigation widgets
  *
  * @return void
  */
 protected function loadResourcesForRegisteredNavigationComponents()
 {
     if (!is_array($GLOBALS['TBE_MODULES']['_navigationComponents'])) {
         return;
     }
     $loadedComponents = array();
     foreach ($GLOBALS['TBE_MODULES']['_navigationComponents'] as $module => $info) {
         if (in_array($info['componentId'], $loadedComponents)) {
             continue;
         }
         $loadedComponents[] = $info['componentId'];
         $component = strtolower(substr($info['componentId'], strrpos($info['componentId'], '-') + 1));
         $componentDirectory = 'components/' . $component . '/';
         if ($info['isCoreComponent']) {
             $absoluteComponentPath = PATH_t3lib . 'js/extjs/' . $componentDirectory;
             $relativeComponentPath = '../' . str_replace(PATH_site, '', $absoluteComponentPath);
         } else {
             $absoluteComponentPath = \TYPO3\CMS\Core\Extension\ExtensionManager::extPath($info['extKey']) . $componentDirectory;
             $relativeComponentPath = \TYPO3\CMS\Core\Extension\ExtensionManager::extRelPath($info['extKey']) . $componentDirectory;
         }
         $cssFiles = \TYPO3\CMS\Core\Utility\GeneralUtility::getFilesInDir($absoluteComponentPath . 'css/', 'css');
         if (file_exists($absoluteComponentPath . 'css/loadorder.txt')) {
             // Don't allow inclusion outside directory
             $loadOrder = str_replace('../', '', \TYPO3\CMS\Core\Utility\GeneralUtility::getUrl($absoluteComponentPath . 'css/loadorder.txt'));
             $cssFilesOrdered = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(LF, $loadOrder, TRUE);
             $cssFiles = array_merge($cssFilesOrdered, $cssFiles);
         }
         foreach ($cssFiles as $cssFile) {
             $this->pageRenderer->addCssFile($relativeComponentPath . 'css/' . $cssFile);
         }
         $jsFiles = \TYPO3\CMS\Core\Utility\GeneralUtility::getFilesInDir($absoluteComponentPath . 'javascript/', 'js');
         if (file_exists($absoluteComponentPath . 'javascript/loadorder.txt')) {
             // Don't allow inclusion outside directory
             $loadOrder = str_replace('../', '', \TYPO3\CMS\Core\Utility\GeneralUtility::getUrl($absoluteComponentPath . 'javascript/loadorder.txt'));
             $jsFilesOrdered = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(LF, $loadOrder, TRUE);
             $jsFiles = array_merge($jsFilesOrdered, $jsFiles);
         }
         foreach ($jsFiles as $jsFile) {
             $this->pageRenderer->addJsFile($relativeComponentPath . 'javascript/' . $jsFile);
         }
     }
 }
Esempio n. 15
0
 /**
  * Includes a javascript library that exists in the core /typo3/ directory
  *
  * @param string $lib Library name. Call it with the full path like
  * "sysext/core/Resources/Public/JavaScript/QueryGenerator.js" to load it
  *
  * @return void
  * @internal
  */
 public function loadJavascriptLib($lib)
 {
     // @todo: maybe we can remove this one as well
     $this->pageRenderer->addJsFile($lib);
 }
Esempio n. 16
0
 /**
  * This loads everything needed for the Context Sensitive Help (CSH)
  *
  * @return void
  */
 protected function loadCshJavascript()
 {
     $this->pageRenderer->loadExtJS();
     $this->pageRenderer->addJsFile($this->backPath . 'sysext/backend/Resources/Public/JavaScript/contexthelp.js');
     $this->pageRenderer->addExtDirectCode();
 }
 /**
  * Loads data in the HTML head section (e.g. JavaScript or stylesheet information)
  *
  * @return void
  */
 protected function loadHeaderData()
 {
     $this->doc->addStyleSheet('linkvalidator', $this->relativePath . 'Resources/Public/Css/linkvalidator.css', 'linkvalidator');
     $this->pageRenderer->addJsFile($this->doc->backPath . 'js/extjs/ux/Ext.ux.FitToParent.js');
 }
Esempio n. 18
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->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.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);
        }
    }
    /**
     * Assemble display of list of scheduled tasks
     *
     * @return string Table of pending tasks
     */
    protected function listTasks()
    {
        // Define display format for dates
        $dateFormat = $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'] . ' ' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'];
        $content = '';
        // Get list of registered classes
        $registeredClasses = self::getRegisteredClasses();
        // Get list of registered task groups
        $registeredTaskGroups = self::getRegisteredTaskGroups();
        // add an empty entry for non-grouped tasks
        // add in front of list
        array_unshift($registeredTaskGroups, array('uid' => 0, 'groupName' => ''));
        // Get all registered tasks
        // Just to get the number of entries
        $query = array('SELECT' => '*', 'FROM' => 'tx_scheduler_task', 'WHERE' => '1=1', 'ORDERBY' => '');
        $res = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($query);
        $numRows = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
        $GLOBALS['TYPO3_DB']->sql_free_result($res);
        // No tasks defined, display information message
        if ($numRows == 0) {
            /** @var $flashMessage \TYPO3\CMS\Core\Messaging\FlashMessage */
            $flashMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $GLOBALS['LANG']->getLL('msg.noTasks'), '', \TYPO3\CMS\Core\Messaging\FlashMessage::INFO);
            $content .= $flashMessage->render();
        } else {
            // Load ExtJS framework and specific JS library
            $this->pageRenderer->loadExtJS();
            $this->pageRenderer->addJsFile(ExtensionManagementUtility::extRelPath('scheduler') . 'res/tx_scheduler_be.js');
            // Initialise table layout
            $tableLayout = array('table' => array('<table class="t3-table">', '</table>'), '0' => array('tr' => array('<thead><tr>', '</tr></thead>'), 'defCol' => array('<td>', '</td>'), '1' => array('<td style="width: 56px;">', '</td>'), '3' => array('<td colspan="2">', '</td>')), 'defRow' => array('tr' => array('<tr class="db_list_normal">', '</tr>'), 'defCol' => array('<td>', '</td>'), '1' => array('<td class="right">', '</td>'), '2' => array('<td class="right">', '</td>')));
            $disabledTaskRow = array('tr' => array('<tr class="db_list_normal disabled">', '</tr>'), 'defCol' => array('<td>', '</td>'), '1' => array('<td class="right">', '</td>'), '2' => array('<td class="right">', '</td>'));
            $rowWithSpan = array('tr' => array('<tr class="db_list_normal">', '</tr>'), 'defCol' => array('<td>', '</td>'), '1' => array('<td class="right">', '</td>'), '2' => array('<td class="right">', '</td>'), '3' => array('<td colspan="6">', '</td>'));
            $taskGroupRow = array('tr' => array('<tr class="db_list_normal">', '</tr>'), 'defCol' => array('<td>', '</td>'), '0' => array('<td colspan="10">', '</td>'));
            $table = array();
            $tr = 0;
            // Header row
            $table[$tr][] = '<a href="#" onclick="toggleCheckboxes();" title="' . $GLOBALS['LANG']->getLL('label.checkAll', TRUE) . '" class="icon">' . IconUtility::getSpriteIcon('actions-document-select') . '</a>';
            $table[$tr][] = '&nbsp;';
            $table[$tr][] = $GLOBALS['LANG']->getLL('label.id');
            $table[$tr][] = $GLOBALS['LANG']->getLL('task');
            $table[$tr][] = $GLOBALS['LANG']->getLL('label.type');
            $table[$tr][] = $GLOBALS['LANG']->getLL('label.frequency');
            $table[$tr][] = $GLOBALS['LANG']->getLL('label.parallel');
            $table[$tr][] = $GLOBALS['LANG']->getLL('label.lastExecution');
            $table[$tr][] = $GLOBALS['LANG']->getLL('label.nextExecution');
            $tr++;
            foreach ($registeredTaskGroups as $taskGroup) {
                $query = array('SELECT' => '*', 'FROM' => 'tx_scheduler_task', 'WHERE' => 'task_group=' . $taskGroup['uid'], 'ORDERBY' => 'nextexecution');
                $res = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($query);
                $numRows = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
                if ($numRows === 0) {
                    continue;
                }
                if ($taskGroup['groupName'] !== '') {
                    $tableLayout[$tr] = $taskGroupRow;
                    $groupText = '<strong>' . htmlspecialchars($taskGroup['groupName']) . '</strong>';
                    if (!empty($taskGroup['description'])) {
                        $groupText .= '<br />' . nl2br(htmlspecialchars($taskGroup['description']));
                    }
                    $table[$tr][] = $groupText;
                    $tr++;
                }
                // Loop on all tasks
                while ($schedulerRecord = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
                    // Define action icons
                    $editAction = '<a href="' . $GLOBALS['MCONF']['_'] . '&CMD=edit&tx_scheduler[uid]=' . $schedulerRecord['uid'] . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xlf:edit', TRUE) . '" class="icon">' . IconUtility::getSpriteIcon('actions-document-open') . '</a>';
                    $deleteAction = '<a href="' . $GLOBALS['MCONF']['_'] . '&CMD=delete&tx_scheduler[uid]=' . $schedulerRecord['uid'] . '" onclick="return confirm(\'' . $GLOBALS['LANG']->getLL('msg.delete') . '\');" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xlf:delete', TRUE) . '" class="icon">' . IconUtility::getSpriteIcon('actions-edit-delete') . '</a>';
                    $stopAction = '<a href="' . $GLOBALS['MCONF']['_'] . '&CMD=stop&tx_scheduler[uid]=' . $schedulerRecord['uid'] . '" onclick="return confirm(\'' . $GLOBALS['LANG']->getLL('msg.stop') . '\');" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xlf:stop', TRUE) . '" class="icon">' . '<img ' . IconUtility::skinImg($this->backPath, ExtensionManagementUtility::extRelPath('scheduler') . '/res/gfx/stop.png') . ' alt="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xlf:stop') . '" /></a>';
                    $runAction = '<a href="' . $GLOBALS['MCONF']['_'] . '&tx_scheduler[execute][]=' . $schedulerRecord['uid'] . '" title="' . $GLOBALS['LANG']->getLL('action.run_task') . '" class="icon">' . IconUtility::getSpriteIcon('extensions-scheduler-run-task') . '</a>';
                    // Define some default values
                    $lastExecution = '-';
                    $isRunning = FALSE;
                    $executionStatus = 'scheduled';
                    $executionStatusOutput = '';
                    $name = '';
                    $nextDate = '-';
                    $execType = '-';
                    $frequency = '-';
                    $multiple = '-';
                    $startExecutionElement = '&nbsp;';
                    // Restore the serialized task and pass it a reference to the scheduler object
                    /** @var $task \TYPO3\CMS\Scheduler\Task\AbstractTask|\TYPO3\CMS\Scheduler\ProgressProviderInterface */
                    $task = unserialize($schedulerRecord['serialized_task_object']);
                    $class = get_class($task);
                    if ($class === '__PHP_Incomplete_Class' && preg_match('/^O:[0-9]+:"(?P<classname>.+?)"/', $schedulerRecord['serialized_task_object'], $matches) === 1) {
                        $class = $matches['classname'];
                    }
                    // Assemble information about last execution
                    $context = '';
                    if (!empty($schedulerRecord['lastexecution_time'])) {
                        $lastExecution = date($dateFormat, $schedulerRecord['lastexecution_time']);
                        if ($schedulerRecord['lastexecution_context'] == 'CLI') {
                            $context = $GLOBALS['LANG']->getLL('label.cron');
                        } else {
                            $context = $GLOBALS['LANG']->getLL('label.manual');
                        }
                        $lastExecution .= ' (' . $context . ')';
                    }
                    if ($this->scheduler->isValidTaskObject($task)) {
                        // The task object is valid
                        $name = htmlspecialchars($registeredClasses[$class]['title'] . ' (' . $registeredClasses[$class]['extension'] . ')');
                        $additionalInformation = $task->getAdditionalInformation();
                        if ($task instanceof \TYPO3\CMS\Scheduler\ProgressProviderInterface) {
                            $progress = round(floatval($task->getProgress()), 2);
                            $name .= '<br />' . $this->renderTaskProgressBar($progress);
                        }
                        if (!empty($additionalInformation)) {
                            $name .= '<br />[' . htmlspecialchars($additionalInformation) . ']';
                        }
                        // Check if task currently has a running execution
                        if (!empty($schedulerRecord['serialized_executions'])) {
                            $isRunning = TRUE;
                            $executionStatus = 'running';
                        }
                        // Prepare display of next execution date
                        // If task is currently running, date is not displayed (as next hasn't been calculated yet)
                        // Also hide the date if task is disabled (the information doesn't make sense, as it will not run anyway)
                        if ($isRunning || $schedulerRecord['disable'] == 1) {
                            $nextDate = '-';
                        } else {
                            $nextDate = date($dateFormat, $schedulerRecord['nextexecution']);
                            if (empty($schedulerRecord['nextexecution'])) {
                                $nextDate = $GLOBALS['LANG']->getLL('none');
                            } elseif ($schedulerRecord['nextexecution'] < $GLOBALS['EXEC_TIME']) {
                                // Next execution is overdue, highlight date
                                $nextDate = '<span class="late" title="' . $GLOBALS['LANG']->getLL('status.legend.scheduled') . '">' . $nextDate . '</span>';
                                $executionStatus = 'late';
                            }
                        }
                        // Get execution type
                        if ($task->getExecution()->getInterval() == 0 && $task->getExecution()->getCronCmd() == '') {
                            $execType = $GLOBALS['LANG']->getLL('label.type.single');
                            $frequency = '-';
                        } else {
                            $execType = $GLOBALS['LANG']->getLL('label.type.recurring');
                            if ($task->getExecution()->getCronCmd() == '') {
                                $frequency = $task->getExecution()->getInterval();
                            } else {
                                $frequency = $task->getExecution()->getCronCmd();
                            }
                        }
                        // Get multiple executions setting
                        if ($task->getExecution()->getMultiple()) {
                            $multiple = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xlf:yes');
                        } else {
                            $multiple = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xlf:no');
                        }
                        // Define checkbox
                        $startExecutionElement = '<input type="checkbox" name="tx_scheduler[execute][]" value="' . $schedulerRecord['uid'] . '" id="task_' . $schedulerRecord['uid'] . '" class="checkboxes" />';
                        $actions = $editAction . $deleteAction;
                        // Check the disable status
                        // Row is shown dimmed if task is disabled, unless it is still running
                        if ($schedulerRecord['disable'] == 1 && !$isRunning) {
                            $tableLayout[$tr] = $disabledTaskRow;
                            $executionStatus = 'disabled';
                        }
                        // Show no action links (edit, delete) if task is running
                        if ($isRunning) {
                            $actions = $stopAction;
                        } else {
                            $actions .= $runAction;
                        }
                        // Check if the last run failed
                        $failureOutput = '';
                        if (!empty($schedulerRecord['lastexecution_failure'])) {
                            // Try to get the stored exception object
                            /** @var $exception \Exception */
                            $exception = unserialize($schedulerRecord['lastexecution_failure']);
                            // If the exception could not be unserialized, issue a default error message
                            if ($exception === FALSE || $exception instanceof \__PHP_Incomplete_Class) {
                                $failureDetail = $GLOBALS['LANG']->getLL('msg.executionFailureDefault');
                            } else {
                                $failureDetail = sprintf($GLOBALS['LANG']->getLL('msg.executionFailureReport'), $exception->getCode(), $exception->getMessage());
                            }
                            $failureOutput = ' <img ' . IconUtility::skinImg(ExtensionManagementUtility::extRelPath('scheduler'), 'res/gfx/status_failure.png') . ' alt="' . htmlspecialchars($GLOBALS['LANG']->getLL('status.failure')) . '" title="' . htmlspecialchars($failureDetail) . '" />';
                        }
                        // Format the execution status,
                        // including failure feedback, if any
                        $executionStatusOutput = '<img ' . IconUtility::skinImg(ExtensionManagementUtility::extRelPath('scheduler'), 'res/gfx/status_' . $executionStatus . '.png') . ' id="executionstatus_' . $schedulerRecord['uid'] . '" alt="' . htmlspecialchars($GLOBALS['LANG']->getLL('status.' . $executionStatus)) . '" title="' . htmlspecialchars($GLOBALS['LANG']->getLL('status.legend.' . $executionStatus)) . '" />' . $failureOutput;
                        $table[$tr][] = $startExecutionElement;
                        $table[$tr][] = $actions;
                        $table[$tr][] = $schedulerRecord['uid'];
                        $table[$tr][] = $executionStatusOutput;
                        if ($schedulerRecord['description'] !== '') {
                            if (!empty($this->scheduler->extConf['listShowTaskDescriptionAsHover'])) {
                                $table[$tr][] = '<span title="' . htmlspecialchars($schedulerRecord['description']) . '">' . $name . '</span>';
                            } else {
                                $table[$tr][] = $name . '<br />' . nl2br(htmlspecialchars($schedulerRecord['description'])) . '<br />';
                            }
                        } else {
                            $table[$tr][] = $name;
                        }
                        $table[$tr][] = $execType;
                        $table[$tr][] = $frequency;
                        $table[$tr][] = $multiple;
                        $table[$tr][] = $lastExecution;
                        $table[$tr][] = $nextDate;
                    } else {
                        // The task object is not valid
                        // Prepare to issue an error
                        /** @var $flashMessage \TYPO3\CMS\Core\Messaging\FlashMessage */
                        $flashMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', sprintf($GLOBALS['LANG']->getLL('msg.invalidTaskClass'), $class), '', \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
                        $executionStatusOutput = $flashMessage->render();
                        $tableLayout[$tr] = $rowWithSpan;
                        $table[$tr][] = $startExecutionElement;
                        $table[$tr][] = $deleteAction;
                        $table[$tr][] = $schedulerRecord['uid'];
                        $table[$tr][] = $executionStatusOutput;
                    }
                    $tr++;
                }
                $GLOBALS['TYPO3_DB']->sql_free_result($res);
            }
            // Render table
            $content .= $this->doc->table($table, $tableLayout);
            $content .= '<button name="go" id="scheduler_executeselected">' . IconUtility::getSpriteIcon('extensions-scheduler-run-task') . ' ' . $GLOBALS['LANG']->getLL('label.executeSelected') . '</button>';
        }
        if (!count($registeredClasses) > 0) {
            /** @var $flashMessage \TYPO3\CMS\Core\Messaging\FlashMessage */
            $flashMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $GLOBALS['LANG']->getLL('msg.noTasksDefined'), '', \TYPO3\CMS\Core\Messaging\FlashMessage::INFO);
            $content .= $flashMessage->render();
        }
        // Display legend, if there's at least one registered task
        // Also display information about the usage of server time
        if ($numRows > 0) {
            $content .= $this->doc->spacer(20);
            $content .= '<h3>' . $GLOBALS['LANG']->getLL('status.legend') . '</h3>
			<ul>
				<li><img ' . IconUtility::skinImg(ExtensionManagementUtility::extRelPath('scheduler'), 'res/gfx/status_failure.png') . ' alt="' . htmlspecialchars($GLOBALS['LANG']->getLL('status.failure')) . '" title="' . htmlspecialchars($GLOBALS['LANG']->getLL('status.failure')) . '" /> ' . $GLOBALS['LANG']->getLL('status.legend.failure') . '</li>
				<li><img ' . IconUtility::skinImg(ExtensionManagementUtility::extRelPath('scheduler'), 'res/gfx/status_late.png') . ' alt="' . htmlspecialchars($GLOBALS['LANG']->getLL('status.late')) . '" title="' . htmlspecialchars($GLOBALS['LANG']->getLL('status.late')) . '" /> ' . $GLOBALS['LANG']->getLL('status.legend.late') . '</li>
				<li><img ' . IconUtility::skinImg(ExtensionManagementUtility::extRelPath('scheduler'), 'res/gfx/status_running.png') . ' alt="' . htmlspecialchars($GLOBALS['LANG']->getLL('status.running')) . '" title="' . htmlspecialchars($GLOBALS['LANG']->getLL('status.running')) . '" /> ' . $GLOBALS['LANG']->getLL('status.legend.running') . '</li>
				<li><img ' . IconUtility::skinImg(ExtensionManagementUtility::extRelPath('scheduler'), 'res/gfx/status_scheduled.png') . ' alt="' . htmlspecialchars($GLOBALS['LANG']->getLL('status.scheduled')) . '" title="' . htmlspecialchars($GLOBALS['LANG']->getLL('status.scheduled')) . '" /> ' . $GLOBALS['LANG']->getLL('status.legend.scheduled') . '</li>
				<li><img ' . IconUtility::skinImg(ExtensionManagementUtility::extRelPath('scheduler'), 'res/gfx/status_disabled.png') . ' alt="' . htmlspecialchars($GLOBALS['LANG']->getLL('status.disabled')) . '" title="' . htmlspecialchars($GLOBALS['LANG']->getLL('status.disabled')) . '" /> ' . $GLOBALS['LANG']->getLL('status.legend.disabled') . '</li>
			</ul>';
            $content .= $this->displayServerTime();
        }
        return $content;
    }
 /**
  * @param string $src
  * @param string $type
  * @param boolean $compress
  * @param boolean $forceOnTop
  * @param string $allWrap
  * @param boolean $excludeFromConcatenation
  * @param string $section
  * @param boolean $preventMarkupUpdateOnAjaxLoad
  * @param boolean $moveToExternalFile
  * @param boolean $noCache
  * @param string $name
  * 
  * @return string
  */
 public function render($src = "", $type = 'text/javascript', $compress = TRUE, $forceOnTop = FALSE, $allWrap = '', $excludeFromConcatenation = FALSE, $section = 'footer', $preventMarkupUpdateOnAjaxLoad = false, $moveToExternalFile = false, $noCache = false, $name = '')
 {
     $content = $this->renderChildren();
     if ($this->ajaxDispatcher->getIsActive()) {
         if ($preventMarkupUpdateOnAjaxLoad) {
             $this->ajaxDispatcher->setPreventMarkupUpdateOnAjaxLoad(true);
         }
         // need to just echo the code in ajax call
         if (!$src) {
             if ($compress) {
                 $content = $this->compressScript($content);
             }
             return \TYPO3\CMS\Core\Utility\GeneralUtility::wrapJS($content);
         } else {
             return '<script type="' . htmlspecialchars($type) . '" src="' . htmlspecialchars($src) . '"></script>';
         }
     } else {
         if ($this->isCached()) {
             if ($noCache) {
                 if ($src) {
                     $content = '<script type="' . htmlspecialchars($type) . '" src="' . htmlspecialchars($src) . '"></script>';
                 } else {
                     if ($compress) {
                         $content = $this->compressScript($content);
                     }
                     $content = \TYPO3\CMS\Core\Utility\GeneralUtility::wrapJS($content);
                 }
                 $tslibFE = GeneralUtility::makeInstance('EssentialDots\\ExtbaseHijax\\Tslib\\FE\\Hook');
                 /* @var $tslibFE \EssentialDots\ExtbaseHijax\Tslib\FE\Hook */
                 if ($section == 'footer') {
                     $tslibFE->addNonCacheableFooterCode($name ? $name : md5($content), $content);
                 } else {
                     $tslibFE->addNonCacheableHeaderCode($name ? $name : md5($content), $content);
                 }
                 return '';
             } else {
                 if (!$src && $moveToExternalFile) {
                     $src = 'typo3temp' . DIRECTORY_SEPARATOR . 'extbase_hijax' . DIRECTORY_SEPARATOR . md5($content) . '.js';
                     \TYPO3\CMS\Core\Utility\GeneralUtility::writeFileToTypo3tempDir(PATH_site . $src, $content);
                     if ($GLOBALS['TSFE']) {
                         if ($GLOBALS['TSFE']->baseUrl) {
                             $src = $GLOBALS['TSFE']->baseUrl . $src;
                         } elseif ($GLOBALS['TSFE']->absRefPrefix) {
                             $src = $GLOBALS['TSFE']->absRefPrefix . $src;
                         }
                     }
                 }
                 if (!$src) {
                     if ($section == 'footer') {
                         $this->pageRenderer->addJsFooterInlineCode($name ? $name : md5($content), $content, $compress, $forceOnTop);
                     } else {
                         $this->pageRenderer->addJsInlineCode($name ? $name : md5($content), $content, $compress, $forceOnTop);
                     }
                 } else {
                     if ($section == 'footer') {
                         $this->pageRenderer->addJsFooterFile($src, $type, $compress, $forceOnTop, $allWrap, $excludeFromConcatenation);
                     } else {
                         $this->pageRenderer->addJsFile($src, $type, $compress, $forceOnTop, $allWrap, $excludeFromConcatenation);
                     }
                 }
             }
         } else {
             // additionalFooterData not possible in USER_INT
             if (!$src) {
                 $GLOBALS['TSFE']->additionalHeaderData[$name ? $name : md5($content)] = \TYPO3\CMS\Core\Utility\GeneralUtility::wrapJS($content);
             } else {
                 $GLOBALS['TSFE']->additionalHeaderData[$name ? $name : md5($content)] = '<script type="' . htmlspecialchars($type) . '" src="' . htmlspecialchars($src) . '"></script>';
             }
         }
     }
     return '';
 }
Esempio n. 21
0
 /**
  * Add RTE main scripts and plugin scripts
  *
  * @param int $RTEcounter: The index number of the current RTE editing area within the form. @deprecated since TYPO3 CMS 7, will be removed with TYPO3 CMS 8
  * @return void
  */
 protected function addRteJsFiles($RTEcounter = NULL)
 {
     if ($RTEcounter !== NULL) {
         GeneralUtility::deprecationLog('$RTEcounter parameter is deprecated and ignored');
     }
     // Component files. Order is important.
     $components = array('Util/Wrap.open', 'NameSpace/NameSpace', 'UserAgent/UserAgent', 'Util/Util', 'Util/Color', 'Util/Resizable', 'Util/String', 'Util/Tips', 'Util/TYPO3', 'Ajax/Ajax', 'DOM/DOM', 'Event/Event', 'Event/KeyMap', 'CSS/Parser', 'DOM/BookMark', 'DOM/Node', 'DOM/Selection', 'DOM/Walker', 'Configuration/Config', 'Toolbar/Button', 'Toolbar/ToolbarText', 'Toolbar/Select', 'Extjs/ColorPalette', 'Extjs/ux/ColorMenu', 'Extjs/ux/ColorPaletteField', 'LoremIpsum', 'Plugin/Plugin');
     $components2 = array('Editor/Toolbar', 'Editor/Iframe', 'Editor/TextAreaContainer', 'Editor/StatusBar', 'Editor/Framework', 'Editor/Editor', 'HTMLArea');
     foreach ($components as $component) {
         $this->pageRenderer->addJsFile($this->getFullFileName('EXT:' . $this->ID . '/Resources/Public/JavaScript/HTMLArea/' . $component . '.js'));
     }
     foreach ($this->pluginEnabledCumulativeArray as $pluginId) {
         $extensionKey = is_object($this->registeredPlugins[$pluginId]) ? $this->registeredPlugins[$pluginId]->getExtensionKey() : $this->ID;
         $fileName = 'EXT:' . $extensionKey . '/Resources/Public/JavaScript/Plugins/' . $pluginId . '.js';
         $absolutePath = GeneralUtility::getFileAbsFileName($fileName);
         if (file_exists($absolutePath)) {
             $this->pageRenderer->addJsFile($this->getFullFileName($fileName));
         } else {
             // Backward compatibility
             $pluginName = strtolower(preg_replace('/([a-z])([A-Z])([a-z])/', '$1-$2$3', $pluginId));
             $fileName = 'EXT:' . $extensionKey . '/htmlarea/plugins/' . $pluginId . '/' . $pluginName . '.js';
             $absolutePath = GeneralUtility::getFileAbsFileName($fileName);
             if (file_exists($absolutePath)) {
                 $this->pageRenderer->addJsFile($this->getFullFileName($fileName));
             }
         }
     }
     foreach ($components2 as $component) {
         $this->pageRenderer->addJsFile($this->getFullFileName('EXT:' . $this->ID . '/Resources/Public/JavaScript/HTMLArea/' . $component . '.js'));
     }
     $this->pageRenderer->addJsFile($this->getFullFileName('EXT:' . $this->ID . '/Resources/Public/JavaScript/HTMLArea/Util/Wrap.close.js'));
 }
    /**
     * Return a form to add a new task or edit an existing one
     *
     * @return 	string	HTML form to add or edit a task
     */
    protected function editTask()
    {
        $registeredClasses = self::getRegisteredClasses();
        $registeredTaskGroups = self::getRegisteredTaskGroups();
        $content = '';
        $taskInfo = array();
        $task = NULL;
        $process = 'edit';
        if ($this->submittedData['uid'] > 0) {
            // If editing, retrieve data for existing task
            try {
                $taskRecord = $this->scheduler->fetchTaskRecord($this->submittedData['uid']);
                // If there's a registered execution, the task should not be edited
                if (!empty($taskRecord['serialized_executions'])) {
                    $this->addMessage($GLOBALS['LANG']->getLL('msg.maynotEditRunningTask'), FlashMessage::ERROR);
                    throw new \LogicException('Runnings tasks cannot not be edited', 1251232849);
                }
                // Get the task object
                /** @var $task \TYPO3\CMS\Scheduler\Task\AbstractTask */
                $task = unserialize($taskRecord['serialized_task_object']);
                // Set some task information
                $taskInfo['disable'] = $taskRecord['disable'];
                $taskInfo['description'] = $taskRecord['description'];
                $taskInfo['task_group'] = $taskRecord['task_group'];
                // Check that the task object is valid
                if ($this->scheduler->isValidTaskObject($task)) {
                    // The task object is valid, process with fetching current data
                    $taskInfo['class'] = get_class($task);
                    // Get execution information
                    $taskInfo['start'] = $task->getExecution()->getStart();
                    $taskInfo['end'] = $task->getExecution()->getEnd();
                    $taskInfo['interval'] = $task->getExecution()->getInterval();
                    $taskInfo['croncmd'] = $task->getExecution()->getCronCmd();
                    $taskInfo['multiple'] = $task->getExecution()->getMultiple();
                    if (!empty($taskInfo['interval']) || !empty($taskInfo['croncmd'])) {
                        // Guess task type from the existing information
                        // If an interval or a cron command is defined, it's a recurring task
                        // FIXME: remove magic numbers for the type, use class constants instead
                        $taskInfo['type'] = 2;
                        $taskInfo['frequency'] = $taskInfo['interval'] ?: $taskInfo['croncmd'];
                    } else {
                        // It's not a recurring task
                        // Make sure interval and cron command are both empty
                        $taskInfo['type'] = 1;
                        $taskInfo['frequency'] = '';
                        $taskInfo['end'] = 0;
                    }
                } else {
                    // The task object is not valid
                    // Issue error message
                    $this->addMessage(sprintf($GLOBALS['LANG']->getLL('msg.invalidTaskClassEdit'), get_class($task)), FlashMessage::ERROR);
                    // Initialize empty values
                    $taskInfo['start'] = 0;
                    $taskInfo['end'] = 0;
                    $taskInfo['frequency'] = '';
                    $taskInfo['multiple'] = FALSE;
                    $taskInfo['type'] = 1;
                }
            } catch (\OutOfBoundsException $e) {
                // Add a message and continue throwing the exception
                $this->addMessage(sprintf($GLOBALS['LANG']->getLL('msg.taskNotFound'), $this->submittedData['uid']), FlashMessage::ERROR);
                throw $e;
            }
        } else {
            // If adding a new object, set some default values
            $taskInfo['class'] = key($registeredClasses);
            $taskInfo['type'] = 2;
            $taskInfo['start'] = $GLOBALS['EXEC_TIME'];
            $taskInfo['end'] = '';
            $taskInfo['frequency'] = '';
            $taskInfo['multiple'] = 0;
            $process = 'add';
        }
        if (count($this->submittedData) > 0) {
            // If some data was already submitted, use it to override
            // existing data
            \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($taskInfo, $this->submittedData);
        }
        // Get the extra fields to display for each task that needs some
        $allAdditionalFields = array();
        if ($process === 'add') {
            foreach ($registeredClasses as $class => $registrationInfo) {
                if (!empty($registrationInfo['provider'])) {
                    /** @var $providerObject \TYPO3\CMS\Scheduler\AdditionalFieldProviderInterface */
                    $providerObject = GeneralUtility::getUserObj($registrationInfo['provider']);
                    if ($providerObject instanceof \TYPO3\CMS\Scheduler\AdditionalFieldProviderInterface) {
                        $additionalFields = $providerObject->getAdditionalFields($taskInfo, NULL, $this);
                        $allAdditionalFields = array_merge($allAdditionalFields, array($class => $additionalFields));
                    }
                }
            }
        } else {
            if (!empty($registeredClasses[$taskInfo['class']]['provider'])) {
                $providerObject = GeneralUtility::getUserObj($registeredClasses[$taskInfo['class']]['provider']);
                if ($providerObject instanceof \TYPO3\CMS\Scheduler\AdditionalFieldProviderInterface) {
                    $allAdditionalFields[$taskInfo['class']] = $providerObject->getAdditionalFields($taskInfo, $task, $this);
                }
            }
        }
        // Load necessary JavaScript
        $this->pageRenderer->loadExtJS();
        $this->pageRenderer->loadJquery();
        $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Scheduler/Scheduler');
        $this->pageRenderer->addJsFile($this->backPath . 'sysext/backend/Resources/Public/JavaScript/tceforms.js');
        $this->pageRenderer->addJsFile($this->backPath . 'js/extjs/ux/Ext.ux.DateTimePicker.js');
        // Define settings for Date Picker
        $typo3Settings = array('datePickerUSmode' => $GLOBALS['TYPO3_CONF_VARS']['SYS']['USdateFormat'] ? 1 : 0, 'dateFormat' => array('j-n-Y', 'G:i j-n-Y'), 'dateFormatUS' => array('n-j-Y', 'G:i n-j-Y'));
        $this->pageRenderer->addInlineSettingArray('', $typo3Settings);
        // Define table layout for add/edit form
        $tableLayout = array('table' => array('<table border="0" cellspacing="0" cellpadding="0" id="edit_form" class="typo3-usersettings">', '</table>'));
        // Define a style for hiding
        // Some fields will be hidden when the task is not recurring
        $style = '';
        if ($taskInfo['type'] == 1) {
            $style = ' style="display: none"';
        }
        // Start rendering the add/edit form
        $content .= '<input type="hidden" name="tx_scheduler[uid]" value="' . htmlspecialchars($this->submittedData['uid']) . '" />';
        $content .= '<input type="hidden" name="previousCMD" value="' . htmlspecialchars($this->CMD) . '" />';
        $table = array();
        $tr = 0;
        $defaultCell = array('<td class="td-input">', '</td>');
        // Disable checkbox
        $label = '<label for="task_disable">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xlf:disable') . '</label>';
        $table[$tr][] = BackendUtility::wrapInHelp($this->cshKey, 'task_disable', $label);
        $table[$tr][] = '<input type="hidden" name="tx_scheduler[disable]" value="0" />
			 <input type="checkbox" name="tx_scheduler[disable]" value="1" id="task_disable"' . ($taskInfo['disable'] == 1 ? ' checked="checked"' : '') . ' />';
        $tableLayout[$tr] = array('tr' => array('<tr id="task_disable_row">', '</tr>'), 'defCol' => $defaultCell, '0' => array('<td class="td-label">', '</td>'));
        $tr++;
        // Task class selector
        $label = '<label for="task_class">' . $GLOBALS['LANG']->getLL('label.class') . '</label>';
        $table[$tr][] = BackendUtility::wrapInHelp($this->cshKey, 'task_class', $label);
        // On editing, don't allow changing of the task class, unless it was not valid
        if ($this->submittedData['uid'] > 0 && !empty($taskInfo['class'])) {
            $cell = $registeredClasses[$taskInfo['class']]['title'] . ' (' . $registeredClasses[$taskInfo['class']]['extension'] . ')';
            $cell .= '<input type="hidden" name="tx_scheduler[class]" id="task_class" value="' . htmlspecialchars($taskInfo['class']) . '" />';
        } else {
            $cell = '<select name="tx_scheduler[class]" id="task_class" class="wide">';
            // Group registered classes by classname
            $groupedClasses = array();
            foreach ($registeredClasses as $class => $classInfo) {
                $groupedClasses[$classInfo['extension']][$class] = $classInfo;
            }
            ksort($groupedClasses);
            // Loop on all grouped classes to display a selector
            foreach ($groupedClasses as $extension => $class) {
                $cell .= '<optgroup label="' . htmlspecialchars($extension) . '">';
                foreach ($groupedClasses[$extension] as $class => $classInfo) {
                    $selected = $class == $taskInfo['class'] ? ' selected="selected"' : '';
                    $cell .= '<option value="' . $class . '"' . 'title="' . htmlspecialchars($classInfo['description']) . '"' . $selected . '>' . htmlspecialchars($classInfo['title']) . '</option>';
                }
                $cell .= '</optgroup>';
            }
            $cell .= '</select>';
        }
        $table[$tr][] = $cell;
        // Make sure each row has a unique id, for manipulation with JS
        $tableLayout[$tr] = array('tr' => array('<tr id="task_class_row">', '</tr>'), 'defCol' => $defaultCell, '0' => array('<td class="td-label">', '</td>'));
        $tr++;
        // Task type selector
        $label = '<label for="task_type">' . $GLOBALS['LANG']->getLL('label.type') . '</label>';
        $table[$tr][] = BackendUtility::wrapInHelp($this->cshKey, 'task_type', $label);
        $table[$tr][] = '<select name="tx_scheduler[type]" id="task_type">' . '<option value="1"' . ($taskInfo['type'] == 1 ? ' selected="selected"' : '') . '>' . $GLOBALS['LANG']->getLL('label.type.single') . '</option>' . '<option value="2"' . ($taskInfo['type'] == 2 ? ' selected="selected"' : '') . '>' . $GLOBALS['LANG']->getLL('label.type.recurring') . '</option>' . '</select>';
        $tableLayout[$tr] = array('tr' => array('<tr id="task_type_row">', '</tr>'), 'defCol' => $defaultCell, '0' => array('<td class="td-label">', '</td>'));
        $tr++;
        // Task group selector
        $label = '<label for="task_group">' . $GLOBALS['LANG']->getLL('label.group') . '</label>';
        $table[$tr][] = BackendUtility::wrapInHelp($this->cshKey, 'task_group', $label);
        $cell = '<select name="tx_scheduler[task_group]" id="task_class" class="wide">';
        // Loop on all groups to display a selector
        $cell .= '<option value="0" title=""></option>';
        foreach ($registeredTaskGroups as $taskGroup) {
            $selected = $taskGroup['uid'] == $taskInfo['task_group'] ? ' selected="selected"' : '';
            $cell .= '<option value="' . $taskGroup['uid'] . '"' . 'title="';
            $cell .= htmlspecialchars($taskGroup['groupName']) . '"' . $selected . '>';
            $cell .= htmlspecialchars($taskGroup['groupName']) . '</option>';
        }
        $cell .= '</select>';
        $table[$tr][] = $cell;
        $tableLayout[$tr] = array('tr' => array('<tr id="task_group_row">', '</tr>'), 'defCol' => $defaultCell, '0' => array('<td class="td-label">', '</td>'));
        $tr++;
        // Start date/time field
        // NOTE: datetime fields need a special id naming scheme
        $label = '<label for="tceforms-datetimefield-task_start">' . $GLOBALS['LANG']->getLL('label.start') . '</label>';
        $table[$tr][] = BackendUtility::wrapInHelp($this->cshKey, 'task_start', $label);
        $table[$tr][] = '<input name="tx_scheduler[start]" type="text" id="tceforms-datetimefield-task_start" value="' . (empty($taskInfo['start']) ? '' : strftime('%H:%M %d-%m-%Y', $taskInfo['start'])) . '" />' . IconUtility::getSpriteIcon('actions-edit-pick-date', array('style' => 'cursor:pointer;', 'id' => 'picker-tceforms-datetimefield-task_start'));
        $tableLayout[$tr] = array('tr' => array('<tr id="task_start_row">', '</tr>'), 'defCol' => $defaultCell, '0' => array('<td class="td-label">', '</td>'));
        $tr++;
        // End date/time field
        // NOTE: datetime fields need a special id naming scheme
        $label = '<label for="tceforms-datetimefield-task_end">' . $GLOBALS['LANG']->getLL('label.end') . '</label>';
        $table[$tr][] = BackendUtility::wrapInHelp($this->cshKey, 'task_end', $label);
        $table[$tr][] = '<input name="tx_scheduler[end]" type="text" id="tceforms-datetimefield-task_end" value="' . (empty($taskInfo['end']) ? '' : strftime('%H:%M %d-%m-%Y', $taskInfo['end'])) . '" />' . IconUtility::getSpriteIcon('actions-edit-pick-date', array('style' => 'cursor:pointer;', 'id' => 'picker-tceforms-datetimefield-task_end'));
        $tableLayout[$tr] = array('tr' => array('<tr id="task_end_row"' . $style . '>', '</tr>'), 'defCol' => $defaultCell, '0' => array('<td class="td-label">', '</td>'));
        $tr++;
        // Frequency input field
        $label = '<label for="task_frequency">' . $GLOBALS['LANG']->getLL('label.frequency.long') . '</label>';
        $table[$tr][] = BackendUtility::wrapInHelp($this->cshKey, 'task_frequency', $label);
        $cell = '<input type="text" name="tx_scheduler[frequency]" id="task_frequency" value="' . htmlspecialchars($taskInfo['frequency']) . '" />';
        $table[$tr][] = $cell;
        $tableLayout[$tr] = array('tr' => array('<tr id="task_frequency_row"' . $style . '>', '</tr>'), 'defCol' => $defaultCell, '0' => array('<td class="td-label">', '</td>'));
        $tr++;
        // Multiple execution selector
        $label = '<label for="task_multiple">' . $GLOBALS['LANG']->getLL('label.parallel.long') . '</label>';
        $table[$tr][] = BackendUtility::wrapInHelp($this->cshKey, 'task_multiple', $label);
        $table[$tr][] = '<input type="hidden"   name="tx_scheduler[multiple]" value="0" />
			 <input type="checkbox" name="tx_scheduler[multiple]" value="1" id="task_multiple"' . ($taskInfo['multiple'] == 1 ? ' checked="checked"' : '') . ' />';
        $tableLayout[$tr] = array('tr' => array('<tr id="task_multiple_row"' . $style . '>', '</tr>'), 'defCol' => $defaultCell, '0' => array('<td class="td-label">', '</td>'));
        $tr++;
        // Description
        $label = '<label for="task_description">' . $GLOBALS['LANG']->getLL('label.description') . '</label>';
        $table[$tr][] = BackendUtility::wrapInHelp($this->cshKey, 'task_description', $label);
        $table[$tr][] = '<textarea name="tx_scheduler[description]">' . htmlspecialchars($taskInfo['description']) . '</textarea>';
        $tableLayout[$tr] = array('tr' => array('<tr id="task_description_row">', '</tr>'), 'defCol' => $defaultCell, '0' => array('<td class="td-label">', '</td>'));
        $tr++;
        // Display additional fields
        foreach ($allAdditionalFields as $class => $fields) {
            if ($class == $taskInfo['class']) {
                $additionalFieldsStyle = '';
            } else {
                $additionalFieldsStyle = ' style="display: none"';
            }
            // Add each field to the display, if there are indeed any
            if (isset($fields) && is_array($fields)) {
                foreach ($fields as $fieldID => $fieldInfo) {
                    $label = '<label for="' . $fieldID . '">' . $GLOBALS['LANG']->sL($fieldInfo['label']) . '</label>';
                    $table[$tr][] = BackendUtility::wrapInHelp($fieldInfo['cshKey'], $fieldInfo['cshLabel'], $label);
                    $table[$tr][] = $fieldInfo['code'];
                    $htmlClassName = strtolower(str_replace('\\', '-', $class));
                    $tableLayout[$tr] = array('tr' => array('<tr id="' . $fieldID . '_row"' . $additionalFieldsStyle . ' class="extraFields extra_fields_' . $htmlClassName . '">', '</tr>'), 'defCol' => $defaultCell, '0' => array('<td class="td-label">', '</td>'));
                    $tr++;
                }
            }
        }
        // Render the add/edit task form
        $content .= '<div style="float: left;"><div class="typo3-dyntabmenu-divs">';
        $content .= $this->doc->table($table, $tableLayout);
        $content .= '</div></div>';
        $content .= '<div style="padding-top: 20px; clear: both;"></div>';
        // Display information about server time usage
        $content .= $this->displayServerTime();
        return $content;
    }
Esempio n. 23
0
 /**
  * This loads everything needed for the Context Sensitive Help (CSH)
  *
  * @return void
  */
 protected function loadCshJavascript()
 {
     $this->pageRenderer->loadExtJS();
     $this->pageRenderer->addJsFile($this->backPath . '../t3lib/js/extjs/contexthelp.js');
     $this->pageRenderer->addExtDirectCode();
 }
Esempio n. 24
0
 /**
  * @validate $syntax NotEmpty
  * @validate $extensions NotEmpty
  * @validate $formats NotEmpty
  * @ignorevalidation $filteredFiles
  * @param array $syntax
  * @param array $extensions
  * @param array $formats
  * @param array $filteredFiles
  */
 public function syntaxAction(array $syntax, array $extensions, array $formats, array $filteredFiles = [])
 {
     /** @var DocumentTemplate $document */
     $document =& $GLOBALS['TBE_TEMPLATE'];
     $resourcePath = $document->backPath . ExtensionManagementUtility::extRelPath('builder') . 'Resources/Public/';
     $pageRenderer = new PageRenderer();
     $pageRenderer->addJsFile($resourcePath . 'Javascript/jqplot.min.js');
     $pageRenderer->addJsFile($resourcePath . 'Javascript/jqplot.canvasTextRenderer.min.js');
     $pageRenderer->addJsFile($resourcePath . 'Javascript/jqplot.canvasAxisTickRenderer.min.js');
     $pageRenderer->addJsFile($resourcePath . 'Javascript/jqplot.cursor.min.js');
     $pageRenderer->addJsFile($resourcePath . 'Javascript/jqplot.categoryAxisRenderer.min.js');
     $pageRenderer->addJsFile($resourcePath . 'Javascript/jqplot.barRenderer.min.js');
     $pageRenderer->addJsFile($resourcePath . 'Javascript/jqplot.pointLabels.min.js');
     $pageRenderer->addJsFile($resourcePath . 'Javascript/plotter.js');
     $reports = [];
     $csvFormats = trim(implode(',', $formats), ',');
     foreach ($extensions as $extensionKey) {
         if (true === empty($extensionKey)) {
             continue;
         }
         $extensionFolder = ExtensionManagementUtility::extPath($extensionKey);
         $reports[$extensionKey] = [];
         foreach ($syntax as $syntaxName) {
             if (true === empty($syntaxName)) {
                 continue;
             }
             $reportsForSyntaxName = [];
             if ('php' === $syntaxName) {
                 $reportsForSyntaxName = $this->syntaxService->syntaxCheckPhpFilesInPath($extensionFolder . '/Classes');
             } elseif ('fluid' === $syntaxName) {
                 $reportsForSyntaxName = $this->syntaxService->syntaxCheckFluidTemplateFilesInPath($extensionFolder . '/Resources', $csvFormats);
             } elseif ('profile' === $syntaxName) {
                 $files = GeneralUtility::getAllFilesAndFoldersInPath([], $extensionFolder, $csvFormats);
                 if (0 === count($filteredFiles)) {
                     $filteredFiles = $files;
                 }
                 $this->view->assign('files', $files);
                 $this->view->assign('basePathLength', strlen($extensionFolder . '/Resources/Private'));
                 foreach ($files as $file) {
                     if (0 < count($filteredFiles) && false === in_array($file, $filteredFiles)) {
                         continue;
                     }
                     $shortFilename = substr($file, strlen($extensionFolder . '/Resources/Private'));
                     /** @var TemplateAnalyzer $templateAnalyzer */
                     $templateAnalyzer = $this->objectManager->get(TemplateAnalyzer::class);
                     $reportsForSyntaxName[$shortFilename] = $templateAnalyzer->analyzePathAndFilename($file);
                 }
                 $reports[$extensionKey][$syntaxName]['json'] = $this->encodeMetricsToJson($reportsForSyntaxName);
             }
             $reports[$extensionKey][$syntaxName]['reports'] = $reportsForSyntaxName;
             $reports[$extensionKey][$syntaxName]['errors'] = $this->syntaxService->countErrorsInResultCollection($reportsForSyntaxName);
         }
     }
     $this->view->assign('filteredFiles', $filteredFiles);
     $this->view->assign('reports', $reports);
     $this->view->assign('extensions', $extensions);
     $this->view->assign('formats', $formats);
     $this->view->assign('syntax', $syntax);
     $this->view->assign('view', 'Index');
 }
Esempio n. 25
0
    /**
     * method that adds JS files within the page renderer
     *
     * @param    array $parameters : An array of available parameters while adding JS to the page renderer
     * @param    \TYPO3\CMS\Core\Page\PageRenderer $pageRenderer : The parent object that triggered this hook
     *
     * @return    void
     */
    protected function addJS($parameters, &$pageRenderer)
    {
        $formprotection = FormProtectionFactory::get();
        if (count($parameters['jsFiles'])) {
            if (method_exists($GLOBALS['SOBE']->doc, 'issueCommand')) {
                /** @var \TYPO3\CMS\Backend\Clipboard\Clipboard $clipObj */
                $clipObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Clipboard\\Clipboard');
                // Start clipboard
                $clipObj->initializeClipboard();
                $clipBoardHasContent = FALSE;
                if (isset($clipObj->clipData['normal']['el']) && strpos(key($clipObj->clipData['normal']['el']), 'tt_content') !== FALSE) {
                    $pasteURL = str_replace('&amp;', '&', $clipObj->pasteUrl('tt_content', 'DD_PASTE_UID', 0));
                    if (isset($clipObj->clipData['normal']['mode'])) {
                        $clipBoardHasContent = 'copy';
                    } else {
                        $clipBoardHasContent = 'move';
                    }
                }
                $moveParams = '&cmd[tt_content][DD_DRAG_UID][move]=DD_DROP_UID';
                $moveURL = str_replace('&amp;', '&', htmlspecialchars($GLOBALS['SOBE']->doc->issueCommand($moveParams, 1)));
                $copyParams = '&cmd[tt_content][DD_DRAG_UID][copy]=DD_DROP_UID&DDcopy=1';
                $copyURL = str_replace('&amp;', '&', htmlspecialchars($GLOBALS['SOBE']->doc->issueCommand($copyParams, 1)));
                // add JavaScript library
                $pageRenderer->addJsFile($GLOBALS['BACK_PATH'] . ExtensionManagementUtility::extRelPath('gridelements') . 'Resources/Public/Backend/JavaScript/dbNewContentElWizardFixDTM.js', $type = 'text/javascript', $compress = TRUE, $forceOnTop = FALSE, $allWrap = '');
                // add JavaScript library
                $pageRenderer->addJsFile($GLOBALS['BACK_PATH'] . ExtensionManagementUtility::extRelPath('gridelements') . 'Resources/Public/Backend/JavaScript/GridElementsDD.js', $type = 'text/javascript', $compress = TRUE, $forceOnTop = FALSE, $allWrap = '');
                // add JavaScript library
                $pageRenderer->addJsFile($GLOBALS['BACK_PATH'] . ExtensionManagementUtility::extRelPath('gridelements') . 'Resources/Public/Backend/JavaScript/GridElementsListView.js', $type = 'text/javascript', $compress = TRUE, $forceOnTop = FALSE, $allWrap = '');
                if (!$pageRenderer->getCharSet()) {
                    $pageRenderer->setCharSet($GLOBALS['LANG']->charSet ? $GLOBALS['LANG']->charSet : 'utf-8');
                }
                if (is_array($clipObj->clipData['normal']['el'])) {
                    $arrCBKeys = array_keys($clipObj->clipData['normal']['el']);
                    $intFirstCBEl = str_replace('tt_content|', '', $arrCBKeys[0]);
                }
                // pull locallang_db.xml to JS side - only the tx_gridelements_js-prefixed keys
                $pageRenderer->addInlineLanguageLabelFile('EXT:gridelements/Resources/Private/Language/locallang_db.xml', 'tx_gridelements_js');
                $pRaddExtOnReadyCode = '
					TYPO3.l10n = {
						localize: function(langKey){
							return TYPO3.lang[langKey];
						}
					}
				';
                $allowedCTypesAndGridTypesClassesByColPos = array();
                $layoutSetup = GeneralUtility::callUserFunction('TYPO3\\CMS\\Backend\\View\\BackendLayoutView->getSelectedBackendLayout', intval(GeneralUtility::_GP('id')), $this);
                if (is_array($layoutSetup) && !empty($layoutSetup['__config']['backend_layout.']['rows.'])) {
                    foreach ($layoutSetup['__config']['backend_layout.']['rows.'] as $rows) {
                        foreach ($rows as $row) {
                            if (!empty($layoutSetup['__config']['backend_layout.']['rows.'])) {
                                foreach ($row as $col) {
                                    $classes = '';
                                    if ($col['allowed']) {
                                        $allowed = explode(',', $col['allowed']);
                                        foreach ($allowed as $ctypes) {
                                            $ctypes = trim($ctypes);
                                            if ($ctypes === '*') {
                                                $classes = 't3-allow-all';
                                                break;
                                            } else {
                                                $ctypes = explode(',', $ctypes);
                                                foreach ($ctypes as $ctype) {
                                                    $classes .= 't3-allow-' . $ctype . ' ';
                                                }
                                            }
                                        }
                                    } else {
                                        $classes = 't3-allow-all';
                                    }
                                    if ($col['allowedGridTypes']) {
                                        $allowedGridTypes = explode(',', $col['allowedGridTypes']);
                                        $classes .= 't3-allow-gridelements_pi1 ';
                                        foreach ($allowedGridTypes as $gridTypes) {
                                            $gridTypes = trim($gridTypes);
                                            if ($gridTypes !== '*') {
                                                $gridTypes = explode(',', $gridTypes);
                                                foreach ($gridTypes as $gridType) {
                                                    $classes .= 't3-allow-gridtype-' . $gridType . ' ';
                                                }
                                            }
                                        }
                                    } else {
                                        if ($classes !== 't3-allow-all') {
                                            $classes .= 't3-allow-gridelements_pi1 ';
                                        }
                                    }
                                    $allowedCTypesAndGridTypesClassesByColPos[] = $col['colPos'] . ':' . trim($classes);
                                }
                            }
                        }
                    }
                }
                // add Ext.onReady() code from file
                $modTSconfig = BackendUtility::getModTSconfig((int) GeneralUtility::_GP('id'), 'mod.web_layout');
                $pageRenderer->addExtOnReadyCode($pRaddExtOnReadyCode . "\n\t\t\t\t\t\ttop.pageColumnsAllowedCTypes = '" . join('|', $allowedCTypesAndGridTypesClassesByColPos) . "';\n\t\t\t\t\t\ttop.pasteURL = '" . $pasteURL . "';\n\t\t\t\t\t\ttop.moveURL = '" . $moveURL . "';\n\t\t\t\t\t\ttop.copyURL = '" . $copyURL . "';\n\t\t\t\t\t\ttop.pasteTpl = '" . str_replace('&redirect=1', '', str_replace('DDcopy=1', 'DDcopy=1&reference=DD_REFYN', $copyURL)) . "';\n\t\t\t\t\t\ttop.DDtceActionToken = '" . $formprotection->generateToken('tceAction') . "';\n\t\t\t\t\t\ttop.DDtoken = '" . $formprotection->generateToken('editRecord') . "';\n\t\t\t\t\t\ttop.DDpid = '" . (int) GeneralUtility::_GP('id') . "';\n\t\t\t\t\t\ttop.DDclipboardfilled = '" . ($clipBoardHasContent ? $clipBoardHasContent : 'false') . "';\n\t\t\t\t\t\ttop.pasteReferenceAllowed = '" . ($GLOBALS['BE_USER']->checkAuthMode('tt_content', 'CType', 11, 'explicitAllow') ? 'true' : 'false') . "';\n\t\t\t\t\t\ttop.newElementWizard = '" . ($modTSconfig['properties']['disableNewContentElementWizard'] ? 'false' : 'true') . "';\n\t\t\t\t\t\ttop.DDclipboardElId = '" . $intFirstCBEl . "';\n\t\t\t\t\t" . str_replace(array('top.skipDraggableDetails = 0;', 'insert_ext_baseurl_here', 'insert_server_time_here', 'top.geSprites = {};', "top.backPath = '';"), array($GLOBALS['BE_USER']->uc['dragAndDropHideNewElementWizardInfoOverlay'] ? 'top.skipDraggableDetails = true;' : 'top.skipDraggableDetails = false;', GeneralUtility::locationHeaderUrl('/' . ExtensionManagementUtility::siteRelPath('gridelements')), time() . '000', "top.geSprites = {\n\t\t\t\t\t\t\tcopyfrompage: '" . IconUtility::getSpriteIconClasses('extensions-gridelements-copyfrompage') . "',\n\t\t\t\t\t\t\t\tpastecopy: '" . IconUtility::getSpriteIconClasses('extensions-gridelements-pastecopy') . "',\n\t\t\t\t\t\t\t\tpasteref: '" . IconUtility::getSpriteIconClasses('extensions-gridelements-pasteref') . "'\n\t\t\t\t\t\t\t};", "top.backPath = '" . $GLOBALS['BACK_PATH'] . "';"), file_get_contents(ExtensionManagementUtility::extPath('gridelements') . 'Resources/Public/Backend/JavaScript/GridElementsDD_onReady.js')), TRUE);
            }
        }
    }
 public function render()
 {
     $this->pageRenderer = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Page\\PageRenderer');
     $baseUrl = '../' . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath('extension_builder');
     $this->pageRenderer->disableCompressJavascript();
     // SECTION: JAVASCRIPT FILES
     // YUI Basis Files
     $this->pageRenderer->addJsFile($baseUrl . 'Resources/Public/jsDomainModeling/wireit/lib/yui/utilities/utilities.js');
     $this->pageRenderer->addJsFile($baseUrl . 'Resources/Public/jsDomainModeling/wireit/lib/yui/resize/resize-min.js');
     $this->pageRenderer->addJsFile($baseUrl . 'Resources/Public/jsDomainModeling/wireit/lib/yui/layout/layout-min.js');
     $this->pageRenderer->addJsFile($baseUrl . 'Resources/Public/jsDomainModeling/wireit/lib/yui/container/container-min.js');
     $this->pageRenderer->addJsFile($baseUrl . 'Resources/Public/jsDomainModeling/wireit/lib/yui/json/json-min.js');
     $this->pageRenderer->addJsFile($baseUrl . 'Resources/Public/jsDomainModeling/wireit/lib/yui/button/button-min.js');
     // YUI-RPC
     $this->pageRenderer->addJsFile($baseUrl . 'Resources/Public/jsDomainModeling/wireit/lib/yui-rpc.js');
     // InputEx with wirable options
     $this->pageRenderer->addJsFile($baseUrl . 'Resources/Public/jsDomainModeling/wireit/lib/inputex/js/inputex.js');
     $this->pageRenderer->addJsFile($baseUrl . 'Resources/Public/jsDomainModeling/wireit/lib/inputex/js/Field.js');
     // extended fields for enabling unique ids
     $this->pageRenderer->addJsFile($baseUrl . 'Resources/Public/jsDomainModeling/extended/ListField.js');
     $this->pageRenderer->addJsFile($baseUrl . 'Resources/Public/jsDomainModeling/extended/Group.js');
     $this->pageRenderer->addJsFile($baseUrl . 'Resources/Public/jsDomainModeling/wireit/js/util/inputex/WirableField-beta.js');
     $this->pageRenderer->addJsFile($baseUrl . 'Resources/Public/jsDomainModeling/wireit/lib/inputex/js/Visus.js');
     $this->pageRenderer->addJsFile($baseUrl . 'Resources/Public/jsDomainModeling/wireit/lib/inputex/js/fields/StringField.js');
     $this->pageRenderer->addJsFile($baseUrl . 'Resources/Public/jsDomainModeling/wireit/lib/inputex/js/fields/Textarea.js');
     $this->pageRenderer->addJsFile($baseUrl . 'Resources/Public/jsDomainModeling/wireit/lib/inputex/js/fields/SelectField.js');
     $this->pageRenderer->addJsFile($baseUrl . 'Resources/Public/jsDomainModeling/wireit/lib/inputex/js/fields/EmailField.js');
     $this->pageRenderer->addJsFile($baseUrl . 'Resources/Public/jsDomainModeling/wireit/lib/inputex/js/fields/UrlField.js');
     $this->pageRenderer->addJsFile($baseUrl . 'Resources/Public/jsDomainModeling/wireit/lib/inputex/js/fields/CheckBox.js');
     $this->pageRenderer->addJsFile($baseUrl . 'Resources/Public/jsDomainModeling/wireit/lib/inputex/js/fields/InPlaceEdit.js');
     $this->pageRenderer->addJsFile($baseUrl . 'Resources/Public/jsDomainModeling/wireit/lib/inputex/js/fields/MenuField.js');
     $this->pageRenderer->addJsFile($baseUrl . 'Resources/Public/jsDomainModeling/wireit/lib/inputex/js/fields/TypeField.js');
     // WireIt
     $this->pageRenderer->addJsFile($baseUrl . 'Resources/Public/jsDomainModeling/wireit/lib/excanvas.js', 'text/javascript', TRUE, FALSE, '<!--[if IE]>|<![endif]-->');
     $this->pageRenderer->addJsFile($baseUrl . 'Resources/Public/jsDomainModeling/wireit/js/WireIt.js');
     $this->pageRenderer->addJsFile($baseUrl . 'Resources/Public/jsDomainModeling/wireit/js/CanvasElement.js');
     $this->pageRenderer->addJsFile($baseUrl . 'Resources/Public/jsDomainModeling/wireit/js/Wire.js');
     $this->pageRenderer->addJsFile($baseUrl . 'Resources/Public/jsDomainModeling/wireit/js/Terminal.js');
     $this->pageRenderer->addJsFile($baseUrl . 'Resources/Public/jsDomainModeling/wireit/js/util/DD.js');
     $this->pageRenderer->addJsFile($baseUrl . 'Resources/Public/jsDomainModeling/wireit/js/util/DDResize.js');
     $this->pageRenderer->addJsFile($baseUrl . 'Resources/Public/jsDomainModeling/wireit/js/Container.js');
     $this->pageRenderer->addJsFile($baseUrl . 'Resources/Public/jsDomainModeling/wireit/js/ImageContainer.js');
     $this->pageRenderer->addJsFile($baseUrl . 'Resources/Public/jsDomainModeling/wireit/js/Layer.js');
     $this->pageRenderer->addJsFile($baseUrl . 'Resources/Public/jsDomainModeling/wireit/js/util/inputex/FormContainer-beta.js');
     $this->pageRenderer->addJsFile($baseUrl . 'Resources/Public/jsDomainModeling/wireit/js/LayerMap.js');
     $this->pageRenderer->addInlineSettingArray('extensionBuilder', array('baseUrl' => $baseUrl));
     $this->setLocallangSettings();
     $this->pageRenderer->addJsFile($baseUrl . 'Resources/Public/jsDomainModeling/wireit/js/WiringEditor.js');
     // Extbase Modelling definition
     $this->pageRenderer->addJsFile($baseUrl . 'Resources/Public/jsDomainModeling/extbaseModeling.js');
     $this->pageRenderer->addJsFile($baseUrl . 'Resources/Public/jsDomainModeling/layout.js');
     $this->pageRenderer->addJsFile($baseUrl . 'Resources/Public/jsDomainModeling/extensionProperties.js');
     $this->pageRenderer->addJsFile($baseUrl . 'Resources/Public/jsDomainModeling/modules/modelObject.js');
     // collapsible forms in relations
     $this->pageRenderer->addJsFile($baseUrl . 'Resources/Public/jsDomainModeling/modules/extendedModelObject.js');
     // SECTION: CSS Files
     // YUI CSS
     $this->pageRenderer->addCssFile($baseUrl . 'Resources/Public/jsDomainModeling/wireit/lib/yui/reset-fonts-grids/reset-fonts-grids.css');
     $this->pageRenderer->addCssFile($baseUrl . 'Resources/Public/jsDomainModeling/wireit/lib/yui/assets/skins/sam/skin.css');
     // InputEx CSS
     $this->pageRenderer->addCssFile($baseUrl . 'Resources/Public/jsDomainModeling/wireit/lib/inputex/css/inputEx.css');
     // WireIt CSS
     $this->pageRenderer->addCssFile($baseUrl . 'Resources/Public/jsDomainModeling/wireit/css/WireIt.css');
     $this->pageRenderer->addCssFile($baseUrl . 'Resources/Public/jsDomainModeling/wireit/css/WireItEditor.css');
     // Custom CSS
     $this->pageRenderer->addCssFile($baseUrl . 'Resources/Public/jsDomainModeling/extbaseModeling.css');
 }
    /**
     * 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. 28
0
 /**
  * Includes a javascript library that exists in the core /typo3/ directory. The
  * backpath is automatically applied
  *
  * @param string $lib: Library name. Call it with the full path like "contrib/prototype/prototype.js" to load it
  * @return void
  */
 public function loadJavascriptLib($lib)
 {
     $this->pageRenderer->addJsFile($this->backPath . $lib);
 }
Esempio n. 29
0
 /**
  * Add the needed JavaScript files for all actions
  */
 public function initializeAction()
 {
     $this->pageRenderer->addJsFile('sysext/backend/Resources/Public/JavaScript/notifications.js');
     $this->pageRenderer->addInlineLanguageLabelFile('EXT:extensionmanager/Resources/Private/Language/locallang.xlf');
 }
Esempio n. 30
0
 /**
  * Includes a javascript library that exists in the core /typo3/ directory
  *
  * @param string $lib: Library name. Call it with the full path like "sysext/core/Resources/Public/JavaScript/QueryGenerator.js" to load it
  * @return void
  * @deprecated since TYPO3 v8, will be removed in TYPO3 v9
  */
 public function loadJavascriptLib($lib)
 {
     GeneralUtility::logDeprecatedFunction();
     $this->pageRenderer->addJsFile($lib);
 }