Example #1
0
        protected void LoadModule()
        {
            if (configureModuleID > -1)
            {
                this.Controls.Clear();
                Module module = new Module(ConfigureModuleId);

                //SiteModuleControl siteModule =
                //    Page.LoadControl("~/" + module.ControlSource) as SiteModuleControl;

                Control c = Page.LoadControl("~/" + module.ControlSource);
                if (c == null)
                {
                    throw new ArgumentException("Unable to load control from ~/" + module.ControlSource);
                }

                if (c is SiteModuleControl)
                {
                    SiteModuleControl siteModule = (SiteModuleControl)c;
                    siteModule.SiteId = SiteSettings.SiteId;
                    siteModule.ModuleConfiguration = module;
                    this.Title = module.ModuleTitle;
                }

                this.Controls.Add(c);
                moduleLoaded = true;
            }
        }
Example #2
0
        private void AddModulePart()
        {
            String moduleIDString = Request.Params.Get("addmpart");
            Module module         = new Module(int.Parse(moduleIDString));

            //TODO: we could support filtering by module.ViewRoles
            if (module.AvailableForMyPage)
            {
                SiteModuleControl siteModule = Page.LoadControl("~/" + module.ControlSource) as SiteModuleControl;
                if (siteModule != null)
                {
                    siteModule.SiteId = siteSettings.SiteId;
                    siteModule.ID     = "module" + module.ModuleId.ToString();

                    siteModule.ModuleConfiguration = module;
                    siteModule.RenderInWebPartMode = true;

                    WebPart webPart = WebPartManager1.CreateWebPart(siteModule);

                    siteModule.ModuleId = module.ModuleId;
                    Module.UpdateCountOfUseOnMyPage(module.ModuleId, 1);

                    CWebPartManager CManager = (CWebPartManager)this.WebPartManager1;
                    CManager.AddWebPart(webPart, this.CenterWebPartZone, 0);
                    CManager.SetDirty();
                }
            }
        }
Example #3
0
        //public String CacheDependencyKey
        //{
        //    get
        //    {
        //        return "Module-" + moduleConfiguration.ModuleId.ToInvariantString();
        //    }
        //}



        protected override void CreateChildControls()
        {
            cacheKey = GetCacheKey();
            if (
                (!Page.IsPostBack) &&
                (moduleConfiguration.CacheTime > 0)
                )
            {
                //cachedOutput = (string)HttpRuntime.Cache[cacheKey];
                cachedOutput = CacheManager.Cache.GetObject(cacheKey) as string;
                if (debugLog)
                {
                    if (cachedOutput == null)
                    {
                        log.Debug("cached module content was null for cacheKey " + cacheKey);
                    }
                    else
                    {
                        log.Debug("cached module content was found for cacheKey " + cacheKey);
                    }
                }
            }

            if ((Page.IsPostBack) || (cachedOutput == null))
            {
                base.CreateChildControls();

                SiteModuleControl module = (SiteModuleControl)Page.LoadControl(moduleConfiguration.ControlSource);

                module.ModuleConfiguration = this.ModuleConfiguration;
                module.SiteId = this.SiteId;

                try
                {
                    this.Controls.Add(module);
                }
                catch (HttpException ex)
                {
                    // when searching using the search input from a page
                    // with viewstate enabled, this exception can be thrown
                    // because when the  SearchResults page accesses the Page.PreviousPage
                    // the viewstate is not the same
                    // the user never sees this and the search works since we catch
                    // the exception
                    if (log.IsErrorEnabled)
                    {
                        if (HttpContext.Current != null)
                        {
                            log.Error("Exception caught and handled in CachedSiteModule for requested url:"
                                      + HttpContext.Current.Request.RawUrl, ex);
                        }
                        else
                        {
                            log.Error("Exception caught and handled in CachedSiteModule", ex);
                        }
                    }
                }
            }
        }
        public override WebPart GetWebPart(WebPartDescription description)
        {
            SiteSettings siteSettings = CacheHelper.GetCurrentSiteSettings();

            if (siteSettings == null)
            {
                return(null);
            }

            WebPart webPart = null;

            if (description.ID.Length == 36)
            {
                Guid           webPartID      = new Guid(description.ID);
                WebPartContent webPartContent = new WebPartContent(webPartID);
                if (webPartContent.WebPartId != Guid.Empty)
                {
                    if (HttpContext.Current != null)
                    {
                        String path = HttpContext.Current.Server.MapPath("~/bin")
                                      + Path.DirectorySeparatorChar + webPartContent.AssemblyName + ".dll";
                        Assembly assembly = Assembly.LoadFrom(path);
                        Type     type     = assembly.GetType(webPartContent.ClassName, true, true);
                        object   obj      = Activator.CreateInstance(type);
                        if (obj != null)
                        {
                            webPart = (WebPart)obj;
                            WebPartContent.UpdateCountOfUseOnMyPage(webPartContent.WebPartId, 1);
                        }
                    }
                }
            }
            else
            {
                mojoPortal.Business.Module module = new mojoPortal.Business.Module(int.Parse(description.ID));

                SiteModuleControl siteModule = Page.LoadControl("~/" + module.ControlSource) as SiteModuleControl;
                if (siteModule != null)
                {
                    siteModule.SiteId = siteSettings.SiteId;
                    siteModule.ID     = "module" + module.ModuleId.ToString(CultureInfo.InvariantCulture);

                    siteModule.ModuleConfiguration = module;
                    siteModule.RenderInWebPartMode = true;

                    webPart = WebPartManager.CreateWebPart(siteModule);


                    siteModule.ModuleId = module.ModuleId;
                    mojoPortal.Business.Module.UpdateCountOfUseOnMyPage(module.ModuleId, 1);
                }
            }

            return(webPart);
        }
