Example #1
1
 /**
  * Render the captcha image html
  *
  * @param string suffix to be appended to the extenstion key when forming css class names
  * @return string The html used to render the captcha image
  */
 public function render($suffix = '')
 {
     $value = '';
     // Include the required JavaScript
     $GLOBALS['TSFE']->additionalHeaderData[$this->extensionKey . '_freeCap'] = '<script type="text/javascript" src="' . GeneralUtility::createVersionNumberedFilename(ExtensionManagementUtility::siteRelPath($this->extensionKey) . 'Resources/Public/JavaScript/freeCap.js') . '"></script>';
     // Disable caching
     $GLOBALS['TSFE']->no_cache = 1;
     // Get the plugin configuration
     $settings = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS, $this->extensionName);
     // Get the translation view helper
     $objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
     $translator = $objectManager->get('SJBR\\SrFreecap\\ViewHelpers\\TranslateViewHelper');
     $translator->injectConfigurationManager($this->configurationManager);
     // Generate the image url
     $fakeId = GeneralUtility::shortMD5(uniqid(rand()), 5);
     $siteURL = GeneralUtility::getIndpEnv('TYPO3_SITE_URL');
     $L = GeneralUtility::_GP('L');
     $urlParams = array('eID' => 'sr_freecap_EidDispatcher', 'id' => $GLOBALS['TSFE']->id, 'vendorName' => 'SJBR', 'extensionName' => 'SrFreecap', 'pluginName' => 'ImageGenerator', 'controllerName' => 'ImageGenerator', 'actionName' => 'show', 'formatName' => 'png', 'L' => $GLOBALS['TSFE']->sys_language_uid);
     if ($GLOBALS['TSFE']->MP) {
         $urlParams['MP'] = $GLOBALS['TSFE']->MP;
     }
     $urlParams['set'] = $fakeId;
     $imageUrl = $siteURL . 'index.php?' . ltrim(GeneralUtility::implodeArrayForUrl('', $urlParams), '&');
     // Generate the html text
     $value = '<img' . $this->getClassAttribute('image', $suffix) . ' id="tx_srfreecap_captcha_image_' . $fakeId . '"' . ' src="' . htmlspecialchars($imageUrl) . '"' . ' alt="' . $translator->render('altText') . ' "/>' . '<span' . $this->getClassAttribute('cant-read', $suffix) . '>' . $translator->render('cant_read1') . ' <a href="#" onclick="this.blur();' . $this->extensionName . '.newImage(\'' . $fakeId . '\', \'' . $translator->render('noImageMessage') . '\');return false;">' . $translator->render('click_here') . '</a>' . $translator->render('cant_read2') . '</span>';
     return $value;
 }
 /**
  * @param array $arguments
  * @param callable $renderChildrenClosure
  * @param RenderingContextInterface $renderingContext
  *
  * @return int
  * @throws Exception
  */
 public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
 {
     $filename = $arguments['filename'];
     if (!$filename) {
         $filename = $renderChildrenClosure();
     }
     $versionedFilename = \TYPO3\CMS\Core\Utility\GeneralUtility::createVersionNumberedFilename($filename);
     return $versionedFilename;
 }
Example #3
0
 /**
  * Processes a Javascript file dependent on the current context
  *
  * Adds the version number for Frontend, compresses the file for Backend
  *
  * @param string $filename Filename
  * @return string New filename
  */
 protected function processJsFile($filename)
 {
     switch (TYPO3_MODE) {
         case 'FE':
             if ($this->compressJavascript) {
                 $filename = $this->getCompressor()->compressJsFile($filename);
             } else {
                 $filename = GeneralUtility::createVersionNumberedFilename($filename);
             }
             break;
         case 'BE':
             if ($this->compressJavascript) {
                 $filename = $this->getCompressor()->compressJsFile($filename);
             }
             break;
     }
     return $filename;
 }
Example #4
0
 /**
  * Implementation of preRender() method. Used to include CSS files.
  *
  * @see Tx_Solr_pluginbase_PluginBase#preRender()
  */
 protected function preRender()
 {
     if ($this->conf['cssFiles.']['results']) {
         $cssFile = \TYPO3\CMS\Core\Utility\GeneralUtility::createVersionNumberedFilename($GLOBALS['TSFE']->tmpl->getFileName($this->conf['cssFiles.']['results']));
         $GLOBALS['TSFE']->additionalHeaderData['tx_solr-resultsCss'] = '<link href="' . $cssFile . '" rel="stylesheet" type="text/css" />';
     }
     if ($this->conf['cssFiles.']['pagebrowser']) {
         $cssFile = \TYPO3\CMS\Core\Utility\GeneralUtility::createVersionNumberedFilename($GLOBALS['TSFE']->tmpl->getFileName($this->conf['cssFiles.']['pagebrowser']));
         $GLOBALS['TSFE']->additionalHeaderData['tx_solr-pageBrowserCss'] = '<link href="' . $cssFile . '" rel="stylesheet" type="text/css" />';
     }
 }
