<?php
    defined('BASEPATH') OR exit('No direct script access allowed');
?>

<section class="container">
    <div class="row">
        <div class="col center">
            <h1><?= lang('ytdl_title'); ?></h1>
            <p class="lead"><?= lang('ytdl_description'); ?></p>
        </div>
    </div>
    <div class="row justify-content-center">
        <form class="form-inline" method="get" id="download" action="/tools/youtube/video">
            <label class="sr-only" for="videoid"><?= lang('ytdl_videoid'); ?></label>
            <input type="text" class="form-control input-lg mb-2 mr-sm-2" id="videoid" name="videoid" placeholder="<?= lang('ytdl_videoid'); ?>" ariadescribedby="description">

            <input type="submit" class="btn btn-primary mb-2" name="type" id="type" value="<?= lang('ytdl_download'); ?>">
        </form>
    </div>
    <div class="row">
        <div class="col center">
            <span id="description" class="help-block"><?= lang('ytdl_help'); ?></span>
        </div>
    </div>
</section>

<?php
    if (isset($_GET['error']) && !empty($_GET['error'])) {
        $errors = lang('ytdl_errors');

        echo '<div class="fixed-bottom"><div class="alert alert-danger alert-dismissible" style="margin: auto 25% 10px 25%" role="alert"><button type="button" class="close" data-dismiss="alert" aria-label="' . lang('ytdl_close') . '"><span aria-hidden="true">&times;</span></button> <strong>' . lang('ytdl_error') . '</strong> ' . $errors[$_GET['error']] . '</div></div>';
    }
?>