public ActionResult Index(FormCollection input) { if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to manage aliases"))) { return(new HttpUnauthorizedResult()); } var viewModel = new AdminIndexViewModel { AliasEntries = new List <AliasEntry>(), Options = new AdminIndexOptions() }; UpdateModel(viewModel); var checkedItems = viewModel.AliasEntries.Where(c => c.IsChecked); switch (viewModel.Options.BulkAction) { case AliasBulkAction.None: break; case AliasBulkAction.Delete: foreach (var checkedItem in checkedItems) { _aliasService.Delete(checkedItem.Alias.Path); } break; default: throw new ArgumentOutOfRangeException(); } return(RedirectToAction("Index")); }
public void RemoveAliases(RoutesPart part) { var aliases = part.AlternateRoutes.Select(x => x.Alias).ToArray(); foreach (var alias in aliases) { _aliasService.Delete(alias, AliasSource); } }
public void Publish(RedirectRoutesPart part) { foreach (var alias in part.OldRoutes) { _aliasService.Delete(alias.Alias); } int i = 0; foreach (var alias in part.Routes) { var routeValues = new RouteValueDictionary(); routeValues.Add("id", part.ContentItem.Id); routeValues.Add("index", i); routeValues.Add("action", "Index"); routeValues.Add("controller", "Redirect"); routeValues.Add("area", "Hazza.Routes"); _aliasService.Set(alias.Alias, routeValues, Source, true); i++; } }
/* * <Aliases> * <Alias Path="Profile/Edit" Area="Custom.Profile"> * <RouteValues> * <Add Key="area" Value="Custom.Profile" /> * <Add Key="controller" Value="Profile" /> * <Add Key="action" Value="Edit" /> * </RouteValues> * </Alias> */ //Enable any features that are in the list, disable features that aren't in the list public void ExecuteRecipeStep(RecipeContext recipeContext) { if (!String.Equals(recipeContext.RecipeStep.Name, "Aliases", StringComparison.OrdinalIgnoreCase)) { return; } var aliasElements = recipeContext.RecipeStep.Step.Descendants("Alias"); foreach (var aliasElement in aliasElements) { var path = aliasElement.Attribute("Path").Value; var rvd = new RouteValueDictionary(); var routeValuesElement = aliasElement.Descendants("RouteValues").FirstOrDefault(); if (routeValuesElement != null) { foreach (var routeValue in routeValuesElement.Descendants("Add")) { rvd.Add(routeValue.Attribute("Key").Value, routeValue.Attribute("Value").Value); } } _aliasService.Set(path, rvd, "Custom"); } //remove all local pathys that are not present in the remote export var allRemotePaths = recipeContext.RecipeStep.Step.XPathSelectElements("Paths/Add").Select(e => e.Attribute("Path").Value); var allLocalPaths = _aliasService.List().Select(t => t.Item1).ToList(); foreach (var path in allLocalPaths.Where(p => !allRemotePaths.Contains(p))) { _aliasService.Delete(path); } recipeContext.Executed = true; }
public void RemoveAliases(AutoroutePart part) { // https://github.com/OrchardCMS/Orchard/issues/5137 // If the alias of the specified part is empty while not being the homepage, // we need to make sure we are not removing all empty aliases in order to prevent losing the homepage content item being the homepage. if (String.IsNullOrWhiteSpace(part.Path)) { if (!IsHomePage(part)) { // The item being removed is NOT the homepage, so we need to make sure we're not removing the alias for the homepage. var aliasRecordId = GetHomePageAliasRecordId(); // Remove all aliases EXCEPT for the alias of the homepage. _aliasStorage.Remove(x => x.Path == part.Path && x.Source == AliasSource && x.Id != aliasRecordId); // Done. return; } } // Safe to delete all aliases for the specified part since it is definitely not the homepage. _aliasService.Delete(part.Path, AliasSource); }
public void RemoveAliases(AutoroutePart part) { _aliasService.Delete(part.Path, AliasSource); }