/** * Render a share button * * @param boolean $loadJs * @return string */ public function render($loadJs = TRUE) { if (!empty($this->arguments['type'])) { $this->tag->addAttribute('data-type', $this->arguments['type']); $this->tag->removeAttribute('type'); } else { $this->tag->addAttribute('data-type', 'button_count'); } $shareUrl = empty($this->arguments['shareurl']) ? \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL') : $this->arguments['shareurl']; $this->tag->addAttribute('data-href', $shareUrl); $this->tag->removeAttribute('shareurl'); $this->tag->addAttribute('class', 'fb-share-button'); $this->tag->setContent(' '); $code = $this->tag->render(); if ($loadJs) { $code .= '<div id="fb-root"></div> <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/de_DE/sdk.js"; fjs.parentNode.insertBefore(js, fjs); }(document, \'script\', \'facebook-jssdk\'));</script>'; } // Social interaction Google Analytics if ($this->pluginSettingsService->getByPath('analytics.social.facebookShare') == 1) { $code .= \TYPO3\CMS\Core\Utility\GeneralUtility::wrapJS("\n\t\t\t\tFB.Event.subscribe('message.send', function(targetUrl) {\n\t\t\t\t _gaq.push(['_trackSocial', 'facebook', 'send', targetUrl]);\n\t\t\t\t});\n\t\t\t"); } return $code; }
/** * Render the facebook like viewhelper * * @return string */ public function render() { $code = ''; $url = !empty($this->arguments['href']) ? $this->arguments['href'] : \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'); // absolute urls are needed $this->tag->addAttribute('href', Tx_News_Utility_Url::prependDomain($url)); $this->tag->forceClosingTag(TRUE); // -1 means no JS if ($this->arguments['javaScript'] != '-1') { if (empty($this->arguments['javaScript'])) { $tsSettings = $this->pluginSettingsService->getSettings(); $locale = !empty($tsSettings['facebookLocale']) && strlen($tsSettings['facebookLocale']) <= 5 ? $tsSettings['facebookLocale'] : 'en_US'; $code = '<script src="https://connect.facebook.net/' . $locale . '/all.js#xfbml=1"></script>'; // Social interaction Google Analytics if ($this->pluginSettingsService->getByPath('analytics.social.facebookLike') == 1) { $code .= \TYPO3\CMS\Core\Utility\GeneralUtility::wrapJS("\n\t\t\t\t\t\tFB.Event.subscribe('edge.create', function(targetUrl) {\n\t\t\t\t\t\t \t_gaq.push(['_trackSocial', 'facebook', 'like', targetUrl]);\n\t\t\t\t\t\t});\n\t\t\t\t\t\tFB.Event.subscribe('edge.remove', function(targetUrl) {\n\t\t\t\t\t\t _gaq.push(['_trackSocial', 'facebook', 'unlike', targetUrl]);\n\t\t\t\t\t\t});\n\t\t\t\t\t"); } } else { $code = '<script src="' . htmlspecialchars($this->arguments['javaScript']) . '"></script>'; } } // seems as if a div with id fb-root is needed this is just a dirty // workaround to make things work again Perhaps we should // use the iframe variation. $code .= '<div id="fb-root"></div>' . $this->tag->render(); return $code; }
/** * Main function. * Creates the header code in XHTML, the JavaScript, then the frameset for the two frames. * * @return void */ public function main() { // Setting GPvars: $mode = GeneralUtility::_GP('mode'); $bparams = GeneralUtility::_GP('bparams'); $moduleUrl = BackendUtility::getModuleUrl('wizard_element_browser') . '&mode='; $documentTemplate = $this->getDocumentTemplate(); $documentTemplate->JScode = GeneralUtility::wrapJS(' function closing() { // close(); } function setParams(mode,params) { // parent.content.location.href = ' . GeneralUtility::quoteJSvalue($moduleUrl) . '+mode+"&bparams="+params; } if (!window.opener) { alert("ERROR: Sorry, no link to main window... Closing"); close(); } '); // build the header part $documentTemplate->startPage($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:TYPO3_Element_Browser')); // URL for the inner main frame: $url = $moduleUrl . rawurlencode($mode) . '&bparams=' . rawurlencode($bparams); // Create the frameset for the window // Formerly there were a ' onunload="closing();"' in the <frameset> tag - but it failed on Safari browser on Mac unless the handler was "onUnload" $this->content = $this->getPageRenderer()->render(PageRenderer::PART_HEADER) . '<frameset rows="*,1" framespacing="0" frameborder="0" border="0"> <frame name="content" src="' . htmlspecialchars($url) . '" marginwidth="0" marginheight="0" frameborder="0" scrolling="auto" noresize="noresize" /> <frame name="menu" src="' . htmlspecialchars(BackendUtility::getModuleUrl('dummy')) . '" marginwidth="0" marginheight="0" frameborder="0" scrolling="no" noresize="noresize" /> </frameset> </html> '; }
/** * JavaScript code used for input-field evaluation. * * Example use: * * $msg .= 'Distribution time (hh:mm dd-mm-yy):<br /><input type="text" name="send_mail_datetime_hr"' * . ' onchange="typo3form.fieldGet(\'send_mail_datetime\', \'datetime\', \'\', 0,0);"' * . $this->getTBE()->formWidth(20) . ' /><input type="hidden" value="' . $GLOBALS['EXEC_TIME'] * . '" name="send_mail_datetime" /><br />'; * $this->extJSCODE .= 'typo3form.fieldSet("send_mail_datetime", "datetime", "", 0,0);'; * * ... and then include the result of this function after the form * * @param string $formname The identification of the form on the page. * @param boolean $update Just extend/update existing settings, e.g. for AJAX call * @return string A section with JavaScript - if $update is FALSE, embedded in <script></script> * @todo Define visibility */ public function JSbottom($formname = 'forms[0]', $update = FALSE) { $jsFile = array(); $elements = array(); $out = ''; // Required: foreach ($this->requiredFields as $itemImgName => $itemName) { $match = array(); if (preg_match('/^(.+)\\[((\\w|\\d|_)+)\\]$/', $itemName, $match)) { $record = $match[1]; $field = $match[2]; $elements[$record][$field]['required'] = 1; $elements[$record][$field]['requiredImg'] = $itemImgName; if (isset($this->requiredAdditional[$itemName]) && is_array($this->requiredAdditional[$itemName])) { $elements[$record][$field]['additional'] = $this->requiredAdditional[$itemName]; } } } // Range: foreach ($this->requiredElements as $itemName => $range) { if (preg_match('/^(.+)\\[((\\w|\\d|_)+)\\]$/', $itemName, $match)) { $record = $match[1]; $field = $match[2]; $elements[$record][$field]['range'] = array($range[0], $range[1]); $elements[$record][$field]['rangeImg'] = $range['imgName']; } } $this->TBE_EDITOR_fieldChanged_func = 'TBE_EDITOR.fieldChanged_fName(fName,formObj[fName+"_list"]);'; if (!$update) { if ($this->loadMD5_JS) { $this->loadJavascriptLib('sysext/backend/Resources/Public/JavaScript/md5.js'); } $pageRenderer = $this->getPageRenderer(); // load the main module for FormEngine with all important JS functions $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/FormEngine'); $pageRenderer->loadPrototype(); $pageRenderer->loadJquery(); $pageRenderer->loadExtJS(); // Make textareas resizable and flexible $beUserAuth = $this->getBackendUserAuthentication(); if (!($beUserAuth->uc['resizeTextareas'] == '0' && $beUserAuth->uc['resizeTextareas_Flexible'] == '0')) { $pageRenderer->addCssFile($this->backPath . 'js/extjs/ux/resize.css'); $this->loadJavascriptLib('js/extjs/ux/ext.resizable.js'); } $resizableSettings = array('textareaMaxHeight' => $beUserAuth->uc['resizeTextareas_MaxHeight'] > 0 ? $beUserAuth->uc['resizeTextareas_MaxHeight'] : '600', 'textareaFlexible' => !$beUserAuth->uc['resizeTextareas_Flexible'] == '0', 'textareaResize' => !$beUserAuth->uc['resizeTextareas'] == '0'); $pageRenderer->addInlineSettingArray('', $resizableSettings); $this->loadJavascriptLib('sysext/backend/Resources/Public/JavaScript/jsfunc.evalfield.js'); $this->loadJavascriptLib('sysext/backend/Resources/Public/JavaScript/jsfunc.tbe_editor.js'); // support placeholders for IE9 and lower if ($this->clientInfo['BROWSER'] == 'msie' && $this->clientInfo['VERSION'] <= 9) { $this->loadJavascriptLib('contrib/placeholdersjs/placeholders.jquery.min.js'); } // Needed for tceform manipulation (date picker) $typo3Settings = array('datePickerUSmode' => $GLOBALS['TYPO3_CONF_VARS']['SYS']['USdateFormat'] ? 1 : 0, 'dateFormat' => array('j-n-Y', 'G:i j-n-Y'), 'dateFormatUS' => array('n-j-Y', 'G:i n-j-Y')); $pageRenderer->addInlineSettingArray('', $typo3Settings); $this->loadJavascriptLib('js/extjs/ux/Ext.ux.DateTimePicker.js'); $this->loadJavascriptLib('sysext/backend/Resources/Public/JavaScript/tceforms.js'); // If IRRE fields were processed, add the JavaScript functions: if ($this->inline->inlineCount) { $pageRenderer->loadScriptaculous(); // We want to load jQuery-ui inside our js. Enable this using requirejs. $pageRenderer->loadRequireJs(); $this->loadJavascriptLib('sysext/backend/Resources/Public/JavaScript/jsfunc.inline.js'); $out .= ' inline.setPrependFormFieldNames("' . $this->inline->prependNaming . '"); inline.setNoTitleString("' . addslashes(BackendUtility::getNoRecordTitle(TRUE)) . '"); '; // Always include JS functions for Suggest fields as we don't know what will come $this->loadJavascriptLib('sysext/backend/Resources/Public/JavaScript/jsfunc.tceforms_suggest.js'); $this->loadJavascriptLib('sysext/backend/Resources/Public/JavaScript/jsfunc.tceforms_selectboxfilter.js'); } else { // If Suggest fields were processed, add the JS functions if ($this->suggest->suggestCount > 0) { $pageRenderer->loadScriptaculous(); $this->loadJavascriptLib('sysext/backend/Resources/Public/JavaScript/jsfunc.tceforms_suggest.js'); } if ($this->multiSelectFilterCount > 0) { $pageRenderer->loadScriptaculous(); $this->loadJavascriptLib('sysext/backend/Resources/Public/JavaScript/jsfunc.tceforms_selectboxfilter.js'); } } // Toggle icons: $toggleIcon_open = IconUtility::getSpriteIcon('actions-move-down', array('title' => 'Open')); $toggleIcon_close = IconUtility::getSpriteIcon('actions-move-right', array('title' => 'Close')); $out .= ' function getOuterHTML(idTagPrefix) { // Function getting the outerHTML of an element with id var str=($(idTagPrefix).inspect()+$(idTagPrefix).innerHTML+"</"+$(idTagPrefix).tagName.toLowerCase()+">"); return str; } function flexFormToggle(id) { // Toggling flexform elements on/off: Element.toggle(""+id+"-content"); if (Element.visible(id+"-content")) { $(id+"-toggle").update(\'' . $toggleIcon_open . '\'); $(id+"-toggleClosed").value = 0; } else { $(id+"-toggle").update(\'' . $toggleIcon_close . '\'); $(id+"-toggleClosed").value = 1; } var previewContent = ""; var children = $(id+"-content").getElementsByTagName("input"); for (var i = 0, length = children.length; i < length; i++) { if (children[i].type=="text" && children[i].value) previewContent+= (previewContent?" / ":"")+children[i].value; } if (previewContent.length>80) { previewContent = previewContent.substring(0,67)+"..."; } $(id+"-preview").update(previewContent); } function flexFormToggleSubs(id) { // Toggling sub flexform elements on/off: var descendants = $(id).immediateDescendants(); var isOpen=0; var isClosed=0; // Traverse and find how many are open or closed: for (var i = 0, length = descendants.length; i < length; i++) { if (descendants[i].id) { if (Element.visible(descendants[i].id+"-content")) {isOpen++;} else {isClosed++;} } } // Traverse and toggle for (var i = 0, length = descendants.length; i < length; i++) { if (descendants[i].id) { if (isOpen!=0 && isClosed!=0) { if (Element.visible(descendants[i].id+"-content")) {flexFormToggle(descendants[i].id);} } else { flexFormToggle(descendants[i].id); } } } } function flexFormSortable(id) { // Create sortables for flexform sections Position.includeScrollOffsets = true; Sortable.create(id, {tag:\'div\',constraint: false, onChange:function(){ setActionStatus(id); } }); } function setActionStatus(id) { // Updates the "action"-status for a section. This is used to move and delete elements. var descendants = $(id).immediateDescendants(); // Traverse and find how many are open or closed: for (var i = 0, length = descendants.length; i < length; i++) { if (descendants[i].id) { $(descendants[i].id+"-action").value = descendants[i].visible() ? i : "DELETE"; } } } TBE_EDITOR.images.req.src = "' . IconUtility::skinImg($this->backPath, 'gfx/required_h.gif', '', 1) . '"; TBE_EDITOR.images.cm.src = "' . IconUtility::skinImg($this->backPath, 'gfx/content_client.gif', '', 1) . '"; TBE_EDITOR.images.sel.src = "' . IconUtility::skinImg($this->backPath, 'gfx/content_selected.gif', '', 1) . '"; TBE_EDITOR.images.clear.src = "' . $this->backPath . 'clear.gif"; TBE_EDITOR.auth_timeout_field = ' . (int) $beUserAuth->auth_timeout_field . '; TBE_EDITOR.formname = "' . $formname . '"; TBE_EDITOR.formnameUENC = "' . rawurlencode($formname) . '"; TBE_EDITOR.backPath = "' . addslashes($this->backPath) . '"; TBE_EDITOR.prependFormFieldNames = "' . $this->prependFormFieldNames . '"; TBE_EDITOR.prependFormFieldNamesUENC = "' . rawurlencode($this->prependFormFieldNames) . '"; TBE_EDITOR.prependFormFieldNamesCnt = ' . substr_count($this->prependFormFieldNames, '[') . '; TBE_EDITOR.isPalettedoc = ' . ($this->isPalettedoc ? addslashes($this->isPalettedoc) : 'null') . '; TBE_EDITOR.doSaveFieldName = "' . ($this->doSaveFieldName ? addslashes($this->doSaveFieldName) : '') . '"; TBE_EDITOR.labels.fieldsChanged = ' . GeneralUtility::quoteJSvalue($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.fieldsChanged')) . '; TBE_EDITOR.labels.fieldsMissing = ' . GeneralUtility::quoteJSvalue($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.fieldsMissing')) . '; TBE_EDITOR.labels.refresh_login = '******'m_refresh_login')) . '; TBE_EDITOR.labels.onChangeAlert = ' . GeneralUtility::quoteJSvalue($this->getLL('m_onChangeAlert')) . '; evalFunc.USmode = ' . ($GLOBALS['TYPO3_CONF_VARS']['SYS']['USdateFormat'] ? '1' : '0') . '; TBE_EDITOR.backend_interface = "' . $beUserAuth->uc['interfaceSetup'] . '"; TBE_EDITOR.customEvalFunctions = {}; '; } // Add JS required for inline fields if (count($this->inline->inlineData)) { $out .= ' inline.addToDataArray(' . json_encode($this->inline->inlineData) . '); '; } // Registered nested elements for tabs or inline levels: if (count($this->requiredNested)) { $out .= ' TBE_EDITOR.addNested(' . json_encode($this->requiredNested) . '); '; } // Elements which are required or have a range definition: if (count($elements)) { $out .= ' TBE_EDITOR.addElements(' . json_encode($elements) . '); TBE_EDITOR.initRequired(); '; } // $this->additionalJS_submit: if ($this->additionalJS_submit) { $additionalJS_submit = implode('', $this->additionalJS_submit); $additionalJS_submit = str_replace(array(CR, LF), '', $additionalJS_submit); $out .= ' TBE_EDITOR.addActionChecks("submit", "' . addslashes($additionalJS_submit) . '"); '; } $out .= LF . implode(LF, $this->additionalJS_post) . LF . $this->extJSCODE; $out .= ' TBE_EDITOR.loginRefreshed(); '; // Regular direct output: if (!$update) { $spacer = LF . TAB; $out = $spacer . implode($spacer, $jsFile) . GeneralUtility::wrapJS($out); } return $out; }
/** * Get mode specific JavaScript code * * @return string */ public function getModeSpecificJavascriptCode() { if (empty($this->mode)) { return ''; } $path_t3e = $GLOBALS['BACK_PATH'] . \t3lib_extmgm::extRelPath('t3editor'); $content = ''; if ($this->mode === self::MODE_TYPOSCRIPT) { $content .= '<script type="text/javascript" src="' . $path_t3e . 'res/jslib/ts_codecompletion/tsref.js' . '"></script>'; $content .= '<script type="text/javascript" src="' . $path_t3e . 'res/jslib/ts_codecompletion/completionresult.js' . '"></script>'; $content .= '<script type="text/javascript" src="' . $path_t3e . 'res/jslib/ts_codecompletion/tsparser.js' . '"></script>'; $content .= '<script type="text/javascript" src="' . $path_t3e . 'res/jslib/ts_codecompletion/tscodecompletion.js' . '"></script>'; } $content .= \TYPO3\CMS\Core\Utility\GeneralUtility::wrapJS('T3editor.parserfile = ' . $this->getParserfileByMode($this->mode) . ';' . LF . 'T3editor.stylesheet = ' . $this->getStylesheetByMode($this->mode) . ';'); return $content; }
/** * Initialisation (additionalParameters is an empty array) * * @param tx_rtehtmlarea_browse_links $parentObject Parent object * @param array $additionalParameters Parameter * * @return void */ public function init($parentObject, $additionalParameters) { $this->pObj = $parentObject; // initialize the tree $this->initTree(); // add js // has to be added as script tags to the body since parentObject // is not passed by reference first we go from html path to typo3 path $linkToTreeJs = '/' . TYPO3_mainDir . 'js/tree.js'; $this->script = '<script src="' . $linkToTreeJs . '" type="text/javascript"></script>'; $this->script .= GeneralUtility::wrapJS(' Tree.ajaxID = "Tx_Commerce_Hook_BrowselinksHooks::ajaxExpandCollapse"; '); if ($parentObject->RTEtsConfigParams) { $this->script .= GeneralUtility::wrapJS(' /** * needed because link_folder contains the side domain lately */ function link_commerce(theLink) { if (document.ltargetform.anchor_title) browse_links_setTitle(document.ltargetform.anchor_title.value); if (document.ltargetform.anchor_class) browse_links_setClass(document.ltargetform.anchor_class.value); if (document.ltargetform.ltarget) browse_links_setTarget(document.ltargetform.ltarget.value); if (document.ltargetform.lrel) browse_links_setAdditionalValue("rel", document.ltargetform.lrel.value); browse_links_setAdditionalValue("data-htmlarea-external", ""); plugin.createLink(theLink, cur_target, cur_class, cur_title, additionalValues); return false; } '); } else { $this->script .= GeneralUtility::wrapJS(' function link_commerce(theLink) { updateValueInMainForm(theLink); close(); return false; } '); } }
/** * Render start page with \TYPO3\CMS\Backend\Template\DocumentTemplate and pageTitle * * @return string * @see \TYPO3\CMS\Backend\Template\DocumentTemplate * @see \TYPO3\CMS\Core\Page\PageRenderer */ public function render() { $pageTitle = $this->arguments['pageTitle']; $enableClickMenu = $this->arguments['enableClickMenu']; $loadExtJs = $this->arguments['loadExtJs']; $loadExtJsTheme = $this->arguments['loadExtJsTheme']; $enableExtJsDebug = $this->arguments['enableExtJsDebug']; $loadJQuery = $this->arguments['loadJQuery']; $includeCssFiles = $this->arguments['includeCssFiles']; $includeJsFiles = $this->arguments['includeJsFiles']; $addJsInlineLabels = $this->arguments['addJsInlineLabels']; $includeRequireJsModules = $this->arguments['includeRequireJsModules']; $jQueryNamespace = $this->arguments['jQueryNamespace']; $pageRenderer = $this->getPageRenderer(); $doc = $this->getDocInstance(); $doc->JScode .= GeneralUtility::wrapJS($doc->redirectUrls()); // Load various standard libraries if ($enableClickMenu) { $pageRenderer->loadJquery(); $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/ClickMenu'); } if ($loadExtJs) { $pageRenderer->loadExtJS(true, $loadExtJsTheme); if ($enableExtJsDebug) { $pageRenderer->enableExtJsDebug(); } } if ($loadJQuery) { $jQueryNamespace = $jQueryNamespace ?: PageRenderer::JQUERY_NAMESPACE_DEFAULT; $pageRenderer->loadJquery(null, null, $jQueryNamespace); } // Include custom CSS and JS files if (is_array($includeCssFiles) && count($includeCssFiles) > 0) { foreach ($includeCssFiles as $addCssFile) { $pageRenderer->addCssFile($addCssFile); } } if (is_array($includeJsFiles) && count($includeJsFiles) > 0) { foreach ($includeJsFiles as $addJsFile) { $pageRenderer->addJsFile($addJsFile); } } if (is_array($includeRequireJsModules) && count($includeRequireJsModules) > 0) { foreach ($includeRequireJsModules as $addRequireJsFile) { $pageRenderer->loadRequireJsModule($addRequireJsFile); } } // Add inline language labels if (is_array($addJsInlineLabels) && count($addJsInlineLabels) > 0) { $extensionKey = $this->controllerContext->getRequest()->getControllerExtensionKey(); foreach ($addJsInlineLabels as $key) { $label = LocalizationUtility::translate($key, $extensionKey); $pageRenderer->addInlineLanguageLabel($key, $label); } } // Render the content and return it $output = $this->renderChildren(); $output = $doc->startPage($pageTitle) . $output; $output .= $doc->endPage(); return $output; }
/** * Renders the review module for a single page. This is used within the * workspace-preview frame. * * @return void */ public function singleIndexAction() { $wsService = GeneralUtility::makeInstance(WorkspaceService::class); $wsList = $wsService->getAvailableWorkspaces(); $activeWorkspace = $this->getBackendUser()->workspace; $wsCur = [$activeWorkspace => true]; $wsList = array_intersect_key($wsList, $wsCur); $backendDomain = GeneralUtility::getIndpEnv('TYPO3_HOST_ONLY'); $this->view->assignMultiple(['pageUid' => (int) GeneralUtility::_GP('id'), 'showGrid' => true, 'workspaceList' => $this->prepareWorkspaceTabs($wsList, $activeWorkspace, false), 'activeWorkspaceUid' => $activeWorkspace, 'backendDomain' => $backendDomain]); // Setting the document.domain early before JavScript // libraries are loaded, try to access top frame reference // and possibly run into some CORS issue $this->pageRenderer->setMetaCharsetTag($this->pageRenderer->getMetaCharsetTag() . LF . GeneralUtility::wrapJS('document.domain = ' . GeneralUtility::quoteJSvalue($backendDomain) . ';')); $this->pageRenderer->addInlineSetting('Workspaces', 'singleView', '1'); }
/** * Renders the review module for a single page. This is used within the * workspace-preview frame. * * @return void */ public function singleIndexAction() { $wsService = GeneralUtility::makeInstance(\TYPO3\CMS\Workspaces\Service\WorkspaceService::class); $wsList = $wsService->getAvailableWorkspaces(); $activeWorkspace = $GLOBALS['BE_USER']->workspace; $wsCur = array($activeWorkspace => true); $wsList = array_intersect_key($wsList, $wsCur); $backendDomain = GeneralUtility::getIndpEnv('TYPO3_HOST_ONLY'); $this->view->assign('pageUid', GeneralUtility::_GP('id')); $this->view->assign('showGrid', true); $this->view->assign('showAllWorkspaceTab', false); $this->view->assign('workspaceList', $wsList); $this->view->assign('backendDomain', $backendDomain); // Setting the document.domain early before JavScript // libraries are loaded, try to access top frame reference // and possibly run into some CORS issue $this->pageRenderer->setMetaCharsetTag($this->pageRenderer->getMetaCharsetTag() . LF . GeneralUtility::wrapJS('document.domain = ' . GeneralUtility::quoteJSvalue($backendDomain) . ';')); $this->pageRenderer->addInlineSetting('Workspaces', 'singleView', '1'); }
/** * @param string $src * @param string $type * @param boolean $compress * @param boolean $forceOnTop * @param string $allWrap * @param boolean $excludeFromConcatenation * @param string $section * @param boolean $preventMarkupUpdateOnAjaxLoad * @param boolean $moveToExternalFile * @param boolean $noCache * @param string $name * * @return string */ public function render($src = "", $type = 'text/javascript', $compress = TRUE, $forceOnTop = FALSE, $allWrap = '', $excludeFromConcatenation = FALSE, $section = 'footer', $preventMarkupUpdateOnAjaxLoad = false, $moveToExternalFile = false, $noCache = false, $name = '') { $content = $this->renderChildren(); if ($this->ajaxDispatcher->getIsActive()) { if ($preventMarkupUpdateOnAjaxLoad) { $this->ajaxDispatcher->setPreventMarkupUpdateOnAjaxLoad(true); } // need to just echo the code in ajax call if (!$src) { if ($compress) { $content = $this->compressScript($content); } return \TYPO3\CMS\Core\Utility\GeneralUtility::wrapJS($content); } else { return '<script type="' . htmlspecialchars($type) . '" src="' . htmlspecialchars($src) . '"></script>'; } } else { if ($this->isCached()) { if ($noCache) { if ($src) { $content = '<script type="' . htmlspecialchars($type) . '" src="' . htmlspecialchars($src) . '"></script>'; } else { if ($compress) { $content = $this->compressScript($content); } $content = \TYPO3\CMS\Core\Utility\GeneralUtility::wrapJS($content); } $tslibFE = GeneralUtility::makeInstance('EssentialDots\\ExtbaseHijax\\Tslib\\FE\\Hook'); /* @var $tslibFE \EssentialDots\ExtbaseHijax\Tslib\FE\Hook */ if ($section == 'footer') { $tslibFE->addNonCacheableFooterCode($name ? $name : md5($content), $content); } else { $tslibFE->addNonCacheableHeaderCode($name ? $name : md5($content), $content); } return ''; } else { if (!$src && $moveToExternalFile) { $src = 'typo3temp' . DIRECTORY_SEPARATOR . 'extbase_hijax' . DIRECTORY_SEPARATOR . md5($content) . '.js'; \TYPO3\CMS\Core\Utility\GeneralUtility::writeFileToTypo3tempDir(PATH_site . $src, $content); if ($GLOBALS['TSFE']) { if ($GLOBALS['TSFE']->baseUrl) { $src = $GLOBALS['TSFE']->baseUrl . $src; } elseif ($GLOBALS['TSFE']->absRefPrefix) { $src = $GLOBALS['TSFE']->absRefPrefix . $src; } } } if (!$src) { if ($section == 'footer') { $this->pageRenderer->addJsFooterInlineCode($name ? $name : md5($content), $content, $compress, $forceOnTop); } else { $this->pageRenderer->addJsInlineCode($name ? $name : md5($content), $content, $compress, $forceOnTop); } } else { if ($section == 'footer') { $this->pageRenderer->addJsFooterFile($src, $type, $compress, $forceOnTop, $allWrap, $excludeFromConcatenation); } else { $this->pageRenderer->addJsFile($src, $type, $compress, $forceOnTop, $allWrap, $excludeFromConcatenation); } } } } else { // additionalFooterData not possible in USER_INT if (!$src) { $GLOBALS['TSFE']->additionalHeaderData[$name ? $name : md5($content)] = \TYPO3\CMS\Core\Utility\GeneralUtility::wrapJS($content); } else { $GLOBALS['TSFE']->additionalHeaderData[$name ? $name : md5($content)] = '<script type="' . htmlspecialchars($type) . '" src="' . htmlspecialchars($src) . '"></script>'; } } } return ''; }
/** * Get the form for extension configuration * * @param string $cat * @param array $theConstants * @param string $script * @param string $addFields * @param string $extKey * @param boolean Adds opening <form> tag to the ouput, if TRUE * @return string The form * @todo Define visibility */ public function ext_getForm($cat, $theConstants, $script = '', $addFields = '', $extKey = '', $addFormTag = TRUE) { $this->ext_makeHelpInformationForCategory($cat); $printFields = trim($this->ext_printFields($theConstants, $cat)); $content = ''; $content .= \TYPO3\CMS\Core\Utility\GeneralUtility::wrapJS(' function uFormUrl(aname) { document.' . $this->ext_CEformName . '.action = "' . \TYPO3\CMS\Core\Utility\GeneralUtility::linkThisScript() . '#"+aname; } '); if ($addFormTag) { $content .= '<form action="' . htmlspecialchars($script ? $script : \TYPO3\CMS\Core\Utility\GeneralUtility::linkThisScript()) . '" name="' . $this->ext_CEformName . '" method="post" enctype="' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'] . '">'; } $content .= $addFields; $content .= $printFields; $content .= '<input type="submit" name="submit" value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_tsfe.xml:update', TRUE) . '" id="configuration-submit-' . htmlspecialchars($extKey) . '" />'; $example = $this->ext_displayExample(); $content .= $example ? '<hr/>' . $example : ''; return $content; }
/** * JavaScript bottom code * * @param string $formname The identification of the form on the page. * @param bool $update Just extend/update existing settings, e.g. for AJAX call * @return string A section with JavaScript - if $update is FALSE, embedded in <script></script> */ public function JSbottom($formname = 'forms[0]', $update = FALSE) { $languageService = $this->getLanguageService(); $jsFile = array(); $out = ''; $this->TBE_EDITOR_fieldChanged_func = 'TBE_EDITOR.fieldChanged_fName(fName,formObj[fName+"_list"]);'; if (!$update) { if ($this->loadMD5_JS) { $this->loadJavascriptLib('sysext/backend/Resources/Public/JavaScript/md5.js'); } $pageRenderer = $this->getPageRenderer(); // load the main module for FormEngine with all important JS functions $this->requireJsModules['TYPO3/CMS/Backend/FormEngine'] = 'function(FormEngine) { FormEngine.setBrowserUrl(' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('browser')) . '); }'; foreach ($this->requireJsModules as $moduleName => $callbacks) { if (!is_array($callbacks)) { $callbacks = array($callbacks); } foreach ($callbacks as $callback) { $pageRenderer->loadRequireJsModule($moduleName, $callback); } } $pageRenderer->loadPrototype(); $pageRenderer->loadJquery(); $pageRenderer->loadExtJS(); $beUserAuth = $this->getBackendUserAuthentication(); // Make textareas resizable and flexible ("autogrow" in height) $textareaSettings = array('autosize' => (bool) $beUserAuth->uc['resizeTextareas_Flexible']); $pageRenderer->addInlineSettingArray('Textarea', $textareaSettings); $this->loadJavascriptLib('sysext/backend/Resources/Public/JavaScript/jsfunc.evalfield.js'); $this->loadJavascriptLib('sysext/backend/Resources/Public/JavaScript/jsfunc.tbe_editor.js'); $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/ValueSlider'); // Needed for FormEngine manipulation (date picker) $dateFormat = $GLOBALS['TYPO3_CONF_VARS']['SYS']['USdateFormat'] ? array('MM-DD-YYYY', 'HH:mm MM-DD-YYYY') : array('DD-MM-YYYY', 'HH:mm DD-MM-YYYY'); $pageRenderer->addInlineSetting('DateTimePicker', 'DateFormat', $dateFormat); // support placeholders for IE9 and lower $clientInfo = GeneralUtility::clientInfo(); if ($clientInfo['BROWSER'] == 'msie' && $clientInfo['VERSION'] <= 9) { $this->loadJavascriptLib('sysext/core/Resources/Public/JavaScript/Contrib/placeholders.jquery.min.js'); } // @todo: remove scriptaclous once suggest & flex form foo is moved to RequireJS, see #55575 $pageRenderer->loadScriptaculous(); $this->loadJavascriptLib('sysext/backend/Resources/Public/JavaScript/jsfunc.tceforms_suggest.js'); $pageRenderer->loadRequireJsModule('TYPO3/CMS/Filelist/FileListLocalisation'); $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/DragUploader'); $pageRenderer->addInlineLanguagelabelFile(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('lang') . 'locallang_core.xlf', 'file_upload'); // We want to load jQuery-ui inside our js. Enable this using requirejs. $this->loadJavascriptLib('sysext/backend/Resources/Public/JavaScript/jsfunc.inline.js'); $out .= ' inline.setNoTitleString("' . addslashes(BackendUtility::getNoRecordTitle(TRUE)) . '"); '; $out .= ' TBE_EDITOR.formname = "' . $formname . '"; TBE_EDITOR.formnameUENC = "' . rawurlencode($formname) . '"; TBE_EDITOR.backPath = ""; TBE_EDITOR.isPalettedoc = null; TBE_EDITOR.doSaveFieldName = "' . ($this->doSaveFieldName ? addslashes($this->doSaveFieldName) : '') . '"; TBE_EDITOR.labels.fieldsChanged = ' . GeneralUtility::quoteJSvalue($languageService->sL('LLL:EXT:lang/locallang_core.xlf:labels.fieldsChanged')) . '; TBE_EDITOR.labels.fieldsMissing = ' . GeneralUtility::quoteJSvalue($languageService->sL('LLL:EXT:lang/locallang_core.xlf:labels.fieldsMissing')) . '; TBE_EDITOR.labels.maxItemsAllowed = ' . GeneralUtility::quoteJSvalue($languageService->sL('LLL:EXT:lang/locallang_core.xlf:labels.maxItemsAllowed')) . '; TBE_EDITOR.labels.refresh_login = '******'LLL:EXT:lang/locallang_core.xlf:mess.refresh_login')) . '; TBE_EDITOR.labels.onChangeAlert = ' . GeneralUtility::quoteJSvalue($languageService->sL('LLL:EXT:lang/locallang_core.xlf:mess.onChangeAlert')) . '; TBE_EDITOR.labels.remainingCharacters = ' . GeneralUtility::quoteJSvalue($languageService->sL('LLL:EXT:lang/locallang_core.xlf:labels.remainingCharacters')) . '; evalFunc.USmode = ' . ($GLOBALS['TYPO3_CONF_VARS']['SYS']['USdateFormat'] ? '1' : '0') . '; TBE_EDITOR.customEvalFunctions = {}; '; } // Add JS required for inline fields if (!empty($this->inlineData)) { $out .= ' inline.addToDataArray(' . json_encode($this->inlineData) . '); '; } // $this->additionalJS_submit: if ($this->additionalJS_submit) { $additionalJS_submit = implode('', $this->additionalJS_submit); $additionalJS_submit = str_replace(array(CR, LF), '', $additionalJS_submit); $out .= ' TBE_EDITOR.addActionChecks("submit", "' . addslashes($additionalJS_submit) . '"); '; } $out .= LF . implode(LF, $this->additionalJS_post) . LF . $this->extJSCODE; // Regular direct output: if (!$update) { $spacer = LF . TAB; $out = $spacer . implode($spacer, $jsFile) . GeneralUtility::wrapJS($out); } return $out; }
/** * Output HTML to a popup window * * @param string html code * @param string (optional) name of the var holding the reference to the window, default is '_popup' * @param string (optional) window parameter string, default is 'width=1280,height=600,resizable,scrollbars=yes' * @param string (optional) url of the new window, keep empty to display your html code * @param string (optional) name of the window * @return bool true if popup was rendered, otherwise false * @author Fabrizio Branca <*****@*****.**> */ public static function outputToPopup($htmlCode, $varName = '_popup', $windowParams = 'width=1280,height=600,resizable,scrollbars=yes', $windowUrl = '', $windowName = '') { if (is_object($GLOBALS['TSFE'])) { $jscode = $varName . ' = window.open("' . $windowUrl . '","' . $windowName . '","' . $windowParams . '");' . chr(10); foreach (explode(chr(10), $htmlCode) as $line) { $line = strtr($line, array('"' => '\\"')); $jscode .= $varName . '.document.writeln("' . $line . '");' . chr(10); } $jscode .= $varName . '.document.close();' . chr(10); $GLOBALS['TSFE']->additionalHeaderData['popup' . $varName] .= GeneralUtility::wrapJS($jscode); return true; } else { return false; } }
/** * Add inline code to the HTML * * @param string $name * @param string $block * @param array $conf * @return void */ public static function addJsInlineCode($name, $block, $conf = array()) { if ($conf['jsinline']) { $GLOBALS['TSFE']->inlineJS['t3jquery.jsdata.' . $name] = $block; } elseif (T3jqueryUtility::getIntFromVersion(TYPO3_version) >= 4003000) { /** @var PageRenderer $pagerender */ $pagerender = $GLOBALS['TSFE']->getPageRenderer(); if ($conf['tofooter'] == 'footer') { $pagerender->addJsFooterInlineCode($name, $block, $conf['compress'], $conf['forceOnTop']); } else { $pagerender->addJsInlineCode($name, $block, $conf['compress'], $conf['forceOnTop']); } } else { if ($conf['compress']) { $block = GeneralUtility::minifyJavaScript($block); } if ($conf['tofooter'] == 'footer') { $GLOBALS['TSFE']->additionalFooterData['t3jquery.jsdata.' . $name] = GeneralUtility::wrapJS($block, TRUE); } else { $GLOBALS['TSFE']->additionalHeaderData['t3jquery.jsdata.' . $name] = GeneralUtility::wrapJS($block, TRUE); } } }
/** * Include all defined resources (JS / CSS) * * @return void */ function addResources() { if (class_exists(t3lib_utility_VersionNumber) && t3lib_utility_VersionNumber::convertVersionNumberToInteger(TYPO3_version) >= 4003000) { $pagerender = $GLOBALS['TSFE']->getPageRenderer(); } // Fix moveJsFromHeaderToFooter (add all scripts to the footer) if ($GLOBALS['TSFE']->config['config']['moveJsFromHeaderToFooter']) { $allJsInFooter = TRUE; } else { $allJsInFooter = FALSE; } // add all defined JS files if (count($this->jsFiles) > 0) { foreach ($this->jsFiles as $jsToLoad) { if (T3JQUERY === TRUE) { $conf = array('jsfile' => $jsToLoad, 'tofooter' => $this->conf['jsInFooter'] || $allJsInFooter, 'jsminify' => $this->conf['jsMinify']); tx_t3jquery::addJS('', $conf); } else { $file = $this->getPath($jsToLoad); if ($file) { if (class_exists(t3lib_utility_VersionNumber) && t3lib_utility_VersionNumber::convertVersionNumberToInteger(TYPO3_version) >= 4003000) { if ($this->conf['jsInFooter'] || $allJsInFooter) { $pagerender->addJsFooterFile($file, 'text/javascript', $this->conf['jsMinify']); } else { $pagerender->addJsFile($file, 'text/javascript', $this->conf['jsMinify']); } } else { $temp_file = '<script type="text/javascript" src="' . $file . '"></script>'; if ($this->conf['jsInFooter'] || $allJsInFooter) { $GLOBALS['TSFE']->additionalFooterData['jsFile_' . $this->extKey . '_' . $file] = $temp_file; } else { $GLOBALS['TSFE']->additionalHeaderData['jsFile_' . $this->extKey . '_' . $file] = $temp_file; } } } else { \TYPO3\CMS\Core\Utility\GeneralUtility::devLog("'{$jsToLoad}' does not exists!", $this->extKey, 2); } } } } // add all defined JS script if (count($this->js) > 0) { foreach ($this->js as $jsToPut) { $temp_js .= $jsToPut; } $conf = array(); $conf['jsdata'] = $temp_js; if (T3JQUERY === TRUE && class_exists(t3lib_utility_VersionNumber) && t3lib_utility_VersionNumber::convertVersionNumberToInteger($this->getExtensionVersion('t3jquery')) >= 1002000) { $conf['tofooter'] = $this->conf['jsInFooter'] || $allJsInFooter; $conf['jsminify'] = $this->conf['jsMinify']; $conf['jsinline'] = $this->conf['jsInline']; tx_t3jquery::addJS('', $conf); } else { // Add script only once $hash = md5($temp_js); if ($this->conf['jsInline']) { $GLOBALS['TSFE']->inlineJS[$hash] = $temp_js; } elseif (class_exists(t3lib_utility_VersionNumber) && t3lib_utility_VersionNumber::convertVersionNumberToInteger(TYPO3_version) >= 4003000) { if ($this->conf['jsInFooter'] || $allJsInFooter) { $pagerender->addJsFooterInlineCode($hash, $temp_js, $this->conf['jsMinify']); } else { $pagerender->addJsInlineCode($hash, $temp_js, $this->conf['jsMinify']); } } else { if ($this->conf['jsMinify']) { $temp_js = \TYPO3\CMS\Core\Utility\GeneralUtility::minifyJavaScript($temp_js); } if ($this->conf['jsInFooter'] || $allJsInFooter) { $GLOBALS['TSFE']->additionalFooterData['js_' . $this->extKey . '_' . $hash] = \TYPO3\CMS\Core\Utility\GeneralUtility::wrapJS($temp_js, TRUE); } else { $GLOBALS['TSFE']->additionalHeaderData['js_' . $this->extKey . '_' . $hash] = \TYPO3\CMS\Core\Utility\GeneralUtility::wrapJS($temp_js, TRUE); } } } } // add all defined CSS files if (count($this->cssFiles) > 0) { foreach ($this->cssFiles as $cssToLoad) { // Add script only once $file = $this->getPath($cssToLoad); if ($file) { if (class_exists(t3lib_utility_VersionNumber) && t3lib_utility_VersionNumber::convertVersionNumberToInteger(TYPO3_version) >= 4003000) { $pagerender->addCssFile($file, 'stylesheet', 'all', '', $this->conf['cssMinify']); } else { $GLOBALS['TSFE']->additionalHeaderData['cssFile_' . $this->extKey . '_' . $file] = '<link rel="stylesheet" type="text/css" href="' . $file . '" media="all" />' . chr(10); } } else { \TYPO3\CMS\Core\Utility\GeneralUtility::devLog("'{$cssToLoad}' does not exists!", $this->extKey, 2); } } } // add all defined CSS Script if (count($this->css) > 0) { foreach ($this->css as $cssToPut) { $temp_css .= $cssToPut; } $hash = md5($temp_css); if (class_exists(t3lib_utility_VersionNumber) && t3lib_utility_VersionNumber::convertVersionNumberToInteger(TYPO3_version) >= 4003000) { $pagerender->addCssInlineBlock($hash, $temp_css, $this->conf['cssMinify']); } else { // addCssInlineBlock $GLOBALS['TSFE']->additionalCSS['css_' . $this->extKey . '_' . $hash] .= $temp_css; } } }
/** * Opens a debug message inside a popup window * * @param mixed $debugVariable * @param string $header * @param string $group */ public static function debugInPopUpWindow($debugVariable, $header = 'Debug', $group = 'Debug') { $debugString = self::renderDump($debugVariable, sprintf('%s (%s)', $header, $group)); $script = ' (function debug() { var debugMessage = ' . GeneralUtility::quoteJSvalue($debugString) . ', header = ' . GeneralUtility::quoteJSvalue($header) . ', group = ' . GeneralUtility::quoteJSvalue($group) . ', browserWindow = function(debug, header, group) { var newWindow = window.open("", "TYPO3DebugWindow_" + group, "width=600,height=400,menubar=0,toolbar=1,status=0,scrollbars=1,resizable=1" ); if (newWindow.document.body.innerHTML) { newWindow.document.body.innerHTML = newWindow.document.body.innerHTML + "<hr />" + debugMessage; } else { newWindow.document.writeln( "<html><head><title>Debug: " + header + "(" + group + ")</title></head>" + "<body onload=\\"self.focus()\\">" + debugMessage + "</body></html>" ); } }; if (top && typeof top.TYPO3 !== "undefined" && typeof top.TYPO3.Modal !== "undefined") { top.TYPO3.Modal.show( "Debug: " + header + " (" + group + ")", debugMessage, top.TYPO3.Severity.notice ); } else { browserWindow(debugMessage, header, group); } })(); '; echo GeneralUtility::wrapJS($script); }
/** * @return void */ public function init() { $this->editorNo = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('editorNo'); $this->siteUrl = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL'); $this->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Template\DocumentTemplate::class); $this->doc->bodyTagAdditions = 'onload="Init();"'; $this->doc->form = ' <form action="" id="process" name="process" method="post"> <input type="hidden" name="processContent" value="" /> <input type="hidden" name="returnUrl" value="' . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REQUEST_URI')) . '" /> '; $JScode = ' var plugin = window.parent.RTEarea["' . $this->editorNo . '"].editor.getPlugin("UserElements"); var HTMLArea = window.parent.HTMLArea; var editor = plugin.editor; function Init() { }; function insertHTML(content,noHide) { plugin.restoreSelection(); editor.getSelection().insertHtml(content); if(!noHide) plugin.close(); }; function wrapHTML(wrap1,wrap2,noHide) { plugin.restoreSelection(); if(!editor.getSelection().isEmpty()) { editor.getSelection().surroundHtml(wrap1,wrap2); } else { alert(' . GeneralUtility::quoteJSvalue($GLOBALS['LANG']->getLL('noTextSelection')) . '); } if(!noHide) plugin.close(); }; function processSelection(script) { plugin.restoreSelection(); document.process.action = script; document.process.processContent.value = editor.getSelection().getHtml(); document.process.submit(); }; function jumpToUrl(URL) { var RTEtsConfigParams = "&RTEtsConfigParams=' . rawurlencode(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('RTEtsConfigParams')) . '"; var editorNo = "&editorNo=' . rawurlencode($this->editorNo) . '"; theLocation = URL+RTEtsConfigParams+editorNo; window.location.href = theLocation; } '; // unset the default jumpToUrl() function unset($this->doc->JScodeArray['jumpToUrl']); $this->doc->JScode = GeneralUtility::wrapJS($JScode); $this->modData = $GLOBALS['BE_USER']->getModuleData('user.php', 'ses'); if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('OC_key')) { $parts = explode('|', \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('OC_key')); $this->modData['openKeys'][$parts[1]] = $parts[0] == 'O' ? 1 : 0; $GLOBALS['BE_USER']->pushModuleData('user.php', $this->modData); } }
/** * JavaScript bottom code * * @param string $formname The identification of the form on the page. * @return string A section with JavaScript - if $update is FALSE, embedded in <script></script> */ protected function JSbottom($formname = 'forms[0]') { $languageService = $this->getLanguageService(); $jsFile = array(); // @todo: this is messy here - "additional hidden fields" should be handled elsewhere $html = implode(LF, $this->hiddenFieldAccum); $this->loadJavascriptLib('sysext/backend/Resources/Public/JavaScript/md5.js'); // load the main module for FormEngine with all important JS functions $this->requireJsModules['TYPO3/CMS/Backend/FormEngine'] = 'function(FormEngine) { FormEngine.setBrowserUrl(' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('wizard_element_browser')) . '); }'; $this->requireJsModules['TYPO3/CMS/Backend/FormEngineValidation'] = 'function(FormEngineValidation) { FormEngineValidation.setUsMode(' . ($GLOBALS['TYPO3_CONF_VARS']['SYS']['USdateFormat'] ? '1' : '0') . '); FormEngineValidation.registerReady(); }'; $pageRenderer = $this->getPageRenderer(); foreach ($this->requireJsModules as $moduleName => $callbacks) { if (!is_array($callbacks)) { $callbacks = array($callbacks); } foreach ($callbacks as $callback) { $pageRenderer->loadRequireJsModule($moduleName, $callback); } } $pageRenderer->loadJquery(); $pageRenderer->loadExtJS(); // Load tree stuff here $pageRenderer->addJsFile('sysext/backend/Resources/Public/JavaScript/tree.js'); $pageRenderer->addInlineLanguageLabelFile(ExtensionManagementUtility::extPath('lang') . 'locallang_csh_corebe.xlf', 'tcatree'); $pageRenderer->addJsFile('sysext/backend/Resources/Public/JavaScript/notifications.js'); if (ExtensionManagementUtility::isLoaded('rtehtmlarea')) { // This js addition is hackish ... it will always load this file even if not RTE // is added here. But this simplifies RTE initialization a lot and is thus kept for now. $pageRenderer->addJsFile('sysext/rtehtmlarea/Resources/Public/JavaScript/HTMLArea/NameSpace/NameSpace.js'); } $beUserAuth = $this->getBackendUserAuthentication(); // Make textareas resizable and flexible ("autogrow" in height) $textareaSettings = array('autosize' => (bool) $beUserAuth->uc['resizeTextareas_Flexible']); $pageRenderer->addInlineSettingArray('Textarea', $textareaSettings); $this->loadJavascriptLib('sysext/backend/Resources/Public/JavaScript/jsfunc.tbe_editor.js'); $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/ValueSlider'); // Needed for FormEngine manipulation (date picker) $dateFormat = $GLOBALS['TYPO3_CONF_VARS']['SYS']['USdateFormat'] ? array('MM-DD-YYYY', 'HH:mm MM-DD-YYYY') : array('DD-MM-YYYY', 'HH:mm DD-MM-YYYY'); $pageRenderer->addInlineSetting('DateTimePicker', 'DateFormat', $dateFormat); // support placeholders for IE9 and lower $clientInfo = GeneralUtility::clientInfo(); if ($clientInfo['BROWSER'] == 'msie' && $clientInfo['VERSION'] <= 9) { $this->loadJavascriptLib('sysext/core/Resources/Public/JavaScript/Contrib/placeholders.jquery.min.js'); } $pageRenderer->loadRequireJsModule('TYPO3/CMS/Filelist/FileListLocalisation'); $pageRenderer->addInlineLanguagelabelFile(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('lang') . 'locallang_core.xlf', 'file_upload'); // Load codemirror for T3Editor if (ExtensionManagementUtility::isLoaded('t3editor')) { $this->loadJavascriptLib('sysext/t3editor/Resources/Public/JavaScript/Contrib/codemirror/js/codemirror.js'); } // We want to load jQuery-ui inside our js. Enable this using requirejs. $this->loadJavascriptLib('sysext/backend/Resources/Public/JavaScript/jsfunc.inline.js'); $out = ' inline.setNoTitleString("' . addslashes(BackendUtility::getNoRecordTitle(true)) . '"); '; $out .= ' TBE_EDITOR.formname = "' . $formname . '"; TBE_EDITOR.formnameUENC = "' . rawurlencode($formname) . '"; TBE_EDITOR.backPath = ""; TBE_EDITOR.isPalettedoc = null; TBE_EDITOR.doSaveFieldName = "' . ($this->doSaveFieldName ? addslashes($this->doSaveFieldName) : '') . '"; TBE_EDITOR.labels.fieldsChanged = ' . GeneralUtility::quoteJSvalue($languageService->sL('LLL:EXT:lang/locallang_core.xlf:labels.fieldsChanged')) . '; TBE_EDITOR.labels.fieldsMissing = ' . GeneralUtility::quoteJSvalue($languageService->sL('LLL:EXT:lang/locallang_core.xlf:labels.fieldsMissing')) . '; TBE_EDITOR.labels.maxItemsAllowed = ' . GeneralUtility::quoteJSvalue($languageService->sL('LLL:EXT:lang/locallang_core.xlf:labels.maxItemsAllowed')) . '; TBE_EDITOR.labels.refresh_login = '******'LLL:EXT:lang/locallang_core.xlf:mess.refresh_login')) . '; TBE_EDITOR.labels.refreshRequired = {}; TBE_EDITOR.labels.refreshRequired.title = ' . GeneralUtility::quoteJSvalue($languageService->sL('LLL:EXT:lang/locallang_core.xlf:mess.refreshRequired.title')) . '; TBE_EDITOR.labels.refreshRequired.content = ' . GeneralUtility::quoteJSvalue($languageService->sL('LLL:EXT:lang/locallang_core.xlf:mess.refreshRequired.content')) . '; TBE_EDITOR.labels.remainingCharacters = ' . GeneralUtility::quoteJSvalue($languageService->sL('LLL:EXT:lang/locallang_core.xlf:labels.remainingCharacters')) . '; TBE_EDITOR.customEvalFunctions = {}; '; // Add JS required for inline fields if (!empty($this->inlineData)) { $out .= ' inline.addToDataArray(' . json_encode($this->inlineData) . '); '; } // $this->additionalJS_submit: if ($this->additionalJS_submit) { $additionalJS_submit = implode('', $this->additionalJS_submit); $additionalJS_submit = str_replace(array(CR, LF), '', $additionalJS_submit); $out .= ' TBE_EDITOR.addActionChecks("submit", "' . addslashes($additionalJS_submit) . '"); '; } $out .= LF . implode(LF, $this->additionalJS_post) . LF . $this->extJSCODE; $spacer = LF . TAB; $out = $html . $spacer . implode($spacer, $jsFile) . GeneralUtility::wrapJS($out); return $out; }
/** * Returns JS callback for the given action * * @param null $action * @param array $arguments * @param null $controller * @param null $extensionName * @param null $pluginName * @param string $format * @param string $section * @return string */ public function getAjaxFunction($action = NULL, array $arguments = array(), $controller = NULL, $extensionName = NULL, $pluginName = NULL, $format = '', $section = 'footer') { // current element needs to have additional logic... $this->hijaxEventDispatcher->setIsHijaxElement(true); $request = $this->mvcDispatcher->getCurrentRequest(); if ($request) { if ($action === NULL) { $action = $request->getControllerActionName(); } if ($controller === NULL) { $controller = $request->getControllerName(); } if ($extensionName === NULL) { $extensionName = $request->getControllerExtensionName(); } if ($pluginName === NULL && TYPO3_MODE === 'FE') { $pluginName = $this->extensionService->getPluginNameByAction($extensionName, $controller, $action); } if ($pluginName === NULL) { $pluginName = $request->getPluginName(); } } $settings = array('extension' => $extensionName, 'plugin' => $pluginName, 'controller' => $controller, 'format' => $format ? $format : 'html', 'action' => $action, 'arguments' => $arguments, 'settingsHash' => $this->mvcDispatcher->getCurrentListener() ? $this->mvcDispatcher->getCurrentListener()->getId() : '', 'namespace' => $extensionName && $pluginName ? $this->extensionService->getPluginNamespace($extensionName, $pluginName) : ''); $functionName = 'extbaseHijax_' . md5(serialize($settings)); $content = "; {$functionName}=function(settings, pendingElement, loaders) {"; foreach ($settings as $k => $v) { $content .= "if (typeof settings.{$k} == 'undefined') settings.{$k}=" . json_encode($v) . ";"; } $content .= "return jQuery.hijax(settings, pendingElement, loaders);};"; if ($this->isCached()) { if ($section == 'footer') { $this->pageRenderer->addJsFooterInlineCode(md5($content), $content, FALSE, TRUE); } else { $this->pageRenderer->addJsInlineCode(md5($content), $content, FALSE, TRUE); } } else { // additionalFooterData not possible in USER_INT $GLOBALS['TSFE']->additionalHeaderData[md5($content)] = \TYPO3\CMS\Core\Utility\GeneralUtility::wrapJS($content); } return $functionName; }
/** * Insert post rendering document style into already rendered content * This is needed for extobjbase * * @param string $content style-content to insert. * @return string content with inserted styles */ public function insertStylesAndJS($content) { $styles = LF . implode(LF, $this->inDocStylesArray); $content = str_replace('/*###POSTCSSMARKER###*/', $styles, $content); // Insert accumulated JS $jscode = $this->JScode . LF . GeneralUtility::wrapJS(implode(LF, $this->JScodeArray)); $content = str_replace('<!--###POSTJSMARKER###-->', $jscode, $content); return $content; }
/** * Render twitter viewhelper * * @return string */ public function render() { $code = ''; $this->tag->addAttribute('href', 'https://twitter.com/share'); $this->tag->addAttribute('class', !empty($this->arguments['class']) ? $this->arguments['class'] : 'twitter-share-button'); // rewrite tags as it seems that it is not possible to have tags with a '-'. $rewriteTags = array('datacount', 'datavia', 'datarelated', 'datatext', 'dataurl', 'datalang'); foreach ($rewriteTags as $tag) { if (!empty($this->arguments[$tag])) { $newTag = str_replace('data', 'data-', $tag); $this->tag->addAttribute($newTag, $this->arguments[$tag]); $this->tag->removeAttribute($tag); } } // -1 means no JS if ($this->arguments['javaScript'] != '-1') { if (empty($this->arguments['javaScript'])) { $code = '<script type="text/javascript" src="https://platform.twitter.com/widgets.js"></script>'; } else { $code = '<script src="' . htmlspecialchars($this->arguments['javaScript']) . '"></script>'; } } // Social interaction Google Analytics if ($this->pluginSettingsService->getByPath('analytics.social.twitter') == 1) { $code .= \TYPO3\CMS\Core\Utility\GeneralUtility::wrapJS("\n\t\t\t\ttwttr.events.bind('tweet', function(event) {\n\t\t\t\t if (event) {\n\t\t\t\t var targetUrl;\n\t\t\t\t if (event.target && event.target.nodeName == 'IFRAME') {\n\t\t\t\t targetUrl = extractParamFromUri(event.target.src, 'url');\n\t\t\t\t }\n\t\t\t\t _gaq.push(['_trackSocial', 'twitter', 'tweet', targetUrl]);\n\t\t\t\t }\n\t\t\t\t});\n\t\t\t"); } $this->tag->removeAttribute('javaScript'); $this->tag->setContent($this->renderChildren()); $code = $this->tag->render() . $code; return $code; }
/** * Render * * @param string $block */ public function render() { $block = $this->renderChildren(); if ($this->isCached()) { $this->pageRenderer->addJsFooterInlineCode($this->arguments['name'], $block, $this->arguments['compress'], $this->arguments['forceOnTop']); } else { // additionalFooterData not possible in USER_INT $GLOBALS['TSFE']->additionalFooterData[md5($this->arguments['name'])] = GeneralUtility::wrapJS($block); } }
/** * Get the form for extension configuration * * @param string $cat * @param array $theConstants * @param string $script * @param string $addFields * @param string $extKey * @param bool $addFormTag Adds opening <form> tag to the output, if TRUE * @return string The form */ public function ext_getForm($cat, $theConstants, $script = '', $addFields = '', $extKey = '', $addFormTag = true) { $this->ext_makeHelpInformationForCategory($cat); $printFields = trim($this->ext_printFields($theConstants, $cat)); $content = ''; $content .= GeneralUtility::wrapJS(' function uFormUrl(aname) { document.' . $this->ext_CEformName . '.action = ' . GeneralUtility::quoteJSvalue(GeneralUtility::linkThisScript() . '#') . '+aname; } '); if ($addFormTag) { $content .= '<form action="' . htmlspecialchars($script ?: GeneralUtility::linkThisScript()) . '" name="' . $this->ext_CEformName . '" method="post" enctype="multipart/form-data">'; } $content .= $addFields; $content .= $printFields; $content .= '<input class="btn btn-default" type="submit" name="submit" value="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_tsfe.xlf:update', true) . '" id="configuration-submit-' . htmlspecialchars($extKey) . '" />'; $example = $this->ext_displayExample(); $content .= $example ? '<hr/>' . $example : ''; return $content; }
/** * Opens a debug message inside a popup window * * @param mixed $debugVariable * @param string $header * @param string $group */ public static function debugInPopUpWindow($debugVariable, $header = 'Debug', $group = 'Debug') { $debugString = self::convertVariableToString($debugVariable); $script = ' (function debug() { var debugMessage = ' . GeneralUtility::quoteJSvalue($debugString) . ', header = ' . GeneralUtility::quoteJSvalue($header) . ', group = ' . GeneralUtility::quoteJSvalue($group) . ', browserWindow = function(debug, header, group) { var newWindow = window.open("", "TYPO3DebugWindow_" + group, "width=600,height=400,menubar=0,toolbar=1,status=0,scrollbars=1,resizable=1" ); if (newWindow.document.body.innerHTML) { newWindow.document.body.innerHTML = newWindow.document.body.innerHTML + "<hr />" + debugMessage; } else { newWindow.document.writeln( "<html><head><title>Debug: " + header + "(" + group + ")</title></head>" + "<body onload=\\"self.focus()\\">" + debugMessage + "</body></html>" ); } } if (!top.Ext) { browserWindow(debugMessage, header, group); } else { top.Ext.onReady(function() { if (top && top.TYPO3 && top.TYPO3.Backend) { top.TYPO3.Backend.DebugConsole.openBrowserWindow(header, debugMessage, group); } else { browserWindow(debugMessage, header, group); } }); } })(); '; echo GeneralUtility::wrapJS($script); }
/** * Renders the HTML script tag for the given jQuery version. * * @param string $version The jQuery version that should be included, either "latest" or any available version * @param string $source The location of the jQuery source, can be "local", "google", "msn" or "jquery * @param string $namespace The namespace in which the jQuery object of the specific version should be stored * @return string */ protected function renderJqueryScriptTag($version, $source, $namespace) { switch (true) { case isset($this->jQueryCdnUrls[$source]): if ($this->enableJqueryDebug) { $minifyPart = ''; } else { $minifyPart = '.min'; } $jQueryFileName = sprintf($this->jQueryCdnUrls[$source], $version, $minifyPart); break; case $source === 'local': $jQueryFileName = $this->jQueryPath . 'jquery-' . rawurlencode($version); if ($this->enableJqueryDebug) { $jQueryFileName .= '.js'; } else { $jQueryFileName .= '.min.js'; } $jQueryFileName = $this->processJsFile($jQueryFileName); break; default: $jQueryFileName = $source; } // Include the jQuery Core $scriptTag = '<script src="' . htmlspecialchars($jQueryFileName) . '" type="text/javascript"></script>' . LF; // Set the noConflict mode to be available via "TYPO3.jQuery" in all installations switch ($namespace) { case self::JQUERY_NAMESPACE_DEFAULT_NOCONFLICT: $scriptTag .= GeneralUtility::wrapJS('jQuery.noConflict();') . LF; break; case self::JQUERY_NAMESPACE_NONE: break; case self::JQUERY_NAMESPACE_DEFAULT: default: $scriptTag .= GeneralUtility::wrapJS('var TYPO3 = TYPO3 || {}; TYPO3.' . $namespace . ' = jQuery.noConflict(true);') . LF; } return $scriptTag; }
/** * JavaScript bottom code * * @return string A section with JavaScript - if $update is FALSE, embedded in <script></script> */ protected function JSbottom() { $pageRenderer = $this->getPageRenderer(); // @todo: this is messy here - "additional hidden fields" should be handled elsewhere $html = implode(LF, $this->hiddenFieldAccum); $pageRenderer->addJsFile('EXT:backend/Resources/Public/JavaScript/md5.js'); // load the main module for FormEngine with all important JS functions $this->requireJsModules['TYPO3/CMS/Backend/FormEngine'] = 'function(FormEngine) { FormEngine.setBrowserUrl(' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('wizard_element_browser')) . '); }'; $this->requireJsModules['TYPO3/CMS/Backend/FormEngineValidation'] = 'function(FormEngineValidation) { FormEngineValidation.setUsMode(' . ($GLOBALS['TYPO3_CONF_VARS']['SYS']['USdateFormat'] ? '1' : '0') . '); FormEngineValidation.registerReady(); }'; foreach ($this->requireJsModules as $moduleName => $callbacks) { if (!is_array($callbacks)) { $callbacks = [$callbacks]; } foreach ($callbacks as $callback) { $pageRenderer->loadRequireJsModule($moduleName, $callback); } } $pageRenderer->loadJquery(); $pageRenderer->loadExtJS(); $beUserAuth = $this->getBackendUserAuthentication(); // define the window size of the element browser etc. $popupWindowWidth = 700; $popupWindowHeight = 750; $popupWindowSize = trim($beUserAuth->getTSConfigVal('options.popupWindowSize')); if (!empty($popupWindowSize)) { list($popupWindowWidth, $popupWindowHeight) = GeneralUtility::intExplode('x', $popupWindowSize); } // define the window size of the popups within the RTE $rtePopupWindowSize = trim($beUserAuth->getTSConfigVal('options.rte.popupWindowSize')); if (!empty($rtePopupWindowSize)) { list($rtePopupWindowWidth, $rtePopupWindowHeight) = GeneralUtility::trimExplode('x', $rtePopupWindowSize); } $rtePopupWindowWidth = !empty($rtePopupWindowWidth) ? (int) $rtePopupWindowWidth : $popupWindowWidth - 100; $rtePopupWindowHeight = !empty($rtePopupWindowHeight) ? (int) $rtePopupWindowHeight : $popupWindowHeight - 150; // Make textareas resizable and flexible ("autogrow" in height) $textareaSettings = ['autosize' => (bool) $beUserAuth->uc['resizeTextareas_Flexible'], 'RTEPopupWindow' => ['width' => $rtePopupWindowWidth, 'height' => $rtePopupWindowHeight]]; $pageRenderer->addInlineSettingArray('Textarea', $textareaSettings); $popupSettings = ['PopupWindow' => ['width' => $popupWindowWidth, 'height' => $popupWindowHeight]]; $pageRenderer->addInlineSettingArray('Popup', $popupSettings); $pageRenderer->addJsFile('EXT:backend/Resources/Public/JavaScript/jsfunc.tbe_editor.js'); $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/ValueSlider'); // Needed for FormEngine manipulation (date picker) $dateFormat = $GLOBALS['TYPO3_CONF_VARS']['SYS']['USdateFormat'] ? ['MM-DD-YYYY', 'HH:mm MM-DD-YYYY'] : ['DD-MM-YYYY', 'HH:mm DD-MM-YYYY']; $pageRenderer->addInlineSetting('DateTimePicker', 'DateFormat', $dateFormat); $pageRenderer->loadRequireJsModule('TYPO3/CMS/Filelist/FileListLocalisation'); $pageRenderer->addInlineLanguageLabelFile('EXT:lang/Resources/Private/Language/locallang_core.xlf', 'file_upload'); if (!empty($this->additionalInlineLanguageLabelFiles)) { foreach ($this->additionalInlineLanguageLabelFiles as $additionalInlineLanguageLabelFile) { $pageRenderer->addInlineLanguageLabelFile($additionalInlineLanguageLabelFile); } } // Load codemirror for T3Editor if (ExtensionManagementUtility::isLoaded('t3editor')) { $pageRenderer->addJsFile('EXT:t3editor/Resources/Public/JavaScript/Contrib/codemirror/js/codemirror.js'); } // We want to load jQuery-ui inside our js. Enable this using requirejs. $pageRenderer->addJsFile('EXT:backend/Resources/Public/JavaScript/jsfunc.inline.js'); // todo: change these things in JS $pageRenderer->addInlineLanguageLabelArray(['FormEngine.noRecordTitle' => 'LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.no_title', 'FormEngine.fieldsChanged' => 'LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.fieldsChanged', 'FormEngine.fieldsMissing' => 'LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.fieldsMissing', 'FormEngine.maxItemsAllowed' => 'LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.maxItemsAllowed', 'FormEngine.refreshRequiredTitle' => 'LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:mess.refreshRequired.title', 'FormEngine.refreshRequiredContent' => 'LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:mess.refreshRequired.content', 'FormEngine.remainingCharacters' => 'LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.remainingCharacters'], true); $out = ' TBE_EDITOR.doSaveFieldName = "' . ($this->doSaveFieldName ? addslashes($this->doSaveFieldName) : '') . '"; '; // Add JS required for inline fields if (!empty($this->inlineData)) { $out .= ' inline.addToDataArray(' . json_encode($this->inlineData) . '); '; } // $this->additionalJS_submit: if ($this->additionalJS_submit) { $additionalJS_submit = implode('', $this->additionalJS_submit); $additionalJS_submit = str_replace([CR, LF], '', $additionalJS_submit); $out .= ' TBE_EDITOR.addActionChecks("submit", "' . addslashes($additionalJS_submit) . '"); '; } $out .= LF . implode(LF, $this->additionalJS_post) . LF . $this->extJSCODE; return $html . LF . TAB . GeneralUtility::wrapJS($out); }
/** * Render a share button * * @param boolean $loadJs * @return string */ public function render($loadJs = TRUE) { // check defaults if (empty($this->arguments['href'])) { $this->tag->addAttribute('href', 'https://www.facebook.com/sharer/sharer.php'); } if (empty($this->arguments['name'])) { $this->tag->addAttribute('name', 'fb_share'); } if (empty($this->arguments['type'])) { $this->tag->addAttribute('type', 'button_count'); } $shareUrl = empty($this->arguments['shareurl']) ? \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL') : $this->arguments['shareurl']; $this->tag->addAttribute('share_url', $shareUrl); $this->tag->removeAttribute('shareurl'); $this->tag->setContent($this->renderChildren()); $code = $this->tag->render(); if ($loadJs) { $code .= '<script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script>'; } // Social interaction Google Analytics if ($this->pluginSettingsService->getByPath('analytics.social.facebookShare') == 1) { $code .= \TYPO3\CMS\Core\Utility\GeneralUtility::wrapJS("\n\t\t\t\tFB.Event.subscribe('message.send', function(targetUrl) {\n\t\t\t\t _gaq.push(['_trackSocial', 'facebook', 'send', targetUrl]);\n\t\t\t\t});\n\t\t\t"); } return $code; }
/** * Main function to draw the map. Outputs all the necessary HTML and * Javascript to draw the map in the frontend or backend. * * @access public * @return string HTML and Javascript markup to draw the map. */ function drawMap() { // TODO: devlog start if (TYPO3_DLOG) { \TYPO3\CMS\Core\Utility\GeneralUtility::devLog($this->mapName . ': starting map drawing', 'wec_map_api'); \TYPO3\CMS\Core\Utility\GeneralUtility::devLog($this->mapName . ': API key: ' . $this->key, 'wec_map_api'); \TYPO3\CMS\Core\Utility\GeneralUtility::devLog($this->mapName . ': domain: ' . \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('HTTP_HOST'), 'wec_map_api'); \TYPO3\CMS\Core\Utility\GeneralUtility::devLog($this->mapName . ': map type: ' . $this->type, 'wec_map_api'); } // devlog end $lang = \TYPO3\CMS\Core\Utility\GeneralUtility::readLLfile('EXT:wec_map/map_service/google/locallang.xml', $this->lang); $hasThingsToDisplay = $this->hasThingsToDisplay(); $hasHeightWidth = $this->hasHeightWidth(); // make sure we have markers to display and an API key if ($hasThingsToDisplay && $hasHeightWidth) { // auto center and zoom if necessary $this->autoCenterAndZoom(); $htmlContent = $this->mapDiv(); $get = \TYPO3\CMS\Core\Utility\GeneralUtility::_GPmerged('tx_wecmap_api'); // if we're forcing static display, skip the js if ($this->static && ($this->staticMode == 'force' || $this->staticUrlParam && intval($get['static']) == 1)) { return $htmlContent; } $scheme = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SSL') ? 'https://' : 'http://'; // get the correct API URL $apiURL = $scheme . 'maps.googleapis.com/maps/api/js?sensor=false&language=' . $this->lang . '&libraries=places'; if (tx_wecmap_backend::getExtConf('useOwnJS')) { $mmURL = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath('wec_map') . 'contribJS/markermanager.js'; $ibURL = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath('wec_map') . 'contribJS/infobubble.js'; $omURL = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath('wec_map') . 'contribJS/oms.min.js'; } else { $mmURL = $scheme . 'google-maps-utility-library-v3.googlecode.com/svn/tags/markermanager/1.0/src/markermanager.js'; $ibURL = $scheme . 'google-maps-utility-library-v3.googlecode.com/svn/trunk/infobubble/src/infobubble.js'; $omURL = $scheme . 'jawj.github.com/OverlappingMarkerSpiderfier/bin/oms.min.js'; } if (TYPO3_DLOG) { \TYPO3\CMS\Core\Utility\GeneralUtility::devLog($this->mapName . ': loading API from URL: ' . $apiURL, 'wec_map_api'); } /* If we're in the frontend, use TSFE. Otherwise, include JS manually. */ $jsDir = tx_wecmap_backend::getExtConf('jsDir'); if (empty($jsDir)) { $jsDir = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath('wec_map') . 'res/'; } $jsFile = $jsDir . 'wecmap.js'; $jsFile2 = $jsDir . 'copyrights.js'; $jsFile3 = $jsDir . 'wecmap_backend.js'; if (TYPO3_MODE == 'FE') { $GLOBALS['TSFE']->additionalHeaderData['wec_map_googleMaps'] = '<script src="' . $apiURL . '" type="text/javascript"></script>' . '<script src="' . $mmURL . '" type="text/javascript"></script>' . '<script src="' . $ibURL . '" type="text/javascript"></script>' . '<script src="' . $omURL . '" type="text/javascript"></script>'; $GLOBALS['TSFE']->additionalHeaderData['wec_map'] = ($jsFile ? '<script src="' . $jsFile . '" type="text/javascript"></script>' : '') . ($jsFile2 ? '<script src="' . $jsFile2 . '" type="text/javascript"></script>' : ''); } else { $htmlContent .= '<script src="' . $apiURL . '" type="text/javascript"></script>'; if (tx_wecmap_backend::getExtConf('useOwnJS')) { $htmlContent .= '<script src="' . \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . $mmURL . '" type="text/javascript"></script>'; $htmlContent .= '<script src="' . \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . $ibURL . '" type="text/javascript"></script>'; $htmlContent .= '<script src="' . \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . $omURL . '" type="text/javascript"></script>'; } else { $htmlContent .= '<script src="' . $mmURL . '" type="text/javascript"></script>'; $htmlContent .= '<script src="' . $ibURL . '" type="text/javascript"></script>'; $htmlContent .= '<script src="' . $omURL . '" type="text/javascript"></script>'; } $htmlContent .= ($jsFile ? '<script src="' . \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . $jsFile . '" type="text/javascript"></script>' : '') . ($jsFile2 ? '<script src="' . \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . $jsFile2 . '" type="text/javascript"></script>' : '') . ($jsFile3 ? '<script src="' . \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . $jsFile3 . '" type="text/javascript"></script>' : ''); } if ($this->enableOverlappingMarkerManager) { $mapOptions['enableOverlappingMarkerManager'] = true; } $jsContent = array(); $jsContent[] = $this->js_createLabels($lang); $jsContent[] = ''; $jsContent[] = $this->js_drawMapStart($mapOptions); $jsContent[] = $this->js_newGDirections(); $jsContent[] = $this->js_setCenter($this->lat, $this->long, $this->zoom, $this->type); if (is_array($this->controls)) { $jsContent = array_merge($jsContent, $this->controls); } $jsContent[] = $this->js_icons(); if (is_array($this->groups)) { foreach ($this->groups as $key => $group) { if (TYPO3_DLOG) { \TYPO3\CMS\Core\Utility\GeneralUtility::devLog($this->mapName . ': adding ' . $group->getMarkerCount() . ' markers from group ' . $group->id, 'wec_map_api'); } $jsContent = array_merge($jsContent, $group->drawMarkerJS()); $jsContent[] = ''; } } $jsContent[] = $this->js_initialOpenInfoWindow(); $jsContent[] = $this->js_addKMLOverlay(); $jsContent[] = $this->js_loadCalls(); $jsContent[] = $this->js_drawMapEnd(); if (TYPO3_DLOG) { \TYPO3\CMS\Core\Utility\GeneralUtility::devLog($this->mapName . ': finished map drawing', 'wec_map_api'); } // get our content out of the array into a string $jsContentString = implode(chr(10), $jsContent); // then return it return $htmlContent . \TYPO3\CMS\Core\Utility\GeneralUtility::wrapJS($jsContentString); } else { if (!$hasThingsToDisplay) { $error = '<p>' . $this->getLL($lang, 'error_nothingToDisplay') . '</p>'; } else { if (!$hasHeightWidth) { $error = '<p>' . $this->getLL($lang, 'error_noHeightWidth') . '</p>'; } } } if (TYPO3_DLOG) { \TYPO3\CMS\Core\Utility\GeneralUtility::devLog($this->mapName . ': finished map drawing with errors', 'wec_map_api', 2); } return $error; }