Ejemplo n.º 1
0
    public string LoadLayout()
    {
        string        filePath = Decide.IsTemplateDefault(TemplateName.Trim()) ? Utils.GetTemplatePath_Default(TemplateName) : Utils.GetTemplatePath(TemplateName);
        DirectoryInfo dir      = new DirectoryInfo(filePath + "/layouts");
        StringBuilder html     = new StringBuilder();

        foreach (FileInfo layout in dir.GetFiles())
        {
            string layoutName = layout.Name.Replace(".xml", "");
            html.Append("<option");
            html.Append(" value='");
            html.Append(layoutName);
            html.Append("'>");
            html.Append(layoutName);
            html.Append("</option>");
        }
        return(html.ToString());
    }
Ejemplo n.º 2
0
    private void BindLayout()
    {
        string        filePath   = Decide.IsTemplateDefault(TemplateName.Trim()) ? Utils.GetTemplatePath_Default(TemplateName) : Utils.GetTemplatePath(TemplateName);
        DirectoryInfo dir        = new DirectoryInfo(filePath + "/layouts");
        StringBuilder html       = new StringBuilder();
        List <string> layoutList = new List <string>();

        html.Append("<ul class='layoutList inactive' style='display:none;'>");
        foreach (FileInfo layout in dir.GetFiles())
        {
            string layoutName = layout.Name.Replace(".xml", "");
            layoutList.Add(layoutName);
            html.Append("<li>");
            html.Append(layoutName);
            html.Append("</li>");
        }
        html.Append("</ul>");
        ddlLayout.DataSource = layoutList;
        ddlLayout.DataBind();

        ltrlayoutList.Text = html.ToString();
    }
