GetFromId() public static method

public static GetFromId ( int id, Type ct ) : ItemType
id int
ct System.Type
return ItemType
Exemplo n.º 1
0
        public static string BuildEditUrl(int itemId, int tabId, int moduleId, int portalId)
        {
            int      id     = Convert.ToInt32(itemId, CultureInfo.InvariantCulture);
            int      typeId = Item.GetItemTypeId(id, portalId);
            ItemType type   = ItemType.GetFromId(typeId, typeof(ItemType));
            Item     i; // = null;

            if (type.Name == ItemType.Article.Name)
            {
                i = Article.GetArticle(id, portalId);
            }
            else
            {
                i = Category.GetCategory(id, portalId);
            }

            string returnUrl = string.Empty;

            if (HttpContext.Current != null)
            {
                returnUrl = "returnUrl=" + HttpUtility.UrlEncode(HttpContext.Current.Request.RawUrl);
            }

            return(Globals.NavigateURL(
                       tabId,
                       string.Empty,
                       "ctl=" + Utility.AdminContainer,
                       "mid=" + moduleId.ToString(CultureInfo.InvariantCulture),
                       "adminType=" + type.Name + "Edit",
                       "versionId=" + i.ItemVersionId.ToString(CultureInfo.InvariantCulture),
                       returnUrl));
        }
Exemplo n.º 2
0
        public static string GetItemLinkUrl(object itemId, PortalSettings portalSettings)
        {
            if (itemId != null)
            {
                int      id     = Convert.ToInt32(itemId, CultureInfo.InvariantCulture);
                int      typeId = Item.GetItemTypeId(id, portalSettings.PortalId);
                ItemType type   = ItemType.GetFromId(typeId, typeof(ItemType));

                Item i;
                if (type.Name == ItemType.Article.Name)
                {
                    i = Article.GetArticle(id, portalSettings.PortalId);
                }
                else
                {
                    i = Category.GetCategory(id, portalSettings.PortalId);
                }

                if (i != null)
                {
                    return(GetItemLinkUrl(i, portalSettings));
                }

                // else there is no current version of this ITEM. Can't view it currently because ItemLink.aspx doesn't
                // support versions. hk
            }

            return(string.Empty);
        }
Exemplo n.º 3
0
        public static string GetItemLinkUrl(int itemId, PortalSettings portalSettings, int tabId, int moduleId, int pageId, string cultureName)
        {
            int      typeId = Item.GetItemTypeId(itemId, portalSettings.PortalId);
            ItemType type   = ItemType.GetFromId(typeId, typeof(ItemType));
            Item     item; // = null;

            if (type.Name == ItemType.Article.Name)
            {
                item = Article.GetArticle(itemId, portalSettings.PortalId);
            }
            else
            {
                item = Category.GetCategory(itemId, portalSettings.PortalId);
            }

            if (item != null)
            {
                return(GetItemLinkUrl(item, portalSettings, tabId, moduleId, pageId, cultureName));
            }

            return(string.Empty);
        }