当前位置: 首页>>代码示例>>PHP>>正文


PHP GeneralUtility::wrapJS方法代码示例

本文整理汇总了PHP中TYPO3\CMS\Core\Utility\GeneralUtility::wrapJS方法的典型用法代码示例。如果您正苦于以下问题:PHP GeneralUtility::wrapJS方法的具体用法?PHP GeneralUtility::wrapJS怎么用?PHP GeneralUtility::wrapJS使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TYPO3\CMS\Core\Utility\GeneralUtility的用法示例。


在下文中一共展示了GeneralUtility::wrapJS方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: render

    /**
     * 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;
    }
开发者ID:woehrlag,项目名称:Intranet,代码行数:36,代码来源:ShareViewHelper.php

示例2: render

 /**
  * 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;
 }
开发者ID:woehrlag,项目名称:Intranet,代码行数:32,代码来源:LikeViewHelper.php

示例3: JSbottom


//.........这里部分代码省略.........
				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 = ' . GeneralUtility::quoteJSvalue($this->getLL('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;
    }
开发者ID:Mr-Robota,项目名称:TYPO3.CMS,代码行数:101,代码来源:FormEngine.php

示例4: getModeSpecificJavascriptCode

 /**
  * 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;
 }
开发者ID:noxludo,项目名称:TYPO3v4-Core,代码行数:21,代码来源:T3Editor.php

示例5: init

    /**
     * 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;
				}
			');
        }
    }
开发者ID:AndreasA,项目名称:commerce,代码行数:46,代码来源:BrowselinksHooks.php

示例6: singleIndexAction

 /**
  * 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');
 }
开发者ID:vip3out,项目名称:TYPO3.CMS,代码行数:25,代码来源:ReviewController.php

示例7: render

 /**
  * @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 '';
 }
开发者ID:seitenarchitekt,项目名称:extbase_hijax,代码行数:87,代码来源:ScriptViewHelper.php

示例8: ext_getForm

    /**
     * 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;
    }
开发者ID:nicksergio,项目名称:TYPO3v4-Core,代码行数:32,代码来源:ConfigurationForm.php

示例9: JSbottom

    /**
     * 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 = ' . GeneralUtility::quoteJSvalue($languageService->sL('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;
    }
开发者ID:adrolli,项目名称:TYPO3.CMS,代码行数:99,代码来源:FormEngine.php

示例10: outputToPopup

 /**
  * 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 <mail@fabrizio-branca.de>
  */
 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;
     }
 }
开发者ID:punktde,项目名称:pt_extbase,代码行数:26,代码来源:Div.php

示例11: addJsInlineCode

 /**
  * 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);
         }
     }
 }
开发者ID:clews,项目名称:t3jquery,代码行数:31,代码来源:T3jqueryUtility.php

示例12: addResources

 /**
  * 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;
//.........这里部分代码省略.........
开发者ID:thegass,项目名称:jfmulticontent,代码行数:101,代码来源:class.tx_jfmulticontent_ttnews_extend.php

示例13: JSbottom

    /**
     * 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 = ' . GeneralUtility::quoteJSvalue($languageService->sL('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;
//.........这里部分代码省略.........
开发者ID:rickymathew,项目名称:TYPO3.CMS,代码行数:101,代码来源:FormResultCompiler.php

示例14: getAjaxFunction

 /**
  * 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;
 }
开发者ID:seitenarchitekt,项目名称:extbase_hijax,代码行数:53,代码来源:JSBuilder.php

示例15: render

 /**
  * 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;
 }
开发者ID:kalypso63,项目名称:news,代码行数:36,代码来源:TwitterViewHelper.php


注:本文中的TYPO3\CMS\Core\Utility\GeneralUtility::wrapJS方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。