Ejemplo n.º 3
0
    protected void btnApply_Click(object sender, EventArgs e)
    {
        HttpRuntime.Cache.Remove(CacheKeys.SageFrameJs);
        HttpRuntime.Cache.Remove(CacheKeys.SageFrameCss);
        string optimized_path = Server.MapPath(SageFrameConstants.OptimizedResourcePath);

        IOHelper.DeleteDirectoryFiles(optimized_path, ".js,.css");
        if (File.Exists(Server.MapPath(SageFrameConstants.OptimizedCssMap)))
        {
            XmlHelper.DeleteNodes(Server.MapPath(SageFrameConstants.OptimizedCssMap), "resourcemaps/resourcemap");
        }
        if (File.Exists(Server.MapPath(SageFrameConstants.OptimizedJsMap)))
        {
            XmlHelper.DeleteNodes(Server.MapPath(SageFrameConstants.OptimizedJsMap), "resourcemap/resourcemap");
        }
        PresetInfo preset = new PresetInfo();

        preset = PresetHelper.LoadActivePagePreset(TemplateName, GetPageSEOName(Request.Url.ToString()));
        if (ddlScreen.SelectedItem.ToString() != string.Empty)
        {
            preset.ActiveWidth = ddlScreen.SelectedItem.ToString();
        }
        if (ddlThemes.SelectedItem != null && ddlThemes.SelectedItem.ToString() != string.Empty)
        {
            preset.ActiveTheme = ddlThemes.SelectedItem.ToString();
        }
        if (ddlLayout.SelectedItem != null && ddlLayout.SelectedItem.ToString() != string.Empty)
        {
            preset.ActiveLayout = Path.GetFileNameWithoutExtension(ddlLayout.SelectedItem.ToString());
        }
        List <KeyValue> lstLayouts = preset.lstLayouts;
        string          pageName   = Request.Url.ToString();
        SageFrameConfig sfConfig   = new SageFrameConfig();

        pageName = Path.GetFileNameWithoutExtension(pageName);
        pageName = pageName.ToLower().Equals("default") ? sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) : pageName;
        bool          isNewLayout     = false;
        int           oldPageCount    = 0;
        bool          isNewPage       = false;
        bool          deleteRepeat    = false;
        bool          duplicateLayout = false;
        List <string> pageList        = new List <string>();

        foreach (KeyValue kvp in lstLayouts)
        {
            if (kvp.Key == preset.ActiveLayout)
            {
                duplicateLayout = true;
            }
            string[] pages = kvp.Value.Split(',');
            pageList.Add(string.Join(",", pages));
            if (pages.Count() == 1 && pages.Contains(pageName)) // for single pagename and if page = currentpageName
            {
                kvp.Key = preset.ActiveLayout;
            }
            else if (pages.Count() > 1 && pages.Contains(pageName)) // for multiple pagename and if page = currentpageName
            {
                isNewLayout = true;                                 //its because we have to insert another layout
                List <string> lstnewpage = new List <string>();
                foreach (string page in pages)
                {
                    if (page.ToLower() != pageName.ToLower())
                    {
                        lstnewpage.Add(page);
                    }
                }
                kvp.Value = string.Join(",", lstnewpage.ToArray());
                pageList.Add(kvp.Value);
            }
            else
            {
                oldPageCount++;
            }
            if (kvp.Value == "All" && kvp.Key == preset.ActiveLayout)
            {
                deleteRepeat = true;
            }
        }
        if (lstLayouts.Count == oldPageCount)
        {
            isNewPage = true;
        }
        List <KeyValue> lstNewLayouts = new List <KeyValue>();

        if (isNewPage)
        {
            bool isAppended = false;
            foreach (KeyValue kvp in lstLayouts)
            {
                if (kvp.Key == preset.ActiveLayout)
                {
                    if (kvp.Value.ToLower() != "all")
                    {
                        kvp.Value += "," + pageName;
                    }
                    isAppended = true;
                }
                lstNewLayouts.Add(new KeyValue(kvp.Key, kvp.Value));
            }
            if (!isAppended)
            {
                lstNewLayouts.Add(new KeyValue(preset.ActiveLayout, pageName));
            }
            lstLayouts = lstNewLayouts;
        }
        else if (isNewLayout)
        {
            bool isAppended = false;
            bool isAll      = false;
            foreach (KeyValue kvp in lstLayouts)
            {
                if (kvp.Key == preset.ActiveLayout)
                {
                    if (kvp.Value.ToLower() != "all")
                    {
                        kvp.Value += "," + pageName;
                        isAll      = true;
                    }
                    isAppended = true;
                }
                lstNewLayouts.Add(new KeyValue(kvp.Key, kvp.Value));
            }
            if (!isAppended && !isAll)
            {
                lstNewLayouts.Add(new KeyValue(preset.ActiveLayout, pageName));
            }
            lstLayouts = lstNewLayouts;
        }
        else if (deleteRepeat)
        {
            foreach (KeyValue kvp in lstLayouts)
            {
                if (kvp.Value.ToLower() != pageName.ToLower())
                {
                    lstNewLayouts.Add(new KeyValue(kvp.Key, kvp.Value));
                }
            }
            lstLayouts = lstNewLayouts;
        }
        else if (duplicateLayout)
        {
            string        key   = preset.ActiveLayout;
            List <string> pages = new List <string>();
            foreach (KeyValue kvp in lstLayouts)
            {
                if (kvp.Key.ToLower() != preset.ActiveLayout.ToLower())
                {
                    lstNewLayouts.Add(new KeyValue(kvp.Key, kvp.Value));
                }
                else
                {
                    pages.Add(kvp.Value);
                }
            }
            lstNewLayouts.Add(new KeyValue(key, string.Join(",", pages.ToArray())));
            lstLayouts = lstNewLayouts;
        }
        preset.lstLayouts = lstLayouts;
        string presetPath = Decide.IsTemplateDefault(TemplateName.Trim()) ? Utils.GetPresetPath_DefaultTemplate(TemplateName) : Utils.GetPresetPath(TemplateName);
        string pagepreset = presetPath + "/" + TemplateConstants.PagePresetFile;

        presetPath += "/" + "pagepreset.xml";
        AppErazer.ClearSysHash(ApplicationKeys.ActivePagePreset + "_" + GetPortalID);
        PresetHelper.WritePreset(presetPath, preset);
        SageFrame.Common.CacheHelper.Clear("PresetList");
        Response.Redirect(Request.Url.OriginalString);
    }
