示例#1
0
 public EditFieldInfo(long editFieldID, string sectionName, string fieldName, int rank, IEditFieldHandler editFieldHandler, IEditFieldHandlerDatabaseInterface dataHandler)
 {
     this.fieldName = fieldName;
     this.sectionName = sectionName;
     this.editFieldID = editFieldID;
     this.editFieldHandler = editFieldHandler;
     this.dataHandler = dataHandler;
     this.rank = rank;
 }
示例#2
0
 public EditFieldInfo(long editFieldID, string sectionName, string fieldName, int rank, IEditFieldHandler editFieldHandler, IEditFieldHandlerDatabaseInterface dataHandler)
 {
     this.fieldName        = fieldName;
     this.sectionName      = sectionName;
     this.editFieldID      = editFieldID;
     this.editFieldHandler = editFieldHandler;
     this.dataHandler      = dataHandler;
     this.rank             = rank;
 }
示例#3
0
        public void LoadContentForPages()
        {
            Dictionary <long, Dictionary <string, List <EditFieldInfo> > > editFieldsBySectionNameByRevisionID = new Dictionary <long, Dictionary <string, List <EditFieldInfo> > >();
            Dictionary <long, Page> pagesByRevisionID = new Dictionary <long, Page>();
            List <long>             ids = new List <long>();

            foreach (Page page in pages)
            {
                editFieldsBySectionNameByRevisionID[page.RevisionID] = new Dictionary <string, List <EditFieldInfo> >();
                pagesByRevisionID[page.RevisionID] = page;
                ids.Add(page.RevisionID);
            }
            Dictionary <string, List <EditFieldInfo> > editFieldsByFieldType = ContentManager.Instance.DataProvider.ListPageEditFieldsByFieldType(ids);

            // build a map of field sections to the fields they contain
            foreach (KeyValuePair <string, List <EditFieldInfo> > fieldListWithCommonFieldType in editFieldsByFieldType)
            {
                // group all of the nodes (currently grouped according to node type) into field name groups
                foreach (EditFieldInfo info in fieldListWithCommonFieldType.Value)
                {
                    Dictionary <string, List <EditFieldInfo> > editFieldsBySectionName = editFieldsBySectionNameByRevisionID[info.PageRevisionID];
                    List <EditFieldInfo> editfields;
                    if (!editFieldsBySectionName.TryGetValue(info.SectionName, out editfields))
                    {
                        editfields = new List <EditFieldInfo>();
                        editFieldsBySectionName.Add(info.SectionName, editfields);
                    }
                    editfields.Add(info);
                }
                // seeing as each iteration in this loop identifies the full set of nodes for a single content node type,
                // get the database interface for that node type and load the data for all the nodes of that type. Note
                // that fieldListWithCommonFieldType, due to the program logic, will always have at least one element, so
                // as such, the first element can be used to retrieve the field type.
                IEditFieldHandlerDatabaseInterface dbi = fieldListWithCommonFieldType.Value[0].DataHandler;
                if (dbi == null)
                {
                    continue;
                }
                dbi.LoadDataList(fieldListWithCommonFieldType.Value);
            }

            // now go and assign all the loaded edit field data to the pages in the list
            foreach (KeyValuePair <long, Dictionary <string, List <EditFieldInfo> > > kvp in editFieldsBySectionNameByRevisionID)
            {
                pagesByRevisionID[kvp.Key].BuildAdminSectionList(kvp.Value);
            }
        }
示例#4
0
        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);
        }
示例#5
0
 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;
 }
示例#6
0
        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;
            }
        }