Beispiel #1
0
    public static List <TemplateInfo> GetTemplateList(int PortalID)
    {
        string              templates      = Utils.GetAbsolutePath(TemplateConstants.TemplateDirectory);
        DirectoryInfo       dir            = new DirectoryInfo(templates);
        List <TemplateInfo> lstTemplates   = new List <TemplateInfo>();
        string              activeTemplate = TemplateController.GetActiveTemplate(PortalID).TemplateName;

        if (activeTemplate.Length < 1)
        {
            activeTemplate = "Default";
        }
        foreach (DirectoryInfo temp in dir.GetDirectories())
        {
            TemplateInfo tempObj = new TemplateInfo(temp.Name, temp.FullName, GetThumbPath(temp.FullName, temp.Name, TemplateConstants.TemplateDirectory), false, false);
            if (temp.Name.ToLower().Replace(' ', '_').Equals(activeTemplate.ToLower()))
            {
                tempObj.IsActive = true;
            }
            lstTemplates.Add(tempObj);
        }
        bool IsDefaultActive = activeTemplate.ToLower().Equals("default") ? true : false;
        //Commented To Get Only AspxCommerce Template From Templates Folder
        //lstTemplates.Insert(0, new TemplateInfo("Default", "/Core/Template/", GetThumbPath(HttpContext.Current.Server.MapPath("~/Core/Template/"), "Template", "Core/"), IsDefaultActive, true));
        List <TemplateInfo> lstFinalTemplates   = new List <TemplateInfo>();
        List <TemplateInfo> lstAppliedTemplates = new List <TemplateInfo>();

        try
        {
            lstAppliedTemplates = TemplateController.GetPortalTemplates();
        }
        catch (Exception)
        {
            throw;
        }
        foreach (TemplateInfo template in lstTemplates)
        {
            bool status = false;
            foreach (TemplateInfo templt in lstAppliedTemplates)
            {
                if (template.TemplateName.ToLower() == templt.TemplateName.ToLower() && templt.PortalID != PortalID)
                {
                    status = true;
                    break;
                }
            }
            if (!status)
            {
                template.IsApplied = false;
            }
            else
            {
                template.IsApplied = true;
            }
        }
        return(lstTemplates);
    }
        //private string GetUpgraderUrl()
        //{
        //    string upgradeLink = string.Empty;
        //    if (GetPortalID > 1)
        //    {
        //        upgradeLink = "~/portal/" + GetPortalSEOName + "/Admin/sfUpgrader" + Extension;
        //    }
        //    else
        //    {
        //        upgradeLink = "~/Admin/sfUpgrader" + Extension;
        //    }
        //    return upgradeLink;
        //}

        private void SetPortalCofig()
        {
            Hashtable       hstPortals = GetPortals();
            SageUserControl suc        = new SageUserControl();

            suc.PagePath = PagePath;
            int portalID = 1;

            #region "Get Portal SEO Name and PortalID"
            if (string.IsNullOrEmpty(Request.QueryString["ptSEO"]))
            {
                if (string.IsNullOrEmpty(PortalSEOName))
                {
                    PortalSEOName = GetDefaultPortalName(hstPortals, 1);
                }
                else if (!hstPortals.ContainsKey(PortalSEOName.ToLower().Trim()))
                {
                    PortalSEOName = GetDefaultPortalName(hstPortals, 1);
                }
                else
                {
                    portalID = int.Parse(hstPortals[PortalSEOName.ToLower().Trim()].ToString());
                }
            }
            else
            {
                PortalSEOName = Request.QueryString["ptSEO"].ToString().ToLower().Trim();
                portalID      = Int32.Parse(Request.QueryString["ptlid"].ToString());
            }
            #endregion
            suc.SetPortalSEOName(PortalSEOName.ToLower().Trim());
            Session[SessionKeys.SageFrame_PortalSEOName]               = PortalSEOName.ToLower().Trim();
            Session[SessionKeys.SageFrame_PortalID]                    = 1;
            Session[SessionKeys.SageFrame_AdminTheme]                  = ThemeHelper.GetAdminTheme(1, GetUsername);
            Globals.sysHst[ApplicationKeys.ActiveTemplate + "_" + 1]   = TemplateController.GetActiveTemplate(1).TemplateSeoName;
            Globals.sysHst[ApplicationKeys.ActivePagePreset + "_" + 1] = PresetHelper.LoadActivePagePreset(GetActiveTemplate, GetPageSEOName(Request.Url.ToString()));
            suc.SetPortalID(1);
            SetPortalID(1);
            #region "Set user credentials for modules"
            //SecurityPolicy objSecurity = new SecurityPolicy();
            //if (objSecurity.GetUser(1) != string.Empty)
            //{
            //    SettingProvider objSP = new SettingProvider();
            //    SageFrameConfig sfConfig = new SageFrameConfig();
            //    string strRoles = string.Empty;
            //    List<SageUserRole> sageUserRolles = objSP.RoleListGetByUsername(objSecurity.GetUser(1), 1);
            //    if (sageUserRolles != null)
            //    {
            //        foreach (SageUserRole userRole in sageUserRolles)
            //        {
            //            strRoles += userRole.RoleId + ",";
            //        }
            //    }
            //    if (strRoles.Length > 1)
            //    {
            //        strRoles = strRoles.Substring(0, strRoles.Length - 1);
            //    }
            //    if (strRoles.Length > 0)
            //    {
            //        SetUserRoles(strRoles);
            //    }
            //}
            #endregion
        }
        private void SetPortalCofig()
        {
            Hashtable       hstPortals = GetPortals();
            SageUserControl suc        = new SageUserControl();
            int             portalID   = 1;

            #region "Get Portal SEO Name and PortalID"
            if (string.IsNullOrEmpty(Request.QueryString["ptSEO"]))
            {
                if (string.IsNullOrEmpty(PortalSEOName))
                {
                    PortalSEOName = GetDefaultPortalName(hstPortals, 1);// 1 is for Default Portal
                }
                else if (!hstPortals.ContainsKey(PortalSEOName.ToLower().Trim()))
                {
                    PortalSEOName = GetDefaultPortalName(hstPortals, 1);// 1 is for Default Portal
                }
                else
                {
                    portalID = int.Parse(hstPortals[PortalSEOName.ToLower().Trim()].ToString());
                }
            }
            else
            {
                PortalSEOName = Request.QueryString["ptSEO"].ToString().ToLower().Trim();
                portalID      = Int32.Parse(Request.QueryString["ptlid"].ToString());
            }
            #endregion

            suc.SetPortalSEOName(PortalSEOName.ToLower().Trim());
            Session[SessionKeys.SageFrame_PortalSEOName] = PortalSEOName.ToLower().Trim();
            Session[SessionKeys.SageFrame_PortalID]      = portalID;
            string tempName = /*activeTemplate;// */ TemplateController.GetActiveTemplate(currentportalID).TemplateSeoName;
            string tempPath = Decide.IsTemplateDefault(tempName) ? Utils.GetTemplatePath_Default(tempName) : Utils.GetTemplatePath(tempName);
            if (!Directory.Exists(tempPath))
            {
                tempName = "default";
            }
            Globals.sysHst[ApplicationKeys.ActiveTemplate + "_" + currentportalID] = tempName;
            //Globals.sysHst[ApplicationKeys.ActivePagePreset + "_" + currentportalID] = LoadActivePagePreset() || PresetHelper.LoadActivePagePreset(tempName, GetPageSEOName(Request.Url.ToString()));
            LoadActivePagePreset();
            suc.SetPortalID(portalID);
            SetPortalID(portalID);
            #region "Set user credentials for modules"
            if (SecurityPolicy.GetUser(GetPortalID) != string.Empty)
            {
                SettingProvider objSP    = new SettingProvider();
                SageFrameConfig sfConfig = new SageFrameConfig();
                if (SecurityPolicy.GetUser(GetPortalID) != string.Empty)
                {
                    string strRoles = string.Empty;

                    List <SageUserRole> sageUserRolles = objSP.RoleListGetByUsername(SecurityPolicy.GetUser(GetPortalID), currentportalID);
                    if (sageUserRolles != null)
                    {
                        foreach (SageUserRole userRole in sageUserRolles)
                        {
                            strRoles += userRole.RoleId + ",";
                        }
                    }
                    if (strRoles.Length > 1)
                    {
                        strRoles = strRoles.Substring(0, strRoles.Length - 1);
                    }
                    if (strRoles.Length > 0)
                    {
                        SetUserRoles(strRoles);
                    }
                }
            }
            #endregion
        }
    public void GetTemplateList(int PortalID)
    {
        string              templates      = Utils.GetAbsolutePath(TemplateConstants.TemplateDirectory);
        DirectoryInfo       dir            = new DirectoryInfo(templates);
        List <TemplateInfo> lstTemplates   = new List <TemplateInfo>();
        string              activeTemplate = TemplateController.GetActiveTemplate(PortalID).TemplateName;

        if (activeTemplate.Length < 1)
        {
            activeTemplate = "Default";
        }
        foreach (DirectoryInfo temp in dir.GetDirectories())
        {
            TemplateInfo tempObj = new TemplateInfo(temp.Name, temp.FullName, GetThumbPath(temp.FullName, temp.Name, TemplateConstants.TemplateDirectory), false, false);
            if (temp.Name.ToLower().Replace(' ', '_').Equals(activeTemplate.ToLower()))
            {
                tempObj.IsActive = true;
            }
            lstTemplates.Add(tempObj);
        }
        //bool IsDefaultActive = activeTemplate.ToLower().Equals("default") ? true : false;
        //lstTemplates.Insert(0, new TemplateInfo("Default", "/Core/Template/", GetThumbPath(HttpContext.Current.Server.MapPath("~/Core/Template/"), "Template", "Core/"), IsDefaultActive, true));
        List <TemplateInfo> lstFinalTemplates   = new List <TemplateInfo>();
        List <TemplateInfo> lstAppliedTemplates = new List <TemplateInfo>();

        try
        {
            lstAppliedTemplates = TemplateController.GetPortalTemplates();
        }
        catch (Exception)
        {
            throw;
        }
        foreach (TemplateInfo template in lstTemplates)
        {
            bool status = false;
            foreach (TemplateInfo templt in lstAppliedTemplates)
            {
                if (template.TemplateName.ToLower() == templt.TemplateName.ToLower() && templt.PortalID != PortalID)
                {
                    status = true;
                    break;
                }
            }
            if (!status)
            {
                template.IsApplied = false;
            }
            else
            {
                template.IsApplied = true;
            }
        }
        StringBuilder html = new StringBuilder();

        foreach (TemplateInfo template in lstTemplates)
        {
            string tempMarkup    = string.Empty;
            string isActiveClass = template.IsActive ? "class='sfTemplateholder sfCurve sfActivetemplate'" : "class='sfTemplateholder  sfCurve '";
            html.Append("<div ");
            html.Append(isActiveClass);
            html.Append(" data-templateName='");
            html.Append(template.TemplateName);
            html.Append("' >");
            //html.Append("<a href='#' rel='");
            //html.Append(template.TemplateName);
            //html.Append("' class='sfTemplatethumb'>");
            html.Append("<div class='ImageWrapper'>");
            html.Append("<img alt='Default' src='");
            html.Append(template.ThumbImage);
            html.Append("'>");
            html.Append("</div>");
            //html.Append("</a>");
            html.Append("<div class='sfTemplatedetail'>");
            html.Append("<ul><li class='title'><span>");
            html.Append(template.TemplateName);
            html.Append("</span> </li> <li class='author'><span>By:<a href='#'>Contentder</a></span> </li>");
            html.Append("</ul></div>");
            string activateId = "lnkActivate#" + template.TemplateSeoName;
            string previewId  = "lnkPreview#" + template.TemplateSeoName;
            if (!template.IsDefault)
            {
                if (!template.IsActive)
                {
                    html.Append("<i class='icon-close sfDelete' href='#' rel=");
                    html.Append(template.TemplateSeoName);
                    html.Append("></i>");
                }
            }
            string isActivated = "<i class='fa fa-check-square-o' aria-hidden='true'></i>";
            if (template.IsActive)
            {
                isActivated = "Activated";
            }
            //html.Append("<div class='sfButtonwrapper'>");
            //html.Append("<ul class='sfTemplateSetting'><li class='sfViewDemo'><a href='#' ><i class="fa fa-eye"></i></a></li><li class="activate"><a href="#" id=' + activateId + '>' + isActivated + '</a></li>';
            //html.Append(" <li class="sfTemplateCustomize"><a href="#"><i class="fa fa-cog"></i></a><ul  class="sfTemplateEdit">';
            //html.Append("<li class="sfPages"><a href="' + SageFrameHostURL + '/Admin/Pages' + p.Extension + '" target="_blank" >Pages</a></li>';
            //html.Append("<li class="templatePreset" data="' + template.TemplateName + '">Preset</li><li class="templateLayout" data="' + template.TemplateName + '">Layout Manager</li><li class="lnkThemes" data="' + template.TemplateName + '">Theme Options</li></ul></li>';
            //var editFileLink = p.EditFilePath + '/Admin/Template-File-Editor' + p.Extension + '?tname=' + template.TemplateSeoName;
            //// if (!item.IsDefault) {
            //tempMarkup += '<li class="sfEditfiles"><a href=' + editFileLink + ' id="lnkEditFiles"><i class="fa fa-pencil-square-o"></i></a></li>';
            ////                        if (!item.IsActive)
            ////                            tempMarkup += ' <li class="sfDelete"><a href="#" id="lnkDelete" rel=' + template.TemplateSeoName + '>Delete</a></li>';
            ////}
            //html.Append("</ul></div><div class='clear'></div></div>");
            html.Append("<div class='templateoverlay'><span class='checked'></span></div>");
            html.Append("<div class='clear'></div></div>");
            //  if (SageFramePortalID == 1) {
            //     html += tempMarkup;
            //}
            //else {
            //if (!template.IsApplied)
            //{
            //    html += tempMarkup;
            //}

            //}
        }
        //lstTemplates;
        ltrTemplateList.Text = html.ToString();
    }