Ejemplo n.º 1
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        public PageEngine()
        {
            this._activeNode        = null;
            this._activeSection     = null;
            this._templateControl   = null;
            this._shouldLoadContent = true;

            // Get services from the container. Ideally, it should be possible to register the aspx page in the container
            // to automatically resolve dependencies but there were memory issues with registering pages in the container.
            this._moduleLoader   = Container.Resolve <ModuleLoader>();
            this._nodeService    = Container.Resolve <INodeService>();
            this._siteService    = Container.Resolve <ISiteService>();
            this._sectionService = Container.Resolve <ISectionService>();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        public PageEngine()
        {
            this._activeNode = null;
            this._activeSection = null;
            this._templateControl = null;
            this._shouldLoadContent = true;

            // Get services from the container. Ideally, it should be possible to register the aspx page in the container
            // to automatically resolve dependencies but there were memory issues with registering pages in the container.
            this._moduleLoader = Container.Resolve<ModuleLoader>();
            this._nodeService = Container.Resolve<INodeService>();
            this._siteService = Container.Resolve<ISiteService>();
            this._sectionService = Container.Resolve<ISectionService>();
        }
Ejemplo n.º 3
0
        private void LoadContent()
        {
            // ===== Load templates  =====

            // We know the active node so the template can be loaded.
            if (this._activeNode.Template != null)
            {
                string templatePath = CurrentSite.SiteDataDirectory + this._activeNode.Template.Path;
                this._templateControl = (BaseTemplate)this.LoadControl(templatePath);
                // Explicitly set the id to 'p' to save some bytes (otherwise _ctl0 would be added).
                this._templateControl.ID    = "p";
                this._templateControl.Title = this._activeNode.Site.Name + " - " + this._activeNode.Title;
                // Register stylesheet that belongs to the template.
                string cssPath = ResolveUrl(string.Format("{0}{1}/Css/{2}", CurrentSite.SiteDataDirectory, this._activeNode.Template.BasePath, this._activeNode.Template.Css));
                RegisterStylesheet("maincss", cssPath);
                //Register the metatags
                if (ActiveNode.MetaKeywords != null)
                {
                    RegisterMetaTag("keywords", ActiveNode.MetaKeywords);
                }
                else
                {
                    RegisterMetaTag("keywords", ActiveNode.Site.MetaKeywords);
                }
                if (ActiveNode.MetaDescription != null)
                {
                    RegisterMetaTag("description", ActiveNode.MetaDescription);
                }
                else
                {
                    RegisterMetaTag("description", ActiveNode.Site.MetaDescription);
                }
                // Load sections that are related to the template
                foreach (KeyValuePair <string, Section> sectionEntry in this.ActiveNode.Template.Sections)
                {
                    string  placeholder = sectionEntry.Key;
                    Section section     = sectionEntry.Value;
                    if (section != null)
                    {
                        BaseModuleControl moduleControl = CreateModuleControlForSection(section);
                        if (moduleControl != null)
                        {
                            ((PlaceHolder)this._templateControl.Containers[placeholder]).Controls.Add(moduleControl);
                        }
                    }
                }
            }
            else
            {
                throw new Exception("No template associated with the current Node.");
            }

            // ===== Load sections and modules =====
            foreach (Section section in this._activeNode.Sections)
            {
                BaseModuleControl moduleControl = CreateModuleControlForSection(section);
                if (moduleControl != null)
                {
                    ((PlaceHolder)this._templateControl.Containers[section.PlaceholderId]).Controls.Add(moduleControl);
                }
            }

            this.Controls.AddAt(0, this._templateControl);
            // remove html that was in the original page (Default.aspx)
            for (int i = this.Controls.Count - 1; i < 0; i--)
            {
                this.Controls.RemoveAt(i);
            }
        }
Ejemplo n.º 4
0
        private void LoadContent()
        {
            // ===== Load templates  =====

            // We know the active node so the template can be loaded.
            if (this._activeNode.Template != null)
            {
                string templatePath = CurrentSite.SiteDataDirectory + this._activeNode.Template.Path;
                this._templateControl = (BaseTemplate)this.LoadControl(templatePath);
                // Explicitly set the id to 'p' to save some bytes (otherwise _ctl0 would be added).
                this._templateControl.ID = "p";
                this._templateControl.Title = this._activeNode.Site.Name + " - " + this._activeNode.Title;
                // Register stylesheet that belongs to the template.
                string cssPath = ResolveUrl(string.Format("{0}{1}/Css/{2}", CurrentSite.SiteDataDirectory, this._activeNode.Template.BasePath, this._activeNode.Template.Css));
                RegisterStylesheet("maincss", cssPath);
                //Register the metatags
                if (ActiveNode.MetaKeywords != null)
                {
                    RegisterMetaTag("keywords", ActiveNode.MetaKeywords);
                }
                else
                {
                    RegisterMetaTag("keywords", ActiveNode.Site.MetaKeywords);
                }
                if (ActiveNode.MetaDescription != null)
                {
                    RegisterMetaTag("description", ActiveNode.MetaDescription);
                }
                else
                {
                    RegisterMetaTag("description", ActiveNode.Site.MetaDescription);
                }
                // Load sections that are related to the template
                foreach (KeyValuePair<string, Section> sectionEntry in this.ActiveNode.Template.Sections)
                {
                    string placeholder = sectionEntry.Key;
                    Section section = sectionEntry.Value;
                    if (section != null)
                    {
                        BaseModuleControl moduleControl = CreateModuleControlForSection(section);
                        if (moduleControl != null)
                        {
                            ((PlaceHolder)this._templateControl.Containers[placeholder]).Controls.Add(moduleControl);
                        }
                    }
                }
            }
            else
            {
                throw new Exception("No template associated with the current Node.");
            }

            // ===== Load sections and modules =====
            foreach (Section section in this._activeNode.Sections)
            {
                BaseModuleControl moduleControl = CreateModuleControlForSection(section);
                if (moduleControl != null)
                {
                    ((PlaceHolder)this._templateControl.Containers[section.PlaceholderId]).Controls.Add(moduleControl);
                }
            }

            this.Controls.AddAt(0, this._templateControl);
            // remove html that was in the original page (Default.aspx)
            for (int i = this.Controls.Count -1; i < 0; i --)
                this.Controls.RemoveAt(i);
        }
Ejemplo n.º 5
0
        private void LoadContent()
        {
            //
            PageEngine page = ( PageEngine ) Page;
            bool isAdmin = ( ( page.CuyahogaUser != null && page.CuyahogaUser.HasPermission( AccessLevel.Administrator ) ) );

            // # added for v1.6.0
            if ( ActiveNode.Site.OfflineTemplate != null) // check if an Offline template was selected
            {

                // check if any parent is offline
                if (_activeNode.Level >= 1 && !isAdmin) // from the 2nd level
                {
                    if (IsAnyParentOffline(_activeNode, 1))
                    {
                        _activeNode.Template = _currentSite.OfflineTemplate;
                        ActiveNode.Status = (int) NodeStatus.Offline; // lo mettiamo off-line
                    }
                }

            }
            // # added for v1.6.0

            // ===== Load templates  =====

            string appRoot = UrlHelper.GetApplicationPath();
            // We know the active node so the template can be loaded.
            if (this._activeNode.Template != null)
            {
                string templatePath = appRoot + this._activeNode.Template.Path;
                this._templateControl = (BaseTemplate)this.LoadControl(templatePath);
                // Explicitly set the id to 'p' to save some bytes (otherwise _ctl0 would be added).
                this._templateControl.ID = "p";
                this._templateControl.Title = this._activeNode.Site.Name + " - " + this._activeNode.Title;
                // Register stylesheet that belongs to the template.
                RegisterStylesheet("maincss", appRoot + this._activeNode.Template.BasePath + "/Css/" + this._activeNode.Template.Css);
                //Register the metatags
                if (ActiveNode.MetaKeywords != null)
                {
                    RegisterMetaTag("keywords", ActiveNode.MetaKeywords);
                }
                else
                {
                    RegisterMetaTag("keywords", ActiveNode.Site.MetaKeywords);
                }
                if (ActiveNode.MetaDescription != null)
                {
                    RegisterMetaTag("description", ActiveNode.MetaDescription);
                }
                else
                {
                    RegisterMetaTag("description", ActiveNode.Site.MetaDescription);
                }

                // # added for v1.6.0
                if( ActiveNode.Status == ( int ) NodeStatus.Online || (ActiveNode.Status == ( int ) NodeStatus.Offline && isAdmin) )
                {
                // # added for v1.6.0

                    // Load sections that are related to the template
                    foreach (DictionaryEntry sectionEntry in this.ActiveNode.Template.Sections)
                    {
                        string placeholder = sectionEntry.Key.ToString();
                        Section section = sectionEntry.Value as Section;
                        if (section != null)
                        {
                            BaseModuleControl moduleControl = CreateModuleControlForSection(section);
                            if (moduleControl != null)
                            {
                                ((PlaceHolder)this._templateControl.Containers[placeholder]).Controls.Add(moduleControl);
                            }
                        }
                    }

                // # added for v1.6.0
                }
                // # added for v1.6.0
            }
            else
            {
                throw new Exception("No template associated with the current Node.");
            }

            // # added for v1.6.0
            if( ActiveNode.Status == ( int ) NodeStatus.Online || ( ActiveNode.Status == ( int ) NodeStatus.Offline && isAdmin ) )
            {
            // # added for v1.6.0

                // ===== Load sections and modules =====
                foreach (Section section in this._activeNode.Sections)
                {
                    BaseModuleControl moduleControl = CreateModuleControlForSection(section);
                    if (moduleControl != null)
                    {
                        ((PlaceHolder) this._templateControl.Containers[section.PlaceholderId]).Controls.Add(
                            moduleControl);
                    }
                }

            // # added for v1.6.0
            }
            // # added for v1.6.0

            this.Controls.AddAt(0, this._templateControl);
            // remove html that was in the original page (Default.aspx)
            for (int i = this.Controls.Count -1; i < 0; i --)
                this.Controls.RemoveAt(i);
        }
        private void LoadContent()
        {
            // ===== Load templates  =====

            string appRoot = UrlHelper.GetApplicationPath();
            // We know the active node so the template can be loaded.
            if (this._activeNode.Template != null)
            {
                string templatePath = appRoot + this._activeNode.Template.Path;
                this._templateControl = (BaseTemplate)this.LoadControl(templatePath);
                // Explicitly set the id to 'p' to save some bytes (otherwise _ctl0 would be added).
                this._templateControl.ID = "p";

                // Custom
                //this._templateControl.Title = this._activeNode.Site.Name + " - " + this._activeNode.Title;
                // Where there is an TitleSEO value set it to the page title. Otherwise just use the node Title
                if (this._activeNode.TitleSEO != "")
                {
                    this._templateControl.Title = this._activeNode.Site.Name + " - " + this._activeNode.TitleSEO;
                }
                else
                {
                    this._templateControl.Title = this._activeNode.Site.Name + " - " + this._activeNode.Title;
                }

                // Register stylesheet that belongs to the template.
                RegisterStylesheet("maincss", appRoot + this._activeNode.Template.BasePath + "/Css/" + this._activeNode.Template.Css);
                // Register the metatags
                if (ActiveNode.MetaKeywords != null)
                {
                    RegisterMetaTag("keywords", ActiveNode.MetaKeywords);
                }
                else
                {
                    RegisterMetaTag("keywords", ActiveNode.Site.MetaKeywords);
                }
                if (ActiveNode.MetaDescription != null)
                {
                    RegisterMetaTag("description", ActiveNode.MetaDescription);
                }
                else
                {
                    RegisterMetaTag("description", ActiveNode.Site.MetaDescription);
                }
                // Load sections that are related to the template
                foreach (KeyValuePair<string, Section> sectionEntry in this.ActiveNode.Template.Sections)
                {
                    string placeholder = sectionEntry.Key;
                    Section section = sectionEntry.Value;
                    if (section != null)
                    {
                        BaseModuleControl moduleControl = CreateModuleControlForSection(section);
                        if (moduleControl != null)
                        {
                            ((PlaceHolder)this._templateControl.Containers[placeholder]).Controls.Add(moduleControl);
                        }
                    }
                }
            }
            else
            {
                throw new Exception("No template associated with the current Node.");
            }

            // ===== Load sections and modules =====
            foreach (Section section in this._activeNode.Sections)
            {
                BaseModuleControl moduleControl = CreateModuleControlForSection(section);
                if (moduleControl != null)
                {
                    ((PlaceHolder)this._templateControl.Containers[section.PlaceholderId]).Controls.Add(moduleControl);
                }
            }

            this.Controls.AddAt(0, this._templateControl);
            // remove html that was in the original page (Default.aspx)
            for (int i = this.Controls.Count -1; i < 0; i --)
                this.Controls.RemoveAt(i);
        }