예제 #1
0
 public List <TagDetailsInfo> GetAllPopularTags(AspxCommonInfo aspxCommonObj, int count)
 {
     try
     {
         PopularTagsController ptc          = new PopularTagsController();
         List <TagDetailsInfo> lstTagDetail = ptc.GetAllPopularTags(aspxCommonObj, count);
         return(lstTagDetail);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
    public void GetAllPopularTags()
    {
        AspxCommonInfo aspxCommonObj = new AspxCommonInfo();

        aspxCommonObj.StoreID     = StoreID;
        aspxCommonObj.PortalID    = PortalID;
        aspxCommonObj.UserName    = UserName;
        aspxCommonObj.CultureName = CultureName;
        string modulePath             = this.AppRelativeTemplateSourceDirectory;
        string aspxTemplateFolderPath = ResolveUrl("~/") + "Templates/" + TemplateName;
        string aspxRootPath           = ResolveUrl("~/");

        hst = AppLocalized.getLocale(modulePath);
        string pageExtension               = SageFrameSettingKeys.PageExtension;
        int?   tagCount                    = 0;
        PopularTagsController ptc          = new PopularTagsController();
        List <TagDetailsInfo> lstTagDetail = ptc.GetAllPopularTags(aspxCommonObj, PopularTagCount);

        tagCount = lstTagDetail.Count;
        if (tagCount > PopularTagCount)
        {
            lstTagDetail.RemoveAt(lstTagDetail.Count - 1);
        }
        StringBuilder popularTagContent = new StringBuilder();

        popularTagContent.Append("<div id=\"divPopularTags\" class=\"cssClassPopularTags\">");
        StringBuilder allTag = new StringBuilder();

        allTag.Append("<span id=\"divViewAllTags\" class=\"cssClassViewAllTags\"></span>");
        ltrViewAllTag.Text = allTag.ToString();
        if (lstTagDetail != null && lstTagDetail.Count > 0)
        {
            float?totalTagCount = 0;
            popularTagContent.Append("<ul id=\"tagList\">");
            for (int index = 0; index < lstTagDetail.Count; index++)
            {
                totalTagCount = lstTagDetail[index].TagCount;
                string fSize = (totalTagCount / 10 < 1) ? ((totalTagCount / 10) + 1) + "em" : (((totalTagCount / 10) > 2) ? "2em" : (totalTagCount / 10) + "em");
                if (index != lstTagDetail.Count - 1)
                {
                    popularTagContent.Append("<li><a title=\"See all items tagged with ");
                    popularTagContent.Append(lstTagDetail[index].Tag);
                    popularTagContent.Append("\" href=\"");
                    popularTagContent.Append(aspxRedirectPath + ViewTaggedItemPageName + pageExtension + "?tagsId=");
                    popularTagContent.Append(lstTagDetail[index].ItemTagIDs);
                    popularTagContent.Append("\" style=\"");
                    popularTagContent.Append("font-size: ");
                    popularTagContent.Append(fSize);
                    popularTagContent.Append(";\">");
                    popularTagContent.Append(lstTagDetail[index].Tag + " ");
                    popularTagContent.Append("</a></li>");
                }
                else
                {
                    popularTagContent.Append("<li><a title=\"See all items tagged with ");
                    popularTagContent.Append(lstTagDetail[index].Tag);
                    popularTagContent.Append("\" href=\"");
                    popularTagContent.Append(aspxRedirectPath + ViewTaggedItemPageName + pageExtension + "?tagsId=");
                    popularTagContent.Append(lstTagDetail[index].ItemTagIDs);
                    popularTagContent.Append("\" style=\"");
                    popularTagContent.Append("font-size: ");
                    popularTagContent.Append(fSize);
                    popularTagContent.Append("\">");
                    popularTagContent.Append(lstTagDetail[index].Tag);
                    popularTagContent.Append("</a></li>");
                }
            }
            popularTagContent.Append("</ul><div class=\"cssClassClear\"></div>");
            if (tagCount > PopularTagCount && tagCount > 0)
            {
                string strHtml = "<span class=\"cssClassViewMore\"><a href=\"" + aspxRedirectPath + ViewAllTagsPageName + pageExtension + "\" title =\"View all tags\">" + getLocale("View All Tags") + "</a></span>";
                popularTagContent.Append(strHtml);
                ltrViewAllTag.Visible = true;
            }
            else
            {
                ltrViewAllTag.Visible = false;
            }
        }
        else
        {
            popularTagContent.Append("<span class=\"cssClassNotFound\">");
            popularTagContent.Append(getLocale("Not any items have been tagged yet!"));
            popularTagContent.Append("</span>");
            ltrViewAllTag.Visible = false;
        }
        popularTagContent.Append("</div>");
        ltrPopularTags.Text = popularTagContent.ToString();
    }