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


PHP Requirements::insertHeadTags方法代码示例

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


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

示例1: fix_fluent_menu

    public function fix_fluent_menu()
    {
        if (!class_exists('Fluent')) {
            return;
        }
        $conf = SiteConfig::current_site_config();
        $localesNames = Fluent::locale_names();
        if ($conf->hasExtension('ActiveLocalesExtension') && $conf->ActiveLocales) {
            $localesNames = $conf->ActiveLocalesNames();
        }
        $locales = json_encode($localesNames);
        $locale = json_encode(Fluent::current_locale());
        // If we have only one locale, set this one as default
        if (count($localesNames) === 1) {
            $locale = json_encode(key($localesNames));
        }
        $param = json_encode(Fluent::config()->query_param);
        $buttonTitle = json_encode(_t('Fluent.ChangeLocale', 'Change Locale'));
        Requirements::block('FluentHeadScript');
        Requirements::insertHeadTags(<<<EOT
<script type="text/javascript">
//<![CDATA[
\tvar fluentLocales = {$locales};
\tvar fluentLocale = {$locale};
\tvar fluentParam = {$param};
\tvar fluentButtonTitle = {$buttonTitle};
//]]>
</script>
EOT
, 'FluentHeadScriptSubsite');
    }
开发者ID:helpfulrobot,项目名称:lekoala-silverstripe-subsites-extras,代码行数:31,代码来源:LeftAndMainSubsiteExtension.php

示例2: init

 public function init()
 {
     parent::init();
     Requirements::clear();
     Requirements::insertHeadTags('<meta http-equiv="Content-language" content="' . i18n::get_locale() . '" />');
     Requirements::themedCSS('sendfriend', 'screen');
 }
开发者ID:helpfulrobot,项目名称:hubertusanton-silverstripe-sendfriend,代码行数:7,代码来源:SendFriendController.php

示例3: insert

 /**
  * Insert the data to pass to JS in to the DOM
  * @return void
  */
 public static function insert()
 {
     if (!self::$has_inserted) {
         self::$has_inserted = true;
         Requirements::insertHeadTags(self::get_script_tag());
     }
 }
开发者ID:betterbrief,项目名称:silverstripe-jsconfig,代码行数:11,代码来源:JSConfig.php

示例4: onAfterInit

 public function onAfterInit()
 {
     $config = SiteConfig::current_site_config();
     // include the JS snippet into the frontend page markup
     if ($trackingID = $config->GoogleAnalyticsTrackingID) {
         $data = array('GoogleAnalyticsTrackingID' => $trackingID, 'GoogleAnalyticsParameters' => $config->GoogleAnalyticsParameters, 'GoogleAnalyticsConstructorParameters' => $config->GoogleAnalyticsConstructorParameters);
         $analyticsData = new ArrayData($data);
         Requirements::insertHeadTags($analyticsData->renderWith('GoogleAnalyticsJSSnippet'), 'GoogleAnalytics');
     }
 }
开发者ID:helpfulrobot,项目名称:kinglozzer-bfgoogleanalytics,代码行数:10,代码来源:GoogleLogger.php

示例5: init

 /**
  * Inlcudes the CSS and Javascript files required by the cwsoft-foldergallery module
  *
  * @return void
  */
 function init()
 {
     parent::init();
     // include i18n Javascript library and lang files
     // it doesn't work without the meta-tag (see http://open.silverstripe.org/ticket/7949)
     Requirements::insertHeadTags('<meta http-equiv="Content-language" content="' . i18n::get_locale() . '" />');
     Requirements::javascript(FRAMEWORK_DIR . "/javascript/i18n.js");
     Requirements::add_i18n_javascript('cwsoft-foldergallery/javascript/lang');
     // load cwsoft-foldergallery Javascript files into head
     Requirements::set_write_js_to_body(false);
     // include required cwsoft-foldergallery CSS and Javascript files
     Requirements::css('cwsoft-foldergallery/thirdparty/colorbox/colorbox.css');
     Requirements::css('cwsoft-foldergallery/css/cwsoft-foldergallery.css');
     Requirements::javascript('cwsoft-foldergallery/thirdparty/jquery/jquery.min.js');
     Requirements::javascript('cwsoft-foldergallery/thirdparty/colorbox/jquery.colorbox-min.js');
     Requirements::javascript('cwsoft-foldergallery/javascript/cwsoft-foldergallery.js');
 }
