public ResourceCollection UserInterfaceJs() { var js = new ResourceCollection(); foreach (var plugin in ObjectFactory.Model.GetAllPossible<IEyePatchPlugin>()) { js.AddRange(plugin.Js); } return js; }
public ResourceCollection AdminJs(string id) { var page = Load(id); var distinctWidgets = page.ContentAreas.SelectMany(w => w.Widgets).GroupBy(w => w.Type).Select(g => g.First().GetInstance()); var result = new ResourceCollection(); foreach (var widget in distinctWidgets.Where(w => w.AdminJs != null)) { result.AddRange(widget.AdminJs); } return result; }
public static WidgetInstance ToViewModel(this Widget pageWidget, ResourceCollection pageJs, ResourceCollection pageCss, IContentManager contentManager, Controller controller, string sourceUrl) { var widget = pageWidget.GetInstance(); pageJs.AddRange(AdminPanelViewModel.DependentJs); pageCss.AddRange(AdminPanelViewModel.DependentCss); var remainingJs = contentManager.Resources.GetResourcePaths(widget.AdminJs.Except(pageJs).ToResourceCollection()).ToList(); var remainingCss = contentManager.Resources.GetResourcePaths(widget.AdminCss.Except(pageCss).ToResourceCollection()).ToList (); string contents; using (var sw = new MemoryStream()) { using (var writer = new HtmlTextWriter(new StringWriter())) { widget.Render(new WidgetContext(controller.ControllerContext, pageWidget, writer, sourceUrl)); contents = writer.InnerWriter.ToString(); } } return new WidgetInstance { Id = pageWidget.Id, InitializeFunction = widget.CreateFunction, CssClass = widget.CssClass, Js = remainingJs, Css = remainingCss, Contents = contents }; }