예제 #1
0
        public void AddContentTypeField(CmsContentType type, CmsContentTypeField field)
        {
            CmsContentTypeDao dao = new CmsContentTypeDao();
            field.Parent = type;

            using (Transaction tx = new Transaction())
            {
                dao.Save<CmsContentTypeField>(field);
                tx.Commit();
            }
        }
예제 #2
0
        protected void AddContentType_Click(object sender, EventArgs e)
        {
            try
            {
                String guid = this.ExistingContentTypeGuid.Value;
                CmsContentType type = ContentManager.Instance.GetContentType(guid);

                Boolean isNew = false;
                if (type == null)
                {
                    type = new CmsContentType();
                    isNew = true;
                }

                type.DisplayName = this.ContentDispayName.Text;
                type.Name = this.ContentSystemName.Text.Replace(" ","_");
                type.Description = this.ContentDescription.Text;
                type.IsFileType = this.ContentFileYes.Checked;
                type.IsEditorVisible = this.ContentEditorYes.Checked;

                if (isNew)
                    ContentManager.Instance.AddContentType(type);
                else
                    ContentManager.Instance.Save(type);

                if (isNew)
                {
                    CmsContentTypeField field = new CmsContentTypeField();
                    field.Name = "Title";
                    field.ObjectType = "System.String";
                    field.IsRequired = true;
                    field.Description = "Title";
                    field.SystemName = "title";
                    field.FieldType = CmsContentTypeField.Textbox;

                    ContentManager.Instance.AddContentTypeField(type, field);

                    //Set the default title to the one we just created
                    type.TitleFieldName = field.SystemName;
                    ContentManager.Instance.Save(type);
                }

                Response.Redirect("./ContentTypeFields.aspx?tid=" + Server.UrlEncode(type.Guid), true);
            }
            catch (Exception ex)
            {
                Status.ForeColor = System.Drawing.Color.Red;
                Status.Text = ex.Message;
            }
        }
예제 #3
0
        public void AddContentType(Data.Guid siteGuid, CmsContentType type)
        {
            if (String.IsNullOrEmpty(type.Guid))
                type.Guid = Data.Guid.Create().Value;

            if (!type.IsGlobalType)
                type.SubscriptionId = siteGuid.Value;

            //make sure this name doesn't already exist
            CmsContentTypeDao dao = new CmsContentTypeDao();

            CmsContentType existing = dao.FindBySiteAndName(type.SubscriptionId, type.Name);
            if (existing != null)
                throw new ArgumentException("This type name already exists and may not be used again.");

            using (Transaction tx = new Transaction())
            {
                dao.Save<CmsContentType>(type);
                tx.Commit();
            }

            type = GetContentType(type.Guid);
        }
예제 #4
0
 public void AddContentType(CmsContentType type)
 {
     AddContentType(CurrentSite.Guid, type);
 }
예제 #5
0
 public void Save(CmsContentType type)
 {
     CmsContentTypeDao dao = new CmsContentTypeDao();
     using (Transaction tx = new Transaction())
     {
         dao.Save<CmsContentType>(type);
         tx.Commit();
     }
 }
예제 #6
0
        public IList<CmsContent> GetExistingContent(Data.Guid siteGuid, CmsContentType filter)
        {
            CmsContentDao dao = new CmsContentDao();
            IList<CmsContent> results;
            if (filter == null)
            {
                results = dao.FindAllContent(siteGuid);
            }
            else
            {
                results = dao.FindContentByType(siteGuid,filter);
            }

            return results;
        }
예제 #7
0
 public IList<CmsContent> GetExistingContent(CmsContentType filter)
 {
     return GetExistingContent(CurrentSite.Guid, filter);
 }
예제 #8
0
        /// <summary>
        /// Creates a duplicate of the specified content type. Adjusting the names as necessary to avoid conflicts.
        /// </summary>
        /// <param name="guid"></param>
        /// <param name="systemType"></param>
        public void Duplicate(Data.Guid siteGuid, CmsContentType typeToCopy)
        {
            String systemName = typeToCopy.Name;

            //Make sure that this system name doesn't already exist
            CmsContentTypeDao dao = new CmsContentTypeDao();
            CmsContentType existing = dao.FindBySiteAndName(siteGuid.Value, systemName);

            if (existing != null)
                systemName = systemName + "_c";

            CmsContentType type = new CmsContentType();
            type.Guid = System.Guid.NewGuid().ToString();
            type.DisplayName = typeToCopy.DisplayName;
            type.Description = type.Description;
            type.IsEditorVisible = type.IsEditorVisible;
            type.IsFileType = type.IsFileType;
            type.IsGlobalType = false;
            type.Name = systemName;
            type.SubscriptionId = siteGuid.Value;
            type.TitleFieldName = typeToCopy.TitleFieldName;

            AddContentType(siteGuid,type);

            //Copy all of the fields
            IList<CmsContentTypeField> fieldsToCopy = GetContentTypeFields(typeToCopy.Guid);
            foreach (CmsContentTypeField fieldToCopy in fieldsToCopy)
            {
                CmsContentTypeField field = new CmsContentTypeField();
                field._SelectOptions = fieldToCopy._SelectOptions;
                field.Columns = fieldToCopy.Columns;
                field.Description = fieldToCopy.Description;
                field.FieldType = fieldToCopy.FieldType;
                field.IsRequired = fieldToCopy.IsRequired;
                field.IsSystemDefault = fieldToCopy.IsSystemDefault;
                field.Name = fieldToCopy.Name;
                field.ObjectType = fieldToCopy.ObjectType;
                field.Parent = fieldToCopy.Parent;
                field.Position = fieldToCopy.Position;
                field.Rows = fieldToCopy.Rows;
                field.SystemName = fieldToCopy.SystemName;

                AddContentTypeField(type, field);
            }
        }
예제 #9
0
 public void Delete(CmsContentType contentType)
 {
     if (contentType != null)
     {
         CmsContentTypeDao dao = new CmsContentTypeDao();
         using (Transaction tx = new Transaction())
         {
             dao.Delete<CmsContentType>(contentType);
             tx.Commit();
         }
     }
 }
예제 #10
0
 public IList<CmsContent> FindContentByType(Guid siteGuid, CmsContentType filter)
 {
     String hql = "select content from CmsContent content where content.SubscriptionId = :guid and content.ContentType.Guid = :typeGuid";
     return base.NewHqlQuery(hql).SetString("guid", siteGuid.Value).SetString("typeGuid", filter.Guid).List<CmsContent>();
 }