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


PHP JSNHtmlAsset::buildHeader方法代码示例

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


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

示例1: onAfterRender


//.........这里部分代码省略.........
         if (JSNVersion::isJoomlaCompatible('2.5') and !JSNVersion::isJoomlaCompatible('3.0') and strpos($html, JSN_URL_ASSETS) !== false) {
             // Get asset link
             if (preg_match_all('#<(link|script)([^\\>]*)(href|src)="([^"]*' . JSN_URL_ASSETS . '[^"]+)"#i', $html, $matches, PREG_SET_ORDER)) {
                 foreach ($matches as $match) {
                     // Do replace
                     $html = str_replace($match[0], '<' . $match[1] . $match[2] . $match[3] . '="' . dirname(dirname($match[4])) . '/' . str_replace('.', '-', basename(dirname($match[4]))) . '/' . basename($match[4]) . '"', $html);
                 }
             }
         }
         // Remove our extensions from the Joomla 3.0's global config page
         if ($option == 'com_config' and JSNVersion::isJoomlaCompatible('3.0')) {
             $html = preg_replace('#[\\s\\t]*<li[^\\r\\n]*>[\\r\\n\\s\\t]*<a[^\\r\\n]+index.php\\?option=com_config&view=component&component=(' . implode('|', JSNVersion::$products) . ')[^\\r\\n]+</a>[\\r\\n\\s\\t]*</li>[\\r\\n]#', '', $html);
         }
         // Alter body tag
         if (preg_match('/<body[^>]*>/i', $html, $match) and strpos($match[0], 'jsn-master tmpl-' . self::$_app->getTemplate()) === false) {
             if (strpos($match[0], 'class=') === false) {
                 $match[1] = substr($match[0], 0, -1) . ' class=" jsn-master tmpl-' . self::$_app->getTemplate() . ' ">';
             } else {
                 $match[1] = str_replace('class="', 'class=" jsn-master tmpl-' . self::$_app->getTemplate() . ' ', $match[0]);
             }
             $html = str_replace($match[0], $match[1], $html);
         }
         if (JSNVersion::isJoomlaCompatible('3.2')) {
             // Clean-up HTML5 fall-back script if running on Joomla 3.2
             if (in_array($option, JSNVersion::$products) and preg_match('#[\\r\\n][\\s\\t]+<script src="[^"]*/media/system/js/html5fallback(-uncompressed)?\\.js"[^>]+></script>#', $html, $match)) {
                 $html = str_replace($match[0], '', $html);
             }
             // Temporary fix jQuery version conflict on Joomla 3.2
             $pos = strpos($html, JSN_URL_ASSETS . '/3rd-party/jquery/jquery.min.js');
             if ($pos !== false and preg_match('#<script[^>]+src="' . JSN_URL_ASSETS . '/3rd-party/jquery/jquery.min.js"[^>]*></script>#', $html, $match)) {
                 $html = explode($match[0], $html);
                 // Do some tricks on multiple jQuery instances
                 $script = '<script type="text/javascript">' . "\n\t\t" . '(JoomlaShine = window.JoomlaShine || {});' . "\n\t\t" . '(!window.jQuery || (JoomlaShine.jQueryBackup = jQuery));' . "\n\t" . '</script>' . "\n\t" . $match[0];
                 // Update document header
                 $html[0] .= $script;
                 // Truncate content
                 $html[2] = substr($html[1], strpos($html[1], '</head>'));
                 $html[1] = substr($html[1], 0, strpos($html[1], '</head>'));
                 if (preg_match('#<script[^>]+src="[^"]*/media/jui/js/jquery(\\.min)?\\.js"[^>]*></script>#', $html[1], $match)) {
                     $script = '<script type="text/javascript">' . "\n\t\t" . '(JoomlaShine = window.JoomlaShine || {});' . "\n\t\t" . '(!window.jQuery || (JoomlaShine.jQuery = jQuery));' . "\n\t" . '</script>' . "\n\t" . $match[0];
                     // Update document header
                     $html[1] = str_replace($match[0], $script, $html[1]);
                 } elseif (preg_match('#<script[^>]+src="[^"]*/js/template\\.js[^"]*"[^>]*></script>#', $html[1], $match)) {
                     $script = '<script type="text/javascript">' . "\n\t\t" . '(JoomlaShine = window.JoomlaShine || {});' . "\n\t\t" . '(!window.jQuery || (JoomlaShine.jQuery = jQuery));' . "\n\t\t" . '(!JoomlaShine.jQueryBackup || (jQuery = JoomlaShine.jQueryBackup));' . "\n\t" . '</script>' . "\n\t" . $match[0];
                     // Update document header
                     $html[1] = str_replace($match[0], $script, $html[1]);
                 } elseif (preg_match('#<script type="text/javascript">#', $html[1], $match)) {
                     $script = '<script type="text/javascript">' . "\n\t\t" . '(JoomlaShine = window.JoomlaShine || {});' . "\n\t\t" . '(!window.jQuery || (JoomlaShine.jQuery = jQuery));' . "\n\t\t" . '(!JoomlaShine.jQueryBackup || (jQuery = JoomlaShine.jQueryBackup));';
                     // Update document header
                     $html[1] = str_replace($match[0], $script, $html[1]);
                 }
                 $html = implode($html);
                 // Fix for (function($) { ... })(jQuery);
                 $tmp = preg_split('/\\}[\\s\\t\\r\\n]*\\)*\\([^\\r\\n]*jQuery[^\\r\\n]*\\)\\s*;?/', $html);
                 $html = '';
                 $i = 0;
                 foreach ($tmp as $part) {
                     $i++;
                     if ($i == count($tmp)) {
                         $html .= $part;
                     } else {
                         $parts = preg_split('/\\(\\s*function\\s*\\(\\s*\\$\\s*\\)\\s*\\{/', $part, 2);
                         if (count($parts) < 2) {
                             $html .= $part;
                         } elseif (stripos($parts[1], 'jsn') !== false) {
                             $html .= "{$parts[0]}(function(\$) {{$parts[1]}})((window.JoomlaShine && JoomlaShine.jQuery) ? JoomlaShine.jQuery : jQuery);";
                         } else {
                             $html .= "{$parts[0]}(function(\$) {{$parts[1]}})(jQuery);";
                         }
                     }
                 }
                 // Remove JSN ImageShow's buggy fix for jQuery conflict
                 if (strpos($html, 'administrator/components/com_imageshow/assets/js/joomlashine/jquery.safe.element.js') !== false) {
                     $html = preg_replace('#[\\r\\n][\\s\\t]*<script[^>]+src="[^"]*/joomlashine/jquery.safe.element.js[^"]*"[^>]*></script>#', '', $html);
                 }
             }
         }
     }
     // Attach JS declaration
     $html = str_replace('</head>', JSNHtmlAsset::buildHeader() . '</head>', $html);
     // Optimize script tags position
     self::moveScriptTags($html);
     // Fix compatibility problem between require.js and RokPad editor
     if (strpos($html, '/plugins/editors/rokpad/')) {
         if (preg_match_all('#[\\r\\n][\\s\\t]*<script[^>]+src="[^"]*/plugins/editors/rokpad/[^"]+"[^>]*></script>#', $html, $matches, PREG_SET_ORDER)) {
             foreach ($matches as $match) {
                 // Clean the script tag from its original position
                 $html = str_replace($match[0], '', $html);
                 // Inject the removed script tag into the end of head section
                 $html = str_replace('</head>', $match[0] . '</head>', $html);
             }
         }
     }
     // Set new response body
     JResponse::setBody($html);
     // Execute update checker
     if (!JSNVersion::isJoomlaCompatible('3.1')) {
         !isset($this) or $this->checkUpdate();
     }
 }
开发者ID:NallelyFlores89,项目名称:basvec,代码行数:101,代码来源:jsnframework.php


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