/// <summary> /// Constructor to set default properties. /// </summary> /// <param name="c"></param> /// <param name="CanPublish"></param> /// <param name="Id"></param> /// <remarks> /// This method used to create all of the child controls too which is BAD since /// the page hasn't started initializing yet. Control IDs were not being named /// correctly, etc... I've moved the child control setup/creation to the CreateChildControls /// method where they are suposed to be. /// </remarks> public ContentControl(Content c, publishModes CanPublish, string Id) { ID = Id; this.CanPublish = CanPublish; _content = c; Width = 350; Height = 350; SaveAndPublish += new EventHandler(standardSaveAndPublishHandler); Save += new EventHandler(standardSaveAndPublishHandler); prntpage = (UmbracoEnsuredPage)Page; // zb-00036 #29889 : load it only once if (virtualTabs == null) { virtualTabs = _content.ContentType.getVirtualTabs.ToList(); } foreach (ContentType.TabI t in virtualTabs) { TabPage tp = NewTabPage(t.Caption); addSaveAndPublishButtons(ref tp); } }
/// <summary> /// Create and setup all of the controls child controls. /// </summary> protected override void CreateChildControls() { base.CreateChildControls(); SaveAndPublish += new EventHandler(standardSaveAndPublishHandler); Save += new EventHandler(standardSaveAndPublishHandler); prntpage = (UmbracoEnsuredPage)Page; int i = 0; var inTab = new Hashtable(); // zb-00036 #29889 : load it only once if (virtualTabs == null) { virtualTabs = _content.ContentType.getVirtualTabs.ToList(); } foreach (ContentType.TabI t in virtualTabs) { var tp = this.Panels[i] as TabPage; if (tp == null) { throw new ArgumentException("Unable to load tab \"" + t.Caption + "\""); } //TabPage tp = NewTabPage(t.Caption); //addSaveAndPublishButtons(ref tp); tp.Style.Add("text-align", "center"); // Iterate through the property types and add them to the tab // zb-00036 #29889 : fix property types getter to get the right set of properties foreach (PropertyType pt in t.GetPropertyTypes(_content.ContentType.Id)) { // table.Rows.Add(addControl(_content.getProperty(editPropertyType.Alias), tp)); addControlNew(_content.getProperty(pt), tp, t.Caption); inTab.Add(pt.Id.ToString(), true); } i++; } // Add property pane tpProp = NewTabPage(ui.Text("general", "properties", null)); addSaveAndPublishButtons(ref tpProp); tpProp.Controls.Add( new LiteralControl("<div id=\"errorPane_" + tpProp.ClientID + "\" style=\"display: none; text-align: left; color: red;width: 100%; border: 1px solid red; background-color: #FCDEDE\"><div><b>There were errors - data has not been saved!</b><br/></div></div>")); //if the property is not in a tab, add it to the general tab var props = _content.GenericProperties; foreach (Property p in props) { if (inTab[p.PropertyType.Id.ToString()] == null) { addControlNew(p, tpProp, ui.Text("general", "properties", null)); } } }
protected override void OnInit(EventArgs e) { base.OnInit(e); BasePages.UmbracoEnsuredPage uep = new UmbracoEnsuredPage(); System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(ui.Culture(uep.getUser())); System.Threading.Thread.CurrentThread.CurrentUICulture = System.Threading.Thread.CurrentThread.CurrentCulture; }
/// <summary> /// Initializes the control and looks up the tree structures that are required to be rendered. /// Properties of the control (or SetTreeService) need to be set before pre render or calling /// GetJSONContextMenu or GetJSONNode /// </summary> protected void Initialize() { //use the query strings if the TreeParams isn't explicitly set if (m_TreeService == null) { m_TreeService = TreeRequestParams.FromQueryStrings().CreateTreeService(); } m_TreeService.App = GetCurrentApp(); // Validate permissions if (!BasePages.BasePage.ValidateUserContextID(BasePages.BasePage.umbracoUserContextID)) { return; } UmbracoEnsuredPage page = new UmbracoEnsuredPage(); if (!page.ValidateUserApp(GetCurrentApp())) { throw new ArgumentException("The current user doesn't have access to this application. Please contact the system administrator."); } //find all tree definitions that have the current application alias that are ACTIVE. //if an explicit tree has been requested, then only load that tree in. //m_ActiveTreeDefs = TreeDefinitionCollection.Instance.FindActiveTrees(GetCurrentApp()); m_ActiveTreeDefs = Services.ApplicationTreeService.GetApplicationTrees(GetCurrentApp(), true).ToList(); if (!string.IsNullOrEmpty(this.TreeType)) { m_ActiveTreeDefs = m_ActiveTreeDefs .Where(x => x.Alias == this.TreeType) .ToList(); //this will only return 1 } //find all tree defs that exists for the current application regardless of if they are active var appTreeDefs = Services.ApplicationTreeService.GetApplicationTrees(GetCurrentApp()).ToList(); //Create the BaseTree's based on the tree definitions found foreach (var treeDef in appTreeDefs) { //create the tree and initialize it var bTree = LegacyTreeDataConverter.GetLegacyTreeForLegacyServices(treeDef); //BaseTree bTree = treeDef.CreateInstance(); bTree.SetTreeParameters(m_TreeService); //store the created tree m_AllAppTrees.Add(bTree); if (treeDef.Initialize) { m_ActiveTrees.Add(bTree); } } m_IsInit = true; }
/// <summary> /// Whenever an action is performed upon a document/media/member, this method is executed, ensuring that /// all registered handlers will have an oppotunity to handle the action. /// </summary> /// <param Name="d">The document being operated on</param> /// <param Name="action">The action triggered</param> public static void RunActionHandlers(Document d, IAction action) { foreach (IActionHandler ia in _actionHandlers) { try { foreach (IAction a in ia.ReturnActions()) { if (a.Alias == action.Alias) { // Uncommented for auto publish support // System.Web.HttpContext.Current.Trace.Write("Umbraco.Cms.BusinessLogic.Action.RunActionHandlers", "Running " + ia.HandlerName() + " (matching action: " + a.Alias + ")"); ia.Execute(d, action); } } } catch (Exception iaExp) { Log.Add(LogTypes.Error, User.GetUser(0), -1, string.Format("Error loading actionhandler '{0}': {1}", ia.HandlerName(), iaExp)); } } // Run notification // Find current user User u; try { u = new UmbracoEnsuredPage().ValidatedUser; } catch { u = User.GetUser(0); } Notification.GetNotifications(d, u, action); }
/// <summary> /// Create and setup all of the controls child controls. /// </summary> protected override void CreateChildControls() { base.CreateChildControls(); SaveAndPublish += new EventHandler(standardSaveAndPublishHandler); Save += new EventHandler(standardSaveAndPublishHandler); prntpage = (UmbracoEnsuredPage)Page; int i = 0; var inTab = new Hashtable(); // zb-00036 #29889 : load it only once if (virtualTabs == null) { virtualTabs = _content.ContentType.getVirtualTabs.ToList(); } foreach (ContentType.TabI tab in virtualTabs) { var tabPage = this.Panels[i] as TabPage; if (tabPage == null) { throw new ArgumentException("Unable to load tab \"" + tab.Caption + "\""); } //TabPage tp = NewTabPage(t.Caption); //addSaveAndPublishButtons(ref tp); tabPage.Style.Add("text-align", "center"); // Iterate through the property types and add them to the tab // zb-00036 #29889 : fix property types getter to get the right set of properties // ge : had a bit of a corrupt db and got weird NRE errors so rewrote this to catch the error and rethrow with detail foreach (PropertyType propertyType in tab.GetPropertyTypes(_content.ContentType.Id)) { // table.Rows.Add(addControl(_content.getProperty(editPropertyType.Alias), tp)); var property = _content.getProperty(propertyType); if (property != null && tabPage != null) { addControlNew(property, tabPage, tab.Caption); // adding this check, as we occasionally get an already in dictionary error, though not sure why if (!inTab.ContainsKey(propertyType.Id.ToString())) { inTab.Add(propertyType.Id.ToString(), true); } } else { throw new ArgumentNullException(string.Format("Property {0} ({1}) on Content Type {2} could not be retrieved for Document {3} on Tab Page {4}. To fix this problem, delete the property and recreate it.", propertyType.Alias, propertyType.Id, _content.ContentType.Alias, _content.Id, tab.Caption)); } } i++; } // Add property pane tpProp = NewTabPage(ui.Text("general", "properties", null)); addSaveAndPublishButtons(ref tpProp); tpProp.Controls.Add( new LiteralControl("<div id=\"errorPane_" + tpProp.ClientID + "\" style=\"display: none; text-align: left; color: red;width: 100%; border: 1px solid red; background-color: #FCDEDE\"><div><b>There were errors - data has not been saved!</b><br/></div></div>")); //if the property is not in a tab, add it to the general tab var props = _content.GenericProperties; foreach (Property p in props) { if (inTab[p.PropertyType.Id.ToString()] == null) { addControlNew(p, tpProp, ui.Text("general", "properties", null)); } } }
/// <summary> /// Create and setup all of the controls child controls. /// </summary> protected override void CreateChildControls() { base.CreateChildControls(); _prntpage = (UmbracoEnsuredPage)Page; int i = 0; Hashtable inTab = new Hashtable(); // zb-00036 #29889 : load it only once if (_virtualTabs == null) { _virtualTabs = _content.ContentType.getVirtualTabs.ToList(); } if (_contentType == null) { _contentType = ContentType.GetContentType(_content.ContentType.Id); } foreach (ContentType.TabI tab in _virtualTabs) { var tabPage = this.Panels[i] as TabPage; if (tabPage == null) { throw new ArgumentException("Unable to load tab \"" + tab.Caption + "\""); } tabPage.Style.Add("text-align", "center"); //Legacy vs New API loading of PropertyTypes if (_contentType.ContentTypeItem != null) { LoadPropertyTypes(_contentType.ContentTypeItem, tabPage, inTab, tab.Id, tab.Caption); } else { LoadPropertyTypes(tab, tabPage, inTab); } i++; } // Add property pane tpProp = NewTabPage(ui.Text("general", "properties", null)); AddSaveAndPublishButtons(ref tpProp); tpProp.Controls.Add( new LiteralControl("<div id=\"errorPane_" + tpProp.ClientID + "\" style=\"display: none; text-align: left; color: red;width: 100%; border: 1px solid red; background-color: #FCDEDE\"><div><b>There were errors - data has not been saved!</b><br/></div></div>")); //if the property is not in a tab, add it to the general tab var props = _content.GenericProperties; foreach (Property p in props) { if (inTab[p.PropertyType.Id.ToString()] == null) { AddControlNew(p, tpProp, ui.Text("general", "properties", null)); } } }
private User currentUser() { UmbracoEnsuredPage page = new UmbracoEnsuredPage(); return(page.getUser()); }