Example #5
0
        private void PopulateControls()
        {
            Module module = new Module(moduleId);

            if (module.SiteId != siteSettings.SiteId)
            {
                return;
            }
            if (module.ViewRoles == "Admins;")
            {
                if (!WebUser.IsAdmin)
                {
                    SiteUtils.RedirectToAccessDeniedPage(this);
                    return;
                }
            }

            ModuleDefinition feature = new ModuleDefinition(module.ModuleDefId);

            pnlWarning.Visible  = !feature.SupportsPageReuse;
            lblModuleTitle.Text = module.ModuleTitle;
            String controlToLoad = "~/" + module.ControlSource;

            if (File.Exists(Server.MapPath(controlToLoad)))
            {
                Control c = Page.LoadControl("~/" + module.ControlSource);

                if (c is SiteModuleControl)
                {
                    SiteModuleControl siteModule = c as SiteModuleControl;

                    siteModule.SiteId = siteSettings.SiteId;
                    siteModule.ModuleConfiguration = module;
                    pnlViewModule.Controls.Add(siteModule);
                }
                else
                {
                    // plain UserControl
                    pnlViewModule.Controls.Add(c);
                }

                lnkPublish.Text        = Resource.ContentManagerPublishContentLink;
                lnkPublish.NavigateUrl = SiteRoot + WebConfigSettings.ContentPublishPageRelativeUrl + "?mid=" + this.moduleId;
                if (pageId > -1)
                {
                    lnkPublish.NavigateUrl += "&pageid=" + pageId.ToString(CultureInfo.InvariantCulture);
                }
            }
            else
            {
                WebUtils.SetupRedirect(this, SiteRoot + "/Admin/ContentCatalog.aspx");
            }
        }
Example #6
0
        protected void ibCancelChanges_Click(object sender, ImageClickEventArgs e)
        {
            SiteModuleControl siteModule = GetParentAsSiteModelControl(this);

            if (siteModule == null)
            {
                return;
            }
            if (!(siteModule is IWorkflow))
            {
                return;
            }

            IWorkflow workflow = siteModule as IWorkflow;

            workflow.CancelChanges();
        }
Example #7
0
        protected void ibPostDraftContentForApproval_Click(object sender, ImageClickEventArgs e)
        {
            SiteModuleControl siteModule = GetParentAsSiteModelControl(this);

            if (siteModule == null)
            {
                return;
            }
            if (!(siteModule is IWorkflow))
            {
                return;
            }

            IWorkflow workflow = siteModule as IWorkflow;

            workflow.SubmitForApproval();
        }
Example #8
0
        void ibApproveContent_Click(object sender, ImageClickEventArgs e)
        {
            SiteModuleControl siteModule = GetParentAsSiteModelControl(this);

            if (siteModule == null)
            {
                return;
            }
            if (!(siteModule is IWorkflow))
            {
                return;
            }

            IWorkflow workflow = siteModule as IWorkflow;

            workflow.Approve();
        }
