Пример #1
0
        public BaseCollection <CmsScript> GetAllScripts()
        {
            if (_allScripts == null)
            {
                //eerst alle scripts van site
                _allScripts = Site.Scripts;

                //mocht die dannog leeg zijn, dan nieuwe lege aanmaken:
                if (_allScripts == null)
                {
                    _allScripts = new BaseCollection <CmsScript>();
                }

                //dan alle van template eraan toevoegen
                BaseCollection <CmsScript> templateScripts = this.Template.Scripts;
                foreach (CmsScript script in templateScripts)
                {
                    if (!_allScripts.Contains(script))
                    {
                        _allScripts.Add(script);
                    }
                }
                //dan alle van pagina eraan toevoegen
                BaseCollection <CmsScript> pageScripts = this.Scripts;
                foreach (CmsScript script in pageScripts)
                {
                    if (!_allScripts.Contains(script))
                    {
                        _allScripts.Add(script);
                    }
                }
                //dan nog alle module specifieke scripts toevoegen
                foreach (string scriptUrl in GetModuleDependentScripts())
                {
                    CmsScript dummy = new CmsScript();
                    if (scriptUrl.EndsWith("css"))
                    {
                        dummy.ScriptType = ScriptTypeEnum.Css;
                    }
                    else
                    {
                        dummy.ScriptType = ScriptTypeEnum.Js;
                    }
                    dummy.Url = scriptUrl;
                    //dummy.UrlLive = scriptUrl;
                    dummy.ID = Guid.NewGuid();
                    _allScripts.Add(dummy);
                }
            }
            return(_allScripts);
        }
Пример #2
0
        public static string GetScriptIDByUrl(string url, string siteid)
        {
            string returnValue = "";
            string scriptType  = url.EndsWith(".js") ? "1" : "0";

            url          = url.Replace("/_css/", "").Replace(".css", "");
            url          = url.Replace("/_js/", "").Replace(".js", "");
            string where = String.Format("FK_Site='{0}' AND Name = '{1}' AND ScriptType='{2}'", siteid, url, scriptType);
            CmsScript script = BaseObject.GetFirst <CmsScript>(where);

            if (script != null)
            {
                returnValue = script.ID.ToString();
            }
            return(returnValue);
        }
Пример #3
0
        public CmsScript Copy(string newScriptName)
        {
            CmsScript newScript = this.CreateCopy <CmsScript>(false);

            newScript.Name = newScriptName;
            newScript.LastPublishedDate = null;

            //bij usergroups & users is het niet het script zelf dat onder een template hangt, maar alleen de koppeling (veel op veel).

            if (this.HasAutorisation)
            {
                foreach (Autorisation.SiteUserGroup userGroup in this.AutorizedSiteUserGroups)
                {
                    newScript.AutorizedSiteUserGroups.Add(userGroup);
                }
                foreach (Autorisation.SiteUser user in this.AutorizedSiteUsers)
                {
                    newScript.AutorizedSiteUsers.Add(user);
                }
            }
            newScript.Save();
            return(newScript);
        }
