Added UploadNamespace and UploadedFile entities

Signed-off-by: Gergely POLONKAI (W00d5t0ck) <polesz@w00d5t0ck.info>
This commit is contained in:
Gergely POLONKAI (W00d5t0ck)
2012-08-31 22:16:42 +02:00
parent fc1144ad29
commit d9fe0d8bcf
18 changed files with 375 additions and 19 deletions

View File

@@ -30,7 +30,7 @@ class BlogPost
{
return $this->id;
}
/**
* True if the BlogPost is published. If not, only the author and the
* administrators can see it.
@@ -63,7 +63,7 @@ class BlogPost
{
return $this->published;
}
/**
* The Group which this BlogPost is associated with
*

View File

@@ -224,7 +224,7 @@ class News
$this->sticky = $sticky;
return $this;
}
/**
* Get sticky
*

View File

@@ -0,0 +1,104 @@
<?php
namespace KekRozsak\FrontBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Namespace support for uploaded files
*
* @author Gergely Polonkai
*
* @ORM\Entity
* @ORM\Table(name="upload_namespaces")
*/
class UploadNamespace
{
/**
* The ID of the namespace
*
* @var integer $id
*
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
* @ORM\Column(type="integer")
*/
protected $id;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* The name of the namespace. This will be used when displaying the
* namespace list.
*
* @var string $name
*
* @ORM\Column(type="string", length=50, unique=true, nullable=false)
*
* @Assert\NotBlank()
*/
protected $name;
/**
* Set name
*
* @param string $name
* @return UploadNamespace
*/
public function setName($name)
{
// TODO: Check if not null!
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* The slugified name of the namespace. This will be used in URLs
*
* @var string $slug
*
* @ORM\Column(type="string", length=50, unique=true, nullable=false)
*/
protected $slug;
/**
* Set slug
*
* @param string $slug
* @return UploadNamespace
*/
public function setSlug($slug)
{
// TODO: Check if not null!
$this->slug = $slug;
return $this;
}
/**
* Get slug
*
* @return string
*/
public function getSlug()
{
return $this->slug;
}
}

View File

@@ -0,0 +1,181 @@
<?php
namespace KekRozsak\FrontBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Description of UploadedFile
*
* @author Gergely Polonkai
*
* @ORM\Entity
* @ORM\Table(name="uploaded_files", uniqueConstraints={
* @ORM\UniqueConstraint(columns={"upload_namespace_id", "filename"})
* })
*/
class UploadedFile
{
/**
* The ID of the file
*
* @var integer $id
*
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
* @ORM\Column(type="integer")
*/
protected $id;
/**
* Get ID
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Namespace of the file
*
* @var UploadNamespace $namespace
*
* @ORM\ManyToOne(targetEntity="KekRozsak\FrontBundle\Entity\UploadNamespace")
* @ORM\JoinColumn(name="upload_namespace_id", nullable=false)
*/
protected $namespace;
/**
* Set namespace
*
* @param KekRozsak\FrontBundle\Entity\UploadNamespace $namespace
* @return UploadedFile
*/
public function setNamespace(UploadNamespace $namespace)
{
// TODO: Check if not null!
$this->namespace = $namespace;
return $this;
}
/**
* Get namespace
*
* @return KekRozsak\FrontBundle\Entity\UploadNamespace
*/
public function getNamespace()
{
return $this->namespace;
}
/**
* The file name, as seen in the filesystem
*
* @var string $filename
*
* @ORM\Column(type="string", length=100, nullable=false)
*/
protected $filename;
/**
* Set filename
*
* @param string $filename
* @return UploadedFile
*/
public function setFilename($filename)
{
// TODO: Check if not null nor empty!
$this->filename = $filename;
return $this;
}
/**
* Get filename
*
* @return string
*/
public function getFilename()
{
return $this->filename;
}
/**
* Get filename with namespace
*
* @return string
*/
public function getNsFilename()
{
return $this->namespace->getSlug() . DIRECTORY_SEPARATOR . $this->filename;
}
/**
* MIME type of the file
*
* @var string $mimetype
*
* @ORM\Column(type="string", length=50, nullable=false)
*/
protected $mimeType;
/**
* Set mimeType
*
* @param string $mimeType
* @return UploadedFile
*/
public function setMimeType($mimeType)
{
// TODO: Check if not null nor empty!
$this->mimeType = $mimeType;
return $this;
}
/**
* Get mimeType
*
* @return string
*/
public function getMimeType()
{
return $this->mimeType;
}
/**
* Description of the file
*
* @var string $description
*
* @ORM\Column(type="text", nullable=true)
*/
protected $description;
/**
* Set description
*
* @param string $description
* @return UploadedFile
*/
public function setDescription($description)
{
if ($description === '') {
$description = null;
}
$this->description = $description;
return $this;
}
/**
* Get description
*
* @return string
*/
public function getDescription()
{
return $this->description;
}
}

View File

@@ -516,4 +516,36 @@ class UserData
{
return $this->favouriteTopics->contains($topic);
}
/**
* The avatar image of the user
*
* @var UploadedFile $avatarImage
*
* @ORM\ManyToOne(targetEntity="KekRozsak\FrontBundle\Entity\UploadedFile")
* @ORM\JoinColumn(name="avatar_image_id", nullable=true)
*/
protected $avatarImage;
/**
* Set avaratImage
*
* @param KekRozsak\FrontBundle\Entity\UploadedFile $avatarImage
* @return UserData
*/
public function setAvatarImage(UploadedFile $avatarImage)
{
$this->avatarImage = $avatarImage;
return $this;
}
/**
* Get avatarImage
*
* @return KekRozsak\FrontBundle\Entity\UploadedFile
*/
public function getAvatarImage()
{
return $this->avatarImage;
}
}