Example #9
0
        protected void LoadModule()
        {
            if (configureModuleID > -1)
            {
                this.Controls.Clear();
                Module module = new Module(ConfigureModuleId);

                if (WebConfigSettings.EnforceSiteIdInModuleWrapper)
                {
                    SiteSettings siteSettings = CacheHelper.GetCurrentSiteSettings();
                    if (siteSettings != null)
                    {
                        if (module.SiteId != siteSettings.SiteId)
                        {
                            return;
                        }
                    }
                }


                Control c = Page.LoadControl("~/" + module.ControlSource);
                if (c == null)
                {
                    throw new ArgumentException("Unable to load control from ~/" + module.ControlSource);
                }

                if (c is SiteModuleControl)
                {
                    SiteModuleControl siteModule = (SiteModuleControl)c;
                    siteModule.SiteId = siteSettings.SiteId;
                    siteModule.ModuleConfiguration = module;
                    this.Title = module.ModuleTitle;
                }

                this.Controls.Add(c);
                moduleLoaded = true;
            }
        }
        private void Initialize()
        {
            if (HttpContext.Current == null) { return; }

            siteModule = GetParentAsSiteModelControl(this);

            bool useTextLinksForFeatureSettings = true;
            mojoBasePage basePage = Page as mojoBasePage;
            if (basePage != null)
            {
                useTextLinksForFeatureSettings = basePage.UseTextLinksForFeatureSettings;
            }

            if (siteModule != null)
            {
                module = siteModule.ModuleConfiguration;
                CanEdit = siteModule.IsEditable;
                enableWorkflow = siteModule.EnableWorkflow;
                forbidModuleSettings = siteModule.ForbidModuleSettings;

            }

            if (module != null)
            {
                headingTag = module.HeadElement;
                if (module.ShowTitle)
                {
                    litModuleTitle.Text = Page.Server.HtmlEncode(module.ModuleTitle);
                }
                else
                {
                    useHeading = false;
                }

                if (CanEdit)
                {

                    if (!disabledModuleSettingsLink)
                    {
                        lnkModuleSettings.Visible = true;
                        lnkModuleSettings.Text = Resource.SettingsLink;
                        lnkModuleSettings.ToolTip = Resource.ModuleEditSettings;

                        if (!useTextLinksForFeatureSettings)
                        {
                            lnkModuleSettings.ImageUrl = Page.ResolveUrl("~/Data/SiteImages/" + WebConfigSettings.EditPropertiesImage);
                        }
                        else
                        {
                            // if its a text link make it small like the edit link
                            lnkModuleSettings.CssClass = "ModuleEditLink";
                        }

                        siteRoot = SiteUtils.GetNavigationSiteRoot();

                        lnkModuleSettings.NavigateUrl = siteRoot
                            + "/Admin/ModuleSettings.aspx?mid=" + module.ModuleId.ToInvariantString()
                            + "&pageid=" + module.PageId.ToInvariantString();

                        if ((enableWorkflow) && (siteModule != null) && (siteModule is IWorkflow))
                        {
                            SetupWorkflowControls();

                        }

                    }

                }

                if (
                    ((CanEdit) || (ShowEditLinkOverride))
                    && ((EditText != null) && (editUrl.Length > 0)))
                {

                    lnkModuleEdit.Text = EditText;
                    if (this.ToolTip.Length > 0)
                    {
                        lnkModuleEdit.ToolTip = this.ToolTip;
                    }
                    else
                    {
                        lnkModuleEdit.ToolTip = EditText;
                    }
                    lnkModuleEdit.NavigateUrl = EditUrl
                         + (EditUrl.Contains("?") ? "&" : "?")
                         + "mid=" + module.ModuleId.ToInvariantString()
                         + "&pageid=" + module.PageId.ToInvariantString();

                    if (!useTextLinksForFeatureSettings)
                    {
                        lnkModuleEdit.ImageUrl = Page.ResolveUrl("~/Data/SiteImages/" + WebConfigSettings.EditContentImage);
                    }

                }

            }
        }
