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);
    }
    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();
    }