<commit_before><?php
require_once '../videos/configuration.php';
require_once $global['systemRootPath'] . 'objects/user.php';
if (!User::isAdmin()) {
    header("Location: {$global['webSiteRootURL']}?error=" . __("You can not manager videos"));
    exit;
}
require_once $global['systemRootPath'] . 'objects/category.php';
require_once $global['systemRootPath'] . 'objects/video.php';
$categories = Category::getAllCategories();
require_once $global['systemRootPath'] . 'objects/configuration.php';
$config = new Configuration();
?>
<!DOCTYPE html>
<html lang="<?php echo $_SESSION['language']; ?>">
    <head>
        <title><?php echo $config->getWebSiteTitle(); ?> :: <?php echo __("Videos"); ?></title>
        <?php
        include $global['systemRootPath'] . 'view/include/head.php';
        ?>
    </head>

    <body>
        <?php
        include 'include/navbar.php';
        ?>

        <div class="container">

            <table id="grid" class="table table-condensed table-hover table-striped">
                <thead>
                    <tr>
                        <th data-column-id="id" data-type="numeric" data-identifier="true" data-width="50px"><?php echo __("ID"); ?></th>
                        <th data-column-id="title" ><?php echo __("Title"); ?></th>
                        <th data-column-id="status" data-formatter="status" ><?php echo __("Status"); ?></th>
                        <th data-column-id="category" ><?php echo __("Category"); ?></th>
                        <th data-column-id="type" ><?php echo __("Type"); ?></th>
                        <th data-column-id="duration" ><?php echo __("Duration"); ?></th>
                        <th data-column-id="created" data-order="desc"><?php echo __("Created"); ?></th>
                        <th data-column-id="commands" data-formatter="commands" data-sortable="false"  data-width="300px"></th>
                    </tr>
                </thead>
            </table>

            <div id="videoFormModal" class="modal fade" tabindex="-1" role="dialog">
                <div class="modal-dialog" role="document">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                            <h4 class="modal-title"><?php echo __("Video Form"); ?></h4>
                        </div>
                        <div class="modal-body">
                            <form class="form-compact"  id="updateCategoryForm" onsubmit="">
                                <input type="hidden" id="inputVideoId"  >
                                <label for="inputTitle" class="sr-only"><?php echo __("Title"); ?></label>
                                <input type="text" id="inputTitle" class="form-control first" placeholder="<?php echo __("Title"); ?>" required autofocus>
                                <label for="inputCleanTitle" class="sr-only"><?php echo __("Clean Title"); ?></label>
                                <input type="text" id="inputCleanTitle" class="form-control" placeholder="<?php echo __("Clean Title"); ?>" required>
                                <label for="inputDescription" class="sr-only"><?php echo __("Description"); ?></label>
                                <textarea id="inputDescription" class="form-control" placeholder="<?php echo __("Description"); ?>" required></textarea>
                                <label for="inputCategory" class="sr-only"><?php echo __("Category"); ?></label>
                                <select class="form-control last" id="inputCategory" required>
                                    <?php
                                    foreach ($categories as $value) {
                                        echo "<option value='{$value['id']}'>{$value['name']}</option>";
                                    }
                                    ?>
                                </select>
                            </form>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal"><?php echo __("Close"); ?></button>
                            <button type="button" class="btn btn-primary" id="saveCategoryBtn"><?php echo __("Save changes"); ?></button>
                        </div>
                    </div><!-- /.modal-content -->
                </div><!-- /.modal-dialog -->
            </div><!-- /.modal -->


        </div><!--/.container-->

        <?php
        include 'include/footer.php';
        ?>
        <script>
            function checkProgressVideo(filename, id, refresh) {
                $.ajax({
                    url: 'uploadStatus?filename=' + filename,
                    success: function (response) {
                        console.log(response);
                        var types = <?php echo json_encode(Video::$types); ?>;
                        types.forEach(function (entry) {
                            console.log(entry);
                            var responseType;
                            if (response) {
                                //eval("if(!response."+entry + "){ continue;}");
                                eval("responseType = response." + entry + ";");
                                if (responseType && responseType.progress) {
                                    var txt = entry.toUpperCase() + ": " + responseType.progress + "%";
                                    $('#encoding' + entry + id).html(txt);
                                }
                            }
                            if (responseType && responseType.progress < 100) {
                                if (responseType.progress > 0) {
                                    $('#encoding' + entry + id).removeClass('label-danger');
                                    $('#encoding' + entry + id).addClass('label-warning');
                                }
                            }
                            if (responseType && responseType.progress === 100) {
                                $('#encoding' + entry + id).removeClass('label-warning');
                                $('#encoding' + entry + id).removeClass('label-danger');
                                $('#encoding' + entry + id).addClass('label-success');
                                $('#encoding' + entry + id).html(entry.toUpperCase() + ': 100%');
                                refresh = false;
                            }
                        });
                        if(refresh){
                            setTimeout(function () {
                                checkProgressVideo(filename, id, refresh);
                            }, 1000);
                        }
                    }
                });
            }
            function checkProgressDownload(filename, id) {
                $.ajax({
                    url: 'getDownloadProgress',
                    data: {"filename": filename},
                    type: 'post',
                    success: function (response) {
                        $("#downloadProgress"+id).css({'width': response.progress + '%'});
                        if (response.progress < 100) {
                            setTimeout(function () {
                                checkProgressDownload(filename, id);
                            }, 1000);
                        } else if (response.progress == 100) {
                            $("#downloadProgress"+id).css({'width': '100%'});
                            swal({
                                title: "<?php echo __("Congratulations!"); ?>",
                                text: "<?php echo __("Your video download is complete, it is encoding now"); ?>",
                                type: "success"
                            });<commit_msg>Video Download in video manager<commit_after><?php
require_once '../videos/configuration.php';
require_once $global['systemRootPath'] . 'objects/user.php';
if (!User::isAdmin()) {
    header("Location: {$global['webSiteRootURL']}?error=" . __("You can not manager videos"));
    exit;
}
require_once $global['systemRootPath'] . 'objects/category.php';
require_once $global['systemRootPath'] . 'objects/video.php';
$categories = Category::getAllCategories();
require_once $global['systemRootPath'] . 'objects/configuration.php';
$config = new Configuration();
?>
<!DOCTYPE html>
<html lang="<?php echo $_SESSION['language']; ?>">
    <head>
        <title><?php echo $config->getWebSiteTitle(); ?> :: <?php echo __("Videos"); ?></title>
        <?php
        include $global['systemRootPath'] . 'view/include/head.php';
        ?>
    </head>

    <body>
        <?php
        include 'include/navbar.php';
        ?>

        <div class="container">

            <table id="grid" class="table table-condensed table-hover table-striped">
                <thead>
                    <tr>
                        <th data-column-id="id" data-type="numeric" data-identifier="true" data-width="50px"><?php echo __("ID"); ?></th>
                        <th data-column-id="title" ><?php echo __("Title"); ?></th>
                        <th data-column-id="status" data-formatter="status" ><?php echo __("Status"); ?></th>
                        <th data-column-id="category" ><?php echo __("Category"); ?></th>
                        <th data-column-id="type" ><?php echo __("Type"); ?></th>
                        <th data-column-id="duration" ><?php echo __("Duration"); ?></th>
                        <th data-column-id="created" data-order="desc"><?php echo __("Created"); ?></th>
                        <th data-column-id="commands" data-formatter="commands" data-sortable="false"  data-width="300px"></th>
                    </tr>
                </thead>
            </table>

            <div id="videoFormModal" class="modal fade" tabindex="-1" role="dialog">
                <div class="modal-dialog" role="document">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                            <h4 class="modal-title"><?php echo __("Video Form"); ?></h4>
                        </div>
                        <div class="modal-body">
                            <form class="form-compact"  id="updateCategoryForm" onsubmit="">
                                <input type="hidden" id="inputVideoId"  >
                                <label for="inputTitle" class="sr-only"><?php echo __("Title"); ?></label>
                                <input type="text" id="inputTitle" class="form-control first" placeholder="<?php echo __("Title"); ?>" required autofocus>
                                <label for="inputCleanTitle" class="sr-only"><?php echo __("Clean Title"); ?></label>
                                <input type="text" id="inputCleanTitle" class="form-control" placeholder="<?php echo __("Clean Title"); ?>" required>
                                <label for="inputDescription" class="sr-only"><?php echo __("Description"); ?></label>
                                <textarea id="inputDescription" class="form-control" placeholder="<?php echo __("Description"); ?>" required></textarea>
                                <label for="inputCategory" class="sr-only"><?php echo __("Category"); ?></label>
                                <select class="form-control last" id="inputCategory" required>
                                    <?php
                                    foreach ($categories as $value) {
                                        echo "<option value='{$value['id']}'>{$value['name']}</option>";
                                    }
                                    ?>
                                </select>
                            </form>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal"><?php echo __("Close"); ?></button>
                            <button type="button" class="btn btn-primary" id="saveCategoryBtn"><?php echo __("Save changes"); ?></button>
                        </div>
                    </div><!-- /.modal-content -->
                </div><!-- /.modal-dialog -->
            </div><!-- /.modal -->


        </div><!--/.container-->

        <?php
        include 'include/footer.php';
        ?>
        <script>
            function checkProgressVideo(filename, id, refresh) {
                $.ajax({
                    url: 'uploadStatus?filename=' + filename,
                    success: function (response) {
                        console.log(response);
                        var types = <?php echo json_encode(Video::$types); ?>;
                        var allComplete = true;
                        types.forEach(function (entry) {
                            console.log(entry);
                            var responseType;
                            if (response) {
                                //eval("if(!response."+entry + "){ continue;}");
                                eval("responseType = response." + entry + ";");
                                if (responseType && responseType.progress) {
                                    var txt = entry.toUpperCase() + ": " + responseType.progress + "%";
                                    $('#encoding' + entry + id).html(txt);
                                }
                            }
                            if (responseType && responseType.progress < 100) {
                                if (responseType.progress > 0) {
                                    $('#encoding' + entry + id).removeClass('label-danger');
                                    $('#encoding' + entry + id).addClass('label-warning');
                                }
                                allComplete = false;
                            }
                            if (responseType && responseType.progress === 100) {
                                $('#encoding' + entry + id).removeClass('label-warning');
                                $('#encoding' + entry + id).removeClass('label-danger');
                                $('#encoding' + entry + id).addClass('label-success');
                                $('#encoding' + entry + id).html(entry.toUpperCase() + ': 100%');
                            }
                        });
                        if(refresh && !allComplete){
                            setTimeout(function () {
                                checkProgressVideo(filename, id, refresh);
                            }, 1000);
                        }
                    }
                });
            }
            function checkProgressDownload(filename, id) {
                $.ajax({
                    url: 'getDownloadProgress',
                    data: {"filename": filename},
                    type: 'post',
                    success: function (response) {
                        $("#downloadProgress"+id).css({'width': response.progress + '%'});
                        if (response.progress < 100) {
                            setTimeout(function () {
                                checkProgressDownload(filename, id);
                            }, 1000);
                        } else if (response.progress == 100) {
                            $("#downloadProgress"+id).css({'width': '100%'});
                            swal({
                                title: "<?php echo __("Congratulations!"); ?>",
                                text: "<?php echo __("Your video download is complete, it is encoding now"); ?>",
                                type: "success"
                            });
{'fraction_non_alphanumeric': 0.15122955935588567, 'fraction_numerical': 0.004368992635126701, 'mean_word_length': 1.2821535393818544, 'pattern_counts': {'":': 4, '<': 217, '<?xml version=': 0, '>': 217, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 37, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '80578', 'n_tokens_mistral': 3793, 'n_tokens_neox': 3613, 'n_words': 756}