private FieldList GetItemFieldsInternal(ItemDefinition item, VersionUri version, CallContext context) { var list = new FieldList(); ControllerType controllerType = null; if (item.ID == FolderId || ControllerType.GetAllNamespaces().ContainsKey(item.ID.ToGuid()) || ((controllerType = ControllerType.GetControllerType(item.ID)) != null)) { list.Add(FieldIDs.Icon, Themes.MapTheme("SoftwareV2/16x16/elements.png")); if (controllerType != null) { list.Add(FieldIDs.DisplayName, controllerType.Description); } AddStandardFields(list); } else { var action = ControllerAction.GetControllerAction(item.ID); if (action != null) { AddActionFields(list, action); AddStandardFields(list); } } return(list.Count == 0 ? base.GetItemFields(item, version, context) : list); }
public override IDList GetChildIDs(ItemDefinition itemDefinition, CallContext context) { ControllerType controllerType; var list = new IDList(); if (itemDefinition.ID == ParentId) { if (GetSqlVersion(FolderId, context, GetSqlProvider(Database)) == null) { list.Add(FolderId); } } else if (itemDefinition.ID == FolderId) { AddAllNamespaces(list, context); } else if (ControllerType.GetAllNamespaces().ContainsKey(itemDefinition.ID.ToGuid())) { AddControllers(list, itemDefinition.ID.ToGuid(), context); } else if ((controllerType = ControllerType.GetControllerType(itemDefinition.ID)) != null) { AddAllActions(list, controllerType, context); } else { return(null); } if (list.Count == 0) { return(null); } return(list); }
public override ID GetParentID(ItemDefinition itemDefinition, CallContext context) { if (context.CurrentResult != null) { return(null); } if (itemDefinition.ID == FolderId) { return(ParentId); } if (ControllerType.GetAllNamespaces().ContainsKey(itemDefinition.ID.ToGuid())) { return(FolderId); } ControllerType controller = ControllerType.GetControllerType(itemDefinition.ID); if (controller != null) { return(new ID(controller.ParentId)); } ControllerAction action = ControllerAction.GetControllerAction(itemDefinition.ID); if (action != null) { return(new ID(action.ControllerType.Id)); } return(base.GetParentID(itemDefinition, context)); }
private bool EnsureSqlVersion(ItemDefinition itemDefinition, DataProvider sqlProvider, CallContext context) { var sqlVersion = GetSqlVersion(itemDefinition.ID, context, sqlProvider); if (sqlVersion != null) { return(true); } if (itemDefinition.ID == FolderId || ControllerType.GetAllNamespaces().ContainsKey(itemDefinition.ID.ToGuid()) || ControllerType.GetAllControllers().ContainsKey(itemDefinition.ID.ToGuid()) || ControllerAction.GetControllerAction(itemDefinition.ID) != null) { var parentId = GetParentID(itemDefinition, context) ?? sqlProvider.GetParentID(itemDefinition, context); var itemdef = GetItemDefinition(parentId, context) ?? sqlProvider.GetItemDefinition(parentId, context); if (!sqlProvider.CreateItem(itemDefinition.ID, itemDefinition.Name, itemDefinition.TemplateID, itemdef, context)) { return(false); } var item = Database.GetItem(itemDefinition.ID); var existingFields = new ItemChanges(item); foreach (Field field in item.Fields) { existingFields.SetFieldValue(field, item[field.ID]); } sqlProvider.SaveItem(itemDefinition, existingFields, context); return(true); } return(false); }
void AddAllNamespaces(IDList list, IDList existingList) { foreach (var nspace in ControllerType.GetAllNamespaces()) { if (!existingList.Contains(new ID(nspace.Key))) { list.Add(new ID(nspace.Key)); } } }
void AddAllNamespaces(IDList list, CallContext context) { var sqlProvider = GetSqlProvider(Database); foreach (var nspace in ControllerType.GetAllNamespaces().Where(s => { return(GetSqlVersion(new ID(s.Key), context, sqlProvider) == null); })) { list.Add(new ID(nspace.Key)); } }
public override ItemDefinition GetItemDefinition(ID itemId, CallContext context) { Assert.ArgumentNotNull(itemId, "itemId"); Assert.ArgumentNotNull(context, "context"); if (context.CurrentResult != null) { return(null); } if (itemId == FolderId) { return(new ItemDefinition(itemId, FolderName, FolderTemplateId, this.MasterId)); } var allNamespaces = ControllerType.GetAllNamespaces(); var nspace = allNamespaces.ContainsKey(itemId.ToGuid()) ? allNamespaces[itemId.ToGuid()] : null; if (!string.IsNullOrEmpty(nspace)) { return(new ItemDefinition(itemId, ItemUtil.ProposeValidItemName(nspace.Replace(".", "_")), FolderTemplateId, this.MasterId)); } var type = ControllerType.GetControllerType(itemId); if (type != null) { return(new ItemDefinition(itemId, ItemUtil.ProposeValidItemName(type.ControllerName), FolderTemplateId, this.MasterId)); } var action = ControllerAction.GetControllerAction(itemId); if (action != null) { return(new ItemDefinition(itemId, ItemUtil.ProposeValidItemName(action.ActionName), ControllerRenderingId, this.MasterId)); } return(base.GetItemDefinition(itemId, context)); }
public override ItemDefinition GetItemDefinition(ID itemId, CallContext context) { Assert.ArgumentNotNull(itemId, "itemId"); Assert.ArgumentNotNull(context, "context"); if (GetSqlVersion(itemId, context, GetSqlProvider(Database)) != null) { return(null); } if (itemId == FolderId) { return(new ItemDefinition(itemId, FolderName, FolderTemplateId, this.MasterId)); } var allNamespaces = ControllerType.GetAllNamespaces(); var nspace = allNamespaces.ContainsKey(itemId.ToGuid()) ? allNamespaces[itemId.ToGuid()] : null; if (!string.IsNullOrEmpty(nspace)) { return(new ItemDefinition(itemId, nspace, FolderTemplateId, this.MasterId)); } var type = ControllerType.GetControllerType(itemId); if (type != null) { return(new ItemDefinition(itemId, type.ControllerName, FolderTemplateId, this.MasterId)); } var action = ControllerAction.GetControllerAction(itemId); if (action != null) { return(new ItemDefinition(itemId, action.ActionName, ControllerRenderingId, this.MasterId)); } return(base.GetItemDefinition(itemId, context)); }
public override VersionUriList GetItemVersions(ItemDefinition itemDefinition, CallContext context) { Assert.ArgumentNotNull(itemDefinition, "itemDefinition"); Assert.ArgumentNotNull(context, "context"); if (context.CurrentResult != null) { return(null); } if (itemDefinition.ID == FolderId || ControllerType.GetAllNamespaces().ContainsKey(itemDefinition.ID.ToGuid()) || ControllerType.GetAllControllers().ContainsKey(itemDefinition.ID.ToGuid()) || ControllerAction.GetControllerAction(itemDefinition.ID) != null) { VersionUriList versionUriList = new VersionUriList(); foreach (Language language in LanguageManager.GetLanguages(Database)) { versionUriList.Add(language, Version.First); } return(versionUriList); } return(null); }
public override FieldList GetItemFields(ItemDefinition item, VersionUri version, CallContext context) { Assert.ArgumentNotNull(item, "item"); Assert.ArgumentNotNull(version, "version"); Assert.ArgumentNotNull(context, "context"); if (GetSqlVersion(item.ID, context, GetSqlProvider(Database)) != null) { return(null); } var list = new FieldList(); ControllerType controllerType = null; if (item.ID == FolderId || ControllerType.GetAllNamespaces().ContainsKey(item.ID.ToGuid()) || ((controllerType = ControllerType.GetControllerType(item.ID)) != null)) { list.Add(FieldIDs.Icon, Themes.MapTheme("SoftwareV2/16x16/elements.png")); if (controllerType != null) { list.Add(FieldIDs.DisplayName, controllerType.Description); } } else { var action = ControllerAction.GetControllerAction(item.ID); if (action != null && HttpContext.Current != null) { AddActionFields(list, action); } } if (list.Count == 0) { return(base.GetItemFields(item, version, context)); } return(list); }
public override IDList GetChildIDs(ItemDefinition itemDefinition, CallContext context) { ControllerType controllerType; var list = new IDList(); var existingList = context.CurrentResult as IDList ?? new IDList(); if (itemDefinition.ID == ParentId) { if (!existingList.Contains(FolderId)) { list.Add(FolderId); } } else if (itemDefinition.ID == FolderId) { AddAllNamespaces(list, existingList); } else if (ControllerType.GetAllNamespaces().ContainsKey(itemDefinition.ID.ToGuid())) { AddControllers(list, itemDefinition.ID.ToGuid(), existingList); } else if ((controllerType = ControllerType.GetControllerType(itemDefinition.ID)) != null) { AddAllActions(list, controllerType, existingList); } else { return(null); } if (list.Count == 0) { return(null); } return(list); }