You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
593 lines
14 KiB
593 lines
14 KiB
![]()
8 years ago
|
<?php
|
||
![]()
6 years ago
|
|
||
![]()
8 years ago
|
/* For licensing terms, see /license.txt */
|
||
|
|
||
![]()
5 years ago
|
namespace Chamilo\CoreBundle\Entity;
|
||
![]()
8 years ago
|
|
||
![]()
5 years ago
|
use ApiPlatform\Core\Annotation\ApiFilter;
|
||
![]()
5 years ago
|
use ApiPlatform\Core\Annotation\ApiProperty;
|
||
![]()
5 years ago
|
use ApiPlatform\Core\Annotation\ApiResource;
|
||
![]()
5 years ago
|
use ApiPlatform\Core\Annotation\ApiSubresource;
|
||
|
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter;
|
||
|
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
|
||
![]()
5 years ago
|
use ApiPlatform\Core\Serializer\Filter\PropertyFilter;
|
||
![]()
6 years ago
|
use Chamilo\CoreBundle\Entity\Session;
|
||
![]()
5 years ago
|
use Chamilo\CoreBundle\Entity\User;
|
||
![]()
5 years ago
|
use Chamilo\CoreBundle\Traits\TimestampableAgoTrait;
|
||
![]()
8 years ago
|
use Doctrine\Common\Collections\ArrayCollection;
|
||
![]()
6 years ago
|
use Doctrine\Common\Collections\Criteria;
|
||
![]()
8 years ago
|
use Doctrine\ORM\Mapping as ORM;
|
||
|
use Gedmo\Mapping\Annotation as Gedmo;
|
||
![]()
6 years ago
|
use Gedmo\Timestampable\Traits\TimestampableEntity;
|
||
![]()
6 years ago
|
use Symfony\Component\Routing\RouterInterface;
|
||
![]()
5 years ago
|
use Symfony\Component\Serializer\Annotation\Groups;
|
||
![]()
8 years ago
|
use Symfony\Component\Validator\Constraints as Assert;
|
||
![]()
8 years ago
|
|
||
![]()
5 years ago
|
//* attributes={"security"="is_granted('ROLE_ADMIN')"},
|
||
![]()
8 years ago
|
/**
|
||
|
* Base entity for all resources.
|
||
![]()
8 years ago
|
*
|
||
![]()
5 years ago
|
* @ApiResource(
|
||
|
* collectionOperations={"get"},
|
||
![]()
5 years ago
|
* normalizationContext={"groups"={"resource_node:read", "document:read"}},
|
||
|
* denormalizationContext={"groups"={"resource_node:write", "document:write"}}
|
||
![]()
5 years ago
|
* )
|
||
![]()
5 years ago
|
* @ApiFilter(SearchFilter::class, properties={"title": "partial"})
|
||
![]()
5 years ago
|
* @ApiFilter(PropertyFilter::class)
|
||
![]()
5 years ago
|
* @ApiFilter(OrderFilter::class, properties={"id", "title", "resourceFile", "createdAt", "updatedAt"})
|
||
![]()
6 years ago
|
* @ORM\Entity(repositoryClass="Chamilo\CoreBundle\Repository\ResourceNodeRepository")
|
||
![]()
7 years ago
|
*
|
||
![]()
8 years ago
|
* @ORM\Table(name="resource_node")
|
||
![]()
7 years ago
|
*
|
||
![]()
8 years ago
|
* @Gedmo\Tree(type="materializedPath")
|
||
|
*/
|
||
|
class ResourceNode
|
||
|
{
|
||
![]()
6 years ago
|
public const PATH_SEPARATOR = '`';
|
||
![]()
6 years ago
|
use TimestampableEntity;
|
||
![]()
5 years ago
|
use TimestampableAgoTrait;
|
||
![]()
6 years ago
|
|
||
![]()
8 years ago
|
/**
|
||
![]()
5 years ago
|
* @Groups({"resource_node:read", "document:read"})
|
||
![]()
8 years ago
|
* @ORM\Id
|
||
|
* @ORM\Column(type="integer")
|
||
|
* @ORM\GeneratedValue(strategy="AUTO")
|
||
|
*/
|
||
|
protected $id;
|
||
|
|
||
![]()
7 years ago
|
/**
|
||
|
* @Assert\NotBlank()
|
||
![]()
5 years ago
|
* @Groups({"resource_node:read", "resource_node:write", "document:read"})
|
||
![]()
6 years ago
|
* @Gedmo\TreePathSource
|
||
![]()
5 years ago
|
*
|
||
|
* @ORM\Column(name="title", type="string", length=255, nullable=false)
|
||
|
*/
|
||
|
protected $title;
|
||
|
|
||
|
/**
|
||
|
* @Assert\NotBlank()
|
||
|
*
|
||
|
* @Gedmo\Slug(fields={"title"})
|
||
|
* @ORM\Column(name="slug", type="string", length=255, nullable=false)
|
||
![]()
7 years ago
|
*/
|
||
![]()
6 years ago
|
protected $slug;
|
||
![]()
7 years ago
|
|
||
![]()
8 years ago
|
/**
|
||
![]()
5 years ago
|
* @Groups({"resource_node:read", "resource_node:write"})
|
||
|
*
|
||
![]()
5 years ago
|
* @ORM\ManyToOne(targetEntity="ResourceType")
|
||
![]()
7 years ago
|
* @ORM\JoinColumn(name="resource_type_id", referencedColumnName="id", nullable=false)
|
||
![]()
8 years ago
|
*/
|
||
![]()
7 years ago
|
protected $resourceType;
|
||
![]()
8 years ago
|
|
||
|
/**
|
||
![]()
5 years ago
|
* @Groups({"resource_node:read", "resource_node:write"})
|
||
|
*
|
||
![]()
6 years ago
|
* @var ResourceLink[]
|
||
|
*
|
||
![]()
6 years ago
|
* @ORM\OneToMany(targetEntity="ResourceLink", mappedBy="resourceNode", cascade={"remove"})
|
||
![]()
8 years ago
|
*/
|
||
![]()
7 years ago
|
protected $resourceLinks;
|
||
![]()
8 years ago
|
|
||
![]()
7 years ago
|
/**
|
||
![]()
5 years ago
|
* @var ResourceFile available file for this node
|
||
|
*
|
||
![]()
5 years ago
|
* @Groups({"resource_node:read", "resource_node:write", "document:read"})
|
||
![]()
7 years ago
|
*
|
||
![]()
5 years ago
|
* @ORM\OneToOne(targetEntity="ResourceFile", inversedBy="resourceNode", orphanRemoval=true)
|
||
![]()
6 years ago
|
* @ORM\JoinColumn(name="resource_file_id", referencedColumnName="id", onDelete="CASCADE")
|
||
![]()
7 years ago
|
*/
|
||
|
protected $resourceFile;
|
||
|
|
||
![]()
8 years ago
|
/**
|
||
![]()
5 years ago
|
* @var User the creator of this node
|
||
|
* @Assert\Valid()
|
||
![]()
5 years ago
|
* @Groups({"resource_node:read", "resource_node:write"})
|
||
![]()
8 years ago
|
* @ORM\ManyToOne(
|
||
![]()
5 years ago
|
* targetEntity="Chamilo\CoreBundle\Entity\User", inversedBy="resourceNodes"
|
||
![]()
8 years ago
|
* )
|
||
![]()
6 years ago
|
* @ORM\JoinColumn(name="creator_id", referencedColumnName="id", nullable=true, onDelete="CASCADE")
|
||
![]()
8 years ago
|
*/
|
||
|
protected $creator;
|
||
|
|
||
|
/**
|
||
|
* @Gedmo\TreeParent
|
||
|
* @ORM\ManyToOne(
|
||
![]()
6 years ago
|
* targetEntity="ResourceNode",
|
||
![]()
8 years ago
|
* inversedBy="children"
|
||
|
* )
|
||
|
* @ORM\JoinColumns({@ORM\JoinColumn(onDelete="CASCADE")})
|
||
|
*/
|
||
|
protected $parent;
|
||
|
|
||
|
/**
|
||
|
* @Gedmo\TreeLevel
|
||
![]()
7 years ago
|
*
|
||
![]()
8 years ago
|
* @ORM\Column(name="level", type="integer", nullable=true)
|
||
|
*/
|
||
|
protected $level;
|
||
|
|
||
|
/**
|
||
![]()
6 years ago
|
* @var ResourceNode[]
|
||
|
*
|
||
![]()
8 years ago
|
* @ORM\OneToMany(
|
||
![]()
6 years ago
|
* targetEntity="ResourceNode",
|
||
![]()
8 years ago
|
* mappedBy="parent"
|
||
|
* )
|
||
|
* @ORM\OrderBy({"id" = "ASC"})
|
||
|
*/
|
||
|
protected $children;
|
||
|
|
||
|
/**
|
||
![]()
5 years ago
|
* @Gedmo\TreePath(appendId=true,separator="`")
|
||
![]()
7 years ago
|
*
|
||
![]()
5 years ago
|
* @ORM\Column(name="path", type="text", nullable=true)
|
||
![]()
8 years ago
|
*/
|
||
|
protected $path;
|
||
|
|
||
![]()
6 years ago
|
/**
|
||
|
* Shortcut to access Course resource from ResourceNode.
|
||
|
*
|
||
![]()
5 years ago
|
* ORM\OneToOne(targetEntity="Chamilo\CoreBundle\Entity\Illustration", mappedBy="resourceNode")
|
||
![]()
6 years ago
|
*/
|
||
![]()
5 years ago
|
//protected $illustration;
|
||
![]()
6 years ago
|
|
||
![]()
6 years ago
|
/**
|
||
![]()
6 years ago
|
* @var ResourceComment[]|ArrayCollection
|
||
![]()
6 years ago
|
*
|
||
|
* @ORM\OneToMany(targetEntity="ResourceComment", mappedBy="resourceNode", cascade={"persist", "remove"})
|
||
|
*/
|
||
|
protected $comments;
|
||
|
|
||
![]()
5 years ago
|
/**
|
||
|
* @var \DateTime
|
||
|
*
|
||
![]()
5 years ago
|
* @Groups({"resource_node:read", "document:read"})
|
||
![]()
5 years ago
|
* @Gedmo\Timestampable(on="create")
|
||
|
* @ORM\Column(type="datetime")
|
||
|
*/
|
||
|
protected $createdAt;
|
||
|
|
||
|
/**
|
||
|
* @var \DateTime
|
||
|
*
|
||
![]()
5 years ago
|
* @Groups({"resource_node:read", "document:read"})
|
||
![]()
5 years ago
|
* @Gedmo\Timestampable(on="update")
|
||
|
* @ORM\Column(type="datetime")
|
||
|
*/
|
||
|
protected $updatedAt;
|
||
![]()
8 years ago
|
|
||
|
/**
|
||
![]()
8 years ago
|
* Constructor.
|
||
![]()
8 years ago
|
*/
|
||
|
public function __construct()
|
||
|
{
|
||
|
$this->children = new ArrayCollection();
|
||
![]()
6 years ago
|
$this->resourceLinks = new ArrayCollection();
|
||
![]()
6 years ago
|
$this->comments = new ArrayCollection();
|
||
![]()
6 years ago
|
$this->createdAt = new \DateTime();
|
||
![]()
8 years ago
|
}
|
||
|
|
||
![]()
6 years ago
|
/**
|
||
|
* @return string
|
||
|
*/
|
||
|
public function __toString()
|
||
|
{
|
||
|
return (string) $this->getPathForDisplay();
|
||
|
}
|
||
|
|
||
![]()
8 years ago
|
/**
|
||
|
* Returns the resource id.
|
||
|
*
|
||
![]()
8 years ago
|
* @return int
|
||
![]()
8 years ago
|
*/
|
||
|
public function getId()
|
||
|
{
|
||
|
return $this->id;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @param int $id
|
||
![]()
8 years ago
|
*
|
||
![]()
8 years ago
|
* @return $this
|
||
|
*/
|
||
|
public function setId($id)
|
||
|
{
|
||
|
$this->id = $id;
|
||
|
|
||
|
return $this;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Returns the resource creator.
|
||
|
*
|
||
|
* @return User
|
||
|
*/
|
||
![]()
6 years ago
|
public function getCreator(): ?User
|
||
![]()
8 years ago
|
{
|
||
|
return $this->creator;
|
||
|
}
|
||
|
|
||
![]()
6 years ago
|
public function setCreator(User $creator = null)
|
||
![]()
8 years ago
|
{
|
||
|
$this->creator = $creator;
|
||
|
|
||
|
return $this;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Returns the children resource instances.
|
||
|
*
|
||
![]()
6 years ago
|
* @return ResourceNode[]|ArrayCollection
|
||
![]()
8 years ago
|
*/
|
||
|
public function getChildren()
|
||
|
{
|
||
|
return $this->children;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Sets the parent resource.
|
||
|
*
|
||
|
* @param ResourceNode $parent
|
||
|
*
|
||
|
* @return $this
|
||
|
*/
|
||
![]()
6 years ago
|
public function setParent(self $parent = null)
|
||
![]()
8 years ago
|
{
|
||
|
$this->parent = $parent;
|
||
|
|
||
|
return $this;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Returns the parent resource.
|
||
|
*
|
||
![]()
6 years ago
|
* @return ResourceNode
|
||
![]()
8 years ago
|
*/
|
||
|
public function getParent()
|
||
|
{
|
||
|
return $this->parent;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Return the lvl value of the resource in the tree.
|
||
|
*
|
||
![]()
8 years ago
|
* @return int
|
||
![]()
8 years ago
|
*/
|
||
|
public function getLevel()
|
||
|
{
|
||
|
return $this->level;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Returns the "raw" path of the resource
|
||
|
* (the path merge names and ids of all items).
|
||
![]()
8 years ago
|
* Eg.: "Root-1/subdir-2/file.txt-3/".
|
||
|
*
|
||
![]()
8 years ago
|
* @return string
|
||
|
*/
|
||
|
public function getPath()
|
||
|
{
|
||
|
return $this->path;
|
||
|
}
|
||
|
|
||
![]()
6 years ago
|
/**
|
||
|
* @return ResourceComment[]|ArrayCollection
|
||
|
*/
|
||
|
public function getComments()
|
||
|
{
|
||
|
return $this->comments;
|
||
|
}
|
||
|
|
||
|
public function addComment(ResourceComment $comment)
|
||
|
{
|
||
|
$comment->setResourceNode($this);
|
||
|
|
||
|
return $this->comments->add($comment);
|
||
|
}
|
||
|
|
||
![]()
8 years ago
|
/**
|
||
|
* Returns the path cleaned from its ids.
|
||
![]()
8 years ago
|
* Eg.: "Root/subdir/file.txt".
|
||
|
*
|
||
![]()
6 years ago
|
* @return string
|
||
![]()
8 years ago
|
*/
|
||
|
public function getPathForDisplay()
|
||
|
{
|
||
|
return self::convertPathForDisplay($this->path);
|
||
![]()
6 years ago
|
}
|
||
|
|
||
![]()
5 years ago
|
public function getPathForDisplayToArray($baseRoot = null)
|
||
|
{
|
||
|
$parts = explode(self::PATH_SEPARATOR, $this->path);
|
||
|
$list = [];
|
||
|
foreach ($parts as $part) {
|
||
|
$parts = explode('-', $part);
|
||
|
if (empty($parts[1])) {
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
$value = $parts[0];
|
||
|
$id = $parts[1];
|
||
|
|
||
|
if (!empty($baseRoot)) {
|
||
|
if ($id < $baseRoot) {
|
||
|
continue;
|
||
|
}
|
||
|
}
|
||
|
$list[$id] = $value;
|
||
|
}
|
||
|
|
||
|
return $list;
|
||
|
}
|
||
|
|
||
![]()
6 years ago
|
/**
|
||
|
* @return string
|
||
|
*/
|
||
|
public function getPathForDisplayRemoveBase(string $base)
|
||
|
{
|
||
|
$path = str_replace($base, '', $this->path);
|
||
|
|
||
|
return self::convertPathForDisplay($path);
|
||
![]()
8 years ago
|
}
|
||
|
|
||
![]()
6 years ago
|
public function getSlug()
|
||
![]()
8 years ago
|
{
|
||
![]()
6 years ago
|
return $this->slug;
|
||
![]()
8 years ago
|
}
|
||
|
|
||
![]()
5 years ago
|
public function getTitle()
|
||
|
{
|
||
|
return $this->title;
|
||
|
}
|
||
|
|
||
![]()
5 years ago
|
public function setTitle(string $title)
|
||
|
{
|
||
|
$this->title = $title;
|
||
|
|
||
|
return $this;
|
||
|
}
|
||
|
|
||
![]()
8 years ago
|
/**
|
||
![]()
6 years ago
|
* @return ResourceNode
|
||
![]()
8 years ago
|
*/
|
||
![]()
6 years ago
|
public function setSlug(string $slug)
|
||
![]()
8 years ago
|
{
|
||
![]()
6 years ago
|
if (false !== strpos(self::PATH_SEPARATOR, $slug)) {
|
||
![]()
6 years ago
|
throw new \InvalidArgumentException('Invalid character "'.self::PATH_SEPARATOR.'" in resource name.');
|
||
|
}
|
||
|
|
||
|
$this->slug = $slug;
|
||
|
|
||
|
return $this;
|
||
![]()
8 years ago
|
}
|
||
|
|
||
|
/**
|
||
|
* Convert a path for display: remove ids.
|
||
|
*
|
||
|
* @param string $path
|
||
|
*
|
||
|
* @return string
|
||
|
*/
|
||
|
public static function convertPathForDisplay($path)
|
||
|
{
|
||
![]()
6 years ago
|
/*$pathForDisplay = preg_replace(
|
||
![]()
8 years ago
|
'/-\d+'.self::PATH_SEPARATOR.'/',
|
||
|
' / ',
|
||
|
$path
|
||
|
);
|
||
![]()
6 years ago
|
if ($pathForDisplay !== null && strlen($pathForDisplay) > 0) {
|
||
|
$pathForDisplay = substr_replace($pathForDisplay, '', -3);
|
||
|
}
|
||
|
*/
|
||
|
$pathForDisplay = preg_replace(
|
||
|
'/-\d+'.self::PATH_SEPARATOR.'/',
|
||
|
'/',
|
||
|
$path
|
||
|
);
|
||
![]()
8 years ago
|
|
||
![]()
6 years ago
|
if (null !== $pathForDisplay && strlen($pathForDisplay) > 0) {
|
||
![]()
6 years ago
|
$pathForDisplay = substr_replace($pathForDisplay, '', -1);
|
||
![]()
8 years ago
|
}
|
||
|
|
||
|
return $pathForDisplay;
|
||
|
}
|
||
|
|
||
|
/**
|
||
![]()
7 years ago
|
* @return ResourceType
|
||
|
*/
|
||
|
public function getResourceType()
|
||
|
{
|
||
|
return $this->resourceType;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @param ResourceType $resourceType
|
||
![]()
8 years ago
|
*
|
||
![]()
7 years ago
|
* @return ResourceNode
|
||
![]()
8 years ago
|
*/
|
||
![]()
7 years ago
|
public function setResourceType($resourceType)
|
||
![]()
8 years ago
|
{
|
||
![]()
7 years ago
|
$this->resourceType = $resourceType;
|
||
![]()
8 years ago
|
|
||
|
return $this;
|
||
|
}
|
||
|
|
||
|
/**
|
||
![]()
6 years ago
|
* @return ArrayCollection|ResourceLink[]
|
||
![]()
7 years ago
|
*/
|
||
|
public function getResourceLinks()
|
||
|
{
|
||
|
return $this->resourceLinks;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @return ResourceNode
|
||
|
*/
|
||
|
public function setResourceLinks($resourceLinks)
|
||
|
{
|
||
|
$this->resourceLinks = $resourceLinks;
|
||
|
|
||
|
return $this;
|
||
|
}
|
||
|
|
||
![]()
6 years ago
|
/**
|
||
|
* @param Session $session
|
||
|
*
|
||
|
* @return ArrayCollection
|
||
|
*/
|
||
|
public function hasSession(Session $session = null)
|
||
|
{
|
||
|
$links = $this->getResourceLinks();
|
||
|
$criteria = Criteria::create();
|
||
|
|
||
|
$criteria->andWhere(
|
||
|
Criteria::expr()->eq('session', $session)
|
||
|
);
|
||
|
|
||
![]()
6 years ago
|
return $links->matching($criteria);
|
||
![]()
6 years ago
|
}
|
||
|
|
||
![]()
6 years ago
|
/**
|
||
|
* @return bool
|
||
|
*/
|
||
|
public function hasResourceFile()
|
||
|
{
|
||
![]()
6 years ago
|
return null !== $this->resourceFile;
|
||
![]()
6 years ago
|
}
|
||
|
|
||
![]()
7 years ago
|
/**
|
||
|
* @return ResourceFile
|
||
![]()
8 years ago
|
*/
|
||
![]()
6 years ago
|
public function getResourceFile(): ?ResourceFile
|
||
![]()
8 years ago
|
{
|
||
![]()
7 years ago
|
return $this->resourceFile;
|
||
|
}
|
||
|
|
||
![]()
6 years ago
|
/**
|
||
|
* @return bool
|
||
|
*/
|
||
![]()
6 years ago
|
public function hasEditableContent()
|
||
![]()
6 years ago
|
{
|
||
|
if ($this->hasResourceFile()) {
|
||
|
$mimeType = $this->getResourceFile()->getMimeType();
|
||
![]()
6 years ago
|
if (false !== strpos($mimeType, 'text')) {
|
||
![]()
6 years ago
|
return true;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return false;
|
||
|
}
|
||
|
|
||
![]()
6 years ago
|
/**
|
||
|
* @return bool
|
||
|
*/
|
||
|
public function isResourceFileAnImage()
|
||
|
{
|
||
|
if ($this->hasResourceFile()) {
|
||
|
$mimeType = $this->getResourceFile()->getMimeType();
|
||
![]()
6 years ago
|
if (false !== strpos($mimeType, 'image')) {
|
||
![]()
6 years ago
|
return true;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return false;
|
||
|
}
|
||
|
|
||
![]()
6 years ago
|
/**
|
||
|
* @return bool
|
||
|
*/
|
||
![]()
6 years ago
|
public function isResourceFileAVideo()
|
||
|
{
|
||
|
if ($this->hasResourceFile()) {
|
||
|
$mimeType = $this->getResourceFile()->getMimeType();
|
||
![]()
6 years ago
|
if (false !== strpos($mimeType, 'video')) {
|
||
![]()
6 years ago
|
return true;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return false;
|
||
|
}
|
||
|
|
||
![]()
6 years ago
|
public function setResourceFile(ResourceFile $resourceFile = null): self
|
||
![]()
7 years ago
|
{
|
||
|
$this->resourceFile = $resourceFile;
|
||
|
|
||
|
return $this;
|
||
![]()
8 years ago
|
}
|
||
![]()
6 years ago
|
|
||
|
/**
|
||
|
* @return string
|
||
|
*/
|
||
|
public function getIcon()
|
||
|
{
|
||
|
$class = 'fa fa-folder';
|
||
|
if ($this->hasResourceFile()) {
|
||
|
$class = 'far fa-file';
|
||
|
|
||
|
if ($this->isResourceFileAnImage()) {
|
||
|
$class = 'far fa-file-image';
|
||
|
}
|
||
|
if ($this->isResourceFileAVideo()) {
|
||
|
$class = 'far fa-file-video';
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return '<i class="'.$class.'"></i>';
|
||
|
}
|
||
![]()
6 years ago
|
|
||
|
/**
|
||
|
* @return string
|
||
|
*/
|
||
|
public function getThumbnail(RouterInterface $router)
|
||
|
{
|
||
|
$size = 'fa-3x';
|
||
|
$class = "fa fa-folder $size";
|
||
|
if ($this->hasResourceFile()) {
|
||
|
$class = "far fa-file $size";
|
||
|
|
||
|
if ($this->isResourceFileAnImage()) {
|
||
|
$class = "far fa-file-image $size";
|
||
|
|
||
|
$params = [
|
||
|
'id' => $this->getId(),
|
||
|
'tool' => $this->getResourceType()->getTool(),
|
||
|
'type' => $this->getResourceType()->getName(),
|
||
|
'filter' => 'editor_thumbnail',
|
||
|
];
|
||
|
$url = $router->generate(
|
||
![]()
6 years ago
|
'chamilo_core_resource_view_file',
|
||
![]()
6 years ago
|
$params
|
||
|
);
|
||
|
|
||
|
return "<img src='$url'/>";
|
||
|
}
|
||
|
if ($this->isResourceFileAVideo()) {
|
||
|
$class = "far fa-file-video $size";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return '<i class="'.$class.'"></i>';
|
||
|
}
|
||
![]()
8 years ago
|
}
|