View File

@@ -1,4 +1,4 @@
/*
/*
Document : book.css
Created on : 2012.08.17., 18:23:37
Author : Gergely Polonkai
@@ -31,4 +31,4 @@
#book-list tbody tr.even td {
background-color: #c6ecfe;
}
}

View File

@@ -1,4 +1,4 @@
/*
/*
Document : eventbox
Created on : 2012.08.15., 11:34:17
Author : Gergely Polonkai

View File

@@ -1,4 +1,4 @@
/*
/*
Document : forum.css
Created on : 2012.08.15., 11:40:39
Author : Gergely

View File

@@ -1,4 +1,4 @@
/*
/*
Document : books.css
Created on : 2012.08.15., 11:41:37
Author : Gergely Polonkai

View File

@@ -1,4 +1,4 @@
/*
/*
Document : loginbox
Created on : 2012.08.15., 11:32:19
Author : Gergely Polonkai

View File

@@ -1,4 +1,4 @@
/*
/*
Document : main
Created on : 2012.08.15., 10:58:08
Author : Gergely Polonkai
@@ -96,4 +96,4 @@ h3 a {
#help-button {
display: block;
float: right;
}
}

View File

@@ -1,4 +1,4 @@
/*
/*
Document : menu.css
Created on : 2012.08.15., 11:10:44
Author : Gergely Polonkai

View File

@@ -1,4 +1,4 @@
/*
/*
Document : news
Created on : 2012.08.16., 16:26:16
Author : Gergely Polonkai

View File

@@ -1,4 +1,4 @@
/*
/*
Document : popup
Created on : 2012.08.15., 11:29:58
Author : Gergely Polonkai

View File

@@ -1,4 +1,4 @@
/*
/*
Document : profilebox
Created on : 2012.08.15., 11:31:41
Author : Gergely Polonkai

View File

@@ -1,4 +1,4 @@
/*
/*
Document : statuslines
Created on : 2012.08.16., 16:28:11
Author : Gergely Polonkai

View File

@@ -11,7 +11,7 @@ use Symfony\Component\Routing\Exception\RouteNotFoundException;
* Description of HelpUrlExtension
*
* @author Gergely Polonkai
*
*
* @DI\Service
* @DI\Tag("twig.extension")
*/
@@ -33,7 +33,7 @@ class HelpUrlExtension extends \Twig_Extension
public function getGlobals() {
parent::getGlobals();
$request = $this->container->get('request');
$router = $this->container->get('router');
@@ -61,7 +61,7 @@ class HelpUrlExtension extends \Twig_Extension
'helpUrl' => $helpUrl,
);
}
public function getName()
{
return 'HelpUrl';