public static IEditFieldObjectCreator GetEditFieldObjectCreator(string editFieldTypeName) { IEditFieldObjectCreator t = null; Instance.stateValues.EditFieldTypes.TryGetValue(editFieldTypeName, out t); return(t); }
void Core_OnInitialise(Dictionary <Type, List <Type> > interfaceImplementations) { List <Type> list; interfaceImplementations.TryGetValue(typeof(IEditFieldObjectCreator), out list); if (list != null) { foreach (Type t in list) { IEditFieldObjectCreator cntc = (IEditFieldObjectCreator)Activator.CreateInstance(t); Values.EditFieldTypes.Add(cntc.Identifier, cntc); } } }
public bool Read(IDataReader reader) { editFieldID = (long)reader["EditFieldID"]; fieldName = (string)reader["FieldName"]; sectionName = (string)reader["SectionName"]; rank = Convert.ToInt32(reader["Rank"]); pageRevisionID = Convert.ToInt64(reader["PageRevisionID"]); IEditFieldObjectCreator c = ContentManager.GetEditFieldObjectCreator(reader["EditFieldTypeIdentifier"].ToString()); if (c == null) { return(false); } editFieldHandler = c.CreateHandler(); dataHandler = c.CreateDatabaseInterface(); return(true); }
internal static PageAdminSectionDefinition ReadPageAdminSectionXml(XmlElement cfxml) { PageAdminSectionDefinition def = new PageAdminSectionDefinition(); def.SectionName = cfxml.GetAttribute("Name"); XmlElement e = cfxml.SelectSingleNode("Label") as XmlElement; def.Label = e == null ? null : e.InnerText == "" ? null : e.InnerText; e = cfxml.SelectSingleNode("Hint") as XmlElement; def.Hint = e == null ? null : e.InnerText == "" ? null : e.InnerText; if (cfxml.HasAttribute("InSection")) { string inSection = cfxml.GetAttribute("InSection"); if (inSection != null && inSection != String.Empty) { def.InSection = inSection; } } XmlNodeList efnodes = cfxml.SelectNodes("EditFields/*"); foreach (XmlElement xml in efnodes) { IEditFieldObjectCreator creator = ContentManager.GetEditFieldObjectCreator(xml.Name); if (creator != null) { IEditFieldHandler handler = creator.CreateHandler(); handler.Initialise(xml); def.EditFieldHandlers.Add(handler); } } return(def); }
internal void BuildAdminSectionList(Dictionary <string, List <EditFieldInfo> > editFieldsBySectionName) { // sort nodesByFieldName in ascending order, ready to be matched to the template admin fields foreach (List <EditFieldInfo> list in editFieldsBySectionName.Values) { list.Sort(); } adminSectionList = new List <PreparedPageAdminSection>(); Template t = ContentManager.Templates[TemplateName]; if (t == null) { return; } // combine t.GetPageAdminSections() with nodesByFieldName PreparedPageAdminSection pas = new PreparedPageAdminSection(); foreach (PageAdminSectionDefinition def in t.GetPageAdminSections()) { PreparedPageAdminSection section = new PreparedPageAdminSection(); List <EditFieldInfo> list; if (!editFieldsBySectionName.TryGetValue(def.SectionName, out list)) { list = new List <EditFieldInfo>(); } section.SectionDefinition = def; section.FieldList = new List <EditFieldInfo>(); // now that we've preliminarily prepared the section, fill its field list with what will appear in the admin ui foreach (IEditFieldHandler handler in def.EditFieldHandlers) { int index = list.FindIndex(delegate(EditFieldInfo obj) { return(handler.FieldName == obj.FieldName && handler.TypeName == obj.Handler.TypeName); }); EditFieldInfo info; if (index == -1) // create a new field to handle it { IEditFieldHandlerDatabaseInterface dbi = ContentManager.GetEditFieldObjectCreator(handler.TypeName).CreateDatabaseInterface(); info = new EditFieldInfo(0, def.SectionName, handler.FieldName, section.FieldList.Count, handler, dbi); IEditFieldObjectCreator creator = ContentManager.GetEditFieldObjectCreator(handler.TypeName); IEditFieldData data = creator.CreateDataObject(); handler.InitialiseData(data); info.Data = data; } else { info = list[index]; info.Handler = handler; // set it to the template's handler as the one created during database retrieval was for type name purposes only list.RemoveAt(index); info.Rank = section.FieldList.Count; } section.FieldList.Add(info); } section.UpdateFieldsByName(); adminSectionList.Add(section); adminSectionsByName[section.SectionDefinition.SectionName] = section; } }