Example #11
0
        private void LoadPage()
        {
            EnsurePageAndSite();
            if (CurrentPage == null)
            {
                return;
            }
            LoadSettings();
            EnforceSecuritySettings();
            bool redirected = RedirectIfNeeded();

            if (redirected)
            {
                return;
            }

            if (CurrentPage.PageId == -1)
            {
                SetupAdminLinks();
                return;
            }

            if ((CurrentPage.ShowChildPageMenu) ||
                (CurrentPage.ShowBreadcrumbs) ||
                (CurrentPage.ShowChildPageBreadcrumbs)
                )
            {
                // this is needed to override some hide logic in
                // layout.Master.cs
                this.MPContent.Visible        = true;
                this.MPContent.Parent.Visible = true;
            }

            if (CurrentPage.BodyCssClass.Length > 0)
            {
                AddClassToBody(CurrentPage.BodyCssClass);
            }

            // solves background problems with some skin in WLW
            if ((StyleCombiner != null) && (StyleCombiner.AddBodyClassForLiveWriter))
            {
                if (BrowserHelper.IsWindowsLiveWriter())
                {
                    AddClassToBody("wysiwygeditor");
                }
            }

            if (CurrentPage.PageTitle.Length > 0)
            {
                if (WebConfigSettings.FormatOverridePageTitle)
                {
                    Title = SiteUtils.FormatPageTitle(siteSettings, CurrentPage.PageTitle);
                }
                else
                {
                    Title = CurrentPage.PageTitle;
                }
            }
            else
            {
                Title = SiteUtils.FormatPageTitle(siteSettings, CurrentPage.PageName);
            }

            if (CurrentPage.PageMetaKeyWords.Length > 0)
            {
                MetaKeywordCsv = CurrentPage.PageMetaKeyWords;
            }


            if (CurrentPage.PageMetaDescription.Length > 0)
            {
                MetaDescription = CurrentPage.PageMetaDescription;
            }


            if (CurrentPage.CompiledMeta.Length > 0)
            {
                AdditionalMetaMarkup = CurrentPage.CompiledMeta;
            }

            if (WebConfigSettings.AutomaticallyAddCanonicalUrlToCmsPages)
            {
                if ((Page.Header != null) && (CurrentPage.UseUrl) && (CurrentPage.Url.Length > 0))
                {
                    string urlToUse;
                    if (CurrentPage.CanonicalOverride.Length > 0)
                    {
                        urlToUse = CurrentPage.CanonicalOverride;
                    }
                    else
                    {
                        if (CurrentPage.Url.StartsWith("http"))
                        {
                            urlToUse = CurrentPage.Url;
                        }
                        else
                        {
                            if (CurrentPage.UrlHasBeenAdjustedForFolderSites)
                            {
                                urlToUse = WebUtils.GetSiteRoot() + CurrentPage.Url.Replace("~/", "/");
                            }
                            else
                            {
                                urlToUse = SiteRoot + CurrentPage.Url.Replace("~/", "/");
                            }

                            if (SiteUtils.IsSecureRequest() && (!CurrentPage.RequireSsl) && (!siteSettings.UseSslOnAllPages))
                            {
                                if (WebConfigSettings.ForceHttpForCanonicalUrlsThatDontRequireSsl)
                                {
                                    urlToUse = urlToUse.Replace("https:", "http:");
                                }
                            }
                        }
                    }

                    Literal link = new Literal();
                    link.ID   = "pageurl";
                    link.Text = "\n<link rel='canonical' href='"
                                + urlToUse
                                + "' />";

                    Page.Header.Controls.Add(link);
                }
            }

            // if (CurrentPage.Modules.Count == 0) { return; }

            bool isAdmin        = WebUser.IsAdmin;
            bool isContentAdmin = false;
            bool isSiteEditor   = false;

            if (!isAdmin)
            {
                isContentAdmin = WebUser.IsContentAdmin;
                isSiteEditor   = SiteUtils.UserIsSiteEditor();
            }

            if (CurrentPage.Modules.Count == 0)
            {
                if (!CurrentPage.ShowChildPageMenu) // we'll consider Child Page Menu as a feature for our purpose here
                {
                    if (
                        (WebConfigSettings.UsePageContentWizard)
                        &&
                        (isAdmin || isContentAdmin || isSiteEditor || WebUser.IsInRoles(CurrentPage.EditRoles))
                        )
                    {
                        // this is to make it a little more intuitive
                        // sometimes users create pages but fail to see the link in pagesettings to
                        // add features so if they visit the empty page give them an easy opportunity
                        // to add a feature
                        Control wiz = Page.LoadControl("~/Admin/Controls/PageContentWizard.ascx");
                        MPContent.Controls.Add(wiz);
                    }
                }

                return;
            }

            foreach (Module module in CurrentPage.Modules)
            {
                if (!ModuleIsVisible(module))
                {
                    continue;
                }

                if (
                    (!WebUser.IsInRoles(module.ViewRoles)) &&
                    (!isContentAdmin) &&
                    (!isSiteEditor)
                    )
                {
                    continue;
                }

                if ((module.ViewRoles == "Admins;") && (!isAdmin))
                {
                    continue;
                }


                if (module.ControlSource == "Modules/LoginModule.ascx")
                {
                    LoginModuleDisplaySettings loginSettings = new LoginModuleDisplaySettings();
                    this.MPContent.Controls.Add(loginSettings); ///theme is not applied until its loaded
                    if ((Request.IsAuthenticated) && (loginSettings.HideWhenAuthenticated))
                    {
                        continue;
                    }
                }

                Control parent = this.MPContent;

                if (StringHelper.IsCaseInsensitiveMatch(module.PaneName, "leftpane"))
                {
                    parent = this.MPLeftPane;
                }

                if (StringHelper.IsCaseInsensitiveMatch(module.PaneName, "rightpane"))
                {
                    parent = this.MPRightPane;
                }

                if (StringHelper.IsCaseInsensitiveMatch(module.PaneName, "altcontent1"))
                {
                    if (AltPane1 != null)
                    {
                        parent = this.AltPane1;
                    }
                    else
                    {
                        log.Error("Content is assigned to altcontent1 placeholder but it does not exist in layout.master so using center.");
                        parent = this.MPContent;
                    }
                }

                if (StringHelper.IsCaseInsensitiveMatch(module.PaneName, "altcontent2"))
                {
                    if (AltPane2 != null)
                    {
                        parent = this.AltPane2;
                    }
                    else
                    {
                        log.Error("Content is assigned to altcontent2 placeholder but it does not exist in layout.master so using center.");
                        parent = this.MPContent;
                    }
                }

                // this checks if we are using the mobile skin and whether the content is for all web only or mobile only
                if (!ShouldShowModule(module))
                {
                    continue;
                }

                // 2008-10-04 since more an more of our features use postback via ajax
                // its not feasible to use output caching as this breaks postback,
                // so I changed the default the use of WebConfigSettings.DisableContentCache to true
                // this also reduces the memory consumption footprint

                if ((module.CacheTime == 0) || (WebConfigSettings.DisableContentCache))
                {
                    //2008-10-16 in ulu's blog post:http://dotfresh.blogspot.com/2008/10/in-search-of-developer-friendly-cms.html
                    // he complains about having to inherit from a base class (SiteModuleControl) to make a plugin.
                    // he wishes he could just use a UserControl
                    // While SiteModuleControl "is a" UserControl that provides additional functionality
                    // Its easy enough to support using
                    // a plain UserControl so I'm making the needed change here now.
                    // The drawback of a plain UserControl is that is not reusable in the same way as SiteModuleControl.
                    // If you use a plain UserControl, its going to be exactly the same on any page you use it on.
                    // It has no instance specific properties.
                    // SiteModuleControl gives you instance specific ids and internal tracking of which instance this is so
                    // that you can have different instances.
                    // For example the Blog is instance specific, if you put a blog on one page and then put a blog on another page
                    // those are 2 different blogs with different content.
                    // However, if you don't need a re-usable feature with instance specific properties
                    // you are now free to use a plain old UserControl and I think freedom is a good thing
                    // so this was valuable feedback from ulu.
                    // Those who do need instance specific features should read my developer Guidelines for building one:
                    //http://www.mojoportal.com/addingfeatures.aspx

                    try
                    {
                        Control c = Page.LoadControl("~/" + module.ControlSource);
                        if (c == null)
                        {
                            continue;
                        }

                        if (c is SiteModuleControl)
                        {
                            SiteModuleControl siteModule = (SiteModuleControl)c;
                            siteModule.SiteId = siteSettings.SiteId;
                            siteModule.ModuleConfiguration = module;

                            if (siteModule is IWorkflow)
                            {
                                if (WebUser.IsInRoles(module.AuthorizedEditRoles))
                                {
                                    forceShowWorkflow = true;
                                }
                                if (WebUser.IsInRoles(module.DraftEditRoles))
                                {
                                    forceShowWorkflow = true;
                                }

                                countOfIWorkflow += 1;
                            }
                        }

                        parent.Controls.Add(c);
                    }
                    catch (HttpException ex)
                    {
                        log.Error("failed to load control " + module.ControlSource, ex);
                    }
                }
                else
                {
                    CachedSiteModuleControl siteModule = new CachedSiteModuleControl();

                    siteModule.SiteId = siteSettings.SiteId;
                    siteModule.ModuleConfiguration = module;
                    parent.Controls.Add(siteModule);
                }

                parent.Visible        = true;
                parent.Parent.Visible = true;
            } //end foreach

            SetupAdminLinks();

            if ((!WebConfigSettings.DisableExternalCommentSystems) && (siteSettings != null) && (CurrentPage != null) && (CurrentPage.EnableComments))
            {
                switch (siteSettings.CommentProvider)
                {
                case "disqus":

                    if (siteSettings.DisqusSiteShortName.Length > 0)
                    {
                        DisqusWidget disqus = new DisqusWidget();
                        disqus.SiteShortName = siteSettings.DisqusSiteShortName;
                        disqus.WidgetPageUrl = WebUtils.ResolveServerUrl(SiteUtils.GetCurrentPageUrl());
                        if (disqus.WidgetPageUrl.StartsWith("https"))
                        {
                            disqus.WidgetPageUrl = disqus.WidgetPageUrl.Replace("https", "http");
                        }
                        disqus.RenderWidget = true;
                        MPContent.Controls.Add(disqus);
                    }

                    break;

                case "intensedebate":

                    if (siteSettings.IntenseDebateAccountId.Length > 0)
                    {
                        IntenseDebateDiscussion d = new IntenseDebateDiscussion();
                        d.AccountId = siteSettings.IntenseDebateAccountId;
                        d.PostUrl   = SiteUtils.GetCurrentPageUrl();
                        MPContent.Controls.Add(d);
                    }



                    break;

                case "facebook":
                    FacebookCommentWidget fbComments = new FacebookCommentWidget();
                    fbComments.AutoDetectUrl = true;
                    MPContent.Controls.Add(fbComments);

                    break;
                }
            }

            if (WebConfigSettings.HidePageViewModeIfNoWorkflowItems && (countOfIWorkflow == 0))
            {
                HideViewSelector();
            }

            // (to show the last mnodified time of a page we may have this control in layout.master, but I set it invisible by default
            // because we only want to show it on content pages not edit pages
            // since Default.aspx.cs is the handler for content pages, we look for it here and make it visible.
            Control pageLastMod = Master.FindControl("pageLastMod");

            if (pageLastMod != null)
            {
                pageLastMod.Visible = true;
            }
        }
