public ActionResult Index(HiveId id) { var model = new InsertPartialModel { AvailablePartials = Enumerable.Empty <SelectListItem>() }; using (var uow = _partialsStore.CreateReadonly()) { var rootId = _partialsStore.GetRootNodeId(); var root = uow.Repositories.Get <File>(rootId); var partialIds = uow.Repositories.GetDescendantIds(_partialsStore.GetRootNodeId(), FixedRelationTypes.DefaultRelationType); var partials = uow.Repositories.Get <File>(true, partialIds).Where(x => !x.IsContainer); var availablePartials = new List <SelectListItem>(); foreach (var @partial in partials) { availablePartials.Add(new SelectListItem { Text = @partial.GetFilePathForDisplay(), Value = @partial.GetFilePathWithoutExtension() }); } model.AvailablePartials = availablePartials; } return(View(model)); }
public ActionResult Index(HiveId id) { var model = new ImplementSectionModel { AvailableSections = Enumerable.Empty <string>() }; using (var uow = _templateStore.CreateReadonly()) { var template = uow.Repositories.Get <File>(id); if (template != null) { var parser = new TemplateParser(); var result = parser.Parse(template); if (!string.IsNullOrWhiteSpace(result.Layout)) { var layoutFilePath = TemplateHelper.ResolveLayoutPath(result.Layout, template); var layoutFile = uow.Repositories.GetAll <File>().Where(x => x.RootedPath == layoutFilePath).FirstOrDefault(); var layoutResult = parser.Parse(layoutFile); model.AvailableSections = layoutResult.Sections.Where(x => x != "Body").ToArray(); } } } return(View(model)); }
//BUG: Well, not sure if this is a bug or not really but there's currently only 1 way to get the root HiveId for an IO // entity and thats to get Hive to return the entity based on a '/' Id. public static HiveId GetRootNodeId(this ReadonlyGroupUnitFactory <IFileStore> factory) { using (var uow = factory.CreateReadonly()) { var e = uow.Repositories.Get <File>(new HiveId("/")); return(e.Id); } }
public ActionResult Index(HiveId id) { var model = new InsertFieldModel(); using (var uow = _contentStore.CreateReadonly()) { var schemaIds = uow.Repositories.Schemas.GetDescendentRelations(FixedHiveIds.ContentRootSchema, FixedRelationTypes.DefaultRelationType) .DistinctBy(x => x.DestinationId) .Select(x => x.DestinationId).ToArray(); var schemas = uow.Repositories.Schemas.Get <EntitySchema>(true, schemaIds); var attributeDefs = schemas.SelectMany(x => x.AttributeDefinitions) .DistinctBy(x => x.Alias); var attributeAliases = new List <string>(); // This isn't ideal as we are currently hard coding which property editors // have complex data types. This will need to be updated when issue U5-332 // is addressed. foreach (var attributeDef in attributeDefs) { switch (attributeDef.AttributeType.RenderTypeProvider) { case CorePluginConstants.NodeNamePropertyEditorId: attributeAliases.Add("Name"); attributeAliases.Add("UrlName"); break; case CorePluginConstants.SelectedTemplatePropertyEditorId: attributeAliases.Add("CurrentTemplateId"); break; case CorePluginConstants.FileUploadPropertyEditorId: attributeAliases.Add(attributeDef.Alias + " - MediaId"); attributeAliases.Add(attributeDef.Alias + " - Value"); break; default: attributeAliases.Add(attributeDef.Alias); break; } } model.AvailableFields = attributeAliases .OrderBy(x => x.StartsWith("system-") ? 1 : -1) // Force system fields to the bottom .ThenBy(x => x); model.AvailableCasingTypes = Enum.GetNames(typeof(UmbracoRenderItemCaseType)) .OrderBy(x => x == "Unchanged" ? -1 : 1); model.AvailableEncodingTypes = Enum.GetNames(typeof(UmbracoRenderItemEncodingType)) .OrderBy(x => x == "Unchanged" ? -1 : 1); } return(View(model)); }