<?php
/**
 * Blackbird ContentManager Module
 *
 * NOTICE OF LICENSE
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to contact@bird.eu so we can send you a copy immediately.
 *
 * @category        Blackbird
 * @package         Blackbird_ContentManager
 * @copyright       Copyright (c) 2018 Blackbird (https://black.bird.eu)
 * @author          Blackbird Team
 * @license         https://www.advancedcontentmanager.com/license/
 */

namespace FiloBlu\ExtBlackbirdMenuManager\Block\Adminhtml\Menu\Import\Tab;

use Blackbird\ContentManager\Model\ContentType;
use Magento\Backend\Block\Widget\Form\Generic;
use Magento\Backend\Block\Widget\Tab\TabInterface;

/**
 *
 */
class Form extends Generic implements TabInterface
{
    /**
     * {@inheritdoc}
     */
    public function getTabLabel()
    {
        return __('Import Menu');
    }

    /**
     * {@inheritdoc}
     */
    public function getTabTitle()
    {
        return __('Import Menu');
    }

    /**
     * {@inheritdoc}
     */
    public function canShowTab()
    {
        return true;
    }

    /**
     * {@inheritdoc}
     */
    public function isHidden()
    {
        return false;
    }

    /**
     * {@inheritdoc}
     */
    protected function _prepareForm()
    {
        /** @var \Magento\Framework\Data\Form $form */
        $form = $this->_formFactory->create();
        $form->setHtmlIdPrefix('menu_');

        $fieldset = $form->addFieldset('import_content', ['legend' => __('Import Menu')]);

        $fieldset->addField('file', 'file', [
            'name' => 'file',
            'label' => __('File'),
            'title' => __('File'),
            'note' => __('You can import JSON file. Previously exported from the menu  page. Useful to import/export content from local to remote server.'),
            'required' => true,
        ]);



        $fieldset->addField('stop_at_error', 'checkbox', [
            'name' => 'stop_at_error',
            'label' => __('Stop Import at Error'),
            'title' => __('Stop Import at Error'),
            'note' => __('If check, import will stop at error and all saved contents will be rollback, else, import will continue for all content and return you a CSV file with none imported content (caused by an error) with a details about errors.'),
        ]);

        $this->setForm($form);

        return parent::_prepareForm();
    }


}