Example #5
0
    /**
     * This wraps and returns the main content of the page into proper html-code.
     *
     * @param string $content The page content
     * @return string The full HTML page
     * @todo Define visibility
     */
    public function outputWrapper($content)
    {
        // Get the template file
        if (!$this->passwordOK) {
            $this->template = @file_get_contents(PATH_site . $this->templateFilePath . 'Install_login.html');
        } elseif ($this->mode == '123') {
            $this->template = @file_get_contents(PATH_site . $this->templateFilePath . 'Install_123.html');
        } else {
            $this->template = @file_get_contents(PATH_site . $this->templateFilePath . 'Install.html');
        }
        // Add prototype to javascript array for output
        $this->javascript[] = '<script type="text/javascript" src="' . \TYPO3\CMS\Core\Utility\GeneralUtility::createVersionNumberedFilename('../contrib/prototype/prototype.js') . '"></script>';
        // Add JS functions for output
        $this->javascript[] = '<script type="text/javascript" src="' . \TYPO3\CMS\Core\Utility\GeneralUtility::createVersionNumberedFilename('../sysext/install/Resources/Public/Javascript/install.js') . '"></script>';
        // Include the default stylesheets
        $this->stylesheets[] = '<link rel="stylesheet" type="text/css" href="' . \TYPO3\CMS\Core\Utility\GeneralUtility::createVersionNumberedFilename($this->backPath . 'sysext/install/Resources/Public/Stylesheets/reset.css') . '" />';
        $this->stylesheets[] = '<link rel="stylesheet" type="text/css" href="' . \TYPO3\CMS\Core\Utility\GeneralUtility::createVersionNumberedFilename($this->backPath . 'sysext/install/Resources/Public/Stylesheets/general.css') . '" />';
        // Get the browser info
        $browserInfo = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('HTTP_USER_AGENT'));
        // Add the stylesheet for Internet Explorer
        if ($browserInfo['browser'] === 'msie') {
            // IE7
            if (intval($browserInfo['version']) === 7) {
                $this->stylesheets[] = '<link rel="stylesheet" type="text/css" href="' . \TYPO3\CMS\Core\Utility\GeneralUtility::createVersionNumberedFilename($this->backPath . 'sysext/install/Resources/Public/Stylesheets/ie7.css') . '" />';
            }
        }
        // Include the stylesheets based on screen
        if ($this->mode == '123') {
            $this->stylesheets[] = '<link rel="stylesheet" type="text/css" href="' . \TYPO3\CMS\Core\Utility\GeneralUtility::createVersionNumberedFilename($this->backPath . 'sysext/install/Resources/Public/Stylesheets/install_123.css') . '" />';
        } elseif ($this->passwordOK) {
            $this->stylesheets[] = '<link rel="stylesheet" type="text/css" href="' . \TYPO3\CMS\Core\Utility\GeneralUtility::createVersionNumberedFilename($this->backPath . 'sysext/install/Resources/Public/Stylesheets/install.css') . '" />';
        } else {
            $this->stylesheets[] = '<link rel="stylesheet" type="text/css" href="' . \TYPO3\CMS\Core\Utility\GeneralUtility::createVersionNumberedFilename($this->backPath . 'sysext/install/Resources/Public/Stylesheets/install.css') . '" />';
            $this->stylesheets[] = '<link rel="stylesheet" type="text/css" href="' . \TYPO3\CMS\Core\Utility\GeneralUtility::createVersionNumberedFilename($this->backPath . 'sysext/install/Resources/Public/Stylesheets/install_login.css') . '" />';
        }
        // Define the markers content
        if ($this->mode == '123') {
            $this->markers['headTitle'] = 'Installing TYPO3 ' . TYPO3_branch;
        } else {
            $this->markers['headTitle'] = '
				TYPO3 ' . TYPO3_version . '
				Install Tool on site: ' . htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']) . '
			';
        }
        $this->markers['title'] = 'TYPO3 ' . TYPO3_version;
        $this->markers['javascript'] = implode(LF, $this->javascript);
        $this->markers['stylesheets'] = implode(LF, $this->stylesheets);
        $this->markers['llErrors'] = 'The following errors occured';
        $this->markers['copyright'] = $this->copyright();
        $this->markers['charset'] = 'utf-8';
        $this->markers['backendUrl'] = '../index.php';
        $this->markers['backend'] = 'Backend admin';
        $this->markers['frontendUrl'] = '../../index.php';
        $this->markers['frontend'] = 'Frontend website';
        $this->markers['metaCharset'] = 'Content-Type" content="text/html; charset=';
        $this->markers['metaCharset'] .= 'utf-8';
        // Add the error messages
        if (!empty($this->errorMessages)) {
            // Get the subpart for all error messages
            $errorMessagesSubPart = \TYPO3\CMS\Core\Html\HtmlParser::getSubpart($this->template, '###ERRORMESSAGES###');
            // Get the subpart for a single error message
            $errorMessageSubPart = \TYPO3\CMS\Core\Html\HtmlParser::getSubpart($errorMessagesSubPart, '###MESSAGES###');
            $errors = array();
            foreach ($this->errorMessages as $errorMessage) {
                // Define the markers content
                $errorMessageMarkers = array('message' => $errorMessage);
                // Fill the markers in the subpart
                $errors[] = \TYPO3\CMS\Core\Html\HtmlParser::substituteMarkerArray($errorMessageSubPart, $errorMessageMarkers, '###|###', TRUE, FALSE);
            }
            // Substitute the subpart for a single message
            $errorMessagesSubPart = \TYPO3\CMS\Core\Html\HtmlParser::substituteSubpart($errorMessagesSubPart, '###MESSAGES###', implode(LF, $errors));
        }
        // Version subpart is only allowed when password is ok
        if ($this->passwordOK) {
            // Get the subpart for the version
            $versionSubPart = \TYPO3\CMS\Core\Html\HtmlParser::getSubpart($this->template, '###VERSIONSUBPART###');
            // Define the markers content
            $versionSubPartMarkers['version'] = 'Version: ' . TYPO3_version;
            // Fill the markers in the subpart
            $versionSubPart = \TYPO3\CMS\Core\Html\HtmlParser::substituteMarkerArray($versionSubPart, $versionSubPartMarkers, '###|###', TRUE, FALSE);
        }
        // Substitute the version subpart
        $this->template = \TYPO3\CMS\Core\Html\HtmlParser::substituteSubpart($this->template, '###VERSIONSUBPART###', $versionSubPart);
        // Substitute the menu subpart
        $this->template = \TYPO3\CMS\Core\Html\HtmlParser::substituteSubpart($this->template, '###MENU###', $this->menu());
        // Substitute the error messages subpart
        $this->template = \TYPO3\CMS\Core\Html\HtmlParser::substituteSubpart($this->template, '###ERRORMESSAGES###', $errorMessagesSubPart);
        // Substitute the content subpart
        $this->template = \TYPO3\CMS\Core\Html\HtmlParser::substituteSubpart($this->template, '###CONTENT###', $content);
        // Fill the markers
        $this->template = \TYPO3\CMS\Core\Html\HtmlParser::substituteMarkerArray($this->template, $this->markers, '###|###', TRUE, FALSE);
        return $this->template;
    }
    /**
     * Returns a JavaScript <script> section with some function calls to JavaScript functions from "typo3/js/jsfunc.updateform.js" (which is also included by setting a reference in $GLOBALS['TSFE']->additionalHeaderData['JSincludeFormupdate'])
     * The JavaScript codes simply transfers content into form fields of a form which is probably used for editing information by frontend users. Used by fe_adminLib.inc.
     *
     * @param array $dataArray Data array which values to load into the form fields from $formName (only field names found in $fieldList)
     * @param string $formName The form name
     * @param string $arrPrefix A prefix for the data array
     * @param string $fieldList The list of fields which are loaded
     * @return string
     * @access private
     * @see user_feAdmin::displayCreateScreen()
     * @todo Define visibility
     */
    public function getUpdateJS($dataArray, $formName, $arrPrefix, $fieldList)
    {
        $JSPart = '';
        $updateValues = GeneralUtility::trimExplode(',', $fieldList);
        foreach ($updateValues as $fKey) {
            $value = $dataArray[$fKey];
            if (is_array($value)) {
                foreach ($value as $Nvalue) {
                    $JSPart .= '
	updateForm(\'' . $formName . '\',\'' . $arrPrefix . '[' . $fKey . '][]\',' . GeneralUtility::quoteJSvalue($Nvalue, TRUE) . ');';
                }
            } else {
                $JSPart .= '
	updateForm(\'' . $formName . '\',\'' . $arrPrefix . '[' . $fKey . ']\',' . GeneralUtility::quoteJSvalue($value, TRUE) . ');';
            }
        }
        $JSPart = '<script type="text/javascript">
	/*<![CDATA[*/ ' . $JSPart . '
	/*]]>*/
</script>
';
        $GLOBALS['TSFE']->additionalHeaderData['JSincludeFormupdate'] = '<script type="text/javascript" src="' . GeneralUtility::createVersionNumberedFilename($GLOBALS['TSFE']->absRefPrefix . 'typo3/js/jsfunc.updateform.js') . '"></script>';
        return $JSPart;
    }
 /**
  * Processes a Javascript file dependent on the current context
  *
  * Adds the version number for Frontend, compresses the file for Backend
  *
  * @param string $filename Filename
  * @return string New filename
  */
 protected function processJsFile($filename)
 {
     if ($this->compressJavascript) {
         return $this->getCompressor()->compressJsFile($filename);
     } elseif (TYPO3_MODE === 'FE') {
         return GeneralUtility::createVersionNumberedFilename($filename);
     } else {
         return $filename;
     }
 }
Example #8
0
 /**
  * This function acts as a wrapper to allow relative and paths starting with EXT: to be dealt with
  * in this very case to always return the absolute web path to be included directly before output.
  *
  * This is mainly added so the EXT: syntax can be resolved for PageRenderer in one central place,
  * and hopefully removed in the future by one standard API call.
  *
  * @param string $file the filename to process
  * @param bool $prepareForOutput whether the file should be prepared as version numbered file and prefixed as absolute webpath
  * @return string
  * @internal
  */
 protected function getStreamlinedFileName($file, $prepareForOutput = true)
 {
     if (strpos($file, 'EXT:') === 0) {
         $file = GeneralUtility::getFileAbsFileName($file);
         // as the path is now absolute, make it "relative" to the current script to stay compatible
         $file = PathUtility::getRelativePathTo($file);
         $file = rtrim($file, '/');
     } else {
         $file = GeneralUtility::resolveBackPath($file);
     }
     if ($prepareForOutput) {
         $file = GeneralUtility::createVersionNumberedFilename($file);
         $file = PathUtility::getAbsoluteWebPath($file);
     }
     return $file;
 }
    /**
     * Main function.
     * Creates some general objects and calls other functions for the main rendering of module content.
     *
     * @return void
     * @todo Define visibility
     */
    public function main()
    {
        // Access check...
        // The page will show only if there is a valid page and if this page may be viewed by the user
        $access = is_array($this->pageinfo) ? 1 : 0;
        if ($this->id && $access) {
            // Initialize permission settings:
            $this->CALC_PERMS = $GLOBALS['BE_USER']->calcPerms($this->pageinfo);
            $this->EDIT_CONTENT = $this->CALC_PERMS & 16 ? 1 : 0;
            // Start document template object:
            $this->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
            $this->doc->backPath = $GLOBALS['BACK_PATH'];
            $this->doc->setModuleTemplate('templates/db_layout.html');
            // JavaScript:
            $this->doc->JScode = '<script type="text/javascript" ' . 'src="' . \TYPO3\CMS\Core\Utility\GeneralUtility::createVersionNumberedFilename($GLOBALS['BACK_PATH'] . '../t3lib/jsfunc.updateform.js') . '">' . '</script>';
            $this->doc->JScode .= $this->doc->wrapScriptTags('
				if (top.fsMod) top.fsMod.recentIds["web"] = ' . intval($this->id) . ';
				if (top.fsMod) top.fsMod.navFrameHighlightedID["web"] = "pages' . intval($this->id) . '_"+top.fsMod.currentBank; ' . intval($this->id) . ';
				function jumpToUrl(URL,formEl) {	//
					if (document.editform && TBE_EDITOR.isFormChanged)	{	// Check if the function exists... (works in all browsers?)
						if (!TBE_EDITOR.isFormChanged())	{	//
							window.location.href = URL;
						} else if (formEl) {
							if (formEl.type=="checkbox") formEl.checked = formEl.checked ? 0 : 1;
						}
					} else window.location.href = URL;
				}
			' . ($this->popView ? \TYPO3\CMS\Backend\Utility\BackendUtility::viewOnClick($this->id, $GLOBALS['BACK_PATH'], \TYPO3\CMS\Backend\Utility\BackendUtility::BEgetRootLine($this->id)) : '') . '

				function deleteRecord(table,id,url) {	//
					if (confirm(' . $GLOBALS['LANG']->JScharCode($GLOBALS['LANG']->getLL('deleteWarning')) . ')) {
						window.location.href = "' . $GLOBALS['BACK_PATH'] . 'tce_db.php?cmd["+table+"]["+id+"][delete]=1&redirect="+escape(url)+"&vC=' . $GLOBALS['BE_USER']->veriCode() . \TYPO3\CMS\Backend\Utility\BackendUtility::getUrlToken('tceAction') . '&prErr=1&uPT=1";
					}
					return false;
				}
			');
            $this->doc->JScode .= $this->doc->wrapScriptTags('
				var DTM_array = new Array();
				var DTM_origClass = new String();

					// if tabs are used in a popup window the array might not exists
				if(!top.DTM_currentTabs) {
					top.DTM_currentTabs = new Array();
				}

				function DTM_activate(idBase,index,doToogle) {	//
						// Hiding all:
					if (DTM_array[idBase]) {
						for(cnt = 0; cnt < DTM_array[idBase].length ; cnt++) {
							if (DTM_array[idBase][cnt] != idBase+"-"+index) {
								document.getElementById(DTM_array[idBase][cnt]+"-DIV").style.display = "none";
								document.getElementById(DTM_array[idBase][cnt]+"-MENU").attributes.getNamedItem("class").nodeValue = "tab";
							}
						}
					}

						// Showing one:
					if (document.getElementById(idBase+"-"+index+"-DIV")) {
						if (doToogle && document.getElementById(idBase+"-"+index+"-DIV").style.display == "block") {
							document.getElementById(idBase+"-"+index+"-DIV").style.display = "none";
							if(DTM_origClass=="") {
								document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tab";
							} else {
								DTM_origClass = "tab";
							}
							top.DTM_currentTabs[idBase] = -1;
						} else {
							document.getElementById(idBase+"-"+index+"-DIV").style.display = "block";
							if(DTM_origClass=="") {
								document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tabact";
							} else {
								DTM_origClass = "tabact";
							}
							top.DTM_currentTabs[idBase] = index;
						}
					}
				}
				function DTM_toggle(idBase,index,isInit) {	//
						// Showing one:
					if (document.getElementById(idBase+"-"+index+"-DIV")) {
						if (document.getElementById(idBase+"-"+index+"-DIV").style.display == "block") {
							document.getElementById(idBase+"-"+index+"-DIV").style.display = "none";
							if(isInit) {
								document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tab";
							} else {
								DTM_origClass = "tab";
							}
							top.DTM_currentTabs[idBase+"-"+index] = 0;
						} else {
							document.getElementById(idBase+"-"+index+"-DIV").style.display = "block";
							if(isInit) {
								document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tabact";
							} else {
								DTM_origClass = "tabact";
							}
							top.DTM_currentTabs[idBase+"-"+index] = 1;
						}
					}
				}

				function DTM_mouseOver(obj) {	//
						DTM_origClass = obj.attributes.getNamedItem(\'class\').nodeValue;
						obj.attributes.getNamedItem(\'class\').nodeValue += "_over";
				}

				function DTM_mouseOut(obj) {	//
						obj.attributes.getNamedItem(\'class\').nodeValue = DTM_origClass;
						DTM_origClass = "";
				}
			');
            // Setting doc-header
            $this->doc->form = '<form action="' . htmlspecialchars('db_layout.php?id=' . $this->id . '&imagemode=' . $this->imagemode) . '" method="post">';
            // Creating the top function menu:
            $this->topFuncMenu = \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncMenu($this->id, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function'], 'db_layout.php', '');
            $this->languageMenu = count($this->MOD_MENU['language']) > 1 ? $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xml:LGL.language', 1) . \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncMenu($this->id, 'SET[language]', $this->current_sys_language, $this->MOD_MENU['language'], 'db_layout.php', '') : '';
            // Find backend layout / coumns
            $backendLayout = \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction('TYPO3\\CMS\\Backend\\View\\BackendLayoutView->getSelectedBackendLayout', $this->id, $this);
            if (count($backendLayout['__colPosList'])) {
                $this->colPosList = implode(',', $backendLayout['__colPosList']);
            }
            // Removing duplicates, if any
            $this->colPosList = implode(',', array_unique(\TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $this->colPosList)));
            // Page title
            $body = $this->doc->header($this->pageinfo['title']);
            $body .= $this->getHeaderFlashMessagesForCurrentPid();
            // Render the primary module content:
            if ($this->MOD_SETTINGS['function'] == 0) {
                // QuickEdit
                $body .= $this->renderQuickEdit();
            } else {
                // All other listings
                $body .= $this->renderListContent();
            }
            // Setting up the buttons and markers for docheader
            $docHeaderButtons = $this->getButtons($this->MOD_SETTINGS['function'] == 0 ? 'quickEdit' : '');
            $markers = array('CSH' => $docHeaderButtons['csh'], 'TOP_FUNCTION_MENU' => $this->topFuncMenu . $this->editSelect, 'LANGSELECTOR' => $this->languageMenu, 'CONTENT' => $body);
            // Build the <body> for the module
            $this->content .= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
            // Renders the module page
            $this->content = $this->doc->render($GLOBALS['LANG']->getLL('title'), $this->content);
        } else {
            // If no access or id value, create empty document:
            $this->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
            $this->doc->backPath = $GLOBALS['BACK_PATH'];
            $this->doc->setModuleTemplate('templates/db_layout.html');
            $this->doc->JScode = $this->doc->wrapScriptTags('
				if (top.fsMod) top.fsMod.recentIds["web"] = ' . intval($this->id) . ';
			');
            $flashMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $GLOBALS['LANG']->getLL('clickAPage_content'), $GLOBALS['LANG']->getLL('clickAPage_header'), \TYPO3\CMS\Core\Messaging\FlashMessage::INFO);
            $body = $flashMessage->render();
            // Setting up the buttons and markers for docheader
            $docHeaderButtons = array('view' => '', 'history_page' => '', 'new_content' => '', 'move_page' => '', 'move_record' => '', 'new_page' => '', 'edit_page' => '', 'csh' => '', 'shortcut' => '', 'cache' => '', 'savedok' => '', 'savedokshow' => '', 'closedok' => '', 'deletedok' => '', 'undo' => '', 'history_record' => '');
            $markers = array('CSH' => \TYPO3\CMS\Backend\Utility\BackendUtility::cshItem($this->descrTable, '', $GLOBALS['BACK_PATH'], '', TRUE), 'TOP_FUNCTION_MENU' => '', 'LANGSELECTOR' => '', 'CONTENT' => $body);
            $this->content .= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
            // Renders the module page
            $this->content = $this->doc->render($GLOBALS['LANG']->getLL('title'), $this->content);
        }
    }
 /**
  * Adds the stylesheets necessary for the slider
  *
  */
 protected function loadStylesheets()
 {
     $rangeFile = $this->solrConfiguration->getCssFileByFileKey('ui');
     if ($rangeFile !== '' && !$GLOBALS['TSFE']->additionalHeaderData['tx_solr-uiCss']) {
         $cssFile = GeneralUtility::createVersionNumberedFilename($GLOBALS['TSFE']->tmpl->getFileName($rangeFile));
         $GLOBALS['TSFE']->additionalHeaderData['tx_solr-uiCss'] = $rangeFile;
         '<link href="' . $cssFile . '" rel="stylesheet" type="text/css" media="all" />';
     }
 }
Example #11
0
    /**
     * Return the Javascript code for configuring the RTE
     *
     * @param 	integer		$RTEcounter: The index number of the current RTE editing area within the form.
     * @param 	string		$table: The table that includes this RTE (optional, necessary for IRRE).
     * @param 	string		$uid: The uid of that table that includes this RTE (optional, necessary for IRRE).
     * @param 	string		$field: The field of that record that includes this RTE (optional).
     * @param	string		$textAreaId ID of the textarea, to have a unigue number for the editor
     * @return 	string		the Javascript code for configuring the RTE
     * @todo Define visibility
     */
    public function registerRTEinJS($RTEcounter, $table = '', $uid = '', $field = '', $textAreaId = '')
    {
        $configureRTEInJavascriptString = '
			if (typeof(configureEditorInstance) == "undefined") {
				configureEditorInstance = new Object();
			}
			configureEditorInstance["' . $textAreaId . '"] = function() {
				if (typeof(RTEarea) == "undefined" || typeof(HTMLArea) == "undefined") {
					window.setTimeout("configureEditorInstance[\'' . $textAreaId . '\']();", 40);
				} else {
			editornumber = "' . $textAreaId . '";
			RTEarea[editornumber] = new Object();
			RTEarea[editornumber].RTEtsConfigParams = "&RTEtsConfigParams=' . rawurlencode($this->RTEtsConfigParams()) . '";
			RTEarea[editornumber].number = editornumber;
			RTEarea[editornumber].deleted = false;
			RTEarea[editornumber].textAreaId = "' . $textAreaId . '";
			RTEarea[editornumber].id = "RTEarea" + editornumber;
			RTEarea[editornumber].RTEWidthOverride = "' . (is_object($GLOBALS['BE_USER']) && isset($GLOBALS['BE_USER']->uc['rteWidth']) && trim($GLOBALS['BE_USER']->uc['rteWidth']) ? trim($GLOBALS['BE_USER']->uc['rteWidth']) : trim($this->thisConfig['RTEWidthOverride'])) . '";
			RTEarea[editornumber].RTEHeightOverride = "' . (is_object($GLOBALS['BE_USER']) && isset($GLOBALS['BE_USER']->uc['rteHeight']) && (int) $GLOBALS['BE_USER']->uc['rteHeight'] ? (int) $GLOBALS['BE_USER']->uc['rteHeight'] : (int) $this->thisConfig['RTEHeightOverride']) . '";
			RTEarea[editornumber].resizable = ' . (is_object($GLOBALS['BE_USER']) && isset($GLOBALS['BE_USER']->uc['rteResize']) && $GLOBALS['BE_USER']->uc['rteResize'] ? 'true' : (trim($this->thisConfig['rteResize']) ? 'true' : 'false')) . ';
			RTEarea[editornumber].maxHeight = "' . (is_object($GLOBALS['BE_USER']) && isset($GLOBALS['BE_USER']->uc['rteMaxHeight']) && (int) $GLOBALS['BE_USER']->uc['rteMaxHeight'] ? trim($GLOBALS['BE_USER']->uc['rteMaxHeight']) : ((int) $this->thisConfig['rteMaxHeight'] ?: '2000')) . '";
			RTEarea[editornumber].fullScreen = ' . ($this->fullScreen ? 'true' : 'false') . ';
			RTEarea[editornumber].showStatusBar = ' . (trim($this->thisConfig['showStatusBar']) ? 'true' : 'false') . ';
			RTEarea[editornumber].enableWordClean = ' . (trim($this->thisConfig['enableWordClean']) ? 'true' : 'false') . ';
			RTEarea[editornumber].htmlRemoveComments = ' . (trim($this->thisConfig['removeComments']) ? 'true' : 'false') . ';
			RTEarea[editornumber].disableEnterParagraphs = ' . (trim($this->thisConfig['disableEnterParagraphs']) ? 'true' : 'false') . ';
			RTEarea[editornumber].disableObjectResizing = ' . (trim($this->thisConfig['disableObjectResizing']) ? 'true' : 'false') . ';
			RTEarea[editornumber].removeTrailingBR = ' . (trim($this->thisConfig['removeTrailingBR']) ? 'true' : 'false') . ';
			RTEarea[editornumber].useCSS = ' . (trim($this->thisConfig['useCSS']) ? 'true' : 'false') . ';
			RTEarea[editornumber].keepButtonGroupTogether = ' . (trim($this->thisConfig['keepButtonGroupTogether']) ? 'true' : 'false') . ';
			RTEarea[editornumber].disablePCexamples = ' . (trim($this->thisConfig['disablePCexamples']) ? 'true' : 'false') . ';
			RTEarea[editornumber].showTagFreeClasses = ' . (trim($this->thisConfig['showTagFreeClasses']) ? 'true' : 'false') . ';
			RTEarea[editornumber].useHTTPS = ' . (trim(stristr($this->siteURL, 'https')) || $this->thisConfig['forceHTTPS'] ? 'true' : 'false') . ';
			RTEarea[editornumber].tceformsNested = ' . (is_object($this->TCEform) && method_exists($this->TCEform, 'getDynNestedStack') ? $this->TCEform->getDynNestedStack(TRUE) : '[]') . ';
			RTEarea[editornumber].dialogueWindows = new Object();';
        if (isset($this->thisConfig['dialogueWindows.']['defaultPositionFromTop'])) {
            $configureRTEInJavascriptString .= '
			RTEarea[editornumber].dialogueWindows.positionFromTop = ' . (int) $this->thisConfig['dialogueWindows.']['defaultPositionFromTop'] . ';';
        }
        if (isset($this->thisConfig['dialogueWindows.']['defaultPositionFromLeft'])) {
            $configureRTEInJavascriptString .= '
			RTEarea[editornumber].dialogueWindows.positionFromLeft = ' . (int) $this->thisConfig['dialogueWindows.']['defaultPositionFromLeft'] . ';';
        }
        // The following properties apply only to the backend
        if (!$this->is_FE()) {
            $configureRTEInJavascriptString .= '
			RTEarea[editornumber].sys_language_content = "' . $this->contentLanguageUid . '";
			RTEarea[editornumber].typo3ContentLanguage = "' . $this->contentTypo3Language . '";
			RTEarea[editornumber].typo3ContentCharset = "' . $this->contentCharset . '";
			RTEarea[editornumber].userUid = "' . $this->userUid . '";';
        }
        // Setting the plugin flags
        $configureRTEInJavascriptString .= '
			RTEarea[editornumber].plugin = new Object();
			RTEarea[editornumber].pathToPluginDirectory = new Object();';
        foreach ($this->pluginEnabledArray as $pluginId) {
            $configureRTEInJavascriptString .= '
			RTEarea[editornumber].plugin.' . $pluginId . ' = true;';
            if (is_object($this->registeredPlugins[$pluginId])) {
                $pathToPluginDirectory = $this->registeredPlugins[$pluginId]->getPathToPluginDirectory();
                if ($pathToPluginDirectory) {
                    $configureRTEInJavascriptString .= '
			RTEarea[editornumber].pathToPluginDirectory.' . $pluginId . ' = "' . $pathToPluginDirectory . '";';
                }
            }
        }
        // Setting the buttons configuration
        $configureRTEInJavascriptString .= '
			RTEarea[editornumber].buttons = new Object();';
        if (is_array($this->thisConfig['buttons.'])) {
            foreach ($this->thisConfig['buttons.'] as $buttonIndex => $conf) {
                $button = substr($buttonIndex, 0, -1);
                if (is_array($conf)) {
                    $configureRTEInJavascriptString .= '
			RTEarea[editornumber].buttons.' . $button . ' = ' . $this->buildNestedJSArray($conf) . ';';
                }
            }
        }
        // Setting the list of tags to be removed if specified in the RTE config
        if (trim($this->thisConfig['removeTags'])) {
            $configureRTEInJavascriptString .= '
			RTEarea[editornumber].htmlRemoveTags = /^(' . implode('|', GeneralUtility::trimExplode(',', $this->thisConfig['removeTags'], TRUE)) . ')$/i;';
        }
        // Setting the list of tags to be removed with their contents if specified in the RTE config
        if (trim($this->thisConfig['removeTagsAndContents'])) {
            $configureRTEInJavascriptString .= '
			RTEarea[editornumber].htmlRemoveTagsAndContents = /^(' . implode('|', GeneralUtility::trimExplode(',', $this->thisConfig['removeTagsAndContents'], TRUE)) . ')$/i;';
        }
        // Setting array of custom tags if specified in the RTE config
        if (!empty($this->thisConfig['customTags'])) {
            $customTags = GeneralUtility::trimExplode(',', $this->thisConfig['customTags'], TRUE);
            if (!empty($customTags)) {
                $configureRTEInJavascriptString .= '
				RTEarea[editornumber].customTags= ' . json_encode($customTags) . ';';
            }
        }
        // Setting the pageStyle
        $configureRTEInJavascriptString .= '
			RTEarea[editornumber].pageStyle = "' . GeneralUtility::createVersionNumberedFilename($this->getContentCssFileName()) . '";';
        // Process classes configuration
        $classesConfigurationRequired = FALSE;
        foreach ($this->registeredPlugins as $pluginId => $plugin) {
            if ($this->isPluginEnabled($pluginId)) {
                $classesConfigurationRequired = $classesConfigurationRequired || $plugin->requiresClassesConfiguration();
            }
        }
        if ($classesConfigurationRequired) {
            $configureRTEInJavascriptString .= $this->buildJSClassesConfig($RTEcounter);
        }
        // Add Javascript configuration for registered plugins
        foreach ($this->registeredPlugins as $pluginId => $plugin) {
            if ($this->isPluginEnabled($pluginId)) {
                $configureRTEInJavascriptString .= $plugin->buildJavascriptConfiguration('editornumber');
            }
        }
        // Avoid premature reference to HTMLArea when being initially loaded by IRRE Ajax call
        $configureRTEInJavascriptString .= '
			RTEarea[editornumber].toolbar = ' . $this->getJSToolbarArray() . ';
			RTEarea[editornumber].convertButtonId = ' . json_encode(array_flip($this->convertToolbarForHtmlAreaArray)) . ';
			RTEarea.initEditor(editornumber);
				}
			};
			configureEditorInstance["' . $textAreaId . '"]();';
        return $configureRTEInJavascriptString;
    }
 /**
  * Generate the tag
  *
  * @param string $file
  * @return string
  */
 protected function getTag($file)
 {
     $file = \TYPO3\CMS\Core\Utility\GeneralUtility::createVersionNumberedFilename($file);
     $tag = '<script src="' . htmlspecialchars($file) . '" type="text/javascript"></script>';
     return $tag;
 }
 /**
  * Insert javascript-tags for google-analytics
  *
  * @param array $params
  * @param \TYPO3\CMS\Core\Page\PageRenderer $pObj
  * @return void
  */
 public function renderPreProcess($params, $pObj)
 {
     if (TYPO3_MODE === 'FE') {
         // Get plugin-configuration
         $conf = $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_libjsanalytics.']['settings.'];
         // Exclude the analytics-snippet on some pages
         $pageExclude = GeneralUtility::trimExplode(',', $conf['pageExclude'], true);
         // Generate script-tag for google-analytics if enabled
         if ((int) $conf['enable'] && !in_array($GLOBALS['TSFE']->id, $pageExclude)) {
             $analyticsPreScript = '';
             $analyticsPostScript = '';
             // Instruct analytics.js to use the name defined in typoscript
             if (!empty($conf['gaObjectName']) && $conf['gaObjectName'] !== 'ga') {
                 $gaObjectName = $conf['gaObjectName'];
             } else {
                 $gaObjectName = 'ga';
             }
             // Get filePath to analytics.js
             $analyticsJavascriptFile = Tools::getConfParam('localFile');
             if ($conf['forceCdn'] || !file_exists(PATH_site . $analyticsJavascriptFile)) {
                 $analyticsJavascriptFile = Tools::getConfParam('sourceFile');
             } else {
                 // If local file is not available, fall back to CDN
                 if (empty($analyticsJavascriptFile)) {
                     $analyticsJavascriptFile = Tools::getConfParam('sourceFile');
                 } else {
                     // Prefix file with absRefPrefix if path is relative
                     if (!GeneralUtility::isAbsPath($analyticsJavascriptFile)) {
                         $analyticsJavascriptFile = $GLOBALS['TSFE']->absRefPrefix . $analyticsJavascriptFile;
                     }
                     // Append filename with version numbers
                     $analyticsJavascriptFile = GeneralUtility::createVersionNumberedFilename($analyticsJavascriptFile);
                 }
             }
             // Insert different codeblocks for different integration (old/new)
             if ((int) $conf['alternative']) {
                 if ($conf['gaObjectName'] !== 'ga') {
                     $scriptTag .= LF . 'window.GoogleAnalyticsObject = \'' . $gaObjectName . '\';';
                 }
                 // Create an initial analytics() function
                 // The queued commands will be executed once analytics.js loads
                 $scriptTag .= LF . 'window.' . $gaObjectName . ' = window.' . $gaObjectName . ' || function() {' . '(' . $gaObjectName . '.q = ' . $gaObjectName . '.q || []).push(arguments)};';
                 // Set the time (as an integer) this tag was executed (Used for timing hits)
                 $scriptTag .= LF . $gaObjectName . '.l =+ new Date;';
                 // Compile final script-tag for analytics.js
                 $analyticsPostScript = LF . '<script src="' . $analyticsJavascriptFile . '" type="text/javascript" async="async"></script>';
             } else {
                 // Compile final script-tag for analytics.js
                 $analyticsPreScript = LF . '(function(i,s,o,g,r,a,m){i[\'GoogleAnalyticsObject\']=r;i[r]=i[r]||function(){' . LF . '(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),' . LF . 'm=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)' . LF . '})(window,document,\'script\',\'' . $analyticsJavascriptFile . '\',\'' . $gaObjectName . '\');';
             }
             // Create the tracker
             foreach ($conf['gaObject.'] as $gaName => $gaTracker) {
                 // Set the name of the tracker if defined in typoscript
                 $trackerName = '';
                 if ($gaName !== 'default.') {
                     $trackerName = $gaName;
                 }
                 // Check if analytics objects are defined
                 if (is_array($gaTracker)) {
                     $scriptTag .= $this->iterateTrackerMethods($gaObjectName, $trackerName, $gaTracker);
                 }
             }
             // TEST/TODO
             // Add additional javascript to a single page if defined in PageTSConfig
             //debug($GLOBALS['TSFE']->page['TSconfig']);
             /*
              $pageTS = BackendUtility::getPagesTSconfig($GLOBALS['TSFE']->id, [$GLOBALS['TSFE']->id]);
              if (isset($pageTS['tx_libjsanalytics.'])) {
              $analyticsPageTS = $pageTS['tx_libjsanalytics.'];
              if (is_array($analyticsPageTS['additionalScript.'])) {
              $scriptTag .= LF . $this->getCobject($analyticsPageTS['additionalScript'], $analyticsPageTS['additionalScript.']);
              }
              }
             */
             // Compile final codeblock
             $scriptTag = '<script type="text/javascript">' . LF . '/*<![CDATA[*/' . $analyticsPreScript . $scriptTag . LF . '/*]]>*/' . LF . '</script>' . $analyticsPostScript;
             // Add final code to HTML
             $pObj->addHeaderData($scriptTag);
         }
     }
 }
Example #14
0
 /**
  * Implementation of preRender() method. Used to include CSS files.
  *
  */
 protected function preRender()
 {
     $resultsCss = $this->typoScriptConfiguration->getCssFileByFileKey('results');
     if ($resultsCss !== '') {
         $cssFile = GeneralUtility::createVersionNumberedFilename($GLOBALS['TSFE']->tmpl->getFileName($resultsCss));
         $GLOBALS['TSFE']->additionalHeaderData['tx_solr-resultsCss'] = '<link href="' . $cssFile . '" rel="stylesheet" type="text/css" />';
     }
 }
 /**
  * Wrap js files inside <script> tag
  *
  * @param string $file Path to file
  * @return string <script.. string ready for <head> part
  */
 public function wrapJavascriptFile($file)
 {
     if (substr($file, 0, 4) == 'EXT:') {
         list($extKey, $local) = explode('/', substr($file, 4), 2);
         if (strcmp($extKey, '') && \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded($extKey) && strcmp($local, '')) {
             $file = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath($extKey) . $local;
         }
     }
     $file = \TYPO3\CMS\Core\Utility\GeneralUtility::resolveBackPath($file);
     $file = \TYPO3\CMS\Core\Utility\GeneralUtility::createVersionNumberedFilename($file);
     return '<script src="' . htmlspecialchars($file) . '" type="text/javascript"></script>';
 }
 /**
  * wrapCssFile
  *
  * @param string $cssFile
  * @return string
  */
 private function wrapCssFile($cssFile)
 {
     $cssFile = GeneralUtility::resolveBackPath($cssFile);
     $cssFile = GeneralUtility::createVersionNumberedFilename($cssFile);
     return '<link rel="stylesheet" type="text/css" href="' . htmlspecialchars($cssFile) . '" media="screen" />';
 }
Example #17
0
 /**
  * Return the Javascript code for configuring the RTE
  *
  * @return void
  */
 protected function addInstanceJavaScriptRegistration()
 {
     $backendUser = $this->getBackendUserAuthentication();
     $jsArray = array();
     $jsArray[] = 'if (typeof configureEditorInstance === "undefined") {';
     $jsArray[] = '	configureEditorInstance = new Object();';
     $jsArray[] = '}';
     $jsArray[] = 'configureEditorInstance["' . $this->domIdentifier . '"] = function() {';
     $jsArray[] = 'if (typeof RTEarea === "undefined" || typeof HTMLArea === "undefined") {';
     $jsArray[] = '	window.setTimeout("configureEditorInstance[\'' . $this->domIdentifier . '\']();", 40);';
     $jsArray[] = '} else {';
     $jsArray[] = 'editornumber = "' . $this->domIdentifier . '";';
     $jsArray[] = 'RTEarea[editornumber] = new Object();';
     $jsArray[] = 'RTEarea[editornumber].RTEtsConfigParams = "&RTEtsConfigParams=' . rawurlencode($this->RTEtsConfigParams()) . '";';
     $jsArray[] = 'RTEarea[editornumber].number = editornumber;';
     $jsArray[] = 'RTEarea[editornumber].deleted = false;';
     $jsArray[] = 'RTEarea[editornumber].textAreaId = "' . $this->domIdentifier . '";';
     $jsArray[] = 'RTEarea[editornumber].id = "RTEarea" + editornumber;';
     $jsArray[] = 'RTEarea[editornumber].RTEWidthOverride = "' . (isset($backendUser->uc['rteWidth']) && trim($backendUser->uc['rteWidth']) ? trim($backendUser->uc['rteWidth']) : trim($this->processedRteConfiguration['RTEWidthOverride'])) . '";';
     $jsArray[] = 'RTEarea[editornumber].RTEHeightOverride = "' . (isset($backendUser->uc['rteHeight']) && (int) $backendUser->uc['rteHeight'] ? (int) $backendUser->uc['rteHeight'] : (int) $this->processedRteConfiguration['RTEHeightOverride']) . '";';
     $jsArray[] = 'RTEarea[editornumber].resizable = ' . (isset($backendUser->uc['rteResize']) && $backendUser->uc['rteResize'] ? 'true;' : (trim($this->processedRteConfiguration['rteResize']) ? 'true;' : 'false;'));
     $jsArray[] = 'RTEarea[editornumber].maxHeight = "' . (isset($backendUser->uc['rteMaxHeight']) && (int) $backendUser->uc['rteMaxHeight'] ? trim($backendUser->uc['rteMaxHeight']) : ((int) $this->processedRteConfiguration['rteMaxHeight'] ?: '2000')) . '";';
     $jsArray[] = 'RTEarea[editornumber].fullScreen = ' . ($this->isInFullScreenMode() ? 'true;' : 'false;');
     $jsArray[] = 'RTEarea[editornumber].showStatusBar = ' . (trim($this->processedRteConfiguration['showStatusBar']) ? 'true;' : 'false;');
     $jsArray[] = 'RTEarea[editornumber].enableWordClean = ' . (trim($this->processedRteConfiguration['enableWordClean']) ? 'true;' : 'false;');
     $jsArray[] = 'RTEarea[editornumber].htmlRemoveComments = ' . (trim($this->processedRteConfiguration['removeComments']) ? 'true;' : 'false;');
     $jsArray[] = 'RTEarea[editornumber].disableEnterParagraphs = ' . (trim($this->processedRteConfiguration['disableEnterParagraphs']) ? 'true;' : 'false;');
     $jsArray[] = 'RTEarea[editornumber].disableObjectResizing = ' . (trim($this->processedRteConfiguration['disableObjectResizing']) ? 'true;' : 'false;');
     $jsArray[] = 'RTEarea[editornumber].removeTrailingBR = ' . (trim($this->processedRteConfiguration['removeTrailingBR']) ? 'true;' : 'false;');
     $jsArray[] = 'RTEarea[editornumber].useCSS = ' . (trim($this->processedRteConfiguration['useCSS']) ? 'true' : 'false') . ';';
     $jsArray[] = 'RTEarea[editornumber].keepButtonGroupTogether = ' . (trim($this->processedRteConfiguration['keepButtonGroupTogether']) ? 'true;' : 'false;');
     $jsArray[] = 'RTEarea[editornumber].disablePCexamples = ' . (trim($this->processedRteConfiguration['disablePCexamples']) ? 'true;' : 'false;');
     $jsArray[] = 'RTEarea[editornumber].showTagFreeClasses = ' . (trim($this->processedRteConfiguration['showTagFreeClasses']) ? 'true;' : 'false;');
     $jsArray[] = 'RTEarea[editornumber].tceformsNested = ' . (!empty($this->data) ? json_encode($this->data['tabAndInlineStack']) : '[]') . ';';
     $jsArray[] = 'RTEarea[editornumber].dialogueWindows = new Object();';
     if (isset($this->processedRteConfiguration['dialogueWindows.']['defaultPositionFromTop'])) {
         $jsArray[] = 'RTEarea[editornumber].dialogueWindows.positionFromTop = ' . (int) $this->processedRteConfiguration['dialogueWindows.']['defaultPositionFromTop'] . ';';
     }
     if (isset($this->processedRteConfiguration['dialogueWindows.']['defaultPositionFromLeft'])) {
         $jsArray[] = 'RTEarea[editornumber].dialogueWindows.positionFromLeft = ' . (int) $this->processedRteConfiguration['dialogueWindows.']['defaultPositionFromLeft'] . ';';
     }
     $jsArray[] = 'RTEarea[editornumber].sys_language_content = "' . $this->contentLanguageUid . '";';
     $jsArray[] = 'RTEarea[editornumber].typo3ContentLanguage = "' . $this->contentTypo3Language . '";';
     $jsArray[] = 'RTEarea[editornumber].userUid = "' . 'BE_' . $backendUser->user['uid'] . '";';
     // Setting the plugin flags
     $jsArray[] = 'RTEarea[editornumber].plugin = new Object();';
     foreach ($this->pluginEnabledArray as $pluginId) {
         $jsArray[] = 'RTEarea[editornumber].plugin.' . $pluginId . ' = true;';
     }
     // Setting the buttons configuration
     $jsArray[] = 'RTEarea[editornumber].buttons = new Object();';
     if (is_array($this->processedRteConfiguration['buttons.'])) {
         foreach ($this->processedRteConfiguration['buttons.'] as $buttonIndex => $conf) {
             $button = substr($buttonIndex, 0, -1);
             if (is_array($conf)) {
                 $jsArray[] = 'RTEarea[editornumber].buttons.' . $button . ' = ' . $this->buildNestedJSArray($conf) . ';';
             }
         }
     }
     // Setting the list of tags to be removed if specified in the RTE config
     if (trim($this->processedRteConfiguration['removeTags'])) {
         $jsArray[] = 'RTEarea[editornumber].htmlRemoveTags = /^(' . implode('|', GeneralUtility::trimExplode(',', $this->processedRteConfiguration['removeTags'], true)) . ')$/i;';
     }
     // Setting the list of tags to be removed with their contents if specified in the RTE config
     if (trim($this->processedRteConfiguration['removeTagsAndContents'])) {
         $jsArray[] = 'RTEarea[editornumber].htmlRemoveTagsAndContents = /^(' . implode('|', GeneralUtility::trimExplode(',', $this->processedRteConfiguration['removeTagsAndContents'], true)) . ')$/i;';
     }
     // Setting array of custom tags if specified in the RTE config
     if (!empty($this->processedRteConfiguration['customTags'])) {
         $customTags = GeneralUtility::trimExplode(',', $this->processedRteConfiguration['customTags'], true);
         if (!empty($customTags)) {
             $jsArray[] = 'RTEarea[editornumber].customTags= ' . json_encode($customTags) . ';';
         }
     }
     // Setting array of content css files if specified in the RTE config
     $versionNumberedFileNames = array();
     $contentCssFileNames = $this->getContentCssFileNames();
     foreach ($contentCssFileNames as $contentCssFileName) {
         $versionNumberedFileNames[] = GeneralUtility::createVersionNumberedFilename($contentCssFileName);
     }
     $jsArray[] = 'RTEarea[editornumber].pageStyle = ["' . implode('","', $versionNumberedFileNames) . '"];';
     $jsArray[] = 'RTEarea[editornumber].classesUrl = "' . $this->writeTemporaryFile('classes_' . $this->language, 'js', $this->buildJSClassesArray()) . '";';
     // Add Javascript configuration for registered plugins
     foreach ($this->registeredPlugins as $pluginId => $plugin) {
         /** @var RteHtmlAreaApi $plugin */
         if ($this->isPluginEnabled($pluginId)) {
             $jsPluginString = $plugin->buildJavascriptConfiguration();
             if ($jsPluginString) {
                 $jsArray[] = $plugin->buildJavascriptConfiguration();
             }
         }
     }
     // Avoid premature reference to HTMLArea when being initially loaded by IRRE Ajax call
     $jsArray[] = 'RTEarea[editornumber].toolbar = ' . $this->getJSToolbarArray() . ';';
     $jsArray[] = 'RTEarea[editornumber].convertButtonId = ' . json_encode(array_flip($this->convertToolbarForHtmlAreaArray)) . ';';
     $jsArray[] = 'RTEarea.initEditor(editornumber);';
     $jsArray[] = '}';
     $jsArray[] = '}';
     $jsArray[] = 'configureEditorInstance["' . $this->domIdentifier . '"]();';
     $this->resultArray['additionalJavaScriptPost'][] = implode(LF, $jsArray);
 }
Example #18
0
 /**
  * Retrieves JavaScript code (header part) for editor
  *
  * @param \TYPO3\CMS\Backend\Template\DocumentTemplate $doc
  * @return string JavaScript code
  */
 public function getJavascriptCode($doc)
 {
     $content = '';
     $path_t3e = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('t3editor');
     $path_codemirror = 'contrib/codemirror/js/';
     // Include needed javascript-frameworks
     $pageRenderer = $doc->getPageRenderer();
     /** @var $pageRenderer \TYPO3\CMS\Core\Page\PageRenderer */
     $pageRenderer->loadPrototype();
     $pageRenderer->loadScriptaculous();
     // Include editor-css
     $content .= '<link href="' . GeneralUtility::createVersionNumberedFilename($GLOBALS['BACK_PATH'] . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('t3editor') . 'res/css/t3editor.css') . '" type="text/css" rel="stylesheet" />';
     // Include editor-js-lib
     $doc->loadJavascriptLib($path_codemirror . 'codemirror.js');
     $doc->loadJavascriptLib($path_t3e . 'res/jslib/t3editor.js');
     $pageRenderer->loadRequireJsModule('TYPO3/CMS/T3editor/T3editor');
     $content .= GeneralUtility::wrapJS('T3editor = T3editor || {};' . 'T3editor.lang = ' . json_encode($GLOBALS['LANG']->getLabelsWithPrefix('js.', 'label_')) . ';' . LF . 'T3editor.PATH_t3e = "' . $GLOBALS['BACK_PATH'] . $path_t3e . '"; ' . LF . 'T3editor.PATH_codemirror = "' . $GLOBALS['BACK_PATH'] . $path_codemirror . '"; ' . LF . 'T3editor.template = ' . $this->getPreparedTemplate() . ';' . LF . 'T3editor.ajaxSavetype = "' . $this->ajaxSaveType . '";' . LF);
     $content .= $this->getModeSpecificJavascriptCode();
     return $content;
 }
 /**
  * Rendering the cObject, FORM
  *
  * Note on $formData:
  * In the optional $formData array each entry represents a line in the ordinary setup.
  * In those entries each entry (0,1,2...) represents a space normally divided by the '|' line.
  *
  * $formData [] = array('Name:', 'name=input, 25 ', 'Default value....');
  * $formData [] = array('Email:', 'email=input, 25 ', 'Default value for email....');
  *
  * - corresponds to the $conf['data'] value being :
  * Name:|name=input, 25 |Default value....||Email:|email=input, 25 |Default value for email....
  *
  * If $formData is an array the value of $conf['data'] is ignored.
  *
  * @param array $conf Array of TypoScript properties
  * @param array $formData Alternative formdata overriding whatever comes from TypoScript
  * @return string Output
  */
 public function render($conf = array(), $formData = '')
 {
     $content = '';
     if (is_array($formData)) {
         $dataArray = $formData;
     } else {
         $data = isset($conf['data.']) ? $this->cObj->stdWrap($conf['data'], $conf['data.']) : $conf['data'];
         // Clearing dataArr
         $dataArray = array();
         // Getting the original config
         if (trim($data)) {
             $data = str_replace(LF, '||', $data);
             $dataArray = explode('||', $data);
         }
         // Adding the new dataArray config form:
         if (is_array($conf['dataArray.'])) {
             // dataArray is supplied
             $sortedKeyArray = \TYPO3\CMS\Core\TypoScript\TemplateService::sortedKeyList($conf['dataArray.'], true);
             foreach ($sortedKeyArray as $theKey) {
                 $singleKeyArray = $conf['dataArray.'][$theKey . '.'];
                 if (is_array($singleKeyArray)) {
                     $temp = array();
                     $label = isset($singleKeyArray['label.']) ? $this->cObj->stdWrap($singleKeyArray['label'], $singleKeyArray['label.']) : $singleKeyArray['label'];
                     list($temp[0]) = explode('|', $label);
                     $type = isset($singleKeyArray['type.']) ? $this->cObj->stdWrap($singleKeyArray['type'], $singleKeyArray['type.']) : $singleKeyArray['type'];
                     list($temp[1]) = explode('|', $type);
                     $required = isset($singleKeyArray['required.']) ? $this->cObj->stdWrap($singleKeyArray['required'], $singleKeyArray['required.']) : $singleKeyArray['required'];
                     if ($required) {
                         $temp[1] = '*' . $temp[1];
                     }
                     $singleValue = isset($singleKeyArray['value.']) ? $this->cObj->stdWrap($singleKeyArray['value'], $singleKeyArray['value.']) : $singleKeyArray['value'];
                     list($temp[2]) = explode('|', $singleValue);
                     // If value array is set, then implode those values.
                     if (is_array($singleKeyArray['valueArray.'])) {
                         $temp_accumulated = array();
                         foreach ($singleKeyArray['valueArray.'] as $singleKey => $singleKey_valueArray) {
                             if (is_array($singleKey_valueArray) && (int) $singleKey . '.' === (string) $singleKey) {
                                 $temp_valueArray = array();
                                 $valueArrayLabel = isset($singleKey_valueArray['label.']) ? $this->cObj->stdWrap($singleKey_valueArray['label'], $singleKey_valueArray['label.']) : $singleKey_valueArray['label'];
                                 list($temp_valueArray[0]) = explode('=', $valueArrayLabel);
                                 $selected = isset($singleKey_valueArray['selected.']) ? $this->cObj->stdWrap($singleKey_valueArray['selected'], $singleKey_valueArray['selected.']) : $singleKey_valueArray['selected'];
                                 if ($selected) {
                                     $temp_valueArray[0] = '*' . $temp_valueArray[0];
                                 }
                                 $singleKeyValue = isset($singleKey_valueArray['value.']) ? $this->cObj->stdWrap($singleKey_valueArray['value'], $singleKey_valueArray['value.']) : $singleKey_valueArray['value'];
                                 list($temp_valueArray[1]) = explode(',', $singleKeyValue);
                             }
                             $temp_accumulated[] = implode('=', $temp_valueArray);
                         }
                         $temp[2] = implode(',', $temp_accumulated);
                     }
                     $specialEval = isset($singleKeyArray['specialEval.']) ? $this->cObj->stdWrap($singleKeyArray['specialEval'], $singleKeyArray['specialEval.']) : $singleKeyArray['specialEval'];
                     list($temp[3]) = explode('|', $specialEval);
                     // Adding the form entry to the dataArray
                     $dataArray[] = implode('|', $temp);
                 }
             }
         }
     }
     $attachmentCounter = '';
     $hiddenfields = '';
     $fieldlist = array();
     $propertyOverride = array();
     $fieldname_hashArray = array();
     $counter = 0;
     $xhtmlStrict = GeneralUtility::inList('xhtml_strict,xhtml_11,xhtml_2', $GLOBALS['TSFE']->xhtmlDoctype);
     // Formname
     $formName = isset($conf['formName.']) ? $this->cObj->stdWrap($conf['formName'], $conf['formName.']) : $conf['formName'];
     $formName = $this->cleanFormName($formName);
     $formName = $GLOBALS['TSFE']->getUniqueId($formName);
     $fieldPrefix = isset($conf['fieldPrefix.']) ? $this->cObj->stdWrap($conf['fieldPrefix'], $conf['fieldPrefix.']) : $conf['fieldPrefix'];
     if (isset($conf['fieldPrefix']) || isset($conf['fieldPrefix.'])) {
         if ($fieldPrefix) {
             $prefix = $this->cleanFormName($fieldPrefix);
         } else {
             $prefix = '';
         }
     } else {
         $prefix = $formName;
     }
     foreach ($dataArray as $dataValue) {
         $counter++;
         $confData = array();
         if (is_array($formData)) {
             $parts = $dataValue;
             // TRUE...
             $dataValue = 1;
         } else {
             $dataValue = trim($dataValue);
             $parts = explode('|', $dataValue);
         }
         if ($dataValue && strcspn($dataValue, '#/')) {
             // label:
             $confData['label'] = GeneralUtility::removeXSS(trim($parts[0]));
             // field:
             $fParts = explode(',', $parts[1]);
             $fParts[0] = trim($fParts[0]);
             if ($fParts[0][0] === '*') {
                 $confData['required'] = 1;
                 $fParts[0] = substr($fParts[0], 1);
             }
             $typeParts = explode('=', $fParts[0]);
             $confData['type'] = trim(strtolower(end($typeParts)));
             if (count($typeParts) === 1) {
                 $confData['fieldname'] = $this->cleanFormName($parts[0]);
                 if (strtolower(preg_replace('/[^[:alnum:]]/', '', $confData['fieldname'])) == 'email') {
                     $confData['fieldname'] = 'email';
                 }
                 // Duplicate fieldnames resolved
                 if (isset($fieldname_hashArray[md5($confData['fieldname'])])) {
                     $confData['fieldname'] .= '_' . $counter;
                 }
                 $fieldname_hashArray[md5($confData['fieldname'])] = $confData['fieldname'];
                 // Attachment names...
                 if ($confData['type'] == 'file') {
                     $confData['fieldname'] = 'attachment' . $attachmentCounter;
                     $attachmentCounter = (int) $attachmentCounter + 1;
                 }
             } else {
                 $confData['fieldname'] = str_replace(' ', '_', trim($typeParts[0]));
             }
             $confData['fieldname'] = htmlspecialchars($confData['fieldname']);
             $fieldCode = '';
             $wrapFieldName = isset($conf['wrapFieldName']) ? $this->cObj->stdWrap($conf['wrapFieldName'], $conf['wrapFieldName.']) : $conf['wrapFieldName'];
             if ($wrapFieldName) {
                 $confData['fieldname'] = $this->cObj->wrap($confData['fieldname'], $wrapFieldName);
             }
             // Set field name as current:
             $this->cObj->setCurrentVal($confData['fieldname']);
             // Additional parameters
             if (trim($confData['type'])) {
                 if (isset($conf['params.'][$confData['type']])) {
                     $addParams = isset($conf['params.'][$confData['type'] . '.']) ? trim($this->cObj->stdWrap($conf['params.'][$confData['type']], $conf['params.'][$confData['type'] . '.'])) : trim($conf['params.'][$confData['type']]);
                 } else {
                     $addParams = isset($conf['params.']) ? trim($this->cObj->stdWrap($conf['params'], $conf['params.'])) : trim($conf['params']);
                 }
                 if ((string) $addParams !== '') {
                     $addParams = ' ' . $addParams;
                 }
             } else {
                 $addParams = '';
             }
             $dontMd5FieldNames = isset($conf['dontMd5FieldNames.']) ? $this->cObj->stdWrap($conf['dontMd5FieldNames'], $conf['dontMd5FieldNames.']) : $conf['dontMd5FieldNames'];
             if ($dontMd5FieldNames) {
                 $fName = $confData['fieldname'];
             } else {
                 $fName = md5($confData['fieldname']);
             }
             // Accessibility: Set id = fieldname attribute:
             $accessibility = isset($conf['accessibility.']) ? $this->cObj->stdWrap($conf['accessibility'], $conf['accessibility.']) : $conf['accessibility'];
             if ($accessibility || $xhtmlStrict) {
                 $elementIdAttribute = ' id="' . $prefix . $fName . '"';
             } else {
                 $elementIdAttribute = '';
             }
             // Create form field based on configuration/type:
             switch ($confData['type']) {
                 case 'textarea':
                     $cols = trim($fParts[1]) ? (int) $fParts[1] : 20;
                     $compensateFieldWidth = isset($conf['compensateFieldWidth.']) ? $this->cObj->stdWrap($conf['compensateFieldWidth'], $conf['compensateFieldWidth.']) : $conf['compensateFieldWidth'];
                     $compWidth = doubleval($compensateFieldWidth ? $compensateFieldWidth : $GLOBALS['TSFE']->compensateFieldWidth);
                     $compWidth = $compWidth ? $compWidth : 1;
                     $cols = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($cols * $compWidth, 1, 120);
                     $rows = trim($fParts[2]) ? \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($fParts[2], 1, 30) : 5;
                     $wrap = trim($fParts[3]);
                     $noWrapAttr = isset($conf['noWrapAttr.']) ? $this->cObj->stdWrap($conf['noWrapAttr'], $conf['noWrapAttr.']) : $conf['noWrapAttr'];
                     if ($noWrapAttr || $wrap === 'disabled') {
                         $wrap = '';
                     } else {
                         $wrap = $wrap ? ' wrap="' . $wrap . '"' : ' wrap="virtual"';
                     }
                     $noValueInsert = isset($conf['noValueInsert.']) ? $this->cObj->stdWrap($conf['noValueInsert'], $conf['noValueInsert.']) : $conf['noValueInsert'];
                     $default = $this->getFieldDefaultValue($noValueInsert, $confData['fieldname'], str_replace('\\n', LF, trim($parts[2])));
                     $fieldCode = sprintf('<textarea name="%s"%s cols="%s" rows="%s"%s%s>%s</textarea>', $confData['fieldname'], $elementIdAttribute, $cols, $rows, $wrap, $addParams, htmlspecialchars($default));
                     break;
                 case 'input':
                 case 'password':
                     $size = trim($fParts[1]) ? (int) $fParts[1] : 20;
                     $compensateFieldWidth = isset($conf['compensateFieldWidth.']) ? $this->cObj->stdWrap($conf['compensateFieldWidth'], $conf['compensateFieldWidth.']) : $conf['compensateFieldWidth'];
                     $compWidth = doubleval($compensateFieldWidth ? $compensateFieldWidth : $GLOBALS['TSFE']->compensateFieldWidth);
                     $compWidth = $compWidth ? $compWidth : 1;
                     $size = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($size * $compWidth, 1, 120);
                     $noValueInsert = isset($conf['noValueInsert.']) ? $this->cObj->stdWrap($conf['noValueInsert'], $conf['noValueInsert.']) : $conf['noValueInsert'];
                     $default = $this->getFieldDefaultValue($noValueInsert, $confData['fieldname'], trim($parts[2]));
                     if ($confData['type'] == 'password') {
                         $default = '';
                     }
                     $max = trim($fParts[2]) ? ' maxlength="' . \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($fParts[2], 1, 1000) . '"' : '';
                     $theType = $confData['type'] == 'input' ? 'text' : 'password';
                     $fieldCode = sprintf('<input type="%s" name="%s"%s size="%s"%s value="%s"%s />', $theType, $confData['fieldname'], $elementIdAttribute, $size, $max, htmlspecialchars($default), $addParams);
                     break;
                 case 'file':
                     $size = trim($fParts[1]) ? \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($fParts[1], 1, 60) : 20;
                     $fieldCode = sprintf('<input type="file" name="%s"%s size="%s"%s />', $confData['fieldname'], $elementIdAttribute, $size, $addParams);
                     break;
                 case 'check':
                     // alternative default value:
                     $noValueInsert = isset($conf['noValueInsert.']) ? $this->cObj->stdWrap($conf['noValueInsert'], $conf['noValueInsert.']) : $conf['noValueInsert'];
                     $default = $this->getFieldDefaultValue($noValueInsert, $confData['fieldname'], trim($parts[2]));
                     $checked = $default ? ' checked="checked"' : '';
                     $fieldCode = sprintf('<input type="checkbox" value="%s" name="%s"%s%s%s />', 1, $confData['fieldname'], $elementIdAttribute, $checked, $addParams);
                     break;
                 case 'select':
                     $option = '';
                     $valueParts = explode(',', $parts[2]);
                     // size
                     if (strtolower(trim($fParts[1])) == 'auto') {
                         $fParts[1] = count($valueParts);
                     }
                     // Auto size set here. Max 20
                     $size = trim($fParts[1]) ? \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($fParts[1], 1, 20) : 1;
                     // multiple
                     $multiple = strtolower(trim($fParts[2])) == 'm' ? ' multiple="multiple"' : '';
                     // Where the items will be
                     $items = array();
                     //RTF
                     $defaults = array();
                     $pCount = count($valueParts);
                     for ($a = 0; $a < $pCount; $a++) {
                         $valueParts[$a] = trim($valueParts[$a]);
                         // Finding default value
                         if ($valueParts[$a][0] === '*') {
                             $sel = 'selected';
                             $valueParts[$a] = substr($valueParts[$a], 1);
                         } else {
                             $sel = '';
                         }
                         // Get value/label
                         $subParts = explode('=', $valueParts[$a]);
                         // Sets the value
                         $subParts[1] = isset($subParts[1]) ? trim($subParts[1]) : trim($subParts[0]);
                         // Adds the value/label pair to the items-array
                         $items[] = $subParts;
                         if ($sel) {
                             $defaults[] = $subParts[1];
                         }
                     }
                     // alternative default value:
                     $noValueInsert = isset($conf['noValueInsert.']) ? $this->cObj->stdWrap($conf['noValueInsert'], $conf['noValueInsert.']) : $conf['noValueInsert'];
                     $default = $this->getFieldDefaultValue($noValueInsert, $confData['fieldname'], $defaults);
                     if (!is_array($default)) {
                         $defaults = array();
                         $defaults[] = $default;
                     } else {
                         $defaults = $default;
                     }
                     // Create the select-box:
                     $iCount = count($items);
                     for ($a = 0; $a < $iCount; $a++) {
                         $option .= '<option value="' . $items[$a][1] . '"' . (in_array($items[$a][1], $defaults) ? ' selected="selected"' : '') . '>' . trim($items[$a][0]) . '</option>';
                     }
                     if ($multiple) {
                         // The fieldname must be prepended '[]' if multiple select. And the reason why it's prepended is, because the required-field list later must also have [] prepended.
                         $confData['fieldname'] .= '[]';
                     }
                     $fieldCode = sprintf('<select name="%s"%s size="%s"%s%s>%s</select>', $confData['fieldname'], $elementIdAttribute, $size, $multiple, $addParams, $option);
                     //RTF
                     break;
                 case 'radio':
                     $option = '';
                     $valueParts = explode(',', $parts[2]);
                     // Where the items will be
                     $items = array();
                     $default = '';
                     $pCount = count($valueParts);
                     for ($a = 0; $a < $pCount; $a++) {
                         $valueParts[$a] = trim($valueParts[$a]);
                         if ($valueParts[$a][0] === '*') {
                             $sel = 'checked';
                             $valueParts[$a] = substr($valueParts[$a], 1);
                         } else {
                             $sel = '';
                         }
                         // Get value/label
                         $subParts = explode('=', $valueParts[$a]);
                         // Sets the value
                         $subParts[1] = isset($subParts[1]) ? trim($subParts[1]) : trim($subParts[0]);
                         // Adds the value/label pair to the items-array
                         $items[] = $subParts;
                         if ($sel) {
                             $default = $subParts[1];
                         }
                     }
                     // alternative default value:
                     $noValueInsert = isset($conf['noValueInsert.']) ? $this->cObj->stdWrap($conf['noValueInsert'], $conf['noValueInsert.']) : $conf['noValueInsert'];
                     $default = $this->getFieldDefaultValue($noValueInsert, $confData['fieldname'], $default);
                     // Create the select-box:
                     $iCount = count($items);
                     for ($a = 0; $a < $iCount; $a++) {
                         $optionParts = '';
                         $radioId = $prefix . $fName . $this->cleanFormName($items[$a][0]);
                         if ($accessibility) {
                             $radioLabelIdAttribute = ' id="' . $radioId . '"';
                         } else {
                             $radioLabelIdAttribute = '';
                         }
                         $optionParts .= '<input type="radio" name="' . $confData['fieldname'] . '"' . $radioLabelIdAttribute . ' value="' . $items[$a][1] . '"' . ((string) $items[$a][1] === (string) $default ? ' checked="checked"' : '') . $addParams . ' />';
                         if ($accessibility) {
                             $label = isset($conf['radioWrap.']) ? $this->cObj->stdWrap(trim($items[$a][0]), $conf['radioWrap.']) : trim($items[$a][0]);
                             $optionParts .= '<label for="' . $radioId . '">' . $label . '</label>';
                         } else {
                             $optionParts .= isset($conf['radioWrap.']) ? $this->cObj->stdWrap(trim($items[$a][0]), $conf['radioWrap.']) : trim($items[$a][0]);
                         }
                         $option .= isset($conf['radioInputWrap.']) ? $this->cObj->stdWrap($optionParts, $conf['radioInputWrap.']) : $optionParts;
                     }
                     if ($accessibility) {
                         $accessibilityWrap = isset($conf['radioWrap.']['accessibilityWrap.']) ? $this->cObj->stdWrap($conf['radioWrap.']['accessibilityWrap'], $conf['radioWrap.']['accessibilityWrap.']) : $conf['radioWrap.']['accessibilityWrap'];
                         if ($accessibilityWrap) {
                             $search = array('###RADIO_FIELD_ID###', '###RADIO_GROUP_LABEL###');
                             $replace = array($elementIdAttribute, $confData['label']);
                             $accessibilityWrap = str_replace($search, $replace, $accessibilityWrap);
                             $option = $this->cObj->wrap($option, $accessibilityWrap);
                         }
                     }
                     $fieldCode = $option;
                     break;
                 case 'hidden':
                     $value = trim($parts[2]);
                     // If this form includes an auto responder message, include a HMAC checksum field
                     // in order to verify potential abuse of this feature.
                     if ($value !== '') {
                         if (GeneralUtility::inList($confData['fieldname'], 'auto_respond_msg')) {
                             $hmacChecksum = GeneralUtility::hmac($value, 'content_form');
                             $hiddenfields .= sprintf('<input type="hidden" name="auto_respond_checksum" id="%sauto_respond_checksum" value="%s" />', $prefix, $hmacChecksum);
                         }
                         if (GeneralUtility::inList('recipient_copy,recipient', $confData['fieldname']) && $GLOBALS['TYPO3_CONF_VARS']['FE']['secureFormmail']) {
                             break;
                         }
                         if (GeneralUtility::inList('recipient_copy,recipient', $confData['fieldname'])) {
                             $value = \TYPO3\CMS\Compatibility6\Utility\FormUtility::codeString($value);
                         }
                     }
                     $hiddenfields .= sprintf('<input type="hidden" name="%s"%s value="%s" />', $confData['fieldname'], $elementIdAttribute, htmlspecialchars($value));
                     break;
                 case 'property':
                     if (GeneralUtility::inList('type,locationData,goodMess,badMess,emailMess', $confData['fieldname'])) {
                         $value = trim($parts[2]);
                         $propertyOverride[$confData['fieldname']] = $value;
                         $conf[$confData['fieldname']] = $value;
                     }
                     break;
                 case 'submit':
                     $value = trim($parts[2]);
                     if ($conf['image.']) {
                         $this->cObj->data[$this->cObj->currentValKey] = $value;
                         $image = $this->cObj->cObjGetSingle('IMG_RESOURCE', $conf['image.']);
                         $params = $conf['image.']['params'] ? ' ' . $conf['image.']['params'] : '';
                         $params .= $this->cObj->getAltParam($conf['image.'], false);
                         $params .= $addParams;
                     } else {
                         $image = '';
                     }
                     if ($image) {
                         $fieldCode = sprintf('<input type="image" name="%s"%s src="%s"%s />', $confData['fieldname'], $elementIdAttribute, $image, $params);
                     } else {
                         $fieldCode = sprintf('<input type="submit" name="%s"%s value="%s"%s />', $confData['fieldname'], $elementIdAttribute, htmlspecialchars($value, ENT_COMPAT, 'UTF-8', false), $addParams);
                     }
                     break;
                 case 'reset':
                     $value = trim($parts[2]);
                     $fieldCode = sprintf('<input type="reset" name="%s"%s value="%s"%s />', $confData['fieldname'], $elementIdAttribute, htmlspecialchars($value, ENT_COMPAT, 'UTF-8', false), $addParams);
                     break;
                 case 'label':
                     $fieldCode = nl2br(htmlspecialchars(trim($parts[2])));
                     break;
                 default:
                     $confData['type'] = 'comment';
                     $fieldCode = trim($parts[2]) . '&nbsp;';
             }
             if ($fieldCode) {
                 // Checking for special evaluation modes:
                 if (trim($parts[3]) !== '' && GeneralUtility::inList('textarea,input,password', $confData['type'])) {
                     $modeParameters = GeneralUtility::trimExplode(':', $parts[3]);
                 } else {
                     $modeParameters = array();
                 }
                 // Adding evaluation based on settings:
                 switch ((string) $modeParameters[0]) {
                     case 'EREG':
                         $fieldlist[] = '_EREG';
                         $fieldlist[] = $modeParameters[1];
                         $fieldlist[] = $modeParameters[2];
                         $fieldlist[] = $confData['fieldname'];
                         $fieldlist[] = $confData['label'];
                         // Setting this so "required" layout is used.
                         $confData['required'] = 1;
                         break;
                     case 'EMAIL':
                         $fieldlist[] = '_EMAIL';
                         $fieldlist[] = $confData['fieldname'];
                         $fieldlist[] = $confData['label'];
                         // Setting this so "required" layout is used.
                         $confData['required'] = 1;
                         break;
                     default:
                         if ($confData['required']) {
                             $fieldlist[] = $confData['fieldname'];
                             $fieldlist[] = $confData['label'];
                         }
                 }
                 // Field:
                 $fieldLabel = $confData['label'];
                 if ($accessibility && trim($fieldLabel) && !preg_match('/^(label|hidden|comment)$/', $confData['type'])) {
                     $fieldLabel = '<label for="' . $prefix . $fName . '">' . $fieldLabel . '</label>';
                 }
                 // Getting template code:
                 if (isset($conf['fieldWrap.'])) {
                     $fieldCode = $this->cObj->stdWrap($fieldCode, $conf['fieldWrap.']);
                 }
                 $labelCode = isset($conf['labelWrap.']) ? $this->cObj->stdWrap($fieldLabel, $conf['labelWrap.']) : $fieldLabel;
                 $commentCode = isset($conf['commentWrap.']) ? $this->cObj->stdWrap($confData['label'], $conf['commentWrap.']) : $confData['label'];
                 $result = $conf['layout'];
                 $req = isset($conf['REQ.']) ? $this->cObj->stdWrap($conf['REQ'], $conf['REQ.']) : $conf['REQ'];
                 if ($req && $confData['required']) {
                     if (isset($conf['REQ.']['fieldWrap.'])) {
                         $fieldCode = $this->cObj->stdWrap($fieldCode, $conf['REQ.']['fieldWrap.']);
                     }
                     if (isset($conf['REQ.']['labelWrap.'])) {
                         $labelCode = $this->cObj->stdWrap($fieldLabel, $conf['REQ.']['labelWrap.']);
                     }
                     $reqLayout = isset($conf['REQ.']['layout.']) ? $this->cObj->stdWrap($conf['REQ.']['layout'], $conf['REQ.']['layout.']) : $conf['REQ.']['layout'];
                     if ($reqLayout) {
                         $result = $reqLayout;
                     }
                 }
                 if ($confData['type'] == 'comment') {
                     $commentLayout = isset($conf['COMMENT.']['layout.']) ? $this->cObj->stdWrap($conf['COMMENT.']['layout'], $conf['COMMENT.']['layout.']) : $conf['COMMENT.']['layout'];
                     if ($commentLayout) {
                         $result = $commentLayout;
                     }
                 }
                 if ($confData['type'] == 'check') {
                     $checkLayout = isset($conf['CHECK.']['layout.']) ? $this->cObj->stdWrap($conf['CHECK.']['layout'], $conf['CHECK.']['layout.']) : $conf['CHECK.']['layout'];
                     if ($checkLayout) {
                         $result = $checkLayout;
                     }
                 }
                 if ($confData['type'] == 'radio') {
                     $radioLayout = isset($conf['RADIO.']['layout.']) ? $this->cObj->stdWrap($conf['RADIO.']['layout'], $conf['RADIO.']['layout.']) : $conf['RADIO.']['layout'];
                     if ($radioLayout) {
                         $result = $radioLayout;
                     }
                 }
                 if ($confData['type'] == 'label') {
                     $labelLayout = isset($conf['LABEL.']['layout.']) ? $this->cObj->stdWrap($conf['LABEL.']['layout'], $conf['LABEL.']['layout.']) : $conf['LABEL.']['layout'];
                     if ($labelLayout) {
                         $result = $labelLayout;
                     }
                 }
                 //RTF
                 $content .= str_replace(array('###FIELD###', '###LABEL###', '###COMMENT###'), array($fieldCode, $labelCode, $commentCode), $result);
             }
         }
     }
     if (isset($conf['stdWrap.'])) {
         $content = $this->cObj->stdWrap($content, $conf['stdWrap.']);
     }
     // Redirect (external: where to go afterwards. internal: where to submit to)
     $theRedirect = isset($conf['redirect.']) ? $this->cObj->stdWrap($conf['redirect'], $conf['redirect.']) : $conf['redirect'];
     // redirect should be set to the page to redirect to after an external script has been used. If internal scripts is used, and if no 'type' is set that dictates otherwise, redirect is used as the url to jump to as long as it's an integer (page)
     $target = isset($conf['target.']) ? $this->cObj->stdWrap($conf['target'], $conf['target.']) : $conf['target'];
     // redirect should be set to the page to redirect to after an external script has been used. If internal scripts is used, and if no 'type' is set that dictates otherwise, redirect is used as the url to jump to as long as it's an integer (page)
     $noCache = isset($conf['no_cache.']) ? $this->cObj->stdWrap($conf['no_cache'], $conf['no_cache.']) : $conf['no_cache'];
     // redirect should be set to the page to redirect to after an external script has been used. If internal scripts is used, and if no 'type' is set that dictates otherwise, redirect is used as the url to jump to as long as it's an integer (page)
     $page = $GLOBALS['TSFE']->page;
     // Internal: Just submit to current page
     if (!$theRedirect) {
         $LD = $GLOBALS['TSFE']->tmpl->linkData($page, $target, $noCache, 'index.php', '', $this->cObj->getClosestMPvalueForPage($page['uid']));
     } elseif (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($theRedirect)) {
         // Internal: Submit to page with ID $theRedirect
         $page = $GLOBALS['TSFE']->sys_page->getPage_noCheck($theRedirect);
         $LD = $GLOBALS['TSFE']->tmpl->linkData($page, $target, $noCache, 'index.php', '', $this->cObj->getClosestMPvalueForPage($page['uid']));
     } else {
         // External URL, redirect-hidden field is rendered!
         $LD = $GLOBALS['TSFE']->tmpl->linkData($page, $target, $noCache, '', '', $this->cObj->getClosestMPvalueForPage($page['uid']));
         $LD['totalURL'] = $theRedirect;
         $hiddenfields .= '<input type="hidden" name="redirect" value="' . htmlspecialchars($LD['totalURL']) . '" />';
     }
     // Formtype (where to submit to!):
     if ($propertyOverride['type']) {
         $formtype = $propertyOverride['type'];
     } else {
         $formtype = isset($conf['type.']) ? $this->cObj->stdWrap($conf['type'], $conf['type.']) : $conf['type'];
     }
     // Submit to a specific page
     if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($formtype)) {
         $page = $GLOBALS['TSFE']->sys_page->getPage_noCheck($formtype);
         $LD_A = $GLOBALS['TSFE']->tmpl->linkData($page, $target, $noCache, '', '', $this->cObj->getClosestMPvalueForPage($page['uid']));
         $action = $LD_A['totalURL'];
     } elseif ($formtype) {
         // Submit to external script
         $LD_A = $LD;
         $action = $formtype;
     } elseif (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($theRedirect)) {
         $LD_A = $LD;
         $action = $LD_A['totalURL'];
     } else {
         // Submit to "nothing" - which is current page
         $LD_A = $GLOBALS['TSFE']->tmpl->linkData($GLOBALS['TSFE']->page, $target, $noCache, '', '', $this->cObj->getClosestMPvalueForPage($page['uid']));
         $action = $LD_A['totalURL'];
     }
     // Recipient:
     $theEmail = isset($conf['recipient.']) ? $this->cObj->stdWrap($conf['recipient'], $conf['recipient.']) : $conf['recipient'];
     if ($theEmail && !$GLOBALS['TYPO3_CONF_VARS']['FE']['secureFormmail']) {
         $theEmail = \TYPO3\CMS\Compatibility6\Utility\FormUtility::codeString($theEmail);
         $hiddenfields .= '<input type="hidden" name="recipient" value="' . htmlspecialchars($theEmail) . '" />';
     }
     // location data:
     $location = isset($conf['locationData.']) ? $this->cObj->stdWrap($conf['locationData'], $conf['locationData.']) : $conf['locationData'];
     if ($location) {
         if ($location == 'HTTP_POST_VARS' && isset($_POST['locationData'])) {
             $locationData = GeneralUtility::_POST('locationData');
         } else {
             // locationData is [the page id]:[tablename]:[uid of record]. Indicates on which page the record (from tablename with uid) is shown. Used to check access.
             if (isset($this->data['_LOCALIZED_UID'])) {
                 $locationData = $GLOBALS['TSFE']->id . ':' . str_replace($this->data['uid'], $this->data['_LOCALIZED_UID'], $this->cObj->currentRecord);
             } else {
                 $locationData = $GLOBALS['TSFE']->id . ':' . $this->cObj->currentRecord;
             }
         }
         $hiddenfields .= '<input type="hidden" name="locationData" value="' . htmlspecialchars($locationData) . '" />';
     }
     // Hidden fields:
     if (is_array($conf['hiddenFields.'])) {
         foreach ($conf['hiddenFields.'] as $hF_key => $hF_conf) {
             if (substr($hF_key, -1) != '.') {
                 $hF_value = $this->cObj->cObjGetSingle($hF_conf, $conf['hiddenFields.'][$hF_key . '.'], 'hiddenfields');
                 if ((string) $hF_value !== '' && GeneralUtility::inList('recipient_copy,recipient', $hF_key)) {
                     if ($GLOBALS['TYPO3_CONF_VARS']['FE']['secureFormmail']) {
                         continue;
                     }
                     $hF_value = \TYPO3\CMS\Compatibility6\Utility\FormUtility::codeString($hF_value);
                 }
                 $hiddenfields .= '<input type="hidden" name="' . $hF_key . '" value="' . htmlspecialchars($hF_value) . '" />';
             }
         }
     }
     // Wrap all hidden fields in a div tag (see http://forge.typo3.org/issues/14491)
     $hiddenfields = isset($conf['hiddenFields.']['stdWrap.']) ? $this->cObj->stdWrap($hiddenfields, $conf['hiddenFields.']['stdWrap.']) : '<div style="display:none;">' . $hiddenfields . '</div>';
     if ($conf['REQ']) {
         $goodMess = isset($conf['goodMess.']) ? $this->cObj->stdWrap($conf['goodMess'], $conf['goodMess.']) : $conf['goodMess'];
         $badMess = isset($conf['badMess.']) ? $this->cObj->stdWrap($conf['badMess'], $conf['badMess.']) : $conf['badMess'];
         $emailMess = isset($conf['emailMess.']) ? $this->cObj->stdWrap($conf['emailMess'], $conf['emailMess.']) : $conf['emailMess'];
         $validateForm = ' onsubmit="return validateForm(' . GeneralUtility::quoteJSvalue($formName) . ',' . GeneralUtility::quoteJSvalue(implode(',', $fieldlist)) . ',' . GeneralUtility::quoteJSvalue($goodMess) . ',' . GeneralUtility::quoteJSvalue($badMess) . ',' . GeneralUtility::quoteJSvalue($emailMess) . ')"';
         $GLOBALS['TSFE']->additionalHeaderData['JSFormValidate'] = '<script type="text/javascript" src="' . GeneralUtility::createVersionNumberedFilename($GLOBALS['TSFE']->absRefPrefix . 'typo3/sysext/compatibility6/Resources/Public/JavaScript/jsfunc.validateform.js') . '"></script>';
     } else {
         $validateForm = '';
     }
     // Create form tag:
     $theTarget = $theRedirect ? $LD['target'] : $LD_A['target'];
     $method = isset($conf['method.']) ? $this->cObj->stdWrap($conf['method'], $conf['method.']) : $conf['method'];
     $content = array('<form' . ' action="' . htmlspecialchars($action) . '"' . ' id="' . $formName . '"' . ($xhtmlStrict ? '' : ' name="' . $formName . '"') . ' enctype="multipart/form-data"' . ' method="' . ($method ? $method : 'post') . '"' . ($theTarget ? ' target="' . $theTarget . '"' : '') . $validateForm . '>', $hiddenfields . $content, '</form>');
     $arrayReturnMode = isset($conf['arrayReturnMode.']) ? $this->cObj->stdWrap($conf['arrayReturnMode'], $conf['arrayReturnMode.']) : $conf['arrayReturnMode'];
     if ($arrayReturnMode) {
         $content['validateForm'] = $validateForm;
         $content['formname'] = $formName;
         return $content;
     } else {
         return implode('', $content);
     }
 }
Example #20
0
 /**
  * Retrieves JavaScript code (header part) for editor
  *
  * @param \TYPO3\CMS\Backend\Template\DocumentTemplate $doc
  * @return string JavaScript code
  */
 public function getJavascriptCode($doc)
 {
     $content = '';
     if ($this->isEnabled()) {
         $path_t3e = \t3lib_extmgm::extRelPath('t3editor');
         $path_codemirror = 'contrib/codemirror/js/';
         // Include needed javascript-frameworks
         $pageRenderer = $doc->getPageRenderer();
         /** @var $pageRenderer \TYPO3\CMS\Core\Page\PageRenderer */
         $pageRenderer->loadPrototype();
         $pageRenderer->loadScriptaculous();
         // Include editor-css
         $content .= '<link href="' . \TYPO3\CMS\Core\Utility\GeneralUtility::createVersionNumberedFilename($GLOBALS['BACK_PATH'] . \t3lib_extmgm::extRelPath('t3editor') . 'res/css/t3editor.css') . '" type="text/css" rel="stylesheet" />';
         // Include editor-js-lib
         $doc->loadJavascriptLib($path_codemirror . 'codemirror.js');
         $doc->loadJavascriptLib($path_t3e . 'res/jslib/t3editor.js');
         $content .= \TYPO3\CMS\Core\Utility\GeneralUtility::wrapJS('T3editor = T3editor || {};' . 'T3editor.lang = ' . json_encode($this->getJavaScriptLabels()) . ';' . LF . 'T3editor.PATH_t3e = "' . $GLOBALS['BACK_PATH'] . $path_t3e . '"; ' . LF . 'T3editor.PATH_codemirror = "' . $GLOBALS['BACK_PATH'] . $path_codemirror . '"; ' . LF . 'T3editor.URL_typo3 = "' . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir) . '"; ' . LF . 'T3editor.template = ' . $this->getPreparedTemplate() . ';' . LF . 'T3editor.ajaxSavetype = "' . $this->ajaxSaveType . '";' . LF);
         $content .= $this->getModeSpecificJavascriptCode();
     }
     return $content;
 }
 /**
  * Adds the stylesheets necessary for the slider
  *
  */
 protected function loadStylesheets()
 {
     if ($this->solrConfiguration['cssFiles.']['ui'] && !$GLOBALS['TSFE']->additionalHeaderData['tx_solr-uiCss']) {
         $cssFile = GeneralUtility::createVersionNumberedFilename($GLOBALS['TSFE']->tmpl->getFileName($this->solrConfiguration['cssFiles.']['ui']));
         $GLOBALS['TSFE']->additionalHeaderData['tx_solr-uiCss'] = '<link href="' . $cssFile . '" rel="stylesheet" type="text/css" media="all" />';
     }
 }
 /**
  * Loads a file by its key as defined in plugin.tx_solr.javascriptFiles.
  *
  * @param string $fileKey Key of the file to load.
  */
 public function loadFile($fileKey)
 {
     if (!array_key_exists($fileKey, self::$files)) {
         $typoScriptPath = 'plugin.tx_solr.javascriptFiles.' . $fileKey;
         $fileReference = Tx_Solr_Util::getTypoScriptValue($typoScriptPath);
         if (!empty($fileReference)) {
             self::$files[$fileKey] = array('addedToPage' => FALSE, 'file' => GeneralUtility::createVersionNumberedFilename($GLOBALS['TSFE']->tmpl->getFileName($fileReference)));
         }
     }
 }