Example #12
0
        private void Initialize()
        {
            if (HttpContext.Current == null)
            {
                return;
            }

            siteModule = GetParentAsSiteModelControl(this);

            bool         useTextLinksForFeatureSettings = true;
            mojoBasePage basePage = Page as mojoBasePage;

            if (basePage != null)
            {
                useTextLinksForFeatureSettings = basePage.UseTextLinksForFeatureSettings;
            }

            if (siteModule != null)
            {
                module               = siteModule.ModuleConfiguration;
                CanEdit              = siteModule.IsEditable;
                enableWorkflow       = siteModule.EnableWorkflow;
                forbidModuleSettings = siteModule.ForbidModuleSettings;
            }

            if (module != null)
            {
                headingTag = module.HeadElement;
                if (module.ShowTitle)
                {
                    litModuleTitle.Text = Page.Server.HtmlEncode(module.ModuleTitle);
                }
                else
                {
                    useHeading = false;
                }

                if (CanEdit)
                {
                    if (!disabledModuleSettingsLink)
                    {
                        lnkModuleSettings.Visible = true;
                        lnkModuleSettings.Text    = Resource.SettingsLink;
                        lnkModuleSettings.ToolTip = Resource.ModuleEditSettings;

                        if (!useTextLinksForFeatureSettings)
                        {
                            lnkModuleSettings.ImageUrl = Page.ResolveUrl("~/Data/SiteImages/" + WebConfigSettings.EditPropertiesImage);
                        }
                        else
                        {
                            // if its a text link make it small like the edit link
                            lnkModuleSettings.CssClass = "ModuleEditLink";
                        }

                        siteRoot = SiteUtils.GetNavigationSiteRoot();

                        lnkModuleSettings.NavigateUrl = siteRoot
                                                        + "/Admin/ModuleSettings.aspx?mid=" + module.ModuleId.ToInvariantString()
                                                        + "&pageid=" + module.PageId.ToInvariantString();

                        if ((enableWorkflow) && (siteModule != null) && (siteModule is IWorkflow))
                        {
                            SetupWorkflowControls();
                        }
                    }
                }

                if (
                    ((CanEdit) || (ShowEditLinkOverride)) &&
                    ((EditText != null) && (editUrl.Length > 0)))
                {
                    lnkModuleEdit.Text = EditText;
                    if (this.ToolTip.Length > 0)
                    {
                        lnkModuleEdit.ToolTip = this.ToolTip;
                    }
                    else
                    {
                        lnkModuleEdit.ToolTip = EditText;
                    }
                    lnkModuleEdit.NavigateUrl = EditUrl
                                                + (EditUrl.Contains("?") ? "&" : "?")
                                                + "mid=" + module.ModuleId.ToInvariantString()
                                                + "&pageid=" + module.PageId.ToInvariantString();

                    if (!useTextLinksForFeatureSettings)
                    {
                        lnkModuleEdit.ImageUrl = Page.ResolveUrl("~/Data/SiteImages/" + WebConfigSettings.EditContentImage);
                    }
                }
            }
        }
        private void LoadPage()
        {
            EnsurePageAndSite();
            if (CurrentPage == null)
            {
                return;
            }
            LoadSettings();
            EnforceSecuritySettings();
            bool redirected = RedirectIfNeeded();

            if (redirected)
            {
                return;
            }
            SetupAdminLinks();
            if (CurrentPage.PageId == -1)
            {
                return;
            }

            if ((CurrentPage.ShowChildPageMenu) ||
                (CurrentPage.ShowBreadcrumbs) ||
                (CurrentPage.ShowChildPageBreadcrumbs)
                )
            {
                // this is needed to override some hide logic in
                // layout.Master.cs
                this.MPContent.Visible        = true;
                this.MPContent.Parent.Visible = true;
            }


            if (CurrentPage.PageTitle.Length > 0)
            {
                Title = Server.HtmlEncode(CurrentPage.PageTitle);
            }
            else
            {
                Title = SiteUtils.FormatPageTitle(siteSettings, CurrentPage.PageName);
            }

            if (CurrentPage.PageMetaKeyWords.Length > 0)
            {
                MetaKeywordCsv = CurrentPage.PageMetaKeyWords;
            }


            if (CurrentPage.PageMetaDescription.Length > 0)
            {
                MetaDescription = CurrentPage.PageMetaDescription;
            }


            if (CurrentPage.CompiledMeta.Length > 0)
            {
                AdditionalMetaMarkup = CurrentPage.CompiledMeta;
            }

            if ((Page.Header != null) && (CurrentPage.UseUrl) && (CurrentPage.Url.Length > 0))
            {
                string urlToUse = SiteRoot + CurrentPage.Url.Replace("~/", "/");
                if (CurrentPage.CanonicalOverride.Length > 0)
                {
                    urlToUse = CurrentPage.CanonicalOverride;
                }
                using (Literal link = new Literal {
                    ID = "pageurl", Text = String.Format("\n<link rel='canonical' href='{0}' />", urlToUse)
                })
                {
                    Page.Header.Controls.Add(link);
                }
            }

            if (CurrentPage.Modules.Count == 0)
            {
                return;
            }

            foreach (Module module in CurrentPage.Modules)
            {
                if (!ModuleIsVisible(module))
                {
                    continue;
                }
                if (!WebUser.IsInRoles(module.ViewRoles))
                {
                    continue;
                }

                Control parent = this.MPContent;

                if (StringHelper.IsCaseInsensitiveMatch(module.PaneName, "leftpane"))
                {
                    parent = this.MPLeftPane;
                }

                if (StringHelper.IsCaseInsensitiveMatch(module.PaneName, "rightpane"))
                {
                    parent = this.MPRightPane;
                }

                if (StringHelper.IsCaseInsensitiveMatch(module.PaneName, "altcontent1"))
                {
                    if (AltPane1 != null)
                    {
                        parent = this.AltPane1;
                    }
                    else
                    {
                        log.Error("Content is assigned to altcontent1 placeholder but it does not exist in layout.master so using center.");
                        parent = this.MPContent;
                    }
                }

                if (StringHelper.IsCaseInsensitiveMatch(module.PaneName, "altcontent2"))
                {
                    if (AltPane2 != null)
                    {
                        parent = this.AltPane2;
                    }
                    else
                    {
                        log.Error("Content is assigned to altcontent2 placeholder but it does not exist in layout.master so using center.");
                        parent = this.MPContent;
                    }
                }

                // 2008-10-04 since more an more of our features use postback via ajax
                // its not feasible to use output caching as this breaks postback,
                // so I changed the default the use of WebConfigSettings.DisableContentCache to true
                // this also reduces the memory consumption footprint

                if ((module.CacheTime == 0) || (WebConfigSettings.DisableContentCache))
                {
                    //2008-10-16 in ulu's blog post:http://dotfresh.blogspot.com/2008/10/in-search-of-developer-friendly-cms.html
                    // he complains about having to inherit from a base class (SiteModuleControl) to make a plugin.
                    // he wishes he could just use a UserControl
                    // While SiteModuleControl "is a" UserControl that provides additional functionality
                    // Its easy enough to support using
                    // a plain UserControl so I'm making the needed change here now.
                    // The drawback of a plain UserControl is that is not reusable in the same way as SiteModuleControl.
                    // If you use a plain UserControl, its going to be exactly the same on any page you use it on.
                    // It has no instance specific properties.
                    // SiteModuleControl gives you instance specific ids and internal tracking of which instance this is so
                    // that you can have different instances.
                    // For example the Blog is instance specific, if you put a blog on one page and then put a blog on another page
                    // those are 2 different blogs with different content.
                    // However, if you don't need a re-usable feature with instance specific properties
                    // you are now free to use a plain old UserControl and I think freedom is a good thing
                    // so this was valuable feedback from ulu.
                    // Those who do need instance specific features should read my developer Guidelines for building one:
                    //http://www.vivasky.com/addingfeatures.aspx

                    Control c = Page.LoadControl("~/" + module.ControlSource);
                    if (c == null)
                    {
                        continue;
                    }

                    if (c is SiteModuleControl)
                    {
                        SiteModuleControl siteModule = (SiteModuleControl)c;
                        siteModule.SiteId = siteSettings.SiteId;
                        siteModule.ModuleConfiguration = module;

                        if (siteModule is IWorkflow)
                        {
                            countOfIWorkflow += 1;
                        }
                    }



                    parent.Controls.Add(c);
                }
                else
                {
                    using (CachedSiteModuleControl siteModule = new CachedSiteModuleControl {
                        SiteId = siteSettings.SiteId, ModuleConfiguration = module
                    })
                    {
                        parent.Controls.Add(siteModule);
                    }
                }

                parent.Visible        = true;
                parent.Parent.Visible = true;
            } //end foreach

            if ((!WebConfigSettings.DisableExternalCommentSystems) && (siteSettings != null) && (CurrentPage != null) && (CurrentPage.EnableComments))
            {
                switch (siteSettings.CommentProvider)
                {
                case "disqus":

                    if (siteSettings.DisqusSiteShortName.Length > 0)
                    {
                        using (DisqusWidget disqus = new DisqusWidget())
                        {
                            disqus.SiteShortName = siteSettings.DisqusSiteShortName;
                            disqus.WidgetPageUrl = SiteUtils.GetCurrentPageUrl();
                            disqus.RenderWidget  = true;
                            MPContent.Controls.Add(disqus);
                        }
                    }

                    break;

                case "intensedebate":

                    if (siteSettings.IntenseDebateAccountId.Length > 0)
                    {
                        using (IntenseDebateDiscussion d = new IntenseDebateDiscussion())
                        {
                            d.AccountId = siteSettings.IntenseDebateAccountId;
                            d.PostUrl   = SiteUtils.GetCurrentPageUrl();
                            MPContent.Controls.Add(d);
                        }
                    }

                    break;
                }
            }

            if (WebConfigSettings.HidePageViewModeIfNoWorkflowItems && (countOfIWorkflow == 0))
            {
                HideViewSelector();
            }

            // (to show the last mnodified time of a page we may have this control in layout.master, but I set it invisible by default
            // because we only want to show it on content pages not edit pages
            // since Default.aspx.cs is the handler for content pages, we look for it here and make it visible.
            Control pageLastMod = Master.FindControl("pageLastMod");

            if (pageLastMod != null)
            {
                pageLastMod.Visible = true;
            }
        }
