<?php

/*
 * Created on Mon Mar 25 2019
 * HomePage: http://dcforo.com/
 * Email: datdaik000@gmail.com
 * Blog: https://fb.com/dcstylexf/
 * Copyright (c) 2019 D.C Style XenForo -  All Rights Reserved
 */

namespace DC\ThreadThumbnail;
use XF\Mvc\Entity\Entity;

class Listener
{
    public static function threadEntityStructure(\XF\Mvc\Entity\Manager $em, \XF\Mvc\Entity\Structure &$structure)
    {
        $structure->columns['DC_ThreadThumbnail_thumbCustom'] = ['type' => Entity::INT, 'default' => 0];
        $structure->columns['DC_ThreadThumbnail_threadCover'] = ['type' => Entity::INT, 'default' => 0];
        $structure->columns['DC_ThreadThumbnail_thumbUrl'] = ['type' => Entity::STR, 'default' => ''];
        $structure->columns['DC_ThreadThumbnail_threadCoverUrl'] = ['type' => Entity::STR, 'default' => ''];
        $structure->columns['DC_ThreadThumbnail_threadVideoID'] = ['type' => Entity::STR, 'default' => ''];
        $structure->columns['DC_ThreadThumbnail_threadVideoSite'] = ['type' => Entity::STR, 'default' => ''];
        $structure->columns['DC_ThreadThumbnail_threadVideoUrl'] = ['type' => Entity::STR, 'default' => ''];
        $structure->columns['DC_ThreadThumbnail_tempThumbUrl'] = ['type' => Entity::STR, 'default' => ''];
        $structure->columns['DC_ThreadThumbnail_tempImageUrl'] = ['type' => Entity::STR, 'default' => ''];
    }

    public static function threadEntityPreSave(\XF\Mvc\Entity\Entity $entity)
    {
        
    }
    
    public static function threadEntityPostSave(\XF\Mvc\Entity\Entity $entity)
    {
        
    }

    public static function appSetup(\XF\App $app)
    {
        $options = \XF::options();
        
        $app->thumbNode = $options->DC_ThreadThumbnail_forumView;
        $app->thumbSize = $options->DC_ThreadThumbnail_thumbSize;
        $app->coverStyle = $options->DC_ThreadThumbnail_styles;
        $app->videoStyle = $options->DC_ThreadThumbnail_videoStyles;
        $app->supportedSites = 'Youtube, Vimeo, Dailymotion';
        $app->base64 = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8Xw8AAoMBgDTD2qgAAAAASUVORK5CYII=';
    }
}