<?php

namespace Solwin\Bannerslider\Block\Widget;

use Magento\Framework\App\Filesystem\DirectoryList;

class BannerWidget extends \Magento\Framework\View\Element\Template implements \Magento\Widget\Block\BlockInterface {

    /**
     * @var \Magento\Cms\Model\Template\FilterProvider
     */
    protected $_filterProvider;

    /**
     * @var \Solwin\Bannerslider\Model\ResourceModel\Banner\Collection
     */
    protected $_collection;

    public function __construct(
        \Magento\Framework\View\Element\Template\Context $context,
        \Magento\Cms\Model\Template\FilterProvider $filterProvider,
        \Solwin\Bannerslider\Model\Resource\BannerImages\Collection $collection,
        array $data = []
    ) {
        $this->_filterProvider = $filterProvider;
        $this->_collection = $collection;
        parent::__construct($context, $data);
        $this->setTemplate('widget/bannerwidget.phtml');
    }

    public function getBannerData() {
        $collection = $this->_collection
                ->addStoreFilter($this->_storeManager->getStore()->getId())
                ->addFieldToFilter('status', 1);

        $collection->getSelect()
                ->order('imageorder');


        return $collection;
    }

    /* get module is enable or not */

    public function getEnableModule() {
        return $this->_scopeConfig->getValue('bannersection/bannergroup/active', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
    }

    /* get Animation Type */

    public function getAnimationType() {
        return $this->_scopeConfig->getValue('bannersection/bannergroup/animation', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
    }

    /* get Control Nav */

    public function getControlNav() {
        return $this->_scopeConfig->getValue('bannersection/bannergroup/controlnav', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
    }

    /* get Slide Speed  */

    public function getSlideshowSpeed() {
        return $this->_scopeConfig->getValue('bannersection/bannergroup/slideshowSpeed', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
    }

    /* get Direction */

    public function getDirection() {
        return $this->_scopeConfig->getValue('bannersection/bannergroup/direction', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
    }

    /* get Animation loop */

    public function getAnimationLoop() {
        return $this->_scopeConfig->getValue('bannersection/bannergroup/animationLoop', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
    }

    /* get Smooth height */

    public function getSmoothHeight() {
        return $this->_scopeConfig->getValue('bannersection/bannergroup/smoothHeight', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
    }

    /* get Start At */

    public function getStartAt() {
        return $this->_scopeConfig->getValue('bannersection/bannergroup/startAt', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
    }

    /* get Sliode Show */

    public function getSlideshow() {
        return $this->_scopeConfig->getValue('bannersection/bannergroup/slideshow', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
    }

    /* get Animation speed   */

    public function getAnimationSpeed() {
        return $this->_scopeConfig->getValue('bannersection/bannergroup/animationSpeed', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
    }

    /* get Init Delay */

    public function getInitDelay() {
        return $this->_scopeConfig->getValue('bannersection/bannergroup/initDelay', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
    }

    /* get Pause on hover value  */

    public function getPauseOnHover() {
        return $this->_scopeConfig->getValue('bannersection/bannergroup/pauseOnHover', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
    }

    /* get Touch */

    public function getTouch() {
        return $this->_scopeConfig->getValue('bannersection/bannergroup/touch', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
    }

    /* get direction nav */

    public function getDirectionNav() {
        return $this->_scopeConfig->getValue('bannersection/bannergroup/directionNav', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
    }

    /* get Keyboard */

    public function getKeyboard() {
        return $this->_scopeConfig->getValue('bannersection/bannergroup/keyboard', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
    }

    /* get Mouse Wheel */

    public function getMousewheel() {
        return $this->_scopeConfig->getValue('bannersection/bannergroup/mousewheel', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
    }

    /**
     * get base url with store code
     */
    public function getBaseUrlWithStoreCode() {
        return $this->_storeManager->getStore()->getBaseUrl();
    }

    /**
     * get base url without store code
     */
    public function getBaseUrl() {
        return $this->_storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_WEB);
    }

    /* getMedia path */

    public function getMediaPath() {
        return $this->_filesystem->getDirectoryRead(
                        DirectoryList::MEDIA
                )->getAbsolutePath('');
    }

    /* get previous button text */

    public function getPrevText() {
        return $this->_scopeConfig->getValue('bannersection/bannergroup/prevText', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
    }

    /* get next button text */

    public function getNextText() {
        return $this->_scopeConfig->getValue('bannersection/bannergroup/nextText', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
    }

}