Example #14
0
        private void Page_Load(object sender, EventArgs e)
        {
            if (!CurrentZone.AllowBrowserCache)
            {
                SecurityHelper.DisableBrowserCache();
            }

            bool redirected = RedirectIfNeeded();

            if (redirected)
            {
                return;
            }

            // Modified: 2015-01-30 Load all contents from Center Pane
            bool isAdmin        = WebUser.IsAdmin;
            bool isContentAdmin = false;
            bool isSiteEditor   = false;

            if (!isAdmin)
            {
                isContentAdmin = WebUser.IsContentAdmin;
                isSiteEditor   = SiteUtils.UserIsSiteEditor();
            }

            bool forceShowViewMode = false;
            bool forceShowWorkflow = false;
            bool enabledWorkflow   = WebConfigSettings.EnableContentWorkflow && siteSettings.EnableContentWorkflow;

            // hide filter module on product detail
            PageSettings         currentPage = CurrentPage;
            ProductConfiguration config      = null;

            foreach (Module module in currentPage.Modules)
            {
                if (StringHelper.IsCaseInsensitiveMatch(module.ControlSource, "Product/ProductFilterModule.ascx"))
                {
                    module.HideFromAuthenticated   = true;
                    module.HideFromUnauthenticated = true;
                }

                if (StringHelper.IsCaseInsensitiveMatch(module.PaneName, "contentpane") &&
                    StringHelper.IsCaseInsensitiveMatch(module.ControlSource, "Product/ProductModule.ascx"))
                {
                    Hashtable settings = CacheHelper.GetModuleSettings(module.ModuleId);
                    config = new ProductConfiguration(settings);
                    break;
                }
            }
            CurrentPage = currentPage;

            foreach (Module module in CurrentPage.Modules)
            {
                if (StringHelper.IsCaseInsensitiveMatch(module.PaneName, "contentpane"))
                {
                    if (config == null || !config.ShowHiddenContents)
                    {
                        if (!ModuleIsVisible(module))
                        {
                            continue;
                        }
                    }

                    if (
                        (!WebUser.IsInRoles(module.ViewRoles)) &&
                        (!isContentAdmin) &&
                        (!isSiteEditor)
                        )
                    {
                        continue;
                    }

                    if ((module.ViewRoles == "Admins;") && (!isAdmin))
                    {
                        continue;
                    }

                    if (!ShouldShowModule(module))
                    {
                        continue;
                    }

                    Control parent = this.MPContent;

                    if ((module.CacheTime == 0) || (WebConfigSettings.DisableContentCache))
                    {
                        try
                        {
                            Control c = Page.LoadControl("~/" + module.ControlSource);
                            if (c == null)
                            {
                                continue;
                            }

                            if (c is ProductModule)
                            {
                                ProductModule siteModule = (ProductModule)c;
                                siteModule.SiteId = siteSettings.SiteId;
                                siteModule.ModuleConfiguration = module;
                                siteModule.ForceLoadDetail     = true;

                                if (
                                    Request.IsAuthenticated &&
                                    siteModule.UserHasPermission()
                                    )
                                {
                                    forceShowViewMode = true;
                                    forceShowWorkflow = enabledWorkflow;
                                }

                                parent.Controls.Add(c);
                            }
                            else if (c is SiteModuleControl)
                            {
                                if (
                                    !(config != null && config.HideOtherContentsOnDetailPage) ||
                                    (config != null && config.ShowHiddenContents && module.HideFromAuthenticated && module.HideFromUnauthenticated)
                                    )
                                {
                                    SiteModuleControl siteModule = (SiteModuleControl)c;
                                    siteModule.SiteId = siteSettings.SiteId;
                                    siteModule.ModuleConfiguration = module;

                                    if (
                                        Request.IsAuthenticated &&
                                        siteModule.UserHasPermission()
                                        )
                                    {
                                        forceShowViewMode = true;
                                        if (enabledWorkflow && siteModule is IWorkflow)
                                        {
                                            forceShowWorkflow = true;
                                        }
                                    }

                                    parent.Controls.Add(c);
                                }
                            }
                        }
                        catch (HttpException ex)
                        {
                            log.Error("failed to load control " + module.ControlSource, ex);
                        }
                    }
                    else
                    {
                        CachedSiteModuleControl siteModule = new CachedSiteModuleControl();

                        siteModule.SiteId = siteSettings.SiteId;
                        siteModule.ModuleConfiguration = module;
                        parent.Controls.Add(siteModule);
                    }

                    parent.Visible        = true;
                    parent.Parent.Visible = true;
                }
            } //end foreach

            SetupViewModeControls(forceShowViewMode, forceShowWorkflow);

            AddClassToBody("product-detail-page");
        }
