private static string Plugins(HtmlHelper html, ContentItem item, ControlPanelState state) { ContentItem start = html.StartPage(); ContentItem root = html.RootPage(); Page p = new Page(); foreach (IControlPanelPlugin plugin in html.ContentEngine().Resolve <IPluginFinder>().GetPlugins <IControlPanelPlugin>()) { var span = new System.Web.UI.HtmlControls.HtmlGenericControl("span"); span.Attributes["class"] = "control"; var pluginControl = plugin.AddTo(span, new PluginContext(new SelectionUtility(item, null), start, root, state, html.ContentEngine(), html.ViewContext.HttpContext)); if (pluginControl != null) { p.Controls.Add(span); } } using (var sw = new StringWriter()) using (var htw = new HtmlTextWriter(sw)) { p.RenderControl(htw); return(sw.ToString()); } }
protected override void CreateChildControls() { ControlPanelState state = GetState(Page.GetEngine()); if (state.IsFlagSet(ControlPanelState.Hidden)) { AppendDefinedTemplate(HiddenTemplate, this); return; } if (state.IsFlagSet(ControlPanelState.Visible)) { AppendDefinedTemplate(VisibleHeaderTemplate, this); } if (state.IsFlagSet(ControlPanelState.DragDrop)) { AppendDefinedTemplate(DragDropHeaderTemplate, this); } if (state.IsFlagSet(ControlPanelState.Editing)) { AppendDefinedTemplate(EditingHeaderTemplate, this); } if (state.IsFlagSet(ControlPanelState.Previewing)) { AppendDefinedTemplate(PreviewingHeaderTemplate, this); } AddPlugins(state); if (state.IsFlagSet(ControlPanelState.DragDrop)) { AddDefinitions(this); RegisterDragDropStyles(); RegisterDragDropScripts(); } if (state.IsFlagSet(ControlPanelState.Editing)) { Register.JQuery(Page); Register.StyleSheet(Page, Url.ToAbsolute(StyleSheetUrl), Media.All); } if (state.IsFlagSet(ControlPanelState.Previewing)) { AppendDefinedTemplate(PreviewingFooterTemplate, this); } if (state.IsFlagSet(ControlPanelState.Editing)) { AppendDefinedTemplate(EditingFooterTemplate, this); } if (state.IsFlagSet(ControlPanelState.DragDrop)) { AppendDefinedTemplate(DragDropFooterTemplate, this); } if (state.IsFlagSet(ControlPanelState.Visible)) { AppendDefinedTemplate(VisibleFooterTemplate, this); } base.CreateChildControls(); }
protected override void OnInit(System.EventArgs e) { ControlPanelState state = ControlPanel.GetState(Page.GetEngine().SecurityManager, Page.User, Page.Request.QueryString); Visible = state != ControlPanelState.Hidden; base.OnInit(e); }
protected override void OnInit(System.EventArgs e) { ControlPanelState state = ControlPanel.GetState(Page.GetEngine()); Visible = !state.IsFlagSet(ControlPanelState.Hidden); base.OnInit(e); }
public ControlPanelLinkAttribute(string name, string iconUrl, string url, string toolTip, int sortOrder, ControlPanelState showDuring) { IconUrl = iconUrl; NavigateUrl = url; ToolTip = toolTip; ShowDuring = showDuring; SortOrder = sortOrder; Name = name; GlobalResourceClassName = "ControlPanel"; }
public PluginContext(ContentItem selected, ContentItem memorizedItem, ContentItem startItem, ContentItem rootItem, ControlPanelState state, IEditUrlManager editUrlManager) { this.editUrlManager = editUrlManager; State = state; Selected = selected; Memorized = memorizedItem; Start = startItem; Root = rootItem; }
protected override void OnInit(EventArgs e) { State = ControlPanel.GetState(Page.User, Page.Request.QueryString); if (State == ControlPanelState.Editing) { AddEditable(); } else { AddDisplayable(); } }
public PluginContext(ContentItem selected, ContentItem memorizedItem, ContentItem startItem, ContentItem rootItem, ControlPanelState state, IEngine engine, HttpContextBase httpContext) { State = state; Selected = selected; Memorized = memorizedItem; Start = startItem; Root = rootItem; Engine = engine; HttpContext = httpContext; }
protected override void OnInit(EventArgs e) { State = ControlPanel.GetState(Page.GetEngine()); if (State.IsFlagSet(ControlPanelState.Editing)) { AddEditable(); } else { AddDisplayable(); } }
protected override void OnInit(EventArgs e) { State = ControlPanel.GetState(Page.GetEngine().SecurityManager, Page.User, Page.Request.QueryString); if (State == ControlPanelState.Editing) { AddEditable(); } else { AddDisplayable(); } }
public PluginContext(SelectionUtility selection, ContentItem startItem, ContentItem rootItem, ControlPanelState state, IEngine engine, HttpContextBase httpContext) { Selection = selection; State = state; Selected = selection.SelectedItem; Memorized = selection.MemorizedItem; Start = startItem; Root = rootItem; Engine = engine; HttpContext = httpContext; }
public static bool IsManaging(this ControlPanelState state) { switch (state) { case ControlPanelState.DragDrop: case ControlPanelState.Editing: case ControlPanelState.Previewing: return(true); default: return(false); } }
protected virtual void AddPlugins(ControlPanelState state) { var pluginPanel = new Panel(); pluginPanel.CssClass = "plugins"; Controls.Add(pluginPanel); ContentItem start = Engine.Resolve <IUrlParser>().StartPage; ContentItem root = Engine.Persister.Repository.Get(Engine.Resolve <IHost>().CurrentSite.RootItemID); foreach (IControlPanelPlugin plugin in Engine.Resolve <IPluginFinder>().GetPlugins <IControlPanelPlugin>()) { plugin.AddTo(pluginPanel, new PluginContext(new SelectionUtility(CurrentItem, null), start, root, state, Engine, new HttpContextWrapper(Context))); } }
protected override void CreateChildControls() { ControlPanelState state = GetState(Page.User, Page.Request.QueryString); if (state == ControlPanelState.Hidden) { AppendDefinedTemplate(HiddenTemplate, this); } else if (state == ControlPanelState.Visible) { AppendDefinedTemplate(VisibleHeaderTemplate, this); AddPlugins(state); AppendDefinedTemplate(VisibleFooterTemplate, this); } else if (state == ControlPanelState.DragDrop) { AppendDefinedTemplate(DragDropHeaderTemplate, this); AddPlugins(state); AddDefinitions(this); AppendDefinedTemplate(DragDropFooterTemplate, this); RegisterDragDropStyles(); RegisterDragDropScripts(); //Page.Response.CacheControl = "no-cache"; } else if (state == ControlPanelState.Editing) { AppendDefinedTemplate(EditingHeaderTemplate, this); AddPlugins(state); Register.JQuery(Page); Register.StyleSheet(Page, Url.ToAbsolute(StyleSheetUrl), Media.All); AppendDefinedTemplate(EditingFooterTemplate, this); } else if (state == ControlPanelState.Previewing) { AppendDefinedTemplate(PreviewingHeaderTemplate, this); AddPlugins(state); AppendDefinedTemplate(PreviewingFooterTemplate, this); } else { throw new N2Exception("Unknown control panel state: " + state); } base.CreateChildControls(); }
protected virtual void AddPlugins(ControlPanelState state) { var pluginPanel = new Panel(); pluginPanel.CssClass = "plugins"; Controls.Add(pluginPanel); ContentItem start = Engine.Resolve <IUrlParser>().StartPage; ContentItem root = Engine.Persister.Repository.Load(Engine.Resolve <IHost>().CurrentSite.RootItemID); foreach (IControlPanelPlugin plugin in Engine.Resolve <IPluginFinder>().GetPlugins <IControlPanelPlugin>()) { var span = new HtmlGenericControl("span"); span.Attributes["class"] = "control"; pluginPanel.Controls.Add(span); plugin.AddTo(span, new PluginContext(CurrentItem, null, start, root, state, Engine, new HttpContextWrapper(Context))); } }
private static string Plugins(HtmlHelper html, ContentItem item, ControlPanelState state) { ContentItem start = html.StartPage(); ContentItem root = html.RootPage(); Page p = new Page(); foreach (IControlPanelPlugin plugin in html.ContentEngine().Resolve <IPluginFinder>().GetPlugins <IControlPanelPlugin>()) { plugin.AddTo(p, new PluginContext(new SelectionUtility(item, null), start, root, state, html.ContentEngine(), html.ViewContext.HttpContext)); } using (var sw = new StringWriter()) using (var htw = new HtmlTextWriter(sw)) { p.RenderControl(htw); return(sw.ToString()); } }
protected override void CreateItems(Control container) { state = ControlPanel.GetState(Page); if (state == ControlPanelState.DragDrop && (AllowExternalManipulation || CurrentItem == CurrentPage)) { if (ZoneName.IndexOfAny(new[] { '.', ',', ' ', '\'', '"', '\t', '\r', '\n' }) >= 0) { throw new N2Exception("Zone '" + ZoneName + "' contains illegal characters."); } Panel zoneContainer = AddPanel(this, ZoneName + " dropZone"); zoneContainer.Attributes[PartUtilities.PathAttribute] = CurrentItem.Path; zoneContainer.Attributes[PartUtilities.ZoneAttribute] = ZoneName; zoneContainer.Attributes[PartUtilities.AllowedAttribute] = PartUtilities.GetAllowedNames(ZoneName, PartsAdapter.GetAllowedDefinitions(CurrentItem, ZoneName, Page.User)); zoneContainer.ToolTip = GetToolTip(GetDefinition(CurrentItem), ZoneName); base.CreateItems(zoneContainer); } else { base.CreateItems(this); } }
private static string Plugins(HtmlHelper html, ContentItem item, ControlPanelState state) { ContentItem start = html.StartPage(); ContentItem root = html.RootPage(); Page p = new Page(); foreach (IControlPanelPlugin plugin in html.ContentEngine().Resolve<IPluginFinder>().GetPlugins<IControlPanelPlugin>()) { plugin.AddTo(p, new PluginContext(new SelectionUtility(item, null), start, root, state, html.ContentEngine(), html.ViewContext.HttpContext)); } using (var sw = new StringWriter()) using (var htw = new HtmlTextWriter(sw)) { p.RenderControl(htw); return sw.ToString(); } }
public ControlPanelSeparatorAttribute(int sortOrder, ControlPanelState showDuring) { this.ShowDuring = showDuring; SortOrder = sortOrder; }
protected virtual void AddPlugins(ControlPanelState state) { var pluginPanel = new Panel(); pluginPanel.CssClass = "plugins"; Controls.Add(pluginPanel); ContentItem start = Engine.Resolve<IUrlParser>().StartPage; ContentItem root = Engine.Persister.Repository.Get(Engine.Resolve<IHost>().CurrentSite.RootItemID); foreach (IControlPanelPlugin plugin in Engine.Resolve<IPluginFinder>().GetPlugins<IControlPanelPlugin>()) { plugin.AddTo(pluginPanel, new PluginContext(new SelectionUtility(CurrentItem, null), start, root, state, Engine, new HttpContextWrapper(Context))); } }
public ControlPanelDragPluginAttribute(string name, string iconUrl, string url, string toolTip, int sortOrder, ControlPanelState showDuring) : base(name, iconUrl, url, toolTip, sortOrder, showDuring) { IconClass = "n2-icon-th-large"; }
protected virtual bool ActiveFor(Control container, ControlPanelState state) { return state.IsFlagSet(ShowDuring); }
protected virtual bool ActiveFor(Control container, ControlPanelState state) { return(state.IsFlagSet(ShowDuring)); }
public ControlPanelDragPluginAttribute(string name, string iconUrl, string url, string toolTip, int sortOrder, ControlPanelState showDuring) : base(name, iconUrl, url, toolTip, sortOrder, showDuring) { IconClass = "fa fa-th-large"; }
protected virtual bool ActiveFor(Control container, ControlPanelState state) { return((ShowDuring & state) == state); }
protected virtual void AddPlugins(ControlPanelState state) { var pluginPanel = new Panel(); pluginPanel.CssClass = "plugins"; Controls.Add(pluginPanel); ContentItem start = Engine.Resolve<IUrlParser>().StartPage; ContentItem root = Engine.Persister.Repository.Load(Engine.Resolve<IHost>().CurrentSite.RootItemID); foreach (IControlPanelPlugin plugin in Engine.Resolve<IPluginFinder>().GetPlugins<IControlPanelPlugin>()) { var span = new HtmlGenericControl("span"); span.Attributes["class"] = "control"; pluginPanel.Controls.Add(span); plugin.AddTo(span, new PluginContext(CurrentItem, null, start, root, state, Engine.ManagementPaths)); } }
private static string Definitions(HtmlHelper html, IEngine engine, ContentItem item, ControlPanelState state) { if (state == ControlPanelState.DragDrop) { StringBuilder sb = new StringBuilder(); var a = engine.ResolveAdapter <PartsAdapter>(item); foreach (var d in UI.WebControls.ControlPanel.GetPartDefinitions(a, item, null, html.ViewContext.HttpContext.User)) { foreach (var t in a.GetTemplates(item, d)) { sb.AppendFormat( "<div id='{0}' title='{1}' data-type='{2}' data-template='{3}' class='{4}'>{5}</div>", /*{0}*/ t.Definition.ToString().Replace('/', '-'), /*{1}*/ t.Description, /*{2}*/ t.Definition.Discriminator, /*{3}*/ t.Name, /*{4}*/ "definition " + t.Definition.Discriminator, /*{5}*/ UI.WebControls.ControlPanel.FormatImageAndText(t.Definition.IconUrl, t.Title)); } } if (sb.Length > 0) { return("<div class='definitions'>" + sb + "</div>"); } } return(""); }
protected override void CreateItems(Control container) { state = ControlPanel.GetState(Page); if (state == ControlPanelState.DragDrop && (AllowExternalManipulation || CurrentItem == CurrentPage)) { if (ZoneName.IndexOfAny(new[] {'.', ',', ' ', '\'', '"', '\t', '\r', '\n'}) >= 0) throw new N2Exception("Zone '" + ZoneName + "' contains illegal characters."); Panel zoneContainer = AddPanel(this, ZoneName + " dropZone"); zoneContainer.Attributes[PartUtilities.PathAttribute] = CurrentItem.Path; zoneContainer.Attributes[PartUtilities.ZoneAttribute] = ZoneName; zoneContainer.Attributes[PartUtilities.AllowedAttribute] = PartUtilities.GetAllowedNames(ZoneName, PartsAdapter.GetAllowedDefinitions(CurrentItem, ZoneName, Page.User)); zoneContainer.ToolTip = GetToolTip(GetDefinition(CurrentItem), ZoneName); base.CreateItems(zoneContainer); } else { base.CreateItems(this); } }
private static string Plugins(HtmlHelper html, ContentItem item, ControlPanelState state) { ContentItem start = html.StartPage(); ContentItem root = html.RootPage(); Page p = new Page(); foreach (IControlPanelPlugin plugin in html.ContentEngine().Resolve<IPluginFinder>().GetPlugins<IControlPanelPlugin>()) { var span = new System.Web.UI.HtmlControls.HtmlGenericControl("span"); span.Attributes["class"] = "control"; var pluginControl = plugin.AddTo(span, new PluginContext(new SelectionUtility(item, null), start, root, state, html.ContentEngine(), html.ViewContext.HttpContext)); if (pluginControl != null) p.Controls.Add(span); } using (var sw = new StringWriter()) using (var htw = new HtmlTextWriter(sw)) { p.RenderControl(htw); return sw.ToString(); } }
/// <summary>Retrieves content items added to a zone of the parnet item.</summary> /// <param name="belowParentItem">The item whose items to get.</param> /// <param name="inZoneNamed">The zone in which the items should be contained.</param> /// <param name="filteredForInterface">Interface where the parts are displayed.</param> /// <param name="state">The control panel state to consider.</param> /// <returns>A list of items in the zone.</returns> public virtual IEnumerable<ContentItem> GetParts(ContentItem belowParentItem, string inZoneNamed, string filteredForInterface, ControlPanelState state) { if(belowParentItem == null) return new ItemList(); var items = belowParentItem.Children.FindParts(inZoneNamed) .Where(new AccessFilter(WebContext.User, Security)); if(filteredForInterface == Interfaces.Viewing && !state.IsFlagSet(ControlPanelState.Previewing) && !belowParentItem.VersionOf.HasValue) items = items.Where(new PublishedFilter()); return items; }
public static DroppableZoneHelper SetState(this DroppableZoneHelper helper, ControlPanelState state) { _stateField.SetValue(helper, state); return helper; }
public static string GetInterface(this ControlPanelState state) { return(state.IsManaging() ? Interfaces.Managing : Interfaces.Viewing); }
public static DroppableZoneHelper SetState(this DroppableZoneHelper helper, ControlPanelState state) { _stateField.SetValue(helper, state); return(helper); }
public DroppableZoneHelper(HtmlHelper helper, string zoneName, ContentItem currentItem) : base(helper, zoneName, currentItem) { state = helper.GetControlPanelState(); }
/// <summary>Retrieves content items added to a zone of the parnet item.</summary> /// <param name="belowParentItem">The item whose items to get.</param> /// <param name="inZoneNamed">The zone in which the items should be contained.</param> /// <param name="filteredForInterface">Interface where the parts are displayed.</param> /// <param name="state">The control panel state to consider.</param> /// <returns>A list of items in the zone.</returns> public virtual IEnumerable <ContentItem> GetParts(ContentItem belowParentItem, string inZoneNamed, string filteredForInterface, ControlPanelState state) { if (belowParentItem == null) { return(new ItemList()); } var items = belowParentItem.Children.FindParts(inZoneNamed) .Where(new AccessFilter(WebContext.User, Security)); if (filteredForInterface == Interfaces.Viewing && !state.IsFlagSet(ControlPanelState.Previewing) && !belowParentItem.VersionOf.HasValue) { items = items.Where(new PublishedFilter()); } return(items); }
private static string Definitions(HtmlHelper html, IEngine engine, ContentItem item, ControlPanelState state) { if (state == ControlPanelState.DragDrop) { StringBuilder sb = new StringBuilder(); var a = engine.ResolveAdapter<PartsAdapter>(item); foreach (var d in UI.WebControls.ControlPanel.GetPartDefinitions(a, item, null, html.ViewContext.HttpContext.User)) { foreach (var t in a.GetTemplates(item, d)) { sb.AppendFormat( "<div id='{0}' title='{1}' data-type='{2}' data-template='{3}' class='{4}'>{5}</div>", /*{0}*/ t.Definition.ToString().Replace('/', '-'), /*{1}*/ t.Description, /*{2}*/ t.Definition.Discriminator, /*{3}*/ t.Name, /*{4}*/ "definition " + t.Definition.Discriminator, /*{5}*/ UI.WebControls.ControlPanel.FormatImageAndText(t.Definition.IconUrl, t.Title)); } } if (sb.Length > 0) return "<div class='definitions'>" + sb + "</div>"; } return ""; }
protected virtual bool ActiveFor(Control container, ControlPanelState state) { return (ShowDuring & state) == state; }
public static bool IsManaging(this ControlPanelState state) { return(state.IsFlagSet(ControlPanelState.DragDrop) || state.IsFlagSet(ControlPanelState.Editing) || state.IsFlagSet(ControlPanelState.Previewing)); }