<?php
/**
 * @package     DOCman
 * @copyright   Copyright (C) 2019 Timble CVBA. (http://www.timble.net)
 * @license     GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
 * @link        https://github.com/foliolabs/docman for the canonical source repository
 */

namespace Foliolabs\Docman;

use Foliolabs\Component\Base;
use Foliolabs\Library;

class BlockScriptSubmit extends Base\BlockScriptExternal
{
    public function __construct(Library\ObjectConfig $config)
    {
        parent::__construct($config);

        $this->setPath('foliolabs-docman/base/resources/assets/js/block/submit.js');
    }

    public function beforeEnqueue()
    {
        parent::beforeEnqueue();

        BlockScriptCommon::addCommonScripts();

        $this->getObject('translator')->load('com:docman');

        $view = $this->getObject('com:docman.view.default.html');
        $template = $view->getTemplate()
            ->addFilter('style')
            ->addFilter('script');

        $string = "
        <?= helper('ui.styles', [
            'package' => 'docman',
            'domain' => 'site',
            'file' => 'block',
            'dark_mode' => false
        ]); ?>
        <?= helper('translator.script', [
            'strings' => [
                'Select',
                'Notifications',
                'General',
            ]
        ]); ?>
        <?= helper('behavior.jquery'); ?>
        ";

        $template->render($string, [], 'php');

    }
}