Пример #4
0
        //public string GetContainerContent(CmsTemplateContainer container, bool publishAllModules)
        //{
        //    string containerContent = "";

        //    foreach (BaseModule mod in this.GetAllModules())
        //    {
        //        if (mod.ContainerName == container.Name)
        //        {

        //            if (publishAllModules)
        //            {
        //                mod.Publish();
        //            }
        //            if (mod.Type == "HtmlModule" && !mod.HasAutorisation)
        //            {
        //                containerContent += mod.ToString();
        //            }
        //            else
        //            {
        //                containerContent += mod.GetUserControlTag();
        //            }
        //        }
        //    }
        //    return containerContent;
        //}

        protected virtual string getHeader()
        {
            string head = "\r\n<meta name=\"generator\" content=\"Bitplate.CMS " + Assembly.GetExecutingAssembly().GetName().Version.ToString() + "\" />\r\n";

            //head += GetHeaderMetaTags();
            head += this.Site.HeadContent;
            List <CmsScript> allScripts = GetAllScripts(); //new List<CmsScript>();

            //allScripts.AddRange(this.Site.Scripts);
            //allScripts.AddRange(this.Template.Scripts);
            //allScripts.AddRange(this.Scripts);

            //foreach (CmsScript script in this.Site.Scripts)
            //{
            //    head += script.GetTag();
            //}
            //head += Site.HeadContent;
            //foreach (CmsScript script in this.Template.Scripts)
            //{
            //    head += script.GetTag();
            //}
            //foreach (CmsScript script in this.Scripts)
            //{
            //    head += script.GetTag();
            //}
            allScripts = allScripts.Distinct().ToList();

            //Attach css files to head;
            foreach (CmsScript script in allScripts.Where(c => c.ScriptType == ScriptTypeEnum.Css))
            {
                head += script.GetTag();
            }

            //Attach defaultscripts first
            string jQueryVersion = ConfigurationManager.AppSettings["jQueryVersion"];

            if (jQueryVersion == null || jQueryVersion == "")
            {
                jQueryVersion = "jquery-1.8.2.js";
            }
            CmsScript jquery = new CmsScript()
            {
                ID = Guid.NewGuid(), ScriptType = ScriptTypeEnum.Js, Url = "/_js/" + jQueryVersion
            };

            head += jquery.GetTag();
            CmsScript jqueryUI = new CmsScript()
            {
                ID = Guid.NewGuid(), ScriptType = ScriptTypeEnum.Js, Url = "/_js/jquery-ui-1.9.2.custom.min.js"
            };

            head += jqueryUI.GetTag();
            CmsScript bitAjax = new CmsScript()
            {
                ID = Guid.NewGuid(), ScriptType = ScriptTypeEnum.Js, Url = "/_js/bitAjax.js"
            };

            head += bitAjax.GetTag();
            CmsScript bitDragDrop = new CmsScript()
            {
                ID = Guid.NewGuid(), ScriptType = ScriptTypeEnum.Js, Url = "/_js/bitDragDropModules.js"
            };

            head += bitDragDrop.GetTag();

            //Attach scripts
            foreach (CmsScript script in allScripts.Where(c => c.ScriptType == ScriptTypeEnum.Js))
            {
                head += script.GetTag();
            }
            head += HeadContent;

            CmsScript bitSiteScript = new CmsScript()
            {
                ID = Guid.NewGuid(), ScriptType = ScriptTypeEnum.Js, Url = "/_js/bitSiteScript.js"
            };

            head += bitSiteScript.GetTag();
            //head += GetHeaderModuleDependentScripts();

//            head += @"<script type=""text/javascript"" src=""/_js/bitAjax.js""></script>
//<script type=""text/javascript"" src=""/_js/bitSiteScript.js""></script>
//<script type=""text/javascript"" src=""/_js/bitDragDropModules.js""></script>
//";
//            //ADD Jquery
//            string jQueryVersion = ConfigurationManager.AppSettings["jQueryVersion"];
//            if (jQueryVersion == null || jQueryVersion == "")
//            {
//                jQueryVersion = "jquery-1.8.2.js";
//            }
//            string jqueryScriptInclude = String.Format(@"
//<script type=""text/javascript"" src=""/_js/{0}""></script>
//", jQueryVersion);
//            head += jqueryScriptInclude;
//            string jQueryUIVersion = "/_bitPlate/_js/jquery-ui-1.9.1.custom.js";
//            string jqueryUIScriptInclude = String.Format(@"<script type=""text/javascript"" src=""{0}""></script>
//", jQueryUIVersion);
//            head += jqueryUIScriptInclude;

            head += @"
<script type=""text/javascript"">
    BITSITESCRIPT.pageId = '" + this.ID.ToString() + @"';
    BITSITESCRIPT.pageLanguage = '" + this.Template.LanguageCode + @"';
</script>
";
            if (Site.UseGoogleAnalystics)
            {
                //plaats google analytics code aan einde van head
                head += @"
<script type=""text/javascript"">
    //GOOGLE ANALYTICS
    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', '" + Site.GoogleAnalysticsCode + @"']);
    _gaq.push(['_trackPageview']);

    (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
    })();
</script>
";
            }
            return(head);
        }