开发者ID:helpfulrobot,项目名称:cwsoft-silverstripe-foldergallery,代码行数:22,代码来源:cwsFolderGalleryPage.php

示例6: SendFriendLink

 function SendFriendLink()
 {
     if (self::$JSMode == 'Jquery') {
         Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery/jquery.min.js');
         Requirements::javascript(SENDFRIEND_DIR . '/thirdparty/jquery.simplemodal/jquery.simplemodal.1.4.2.min.js');
         Requirements::javascript(SENDFRIEND_DIR . '/thirdparty/jquery.simplemodal/popup.js');
         Requirements::css(SENDFRIEND_DIR . '/thirdparty/jquery.simplemodal/css/basic.css', 'screen');
         return '<a href="' . Director::absoluteBaseURL() . 'sendfriend?sendurl=' . Director::absoluteBaseURL() . $this->owner->URLSegment . '" id="tellafriend">' . _t('SendFriend.SENDFRIENDLINK', "Send to a friend") . '</a>';
     } else {
         //default mode
         Requirements::insertHeadTags('<script type="text/javascript">var GB_ROOT_DIR = "' . Director::absoluteBaseURL() . SENDFRIEND_DIR . '/thirdparty/greybox/";</script>');
         Requirements::javascript(SENDFRIEND_DIR . '/thirdparty/greybox/AJS.js');
         Requirements::javascript(SENDFRIEND_DIR . '/thirdparty/greybox/AJS_fx.js');
         Requirements::javascript(SENDFRIEND_DIR . '/thirdparty/greybox/gb_scripts.js');
         Requirements::css(SENDFRIEND_DIR . '/thirdparty/greybox/gb_styles.css', 'screen');
         return '<a href="' . Director::absoluteBaseURL() . 'sendfriend?sendurl=' . Director::absoluteBaseURL() . $this->owner->URLSegment . '" rel="gb_page_center[' . SENDFRIEND_POPUP_WIDTH . ', ' . SENDFRIEND_POPUP_HEIGHT . ']">' . _t('SendFriend.SENDFRIENDLINK', "Send to a friend") . '</a>';
     }
 }
开发者ID:helpfulrobot,项目名称:hubertusanton-silverstripe-sendfriend,代码行数:18,代码来源:SendFriendDecorator.php

示例7: onAfterInit

 public function onAfterInit()
 {
     if ($this->owner instanceof DevelopmentAdmin || $this->owner instanceof DatabaseAdmin || class_exists('DevBuildController') && $this->owner instanceof DevBuildController) {
         return;
     }
     // include the JS snippet into the frontend page markup
     if (GoogleAnalyticsLiteConfig::get_google_config('code')) {
         $code = GoogleAnalyticsLiteConfig::get_google_config('code');
         $SnippetPlacement = GoogleAnalyticsLiteConfig::get_google_config('placement');
         $snippet = new ArrayData(array('GoogleAnalyticsCode' => $code));
         $snippetHtml = $snippet->renderWith('GoogleAnalyticsLiteJSSnippet');
         if ($SnippetPlacement === 'Head') {
             Requirements::insertHeadTags(sprintf("<script type=\"text/javascript\">%s</script>", $snippetHtml->Value));
         } else {
             Requirements::customScript($snippetHtml);
         }
     }
 }
开发者ID:helpfulrobot,项目名称:patjnr-googleanalytics-lite,代码行数:18,代码来源:GoogleLiteLogger.php

