public ActionResult SetParameters(HiveId contentId, string macroAlias, bool isNew, string inlineMacroId = "", string macroParameters = "") { var viewModel = new SetParametersModel { ContentId = contentId, IsNew = isNew, InlineMacroId = inlineMacroId }; var macroEditorModel = GetMacroByAlias(macroAlias); BackOfficeRequestContext.Application.FrameworkContext.TypeMappers.Map <MacroEditorModel, SetParametersModel>(macroEditorModel, viewModel); if (!string.IsNullOrEmpty(macroParameters)) { var macroParamsDict = macroParameters.DecodeMacroParameters(); foreach (var macroParam in viewModel.MacroParameters.Where(macroParam => macroParamsDict.ContainsKey(macroParam.Alias))) { macroParam.ParameterEditorModel.SetModelValue(macroParamsDict[macroParam.Alias]); } } //return View(EmbeddedViewEngine.EmbeddedViewPath.Create("Rebel.Cms.Web.PropertyEditors.RichTextBox.Views.InsertMacroDialog.cshtml", "Rebel.Cms.Web.PropertyEditors")); return(View(EmbeddedViewPath.Create("Rebel.Cms.Web.PropertyEditors.RichTextBox.TinyMCE.Views.InsertMacro.SetParameters.cshtml, Rebel.Cms.Web.PropertyEditors"), viewModel)); }
public virtual ActionResult Index(IUmbracoRenderModel model) { if (model.CurrentNode == null) { return(new HttpNotFoundResult()); } using (var uow = RoutableRequestContext.Application.Hive.OpenReader <IFileStore>(new Uri("storage://templates"))) { var templateFile = model.CurrentNode.CurrentTemplate != null ? uow.Repositories.Get <File>(model.CurrentNode.CurrentTemplate.Id) : null; if (templateFile != null) { //try to find the view based on all engines registered. var view = MSMvc.ViewEngines.Engines.FindView(ControllerContext, Path.GetFileNameWithoutExtension(templateFile.RootedPath), ""); if (view.View != null) { return(View(view.View, model.CurrentNode)); } } //return the compiled default view! //TODO: Remove magic strings return(View( EmbeddedViewPath.Create("Umbraco.Cms.Web.EmbeddedViews.Views.TemplateNotFound.cshtml,Umbraco.Cms.Web"), model.CurrentNode)); } }
public ActionResult SetParametersForm(HiveId contentId, string macroAlias, bool isNew, string inlineMacroId = "") { // Create the view model var setParamsViewModel = new SetParametersModel { ContentId = contentId, IsNew = isNew, InlineMacroId = inlineMacroId }; // Populate view model with default content from macro definition var macroEditorModel = GetMacroByAlias(macroAlias); BackOfficeRequestContext.Application.FrameworkContext.TypeMappers.Map <MacroEditorModel, SetParametersModel>(macroEditorModel, setParamsViewModel); // Bind the post data back to the view model setParamsViewModel.BindModel(this); // Convert model var insertMacroViewModel = BackOfficeRequestContext.Application.FrameworkContext.TypeMappers.Map <SetParametersModel, InsertMacroModel>(setParamsViewModel); return(View(EmbeddedViewPath.Create("Rebel.Cms.Web.PropertyEditors.RichTextBox.TinyMCE.Views.InsertMacro.InsertMacro.cshtml, Rebel.Cms.Web.PropertyEditors"), insertMacroViewModel)); }
/// <summary> /// Gets the media parameters. /// </summary> /// <param name="EntitySchemaToDocumentTypeEditorModel">The media id.</param> /// <returns></returns> public JsonResult GetMediaParameters(HiveId mediaId) { string path = BackOfficeRequestContext.RoutingEngine.GetUrl(mediaId); Mandate.That <NullReferenceException>(!string.IsNullOrEmpty(path)); IEnumerable <object> viewParams = Enumerable.Empty <object>(); var ext = path.Split('.').LastOrDefault().ToLower(); object view; //first look for custom view using (var uow = BackOfficeRequestContext .Application .Hive.OpenReader <IFileStore>(new Uri("storage://templates"))) { var id = new HiveId(new Uri("storage://templates"), "", new HiveIdValue(string.Format("/MediaTemplates/{0}.cshtml", ext))); var customView = uow.Repositories.Get <File>(id); if (customView != null) { view = BuildManager.CreateInstanceFromVirtualPath(customView.RootRelativePath, typeof(object)); } } try { view = BuildManager.CreateInstanceFromVirtualPath( EmbeddedViewPath.GetFullPath(EmbeddedViewPath.Create( string.Format("Umbraco.Cms.Web.PropertyEditors.RichTextBox.TinyMCE.Views.InsertMedia.Types.{0}.cshtml, Umbraco.Cms.Web.PropertyEditors", ext))) , typeof(object)); } catch (TypeLoadException e) { view = BuildManager.CreateInstanceFromVirtualPath( EmbeddedViewPath.GetFullPath(EmbeddedViewPath.Create( "Umbraco.Cms.Web.PropertyEditors.RichTextBox.TinyMCE.Views.InsertMedia.Types.default.cshtml, Umbraco.Cms.Web.PropertyEditors")) , typeof(object)); } if (view != null) { viewParams = view.GetType() .GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly) .Select(x => new { name = x.Name }); } return(new CustomJsonResult(new { viewParams }.ToJsonString)); }
/// <summary> /// Gets the media markup. /// </summary> /// <param name="mediaId">The media id.</param> /// <param name="mediaParameters">The media parameters.</param> /// <returns></returns> public ActionResult GetMediaMarkup(HiveId mediaId, string mediaParameters = "") { string path = BackOfficeRequestContext.RoutingEngine.GetUrl(mediaId); Mandate.That <NullReferenceException>(!string.IsNullOrEmpty(path)); var ext = path.Split('.').LastOrDefault().ToLower(); var mediaParamsDict = new Dictionary <string, string>(); if (!string.IsNullOrEmpty(mediaParameters)) { mediaParamsDict = (Dictionary <string, string>)mediaParameters.DecodeMacroParameters(); } var bendyParams = new Framework.Dynamics.BendyObject(mediaParamsDict); var model = new Model.BackOffice.TinyMCE.InsertMedia.InsertMediaModel(mediaId, path, bendyParams); //first look for custom view using (var uow = BackOfficeRequestContext .Application .Hive.OpenReader <IFileStore>(new Uri("storage://templates"))) { var id = new HiveId(new Uri("storage://templates"), "", new HiveIdValue(string.Format("/MediaTemplates/{0}.cshtml", ext))); var customView = uow.Repositories.Get <File>(id); if (customView != null) { return(View(ext, model)); } } try { //try returning embedded view for extension return(View(EmbeddedViewPath.Create( string.Format("Umbraco.Cms.Web.PropertyEditors.RichTextBox.TinyMCE.Views.InsertMedia.Types.{0}.cshtml, Umbraco.Cms.Web.PropertyEditors", ext)), model)); } catch (TypeLoadException e) { //view for extension not found, return default image view var viewType = EmbeddedViewPath.Create("Umbraco.Cms.Web.PropertyEditors.RichTextBox.TinyMCE.Views.InsertMedia.Types.default.cshtml, Umbraco.Cms.Web.PropertyEditors"); return(View(viewType, model)); } }
//[EnableCompression] public virtual ActionResult Index(IRebelRenderModel model) { if (model.CurrentNode == null) { return(new HttpNotFoundResult()); } var contentCacheManager = new ContentCacheManager(RoutableRequestContext.Application, this); var content = contentCacheManager.RenderContent(model); if (string.IsNullOrEmpty(content.Key)) { return(View( EmbeddedViewPath.Create("Rebel.Cms.Web.EmbeddedViews.Views.TemplateNotFound.cshtml,Rebel.Cms.Web"), model.CurrentNode)); } return(Content(content.Value, content.Key)); }
public void Created_ViewPath_Passes_Microsoft_VirtualPath_Parser() { var path = EmbeddedViewPath.GetFullPath(EmbeddedViewPath.Create("Umbraco.Tests.Cms.EmbeddedViewEngine.TestView.cshtml", "Umbraco.Tests.Cms")); try { var result = BuildManager.CreateInstanceFromVirtualPath(path, typeof(WebViewPage)); } catch (Exception ex) { //this is the exception we are trying to avoid if (ex is ArgumentException && ex.Message.StartsWith("The relative virtual path") && ex.Message.EndsWith("is not allowed here.")) { throw; } } //no exception was thrown Assert.Pass(); }
public ActionResult SelectMacro(HiveId contentId, bool isNew) { using (var uow = BackOfficeRequestContext.Application.Hive.OpenReader <IFileStore>(new Uri("storage://macros"))) { var macros = uow.Repositories.GetAll <File>() .Select(MacroSerializer.FromFile).Where(x => x.UseInEditor) .Select(x => new SelectListItem { Text = x.Name, Value = x.Alias }); var model = new Rebel.Cms.Web.Model.BackOffice.TinyMCE.InsertMacro.SelectMacroModel { ContentId = contentId, IsNew = isNew, AvailableMacroItems = macros }; return(View( EmbeddedViewPath.Create("Rebel.Cms.Web.PropertyEditors.RichTextBox.TinyMCE.Views.InsertMacro.SelectMacro.cshtml, Rebel.Cms.Web.PropertyEditors"), model)); } }
/// <summary> /// Inserts the media. /// </summary> /// <returns></returns> public ActionResult InsertMedia() { return(View(EmbeddedViewPath.Create("Umbraco.Cms.Web.PropertyEditors.RichTextBox.TinyMCE.Views.InsertMedia.InsertMedia.cshtml, Umbraco.Cms.Web.PropertyEditors"))); }
public ActionResult InsertChar() { return(View(EmbeddedViewPath.Create("Rebel.Cms.Web.PropertyEditors.RichTextBox.TinyMCE.Views.InsertChar.InsertChar.cshtml, Rebel.Cms.Web.PropertyEditors"))); }