Example #15
0
        public void LoadSideContent(bool includeLeft, bool includeRight)
        {
            if (currentPage == null)
            {
                return;
            }

            if ((!includeLeft) && (!includeRight))
            {
                return;
            }

            int leftModulesAdded  = 0;
            int rightModulesAdded = 0;

            if (CurrentPage.Modules.Count > 0)
            {
                foreach (Module module in CurrentPage.Modules)
                {
                    if (ModuleIsVisible(module))
                    {
                        if ((includeLeft) && (StringHelper.IsCaseInsensitiveMatch(module.PaneName, "leftpane")))
                        {
                            Control c = Page.LoadControl("~/" + module.ControlSource);
                            if (c == null)
                            {
                                continue;
                            }

                            if (c is SiteModuleControl)
                            {
                                SiteModuleControl siteModule = (SiteModuleControl)c;
                                siteModule.SiteId = siteSettings.SiteId;
                                siteModule.ModuleConfiguration = module;
                            }

                            MPLeftPane.Controls.Add(c);
                            MPLeftPane.Visible        = true;
                            MPLeftPane.Parent.Visible = true;
                            leftModulesAdded         += 1;
                        }

                        if ((includeRight) && (StringHelper.IsCaseInsensitiveMatch(module.PaneName, "rightpane")))
                        {
                            Control c = Page.LoadControl("~/" + module.ControlSource);
                            if (c == null)
                            {
                                continue;
                            }

                            if (c is SiteModuleControl)
                            {
                                SiteModuleControl siteModule = (SiteModuleControl)c;
                                siteModule.SiteId = siteSettings.SiteId;
                                siteModule.ModuleConfiguration = module;
                            }

                            MPRightPane.Controls.Add(c);
                            MPRightPane.Visible        = true;
                            MPRightPane.Parent.Visible = true;
                            rightModulesAdded         += 1;
                        }
                    }
                }
            }

            forceShowLeft  = (leftModulesAdded > 0);
            forceShowRight = (rightModulesAdded > 0);
        }