<?php
/**
 * Class represents records from table files
 * "path" field may contain numeric id - from the uploads table
 * {autogenerated}
 * @property int $video_id PK
 * @property string $title
 * @property string|null $desc
 * @property string $path
 * @property string|null $filename
 * @property string|null $poster_id
 * @property int|null $cc_id FK cc
 * @property int|null $cc_vtt_id
 * @property string|null $mime
 * @property int|null $size
 * @property datetime|null $dattm
 * @property int|null $hide
 * @property string|null $tpl
 * @property string|null $meta_title
 * @property string|null $meta_keywords
 * @property string|null $meta_description
 * @property mixed|null $meta_robots
 * @property string|null $config
 * @property string|null $no_access_url
 * {/autogenerated}
 */
class Video extends ResourceAbstractFile
{
    public function getUrl()
    {
        $type = $this->mime == 'audio/mpeg' ? 'audio' : 'video';
        return $this->getDi()->url("$type/p/id/" . $this->video_id, false);
    }
}

/** @extends ResourceAbstractTable<Video> */
class VideoTable extends ResourceAbstractTable
{
    protected $_key = 'video_id';
    protected $_table = '?_video';
    protected $_recordClass = 'Video';

    public function getAccessType()
    {
        return ResourceAccess::VIDEO;
    }

    public function getAccessTitle()
    {
        return ___('Video');
    }

    public function getPageId()
    {
        return 'video';
    }
}