示例8: onBeforeInit

 public function onBeforeInit()
 {
     /* =========================================
        * Combine JS
        =========================================*/
     Requirements::combine_files('combined.js', array('boilerplate/javascript/jquery.1.11.1.min.js', 'boilerplate/javascript/modernizr.2.8.3.js', 'boilerplate/javascript/bootstrap-3.2.0.min.js', 'boilerplate/javascript/script.js'));
     /* =========================================
        * CSS
        =========================================*/
     Requirements::css('boilerplate/css/main.min.css');
     //Requirements::css('themes/boilerplate/css/main.min.css');
     /* =========================================
        * IE Shivs
        =========================================*/
     $baseHref = Director::BaseURL();
     Requirements::insertHeadTags('<!--[if lt IE 9]>
         <script type="text/javascript" src="' . $baseHref . 'boilerplate/javascript/html5.js"></script>
         <script type="text/javascript" src="' . $baseHref . 'boilerplate/javascript/respond.min.js"></script>
     <![endif]-->');
 }
开发者ID:ormandroid,项目名称:ss_boilerplate,代码行数:20,代码来源:PageControllerExtension.php

示例9: init

 public function init()
 {
     parent::init();
     Requirements::set_combined_files_folder(project() . '/_combinedfiles');
     Requirements::combine_files('main.js', array(THIRDPARTY_DIR . '/jquery/jquery.min.js', THIRDPARTY_DIR . '/jquery-entwine/dist/jquery.entwine-dist.js', PROJECT_THIRDPARTY_DIR . '/magnific-popup/jquery.magnific-popup.min.js', project() . '/javascript/plugins.js', project() . '/javascript/timer.js', project() . '/javascript/main.js'));
     // insert modernizr into <head> for html5shiv to work
     Requirements::insertHeadTags(sprintf('<script src="%s"></script>', PROJECT_THIRDPARTY_DIR . '/modernizr/modernizr.min.js'));
     // insert google analytics into <head> to also track visitors that cancle the pageload before it completed
     //Requirements::insertHeadTags(sprintf(
     //	"<script>
     //		(function(b,o,i,l,e,r){b.GoogleAnalyticsObject=l;b[l]||(b[l]=
     //		function(){(b[l].q=b[l].q||[]).push(arguments)});b[l].l=+new Date;
     //		e=o.createElement(i);r=o.getElementsByTagName(i)[0];
     //		e.src='//www.google-analytics.com/analytics.js';
     //		r.parentNode.insertBefore(e,r)}(window,document,'script','ga'));
     //		ga('create','%s');ga('send','pageview');
     //	</script>",
     //	'UA-XXXXX-X'
     //));
     Requirements::combine_files('main.css', array(PROJECT_THIRDPARTY_DIR . '/normalize-css/normalize.css', PROJECT_THIRDPARTY_DIR . '/magnific-popup/magnific-popup.css', project() . '/css/screen.css', project() . '/css/typography.css', project() . '/css/form.css', project() . '/css/header.css', project() . '/css/footer.css', project() . '/css/layout.css', project() . '/css/legacy.css'));
     Requirements::css(project() . '/css/print.css', 'print');
 }
开发者ID:kbrauer,项目名称:silverstripe-boilerplate,代码行数:22,代码来源:Page.php

示例10: init

    public function init()
    {
        $dirName = basename(dirname(dirname(dirname(__FILE__))));
        $locales = json_encode(Fluent::locale_names());
        $locale = json_encode(Fluent::current_locale());
        $param = json_encode(Fluent::config()->query_param);
        $buttonTitle = json_encode(_t('Fluent.ChangeLocale', 'Change Locale'));
        // Force the variables to be written to the head, to ensure these are available for other scripts to pick up.
        Requirements::insertHeadTags(<<<EOT
<script type="text/javascript">
//<![CDATA[
\tvar fluentLocales = {$locales};
\tvar fluentLocale = {$locale};
\tvar fluentParam = {$param};
\tvar fluentButtonTitle = {$buttonTitle};
//]]>
</script>
EOT
, 'FluentHeadScript');
        Requirements::javascript("{$dirName}/javascript/fluent.js");
        Requirements::css("{$dirName}/css/fluent.css");
    }
开发者ID:Digitweaks,项目名称:silverstripe-fluent,代码行数:22,代码来源:FluentLeftAndMain.php

示例11: onAfterInit

 public function onAfterInit()
 {
     $config = WebAppConfig::current_site_config();
     $icons = $config->WebAppIcons();
     $splashScreens = $config->WebAppStartupScreens();
     $tags = '';
     $tags .= '<meta name="viewport" content="initial-scale=1, user-scalable=' . $config->UserScalable . $config->MinimalUI . '">';
     $tags .= '<meta name="apple-mobile-web-app-capable" content="' . $config->Fullscreen . '">';
     $tags .= '<meta name="apple-mobile-web-app-status-bar-style" content="' . $config->StatusBar . '">';
     $tags .= '<meta name="apple-mobile-web-app-title" content="' . $config->AppTitle . '">';
     foreach ($icons as $icon) {
         $size = $icon->Size;
         $url = $icon->Image()->URL;
         $tags .= '<link href="' . $url . '" sizes="' . $size . '" rel="apple-touch-icon">';
     }
     foreach ($splashScreens as $splashScreen) {
         $media = $splashScreen->Media;
         $url = $splashScreen->Image()->URL;
         $tags .= '<link href="' . $url . '" media="' . $media . '" rel="apple-touch-startup-image">';
     }
     Requirements::insertHeadTags($tags);
 }
开发者ID:helpfulrobot,项目名称:bramdeleeuw-silverstripe-webapp,代码行数:22,代码来源:WebAppPageControllerExtension.php

示例12: init

 public function init()
 {
     $baseHref = Director::BaseURL();
     /** -----------------------------------------
      * Javascript
      * ----------------------------------------*/
     Requirements::insertHeadTags('<script type="text/javascript" src="' . $baseHref . project() . '/javascript/lib/modernizr.min.js"></script>', 'Modernizr');
     /**
      * Set All JS to be right before the closing </body> tag.
      */
     Requirements::set_force_js_to_bottom(true);
     if (Director::isDev()) {
         Requirements::javascript(project() . '/javascript/main.js');
     } else {
         Requirements::javascript(project() . '/javascript/main.min.js');
     }
     /** -----------------------------------------
      * CSS
      * ----------------------------------------*/
     Requirements::css(project() . '/css/main.min.css', 'all');
     parent::init();
 }
开发者ID:helpfulrobot,项目名称:toastnz-silverstripe-boilerplate-installer,代码行数:22,代码来源:Page.php

示例13: IncludeTrackingEvents

    function IncludeTrackingEvents()
    {
        $page = $this->owner->data();
        $events = SiteConfig::current_site_config()->GoogleTrackEvents()->where('EXISTS ( SELECT 1
			FROM GoogleTrackEvent_Pages gep
			WHERE gep.GoogleTrackEventID = GoogleTrackEvent.ID
				AND gep.SiteTreeID = ' . $page->ID . '
			LIMIT 1 )');
        if ($events->count()) {
            $strCode = "";
            Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
            Requirements::javascript(THIRDPARTY_DIR . '/jquery-livequery/jquery.livequery.js');
            foreach ($events as $event) {
                $strEvent = 'click';
                if ($event->EventType == 'Hover') {
                    $strEvent = 'mouseenter';
                }
                $strCategory = addslashes($event->Category);
                $strAction = addslashes($event->Action);
                $strLabel = addslashes($event->Label);
                $strCode .= <<<JS
(function(){
\t\$("{$event->Target}").livequery('{$strEvent}', function(){
\t\tif(typeof _gaq !== 'undefined'){
\t\t\t_gaq.push(['_trackEvent', '{$strCategory}', '{$strAction}', '{$strLabel}']);
\t\t}
\t});
})(jQuery);
JS;
            }
            if (SiteConfig::current_site_config()->GoogleAnalyticsPosition == 'Head') {
                Requirements::insertHeadTags('<script>' . $strCode . '</script>', 'GA_TRACKERS');
            } else {
                Requirements::customScript($strCode, 'GA_TRACKERS');
            }
        }
    }
开发者ID:helpfulrobot,项目名称:plumpss-googleanalytics,代码行数:37,代码来源:GoogleAnalyticsControllerExtension.php

示例14: linkToFeed

 /**
  * Include an link to the feed
  *
  * @param string $url URL of the feed
  * @param string $title Title to show
  */
 public static function linkToFeed($url, $title = null)
 {
     $title = Convert::raw2xml($title);
     Requirements::insertHeadTags('<link rel="alternate" type="application/rss+xml" title="' . $title . '" href="' . $url . '" />');
 }
开发者ID:aaronleslie,项目名称:aaronunix,代码行数:11,代码来源:RSSFeed.php

示例15: addBasicMetatagRequirements

    /**
     * Puts together all the requirements.
     *
     * @param array $additionalJS (foo.js, bar.js)
     * @param array $additionalCSS (name => media type)
     * @param Boolean $force - run it again
     *
     */
    public function addBasicMetatagRequirements($additionalJS = array(), $additionalCSS = array(), $force = false)
    {
        if (!isset(self::$_metatags_building_completed[$this->owner->dataRecord->ID]) || $force) {
            $combineJS = Config::inst()->get("MetaTagsContentControllerEXT", "combine_js_files_into_one");
            $combineCSS = Config::inst()->get("MetaTagsContentControllerEXT", "combine_css_files_into_one");
            if ($combineJS || $combineCSS) {
                $folderForCombinedFiles = Config::inst()->get("MetaTagsContentControllerEXT", "folder_for_combined_files");
                $folderForCombinedFilesWithBase = Director::baseFolder() . "/" . $folderForCombinedFiles;
            }
            if ($combineJS) {
                $jsFile = $folderForCombinedFiles . "/MetaTagAutomation.js";
            }
            if ($combineCSS) {
                $cssFile = $folderForCombinedFiles . "/MetaTagAutomation.css";
            }
            $jQueryCDNLocation = Config::inst()->get("MetaTagsContentControllerEXT", "jquery_cdn_location");
            $cssArray = Config::inst()->get("MetaTagsContentControllerEXT", "default_css");
            $jsArray = Config::inst()->get("MetaTagsContentControllerEXT", "default_js");
            $jsArray = array_unique(array_merge($jsArray, $additionalJS));
            //javascript
            if ($combineJS && file_exists($folderForCombinedFilesWithBase . $jsFile)) {
                Requirements::javascript($jsFile);
            } else {
                foreach ($jsArray as $key => $js) {
                    if (strpos($js, "framework/thirdparty/jquery/jquery.js") !== false) {
                        //remove, as already included
                        unset($jsArray[$key]);
                    } else {
                        if (!isset($alreadyDone[$js])) {
                            Requirements::javascript($js);
                            $alreadyDone[$js] = 1;
                        }
                    }
                }
            }
            //put jQuery back in, if needed.
            if (!$jQueryCDNLocation) {
                array_unshift($jsArray, "framework/thirdparty/jquery/jquery.js");
            }
            if ($combineJS) {
                Requirements::combine_files($jsFile, $jsArray);
            }
            //css
            if ($combineCSS && file_exists($folderForCombinedFilesWithBase . $cssFile)) {
                Requirements::css($cssFile);
            } else {
                $themeFolder = SSViewer::get_theme_folder();
                $cssArrayLocationOnly = array();
                $expendadCSSArray = array();
                foreach ($cssArray as $name => $media) {
                    if (strpos($name, '.css')) {
                        $expendadCSSArray[] = array("media" => $media, "location" => $name);
                    } else {
                        $expendadCSSArray[] = array("media" => $media, "location" => $themeFolder . '/css/' . $name . '.css');
                    }
                }
                $expendadCSSArray = array_merge($expendadCSSArray, $additionalCSS);
                foreach ($expendadCSSArray as $cssArraySub) {
                    Requirements::css($cssArraySub["location"], $cssArraySub["media"]);
                    $cssArrayLocationOnly[] = $cssArraySub["location"];
                }
                if ($combineCSS) {
                    Requirements::combine_files($cssFile, $cssArrayLocationOnly);
                }
            }
            //google font
            $googleFontArray = Config::inst()->get('MetaTagsContentControllerEXT', 'google_font_collection');
            if ($googleFontArray && count($googleFontArray)) {
                $protocol = Director::protocol();
                foreach ($googleFontArray as $font) {
                    Requirements::insertHeadTags('
			<link href="' . $protocol . 'fonts.googleapis.com/css?family=' . urlencode($font) . '" rel="stylesheet" type="text/css" />');
                }
            }
            //ie header...
            if (isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) {
                header('X-UA-Compatible: IE=edge,chrome=1');
            }
            self::$_metatags_building_completed[$this->owner->dataRecord->ID] = true;
        }
    }
开发者ID:helpfulrobot,项目名称:zucchi-metatags,代码行数:89,代码来源:MetaTagsContentControllerEXT.php


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