Exemplo n.º 1
0
        /// <summary>
        /// Default constructor. Creates a new model.
        /// </summary>
        /// <param name="isfolder">Weather this is a folder or not.</param>
        public EditModel(bool isfolder, Guid parentid)
        {
            Content = new Piranha.Models.Content()
            {
                IsFolder = isfolder, ParentId = parentid
            };
            ContentCategories = new List <Guid>();
            Categories        = new MultiSelectList(Category.GetFields("category_id, category_name",
                                                                       new Params()
            {
                OrderBy = "category_name"
            }), "Id", "Name");
            var folders = Content.GetFields("content_id, content_name", "content_folder=1", new Params()
            {
                OrderBy = "content_name"
            });

            folders.Insert(0, new Content());
            if (Content.ParentId == Guid.Empty)
            {
                Folders = new SelectList(folders, "Id", "Name");
            }
            else
            {
                Folders = new SelectList(folders, "Id", "Name", Content.ParentId);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Default constructor. Creates a new model.
        /// </summary>
        /// <param name="isfolder">Whether this is a folder or not.</param>
        public EditModel(bool isfolder, Guid parentid)
        {
            Content = new Piranha.Models.Content()
            {
                IsFolder = isfolder, ParentId = parentid
            };
            ContentCategories = new List <Guid>();
            Categories        = new MultiSelectList(Category.GetFields("category_id, category_name",
                                                                       new Params()
            {
                OrderBy = "category_name"
            }), "Id", "Name");
            var folders = Content.GetFields("content_id, content_name", "content_folder=1 AND content_draft=1", new Params()
            {
                OrderBy = "content_name"
            });

            folders.Insert(0, new Content());
            Extensions = Content.GetExtensions(true);
            Folders    = SortFolders(Content.GetFolderStructure(false));
            Folders.Insert(0, new Placement()
            {
                Text = "", Value = Guid.Empty
            });
        }
Exemplo n.º 3
0
 /// <summary>
 /// Default constructor. Creates a new model.
 /// </summary>
 public PopupModel()
 {
     Content = new List<Piranha.Models.Content>() ;
     NewContent = new Piranha.Models.Content() ;
     var folders = Piranha.Models.Content.GetFields("content_id, content_name", "content_folder=1", new Params() { OrderBy = "content_name" }) ;
     folders.Insert(0, new Piranha.Models.Content()) ;
     Folders = new SelectList(folders, "Id", "Name") ;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Default constructor. Creates a new model.
 /// </summary>
 public PopupModel()
 {
     Content    = new List <Piranha.Models.Content>();
     NewContent = new Piranha.Models.Content();
     Folders    = SortFolders(Models.Content.GetFolderStructure(false));
     Folders.Insert(0, new Placement()
     {
         Text = "", Value = Guid.Empty
     });
 }
Exemplo n.º 5
0
        /// <summary>
        /// Default constructor. Creates a new model.
        /// </summary>
        public PopupModel()
        {
            Content    = new List <Piranha.Models.Content>();
            NewContent = new Piranha.Models.Content();
            var folders = Piranha.Models.Content.GetFields("content_id, content_name", "content_folder=1", new Params()
            {
                OrderBy = "content_name"
            });

            folders.Insert(0, new Piranha.Models.Content());
            Folders = new SelectList(folders, "Id", "Name");
        }
Exemplo n.º 6
0
 /// <summary>
 /// Default constructor. Creates a new model.
 /// </summary>
 /// <param name="isfolder">Whether this is a folder or not.</param>
 public EditModel(bool isfolder, Guid parentid)
 {
     Content = new Piranha.Models.Content() { IsFolder = isfolder, ParentId = parentid } ;
     ContentCategories = new List<Guid>() ;
     Categories = new MultiSelectList(Category.GetFields("category_id, category_name",
         new Params() { OrderBy = "category_name" }), "Id", "Name") ;
     var folders = Content.GetFields("content_id, content_name", "content_folder=1 AND content_draft=1", new Params() { OrderBy = "content_name" }) ;
     folders.Insert(0, new Content()) ;
     Extensions = Content.GetExtensions() ;
     Folders = SortFolders(Content.GetFolderStructure(false)) ;
     Folders.Insert(0, new Placement() { Text = "", Value = Guid.Empty }) ;
 }
Exemplo n.º 7
0
 /// <summary>
 /// Default constructor. Creates a new model.
 /// </summary>
 /// <param name="isfolder">Weather this is a folder or not.</param>
 public EditModel(bool isfolder, Guid parentid)
 {
     Content = new Piranha.Models.Content() { IsFolder = isfolder, ParentId = parentid } ;
     ContentCategories = new List<Guid>() ;
     Categories = new MultiSelectList(Category.GetFields("category_id, category_name",
         new Params() { OrderBy = "category_name" }), "Id", "Name") ;
     var folders = Content.GetFields("content_id, content_name", "content_folder=1", new Params() { OrderBy = "content_name" }) ;
     folders.Insert(0, new Content()) ;
     if (Content.ParentId == Guid.Empty)
         Folders = new SelectList(folders, "Id", "Name") ;
     else Folders = new SelectList(folders, "Id", "Name", Content.ParentId) ;
 }
Exemplo n.º 8
0
        /// <summary>
        /// Default constructor. Creates a new model.
        /// </summary>
        /// <param name="isfolder">Whether this is a folder or not.</param>
        public EditModel(bool isfolder, Guid parentid)
        {
            Permalink = new Models.Permalink()
            {
                Id = Guid.NewGuid(), NamespaceId = Config.MediaNamespaceId, Type = Models.Permalink.PermalinkType.MEDIA
            };
            Content = new Piranha.Models.Content()
            {
                Id = Guid.NewGuid(), IsFolder = isfolder, ParentId = parentid, PermalinkId = Permalink.Id
            };
            Extensions = Content.GetExtensions(true);

            GetMetaData();
        }
Exemplo n.º 9
0
        public JsonResult Upload()
        {
            // Get custom headers
            var filename = Request.Headers["X-File-Name"];
            var type     = Request.Headers["X-File-Type"];
            var size     = Convert.ToInt32(Request.Headers["X-File-Size"]);
            var parentId = !String.IsNullOrEmpty(Request.Headers["X-File-ParentId"]) ? new Guid(Request.Headers["X-File-ParentId"]) : Guid.Empty;
            var name     = Request.Headers["X-File-DisplayName"];
            var alt      = Request.Headers["X-File-Alt"];
            var desc     = Request.Headers["X-File-Desc"];

            using (var mem = new MemoryStream()) {
                var stream = Request.InputStream;

                stream.Seek(0, SeekOrigin.Begin);
                stream.CopyTo(mem);
                mem.Position = 0;

                using (var binary = new BinaryReader(mem)) {
                    var media = new Piranha.Models.MediaFileContent()
                    {
                        ContentType = type,
                        Filename    = filename,
                        Body        = binary.ReadBytes(size)
                    };
                    var content = new Piranha.Models.Content()
                    {
                        Id            = Guid.NewGuid(),
                        ParentId      = parentId,
                        IsFolder      = false,
                        Name          = name,
                        AlternateText = alt,
                        Description   = desc
                    };
                    if (content.SaveAndPublish(media))
                    {
                        return(Get(content.Id.ToString(), false));
                    }
                }
            }
            return(Json(new {
                Success = false
            }));
        }
Exemplo n.º 10
0
		/// <summary>
		/// Default constructor. Creates a new model.
		/// </summary>
		/// <param name="isfolder">Whether this is a folder or not.</param>
		public EditModel(bool isfolder, Guid parentid) {
			Permalink = new Models.Permalink() { Id = Guid.NewGuid(), NamespaceId = Config.MediaNamespaceId, Type = Models.Permalink.PermalinkType.MEDIA };
			Content = new Piranha.Models.Content() { Id = Guid.NewGuid(), IsFolder = isfolder, ParentId = parentid, PermalinkId = Permalink.Id };
			Extensions = Content.GetExtensions(true);

			GetMetaData();
		}
Exemplo n.º 11
0
		/// <summary>
		/// Default constructor. Creates a new model.
		/// </summary>
		public PopupModel() {
			Content = new List<Piranha.Models.Content>();
			NewContent = new Piranha.Models.Content();
			Folders = SortFolders(Models.Content.GetFolderStructure(false));
			Folders.Insert(0, new Placement() { Text = "", Value = Guid.Empty });
		}
Exemplo n.º 12
0
 /// <summary>
 /// Default constructor. Creates a new model.
 /// </summary>
 public PopupModel()
 {
     Content = new List<Piranha.Models.Content>() ;
     NewContent = new Piranha.Models.Content() ;
 }
Exemplo n.º 13
0
 /// <summary>
 /// Default constructor. Creates a new model.
 /// </summary>
 public EditModel()
 {
     Content = new Piranha.Models.Content() ;
 }
Exemplo n.º 14
0
		public JsonResult Upload() {
			// Get custom headers
			var filename = Request.Headers["X-File-Name"] ;
			var type = Request.Headers["X-File-Type"] ;
			var size = Convert.ToInt32(Request.Headers["X-File-Size"]) ;
			var parentId = !String.IsNullOrEmpty(Request.Headers["X-File-ParentId"]) ? new Guid(Request.Headers["X-File-ParentId"]) : Guid.Empty ;
			var name = Request.Headers["X-File-DisplayName"] ;
			var alt = Request.Headers["X-File-Alt"] ;
			var desc = Request.Headers["X-File-Desc"] ;

			using (var mem = new MemoryStream()) {
				var stream = Request.InputStream ;

				stream.Seek(0, SeekOrigin.Begin) ;
				stream.CopyTo(mem) ;
				mem.Position = 0 ;

				using (var binary = new BinaryReader(mem)) {
					var media = new Piranha.Models.MediaFileContent() {
						ContentType = type,
						Filename = filename,
						Body = binary.ReadBytes(size)
					} ;
					var content = new Piranha.Models.Content() {
						Id = Guid.NewGuid(),
						ParentId = parentId,
						IsFolder = false,
						Name = name,
						AlternateText = alt,
						Description = desc
					} ;
					if (content.SaveAndPublish(media))
						return Get(content.Id.ToString(), false) ;
				}
			}
			return Json(new {
				Success = false
			}) ;
		}
Exemplo n.º 15
0
 /// <summary>
 /// Default constructor. Creates a new model.
 /// </summary>
 public PopupModel()
 {
     Content    = new List <Piranha.Models.Content>();
     NewContent = new Piranha.Models.Content();
 }