Exemplo n.º 1
0
        /// <summary>
        /// Creates a new page from the given template and position and returns it
        /// as an edit model.
        /// </summary>
        /// <param name="templateId">The template id</param>
        /// <param name="parentId">The parent id</param>
        /// <param name="seqno">The position sequence number</param>
        /// <param name="siteTreeId">The id of the site tree</param>
        /// <param name="siteTree">The internal id of the site tree</param>
        /// <returns>The edit model</returns>
        public static EditModel CreateByTemplateAndPosition(Guid templateId, Guid parentId, int seqno, Guid siteTreeId, string siteTree)
        {
            EditModel m = new EditModel();

            m.Page = new Piranha.Models.Page()
            {
                Id                 = Guid.NewGuid(),
                TemplateId         = templateId,
                SiteTreeId         = siteTreeId,
                SiteTreeInternalId = siteTree,
                ParentId           = parentId,
                Seqno              = seqno
            };
            m.GetRelated();

            return(m);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the model for the page specified by the given id.
        /// </summary>
        /// <param name="id">The page id</param>
        /// <param name="draft">Weather to get the draft or not.</param>
        /// <returns>The model</returns>
        public static EditModel GetById(Guid id, bool draft = true)
        {
            EditModel m = new EditModel();

            m.Page = Piranha.Models.Page.GetSingle(id, draft);
            if (m.Page == null)
            {
                m.Page = Piranha.Models.Page.GetSingle(id);
            }

            if (m.Page != null)
            {
                m.GetRelated();
            }
            else
            {
                throw new ArgumentException("Could not find page with id {" + id.ToString() + "}");
            }

            return(m);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets the model for the page specified by the given id.
        /// </summary>
        /// <param name="id">The page id</param>
        /// <param name="draft">Whether to get the draft or not.</param>
        /// <returns>The model</returns>
        public static EditModel GetById(Guid id, bool draft = true)
        {
            EditModel m = new EditModel();

            m.Page = Piranha.Models.Page.GetSingle(id, draft);
            if (m.Page == null)
            {
                m.Page = Piranha.Models.Page.GetSingle(id);
            }

            if (m.Page != null)
            {
                m.GetRelated();
                m.CanDelete = Page.GetScalar("SELECT count(*) FROM page WHERE page_parent_id=@0", id) == 0;
            }
            else
            {
                throw new ArgumentException("Could not find page with id {" + id.ToString() + "}");
            }

            return(m);
        }
Exemplo n.º 4
0
        public static EditModel CreateByOriginalAndPosition(Guid originalId, Guid parentId, int seqno, Guid siteTreeId, string siteTree)
        {
            var m = new EditModel();
            var p = Page.GetSingle(originalId, true);

            m.Page = new Piranha.Models.Page()
            {
                Id                 = Guid.NewGuid(),
                Title              = p.Title,
                NavigationTitle    = p.NavigationTitle,
                TemplateId         = p.TemplateId,
                OriginalId         = originalId,
                SiteTreeId         = siteTreeId,
                SiteTreeInternalId = siteTree,
                ParentId           = parentId,
                Seqno              = seqno,
                PageController     = p.PageController,
                PageRedirect       = p.PageRedirect
            };
            m.GetRelated();

            return(m);
        }
Exemplo n.º 5
0
		public static EditModel CreateByOriginalAndPosition(Guid originalId, Guid parentId, int seqno, Guid siteTreeId, string siteTree) {
			var m = new EditModel();
			var p = Page.GetSingle(originalId, true);

			m.Page = new Piranha.Models.Page() {
				Id = Guid.NewGuid(),
				Title = p.Title,
				NavigationTitle = p.NavigationTitle,
				TemplateId = p.TemplateId,
				OriginalId = originalId,
				SiteTreeId = siteTreeId,
				SiteTreeInternalId = siteTree,
				ParentId = parentId,
				Seqno = seqno,
				PageController = p.PageController,
				PageRedirect = p.PageRedirect
			};
			m.GetRelated();

			return m;
		}
Exemplo n.º 6
0
		/// <summary>
		/// Creates a new page from the given template and position and returns it
		/// as an edit model.
		/// </summary>
		/// <param name="templateId">The template id</param>
		/// <param name="parentId">The parent id</param>
		/// <param name="seqno">The position sequence number</param>
		/// <param name="siteTreeId">The id of the site tree</param>
		/// <param name="siteTree">The internal id of the site tree</param>
		/// <returns>The edit model</returns>
		public static EditModel CreateByTemplateAndPosition(Guid templateId, Guid parentId, int seqno, Guid siteTreeId, string siteTree) {
			EditModel m = new EditModel();

			m.Page = new Piranha.Models.Page() {
				Id = Guid.NewGuid(),
				TemplateId = templateId,
				SiteTreeId = siteTreeId,
				SiteTreeInternalId = siteTree,
				ParentId = parentId,
				Seqno = seqno
			};
			m.GetRelated();

			return m;
		}
Exemplo n.º 7
0
		/// <summary>
		/// Gets the model for the page specified by the given id.
		/// </summary>
		/// <param name="id">The page id</param>
		/// <param name="draft">Whether to get the draft or not.</param>
		/// <returns>The model</returns>
		public static EditModel GetById(Guid id, bool draft = true) {
			EditModel m = new EditModel();

			m.Page = Piranha.Models.Page.GetSingle(id, draft);
			if (m.Page == null)
				m.Page = Piranha.Models.Page.GetSingle(id);

			if (m.Page != null) {
				m.GetRelated();
				m.CanDelete = Page.GetScalar("SELECT count(*) FROM page WHERE page_parent_id=@0", id) == 0;
			} else throw new ArgumentException("Could not find page with id {" + id.ToString() + "}");

			return m;
		}
Exemplo n.º 8
0
		public static EditModel CreateByTemplate(Guid templateId) {
			EditModel m = new EditModel() ;

			m.Page = new Piranha.Models.Page() {
				Id = Guid.NewGuid(),
				TemplateId = templateId,
				SiteTreeId = Config.SiteTreeId
			} ;
			m.GetRelated() ;

			return m ;
		}
Exemplo n.º 9
0
        /// <summary>
        /// Gets the model for the page specified by the given id.
        /// </summary>
        /// <param name="id">The page id</param>
        /// <param name="draft">Weather to get the draft or not.</param>
        /// <returns>The model</returns>
        public static EditModel GetById(Guid id, bool draft = true)
        {
            EditModel m = new EditModel() ;

            m.Page = Piranha.Models.Page.GetSingle(id, draft) ;
            if (m.Page == null)
                m.Page = Piranha.Models.Page.GetSingle(id) ;

            if (m.Page != null) {
                m.GetRelated() ;
            } else throw new ArgumentException("Could not find page with id {" + id.ToString() + "}") ;

            return m ;
        }