Ejemplo n.º 4
0
    protected void ddlLayout_SelectedIndexChanged(object sender, EventArgs e)
    {
        PresetInfo preset   = new PresetInfo();
        string     pageName = ddlPages.SelectedValue;

        pageName = Regex.Replace(pageName, "--+", "");
        preset   = PresetHelper.LoadActivePagePreset(TemplateName, GetPageSEOName(Request.Url.ToString()));
        List <KeyValue> lstLayouts = preset.lstLayouts;

        preset.ActiveLayout = ddlLayout.SelectedValue;
        bool          isNewLayout     = false;
        int           oldPageCount    = 0;
        bool          isNewPage       = false;
        bool          deleteRepeat    = false;
        bool          duplicateLayout = false;
        List <string> pageList        = new List <string>();

        foreach (KeyValue kvp in lstLayouts)
        {
            if (kvp.Key == preset.ActiveLayout)
            {
                duplicateLayout = true;
            }
            string[] pages = kvp.Value.Split(',');
            pageList.Add(string.Join(",", pages));
            if (pages.Count() == 1 && pages.Contains(pageName)) // for single pagename and if page = currentpageName
            {
                kvp.Key = preset.ActiveLayout;
            }
            else if (pages.Count() > 1 && pages.Contains(pageName)) // for multiple pagename and if page = currentpageName
            {
                isNewLayout = true;                                 //its because we have to insert another layout
                List <string> lstnewpage = new List <string>();
                foreach (string page in pages)
                {
                    if (page.ToLower() != pageName.ToLower())
                    {
                        lstnewpage.Add(page);
                    }
                }
                kvp.Value = string.Join(",", lstnewpage.ToArray());
                pageList.Add(kvp.Value);
            }
            else
            {
                oldPageCount++;
            }
            if (kvp.Value == "All" && kvp.Key == preset.ActiveLayout)
            {
                deleteRepeat = true;
            }
        }
        if (lstLayouts.Count == oldPageCount)
        {
            isNewPage = true;
        }
        List <KeyValue> lstNewLayouts = new List <KeyValue>();

        if (isNewPage)
        {
            bool isAppended = false;
            foreach (KeyValue kvp in lstLayouts)
            {
                if (kvp.Key == preset.ActiveLayout)
                {
                    if (kvp.Value.ToLower() != "all")
                    {
                        kvp.Value += "," + pageName;
                    }
                    isAppended = true;
                }
                lstNewLayouts.Add(new KeyValue(kvp.Key, kvp.Value));
            }
            if (!isAppended)
            {
                lstNewLayouts.Add(new KeyValue(preset.ActiveLayout, pageName));
            }
            lstLayouts = lstNewLayouts;
        }
        else if (isNewLayout)
        {
            bool isAppended = false;
            bool isAll      = false;
            foreach (KeyValue kvp in lstLayouts)
            {
                if (kvp.Key == preset.ActiveLayout)
                {
                    if (kvp.Value.ToLower() != "all")
                    {
                        kvp.Value += "," + pageName;
                        isAll      = true;
                    }
                    isAppended = true;
                }
                lstNewLayouts.Add(new KeyValue(kvp.Key, kvp.Value));
            }
            if (!isAppended && !isAll)
            {
                lstNewLayouts.Add(new KeyValue(preset.ActiveLayout, pageName));
            }
            lstLayouts = lstNewLayouts;
        }
        else if (deleteRepeat)
        {
            foreach (KeyValue kvp in lstLayouts)
            {
                if (kvp.Value.ToLower() != pageName.ToLower())
                {
                    lstNewLayouts.Add(new KeyValue(kvp.Key, kvp.Value));
                }
            }
            lstLayouts = lstNewLayouts;
        }
        else if (duplicateLayout)
        {
            string        key   = preset.ActiveLayout;
            List <string> pages = new List <string>();
            foreach (KeyValue kvp in lstLayouts)
            {
                if (kvp.Key.ToLower() != preset.ActiveLayout.ToLower())
                {
                    lstNewLayouts.Add(new KeyValue(kvp.Key, kvp.Value));
                }
                else
                {
                    pages.Add(kvp.Value);
                }
            }
            lstNewLayouts.Add(new KeyValue(key, string.Join(",", pages.ToArray())));
            lstLayouts = lstNewLayouts;
        }
        preset.lstLayouts = lstLayouts;
        string presetPath = Decide.IsTemplateDefault(TemplateName.Trim()) ? Utils.GetPresetPath_DefaultTemplate(TemplateName) : Utils.GetPresetPath(TemplateName);
        string pagepreset = presetPath + "/" + TemplateConstants.PagePresetFile;

        presetPath += "/" + "pagepreset.xml";
        AppErazer.ClearSysHash(ApplicationKeys.ActivePagePreset + "_" + GetPortalID);
        PresetHelper.WritePreset(presetPath, preset);
        HttpRuntime.Cache.Remove(CacheKeys.SageFrameJs);
        HttpRuntime.Cache.Remove(CacheKeys.SageFrameCss);
        SageFrame.Common.CacheHelper.Clear("PresetList");
        pageSEOName = ddlPages.SelectedValue.TrimStart('-');
        layoutName  = ddlLayout.SelectedValue;
        //BuildLayoutControl();
        //BindModuleControls();
        string redirectUrl = BuidRedirectURL(pageSEOName);

        Response.Redirect(redirectUrl);
    }