<?php
require_once('languages/en-GB.php');
require_once('classes/helper.php');

define('_JEXEC', 1);
define('DS', DIRECTORY_SEPARATOR);
define('JPATH_BASE', $_SERVER['DOCUMENT_ROOT']);

require_once(JPATH_BASE . DS . 'includes' . DS . 'defines.php');
require_once(JPATH_BASE . DS . 'includes' . DS . 'framework.php');

jimport('joomla.user.helper');

$url        = $lang['url'] . $_GET['url'];
$id         = $_GET['id'];
$lessonID   = $_GET['lesson'] - 1;
$course     = (object)Course::getCourseByUrl($url);
$lessons    = json_decode($course->lessons);
$files      = json_decode($course->fileDownloadLink)->files;

$app    = JFactory::getApplication('site');
$user   = JFactory::getUser();

$courseApp          = Course::getCourseApplication($course->id, $user->id);
$completedCourses   = (array)json_decode($courseApp['completedCourses'])->courses;
$percentage         = Course::getApplicationPercentage($course->id, $user->id);
$courseArray        = (array)$lessons->courses;
$firstCourse        = key($courseArray);
$nextLesson         = '';
$nextCourse         = '';

if ($id == $lang['download_link']) {
    $table = $_SERVER['HTTP_HOST'] == 'www.archline.hu' ? 'jml_content' : 'eng_content';

    $query = "SELECT * FROM `" . JMLADATBAZIS . "`.`{$table}` WHERE id = ?";
    Database::getInstance()->query($query, array('i', $files->article[0]));
    $article = Database::getInstance()->fetchNext();

    $moduleStr = Course::get_string_between($article['introtext'], '{loadmodule ', '}');
    $module = explode(",", $moduleStr);
    $phoca = Course::get_string_between($article['introtext'], '{phocadownload ', '}');

    $introText = str_replace("{loadmodule " . $module[0] . "," . $module[1] . "}", JModuleHelper::renderModule(JModuleHelper::getModule($module[0], $module[1])), $article['introtext']);
    $introText = str_replace("{phocadownload " . $phoca . "}", "<a id='download_link' href='" . $files->link[0] . "'></a>", $introText);
}

if ($lessonID != '' && $lessonID < 0 && $id != $lang['download_link'] || ($id == $lang['download_link'] && $course->fileDownloadLink == '')) {
    $newUrl = 'https://' . $_SERVER['HTTP_HOST'] . '/' . $url . '/';

    if ($lessonID < 0) {
        if ($course->fileDownloadLink == '') {
            $newUrl .= $firstCourse . '/1';
        } else {
            $newUrl .= $lang['download_link'];
        }
    } else {
        $newUrl .= $firstCourse . '/1';
    }

    header("Location: {$newUrl}");
    exit();
}

$freeLesson = $course->need_login == 0;

if ($id != '' && $id != $lang['download_link'] && $lessonID >= 0) {
    $selectedCourse = $courseArray[$id];

    $selectedLessonName = $selectedCourse->lessons->name[$lessonID];
    $selectedLessonYt   = $selectedCourse->lessons->yt_link[$lessonID];

    $lastLesson = count($selectedCourse->lessons->name);

    if ($lessonID > $lastLesson - 1) {
        $newUrl = 'https://' . $_SERVER['HTTP_HOST'] . '/' . $url . '/';
        $newUrl .= $firstCourse . '/1';

        header("Location: {$newUrl}");
        exit();
    }

    if (!$freeLesson && count($courseArray[$id]->lessons->name) > 1)
        $freeLesson = $lessonID == 0;

    $freeLesson = true;

    $YtId       = substr(strrchr(rtrim($selectedLessonYt, '/'), '/'), 1);
    //$key        = 'AIzaSyAAvKsDP6AF5XseRIDIezkFrrRwy-BwoeE';
    $key        = 'AIzaSyDmEK6HMS1-tPIVZDXwleeTST_fi6Z9TaE';
    $json       = file_get_contents("https://www.googleapis.com/youtube/v3/videos?part=statistics&id=" . $YtId . "&key=" . $key);
    $jsonData   = json_decode($json);
    $views      = $jsonData->items[0]->statistics->viewCount;
} else {
    $nextLesson = 1;

    if (current($courseArray)->lessons == null) {
        next($courseArray);
        $nextCourse = key($courseArray);
    } else {
        $nextCourse = $firstCourse;
    }
}
?>

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?= strip_tags($course->title) ?></title>

    <link href="<?= $lang['icon'] ?>" rel="shortcut icon" type="image/vnd.microsoft.icon" />

    <link rel="stylesheet" href="/templates/shaper_helix3/css/template.css">
    <link href="https://fonts.googleapis.com/css?family=Open+Sans:400,600,700&amp;display=swap" rel="stylesheet">
    <link rel="stylesheet" href="/beiratkozas/public/css/course-player-v2-72334d533118a1e90a0609999366bbe7.css">
    <link href='/beiratkozas/public/css/toga-icons.css' rel='stylesheet' type='text/css'>
    <link rel="stylesheet" href="/beiratkozas/public/css/vendor-e0cb822bbe090c173fe20baeb13b0c48.css">

    <script src="https://www.archline.hu/media/jui/js/jquery.min.js?f047cfec858cbb7542487d594104fb00"></script>
    <script src="https://www.youtube.com/player_api" async></script>

    <style>
        .views {
            font-size: 0.9rem;
            margin-top: 0.5rem;
        }

        #login-form-div {
            padding: 50px;
        }

        body,
        button,
        input,
        textarea {
            font-family: Open Sans;
        }

        ._course-progress__dashboard-link_1rtg53 {
            font-size: 12px !important;
        }

        .progress_desc {
            font-size: 14px;
            margin-top: 10px;
        }

        #signInModalLink {
            cursor: pointer;
        }

        .login-container {
            margin-top: 15%;
        }

        ._top-bar__dashboard-link_v3q4ce .top-bar__dashboard-link__icon {
            font-size: 24px;
        }

        .form-links {
            list-style: none;
            padding-left: 0px;
        }

        .btn-primary {
            border-color: #343a84;
            background-color: #3d449a;
        }

        .form-links>li {
            padding: 2px 0;
            font-size: 14px !important;
            font-weight: 400;
            line-height: 22px;
        }

        .form-links>li>a {
            color: rgb(56, 151, 221) !important;
        }

        .top-bar__dashboard-link__anchor {
            font-size: 14px;
            margin-left: 20px;
        }

        [data-theme] .brand-color__background {
            background-color: #cccccc;
        }

        [data-theme] .brand-color__text {
            color: #cccccc;
        }

        [data-theme] .brand-color__dynamic-text {
            color: #1d1d1d;
        }

        [data-theme] .brand-color__fill {
            fill: #cccccc;
        }

        [data-theme] .brand-color__border {
            border-color: #cccccc;
        }

        [data-theme] .brand-color__border-60-opacity {
            border-color: rgba(204, 204, 204, 0.6);
        }

        [data-theme] .brand-color__border-60-opacity:not([disabled]):hover {
            border-color: #cccccc;
        }

        [data-theme] .brand-color__background-30-opacity:not([disabled]):hover {
            background-color: rgba(204, 204, 204, 0.3);
        }

        .course-player__content-item .toga-icon-checkmark::before {
            color: #1d1d1d !important;
        }

        .course-player__chapter-item__header .toga-icon-checkmark::before {
            color: #1d1d1d !important;
        }

        .progress-bar {
            width: 100%;
            margin-top: 16px;
            margin-bottom: 10px;
            border-radius: 2px;
            overflow: hidden;
            background-color: #CACCD6;
            height: 4px;
        }

        .progress {
            background: <?= $lang['color'] ?>;
            background: -webkit-linear-gradient(to bottom, <?= $lang['linear_color'] ?>, <?= $lang['color'] ?>);
            background: linear-gradient(to bottom, <?= $lang['linear_color'] ?>, <?= $lang['color'] ?>);
            border-radius: 2px;
            height: 4px;
            width: 0;
            transition: width 0.5s ease-in;
        }

        .not-completed-lesson::after {
            height: calc(100% - 100px) !important;
        }

        .course-player__chapters-menu {
            margin-top: 20px !important;
        }

        ._button--default--small_142a8m {
            text-decoration: none;
        }

        @media (min-width: 768px) {
            ._top-bar__logo_v3q4ce {
                height: 2rem !important;
            }

            .signin-container {
                width: 50% !important;
            }
        }

        .modal {
            display: none;
            position: fixed;
            z-index: 1;
            padding-top: 100px;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            overflow: auto;
            background-color: rgb(0, 0, 0);
            background-color: rgba(0, 0, 0, 0.4);
        }

        .modal-content {
            position: relative;
            background-color: #fefefe;
            margin: auto;
            padding: 0;
            border: 1px solid #888;
            width: 80%;
            box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
            -webkit-animation-name: animatetop;
            -webkit-animation-duration: 0.4s;
            animation-name: animatetop;
            animation-duration: 0.4s
        }

        #login-form {
            padding: 10px;
        }

        .form-group {
            margin-bottom: 15px;
        }

        input[type="text"],
        input[type="password"] {
            display: block;
            height: 34px;
            padding: 6px 12px;
            font-size: 14px;
            line-height: 1.428571429;
            color: #555555;
            background-color: #fff;
            background-image: none;
            border: 1px solid #ccc;
            border-radius: 4px;
            width: 80%;
            margin-left: 10%;
        }

        .btn:not(:disabled):not(.disabled) {
            cursor: pointer;
        }

        .btn-primary {
            border-color: #343a84;
            background-color: #3d449a;
            color: #fff;
        }

        .btn-success {
            color: #fff;
            background-color: #5cb85c;
            border-color: #4cae4c;
        }

        #form-login-submit,
        .form-links {
            margin-left: 10%;
        }

        .btn {
            display: inline-block;
            padding: 6px 12px;
            margin-bottom: 0;
            font-size: 14px;
            font-weight: 400;
            line-height: 1.42857143;
            text-align: center;
            white-space: nowrap;
            vertical-align: middle;
            -ms-touch-action: manipulation;
            touch-action: manipulation;
            cursor: pointer;
            -webkit-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
            user-select: none;
            background-image: none;
            border: 1px solid transparent;
            border-radius: 4px;
        }

        @-webkit-keyframes animatetop {
            from {
                top: -300px;
                opacity: 0
            }

            to {
                top: 0;
                opacity: 1
            }
        }

        @keyframes animatetop {
            from {
                top: -300px;
                opacity: 0
            }

            to {
                top: 0;
                opacity: 1
            }
        }

        .close,
        .signInClose {
            color: #36394D;
            float: right;
            font-size: 28px;
            font-weight: bold;
            margin-top: 1vw;
        }

        .close:hover,
        .close:focus,
        .signInClose:hover,
        .signInClose:focus {
            text-decoration: none;
            cursor: pointer;
        }

        .modal-header {
            padding: 2px 16px;
            background-color: rgba(54, 57, 77, .15);
            color: #36394D;
        }

        .modal-body {
            padding: 2px 16px;
        }

        #download_link,
        div>a {
            text-decoration: none;
            color: rgb(56, 151, 221);
        }
    </style>
</head>

<body>
    <div id="wrap">
        <div id="page-content" class="ember-application">
            <div id="modal-overlays"></div>

            <div id="ember393" class="ember-view">
                <div class="course-player  _course-player_1jimy1">
                    <div data-theme="light-theme" id="player-wrapper" class="course-player__container    _course-player__container_n1vbpj">
                        <a href="#main-content" class="skip-link">
                            Skip to main content
                        </a>

                        <header class="course-player__top-bar brand-color__background  _top-bar_n1vbpj">
                            <div class="_container_v3q4ce">
                                <button id="enableMenu" aria-label="Enable menu" class="course-player__top-bar__menu-toggle brand-color__dynamic-text _top-bar__menu-toggle_v3q4ce" data-ember-action="" data-ember-action-659="659">
                                    <span class="course-player__top-bar__menu-toggle__bar _top-bar__menu-toggle__bar_v3q4ce"></span>
                                    <span class="course-player__top-bar__menu-toggle__bar _top-bar__menu-toggle__bar_v3q4ce"></span>
                                    <span class="course-player__top-bar__menu-toggle__bar _top-bar__menu-toggle__bar_v3q4ce"></span>
                                </button>

                                <div class="top-bar__dashboard-link _top-bar__dashboard-link_v3q4ce">
                                    <a href="<?= $lang['courses_url'] ?>" data-qa="dashboard__path" class="top-bar__dashboard-link__anchor brand-color__dynamic-text">
                                        <i aria-hidden="true" class="top-bar__dashboard-link__icon toga-icon toga-icon-caret-stroke-left brand-color__dynamic-text"></i>
                                        <?= $lang['go_to_dashboard'] ?>
                                    </a>
                                </div>
                                <section class="course-player__top-bar__branding _top-bar__branding_v3q4ce">
                                    <div class="_logo__container_v3q4ce">
                                        <img src="<?= $lang['logo'] ?>" class="course-player__top-bar__logo _top-bar__logo_v3q4ce">
                                    </div>
                                </section>
                            </div>
                        </header>

                        <div class="course-player__content     _course-player__content_n1vbpj">
                            <nav class="course-player__left-drawer _left-drawer_n1vbpj">
                                <div class="course-player__course-navigation _course-navigation_t2nzf7">
                                    <div id="ember674" class="ember-view">
                                        <section class="course-progress__container _course-progress__container_1rtg53">
                                            <section class="surface__container _surface__container_1yatsw _surface--default_1yatsw">
                                                <div class="course-progress__school-name brand-color__background _course-progress__school-name_1rtg53">
                                                    <div class="_container_v3q4ce">
                                                        <button aria-label="Enable menu" class="course-player__top-bar__menu-toggle brand-color__dynamic-text _top-bar__menu-toggle_v3q4ce" data-ember-action="" data-ember-action-683="683">
                                                            <span class="course-player__top-bar__menu-toggle__bar _top-bar__menu-toggle__bar_v3q4ce"></span>
                                                            <span class="course-player__top-bar__menu-toggle__bar _top-bar__menu-toggle__bar_v3q4ce"></span>
                                                            <span class="course-player__top-bar__menu-toggle__bar _top-bar__menu-toggle__bar_v3q4ce"></span>
                                                        </button>

                                                        <div class="top-bar__dashboard-link _top-bar__dashboard-link_v3q4ce">
                                                            <a href="<?= $lang['courses_url'] ?>" data-qa="dashboard__path" class="top-bar__dashboard-link__anchor brand-color__dynamic-text">
                                                                <i aria-hidden="true" class="top-bar__dashboard-link__icon toga-icon toga-icon-caret-stroke-left brand-color__dynamic-text"></i>
                                                                <?= $lang['go_to_dashboard'] ?>
                                                            </a>
                                                        </div>

                                                        <section class="course-player__top-bar__branding _top-bar__branding_v3q4ce">
                                                            <div class="_logo__container_v3q4ce">
                                                                <img src="<?= $lang['logo'] ?>">
                                                            </div>
                                                        </section>
                                                    </div>
                                                </div>

                                                <div class="course-progress__inner-container _course-progress__inner-container_1rtg53">
                                                    <a href="<?= $lang['courses_url'] ?>" class="course-progress__dashboard-link _course-progress__dashboard-link_1rtg53"><?= $lang['go_to_dashboard'] ?></a>
                                                    <h1 class="course-progress__title _course-progress__title_1rtg53"><?= $course->title ?></h1>
                                                    <?php if ($id != '' && $id != $lang['download_link']) : ?>
                                                        <div class="views"><?= $lang['views'] ?>: <b><?= $views + $course->views ?></b></div>
                                                    <?php endif; ?>
                                                    <div class="_course-progress__actions-container_1rtg53">
                                                        <div class="progress-bar">
                                                            <div data-size="<?= $percentage ?>" class="progress"></div>
                                                        </div>

                                                        <p class="course-progress__percent-complete _course-progress__percent-complete_1rtg53"><span><?= $percentage ?>%</span> <?= $lang['complete'] ?></p>

                                                        <?php if ($user->id <= 0) : ?>
                                                            <div class="progress_desc"><?= $lang['progress_desc'] ?></div>
                                                        <?php endif; ?>
                                                    </div>
                                                </div>
                                            </section>
                                        </section>
                                    </div>

                                    <div id="ember706" class="ember-view">

                                    </div>

                                    <div role="navigation" aria-label="Chapters" class="course-player__chapters-menu ">
                                        <?php $j = 1; ?>
                                        <?php foreach ($lessons->courses as $key => $lesson) : ?>
                                            <div class="course-player__chapters-item _chapters-item_1tqvoe ember-view ui-accordion ui-widget ui-helper-reset" role="tablist">
                                                <div data-id="<?= $j ?>" class="accordion course-player__chapter-item__header _chapter-item__header_d57kmg ui-accordion-header ui-corner-top ui-accordion-header-collapsed ui-corner-all ui-state-default ui-accordion-icons" role="tab" aria-controls="ui-id-4" aria-selected="false" aria-expanded="false" tabindex="0"><span class="ui-accordion-header-icon ui-icon ui-icon-triangle-1-e"></span>
                                                    <div class="course-player__chapter-item__container _chapter-item__container_d57kmg">
                                                        <span class="course-player__progress _chapter-item__progress_d57kmg">
                                                            <?php if (count($completedCourses[$key]) == count($lesson->lessons->name)) : ?>
                                                                <span data-percentage-completion="100" role="progressbar" aria-label="Complete progress for Overview and Preparation" aria-valuemin="0" aria-valuemax="100" aria-valuenow="100" class="_chapter-item__progress-ring_d57kmg">
                                                                    <span class="progress-ring__ring _progress-ring__ring_jgsecr">
                                                                        <span class="progress-ring__mask progress-ring--full _progress-ring__mask_jgsecr _progress-ring--full_jgsecr">
                                                                            <span class="progress-ring--fill brand-color__background _progress-ring--fill_jgsecr"></span>
                                                                        </span>
                                                                        <span class="progress-ring__mask progress-ring--half _progress-ring__mask_jgsecr ">
                                                                            <span class="progress-ring--fill brand-color__background _progress-ring--fill_jgsecr"></span>
                                                                            <span class="progress-ring--fill progress-ring--fix _progress-ring--fill_jgsecr _progress-ring--fix_jgsecr"></span>
                                                                        </span>
                                                                    </span>
                                                                    <span class="progress-ring__ring-inset _progress-ring__ring-inset_jgsecr"></span>
                                                                    <span class="progress-ring__checkmark brand-color__text _progress-ring__checkmark_jgsecr"><i role="img" aria-label="Completed" class="toga-icon toga-icon-checkmark"></i></span>
                                                                </span>
                                                            <?php else : ?>
                                                                <span role="progressbar" class="_chapter-item__progress-ring_d57kmg">
                                                                    <span class="progress-ring__ring _progress-ring__ring_jgsecr">
                                                                        <span class="progress-ring__mask progress-ring--full _progress-ring__mask_jgsecr _progress-ring--full_jgsecr">
                                                                            <span class="progress-ring--fill brand-color__background _progress-ring--fill_jgsecr"></span>
                                                                        </span>
                                                                        <span class="progress-ring__mask progress-ring--half _progress-ring__mask_jgsecr ">
                                                                            <span class="progress-ring--fill brand-color__background _progress-ring--fill_jgsecr"></span>
                                                                            <span class="progress-ring--fill progress-ring--fix _progress-ring--fill_jgsecr _progress-ring--fix_jgsecr"></span>
                                                                        </span>
                                                                    </span>
                                                                    <span class="progress-ring__ring-inset _progress-ring__ring-inset_jgsecr"></span>
                                                                    <span class="progress-ring__checkmark brand-color__text _progress-ring__checkmark_jgsecr"><i role="img" aria-label="Completed" class="toga-icon toga-icon-checkmark"></i></span>
                                                                </span>
                                                            <?php endif; ?>
                                                        </span>

                                                        <h2 class="_chapter-item__title_d57kmg"><?= $lesson->name ?></h2>

                                                        <span aria-hidden="true" class="course-player__chapter-item__completion _chapter-item__completion_d57kmg">
                                                            <?= count($completedCourses[$key]) ?> / <?= count($lesson->lessons->name) ?>
                                                        </span>

                                                        <span class="course-player__chapter-item__toggle _chapter-item__toggle_d57kmg">
                                                            <i id="icon-<?= $j ?>" aria-hidden="true" class="chapter-item__toggle-icon toga-icon toga-icon-caret-stroke-down _chapter-item__toggle-icon_d57kmg"></i>
                                                        </span>
                                                    </div>
                                                </div>
                                                <div class="ui-accordion-content ui-corner-bottom ui-helper-reset ui-widget-content" id="ui-id-<?= $j ?>" aria-labelledby="ui-id-3" role="tabpanel" aria-hidden="true" <?= $key == $id || ($id == $lang['download_link'] && $j == 1) ? '' : 'style="display: none;"' ?>>
                                                    <ul class="course-player__chapter-item__contents _chapter-item__contents_d57kmg">
                                                        <?php if ($lesson->lessons == null && ($key == 'overview-and-preparation' || mb_strtolower($key) == 'áttekintés-és-előkészítés')) : ?>
                                                            <?php if (($key == 'overview-and-preparation' || mb_strtolower($key) == 'áttekintés-és-előkészítés') && $course->fileDownloadLink != '') : ?>
                                                                <li data-qa="content-item" class="course-player__content-item released content-item__progress--active _content-item_nffvg8" data-ember-action="" data-ember-action-784="784">
                                                                    <a href="<?= '/' . $url . '/' . $lang['download_link'] ?>" id="ember789" class="course-player__content-item__link _content-item__link_nffvg8 <?= $id == $lang['download_link'] ? 'active' : '' ?> ember-view">
                                                                        <div class="brand-color__text _content-item__progress_nffvg8">
                                                                            <i aria-hidden="true" class="content-item__progress-icon content-item__progress-icon--circle--active course-player__content-item__progress-icon _content-item__progress-icon_nffvg8"></i>
                                                                        </div>

                                                                        <div class="content-item__title _content-item__title_nffvg8">
                                                                            <?= $lang['downloads'] ?>
                                                                        </div>
                                                                    </a>
                                                                </li>
                                                            <?php endif; ?>
                                                        <?php else : ?>
                                                            <?php for ($i = 0; $i < count($lesson->lessons->name); $i++) : ?>
                                                                <?php if ($i == 0 && $j == 1 && $course->fileDownloadLink != '') : ?>
                                                                    <li data-qa="content-item" class="course-player__content-item released content-item__progress--active _content-item_nffvg8" data-ember-action="" data-ember-action-784="784">
                                                                        <a href="<?= '/' . $url . '/' . $lang['download_link'] ?>" id="ember789" class="course-player__content-item__link _content-item__link_nffvg8 <?= $id == $lang['download_link'] ? 'active' : '' ?> ember-view">
                                                                            <div class="brand-color__text _content-item__progress_nffvg8">
                                                                                <i aria-hidden="true" class="content-item__progress-icon content-item__progress-icon--circle--active course-player__content-item__progress-icon _content-item__progress-icon_nffvg8"></i>
                                                                            </div>

                                                                            <div class="content-item__title _content-item__title_nffvg8">
                                                                                <?= $lang['downloads'] ?>
                                                                            </div>
                                                                        </a>
                                                                    </li>
                                                                <?php endif; ?>

                                                                <li data-qa="content-item" class="course-player__content-item released content-item__progress--complete _content-item_nffvg8">
                                                                    <a href="<?= '/' . $url . '/' . $key . '/' . ($i + 1) ?>" id="ember815" class="course-player__content-item__link _content-item__link_nffvg8 ember-view <?= $i == $lessonID && $key == $id ? 'active' : '' ?>">
                                                                        <?php if (in_array($i, $completedCourses[$key])) : ?>
                                                                            <div class="brand-color__text _content-item__progress_nffvg8">
                                                                                <i role="img" class="toga-icon toga-icon-checkmark course-player__content-item__progress-icon _content-item__progress-icon_nffvg8"></i>
                                                                            </div>
                                                                        <?php else : ?>
                                                                            <div class="brand-color__text _content-item__progress_nffvg8 not-completed-lesson">
                                                                                <i aria-hidden="true" class="content-item__progress-icon content-item__progress-icon--circle--active course-player__content-item__progress-icon _content-item__progress-icon_nffvg8"></i>
                                                                            </div>
                                                                        <?php endif; ?>

                                                                        <div class="content-item__title _content-item__title_nffvg8">
                                                                            <?= ($i + 1) . '. ' . $lesson->lessons->name[$i] ?>
                                                                        </div>
                                                                    </a>
                                                                </li>
                                                            <?php endfor; ?>
                                                        <?php endif; ?>
                                                    </ul>
                                                </div>
                                            </div>
                                            <?php $j++; ?>
                                        <?php endforeach; ?>
                                    </div>
                                </div>
                            </nav>

                            <main id="main-content" tabindex="-1" class="course-player__lesson _course-player__lesson_n1vbpj">
                                <section class="surface__container _surface__container_1yatsw _surface--content_1yatsw">
                                    <div class="_content-surface_n1vbpj">
                                        <div class="course-player__content-header _content-header__container_h7ytgy">
                                            <div class="_content-header__title-container_h7ytgy">
                                                <h3 class="course-player__content-header__title _content-header__title_h7ytgy">
                                                    <?php if ($id == '' || $id == $lang['download_link']) : ?>
                                                        <?= $lang['exercise_files'] ?>
                                                    <?php else : ?>
                                                        <?= $selectedLessonName ?>
                                                    <?php endif; ?>
                                                </h3>
                                            </div>
                                        </div>

                                        <div class="content-modal-wrapper _content-modal-wrapper_n1vbpj">
                                            <div class="content-modal _content-modal_n1vbpj">
                                                <section id="content-inner" class="course-player__content-inner _content-inner_n1vbpj">
                                                    <?php if (($id == '' || $id == $lang['download_link']) && $course->fileDownloadLink != '') : ?>
                                                        <div class="course-player__download _download__container_1gafvp">
                                                            <div id="ember1090" class="ember-view">

                                                            </div>

                                                            <div class="course-player__download__description">
                                                                <div id="ember1095" class="ember-view">
                                                                    <div class="custom-theme">
                                                                        <div class="fr-view">
                                                                            <div class="fr-view">
                                                                                <p><?= $lang['download_txt'] ?></p>
                                                                            </div>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </div>

                                                            <div class="_download__files_1gafvp">
                                                                <?php for ($i = 0; $i < count($files->name); $i++) : ?>
                                                                    <div class="ember-view">
                                                                        <ul class="course-player__download-files__list _download-files_1j5gba">
                                                                            <li class="course-player__download-files__list-item _download-files__item_1j5gba">
                                                                                <div class="course-player__download-files__details _download-files__details_1j5gba">
                                                                                    <span class="course-player__download-files__label _download-files__label_1j5gba">
                                                                                        <?= $files->name[$i] ?>
                                                                                    </span>
                                                                                </div>

                                                                                <div class="course-player__download-files__menu _download-files__menu-container_1j5gba">
                                                                                    <a href="<?= $files->link[$i] ?>" target="_blank" class=" _button--default_142a8m _button--link_142a8m">
                                                                                        <div class="_content__wrapper_142a8m">
                                                                                            <div class="_content__container_142a8m">
                                                                                                <span>
                                                                                                    <?= $lang['download'] ?>
                                                                                                    <span class="sr-only">Opens in a new window</span>
                                                                                                </span>
                                                                                            </div>
                                                                                        </div>
                                                                                    </a>
                                                                                </div>
                                                                            </li>
                                                                        </ul>
                                                                    </div>
                                                                <?php endfor; ?>
                                                            </div>
                                                        </div>
                                                    <?php else : ?>
                                                        <?php if ($freeLesson || $user->id > 0) : ?>
                                                            <input type="hidden" id="videoID" value="<?= substr(strrchr(rtrim($selectedLessonYt, '/'), '/'), 1) ?>">
                                                            <div id="video" class="_videoproxy__iframe_3iu414"></div>
                                                        <?php else : ?>
                                                            <form action="/beiratkozas/login.php" method="post" id="login-form-div">
                                                                <div id="form-login-username" class="form-group">
                                                                    <input id="modlgn-username" type="text" name="username" class="form-control" tabindex="0" size="18" placeholder="<?= $lang['username'] ?>" required>
                                                                </div>

                                                                <div id="form-login-password" class="form-group">
                                                                    <div class="controls">
                                                                        <input id="modlgn-passwd" type="password" name="password" class="form-control" tabindex="0" size="18" placeholder="<?= $lang['password'] ?>" required>
                                                                    </div>
                                                                </div>

                                                                <div id="form-login-submit" class="form-group">
                                                                    <button type="submit" tabindex="0" name="Submit" class="btn btn-primary"><?= $lang['signIn'] ?></button>
                                                                    <a class="btn btn-success" href="/fiok-letrehozasa/" target="_blank"><?= $lang['createAccount'] ?> <span class="icon-arrow-right"></span></a>
                                                                </div>

                                                                <ul class="form-links">
                                                                    <li>
                                                                        <a href="<?= $lang['usernameLink'] ?>" target="_blank">
                                                                            <?= $lang['forgotUsername'] ?>
                                                                        </a>
                                                                    </li>

                                                                    <li>
                                                                        <a href="<?= $lang['passwordLink'] ?>" target="_blank">
                                                                            <?= $lang['forgotPassword'] ?>
                                                                        </a>
                                                                    </li>
                                                                </ul>

                                                                <input type="hidden" name="url" value="<?= $_SERVER['REQUEST_URI'] ?>">
                                                                <input type="hidden" name="option" value="com_users">
                                                                <input type="hidden" name="task" value="user.login">
                                                                <input type="hidden" name="return" value="aHR0cHM6Ly93d3cuYXJjaGxpbmUuaHUvYmVpcmF0a296YXMvdGFuZm9seWFtb2svYWxhcGZvayVDMyVCQS10YW5mb2x5YW0tMjAyMi9sZXRvbHRlc2Vr">
                                                                <input type="hidden" name="df7241a4fa1b3a72bef63402f1446320" value="1">
                                                            </form>
                                                        <?php endif; ?>
                                                    <?php endif; ?>
                                                </section>

                                                <footer id="course-player-footer" data-navigation="content" class="course-player__content-navigation _content-navigation_apmbd3 _no-audio_apmbd3">
                                                    <?php if ($id == '' || $id == $lang['download_link']) : ?>
                                                        <a href="<?= '/' . $url . '/' . $nextCourse . '/' . $nextLesson ?>" class="brand-color__background brand-color__dynamic-text _button--default--small_142a8m _button--icon-right--small_142a8m link-button">
                                                            <div class="_content__wrapper_142a8m">
                                                                <div class="_content__container_142a8m">
                                                                    <span>
                                                                        <?= $lang['complete_continue'] ?>
                                                                    </span>
                                                                    <i aria-hidden="true" class="toga-icon toga-icon-arrow-right"></i>
                                                                </div>
                                                            </div>
                                                        </a>
                                                    <?php else : ?>
                                                        <form id="process-form" action="/beiratkozas/process.php" method="post">
                                                            <input type="hidden" name="url" value="<?= $url ?>">
                                                            <input type="hidden" name="course" value="<?= $id ?>">
                                                            <input type="hidden" name="lesson" value="<?= $lessonID ?>">

                                                            <button class="brand-color__background brand-color__dynamic-text _button--default--small_142a8m _button--icon-right--small_142a8m">
                                                                <div class="_content__wrapper_142a8m">
                                                                    <div class="_content__container_142a8m">
                                                                        <span>
                                                                            <?= $lang['complete_continue'] ?>
                                                                        </span>
                                                                        <i aria-hidden="true" class="toga-icon toga-icon-arrow-right"></i>
                                                                    </div>
                                                                </div>
                                                            </button>
                                                        </form>
                                                    <?php endif; ?>
                                                </footer>
                                            </div>
                                        </div>
                                    </div>
                                </section>
                            </main>

                            <aside class="course-player__right-drawer _right-drawer_n1vbpj">
                                <div class="course-player__course-discussions _course-discussions_n1vbpj">

                                </div>
                            </aside>
                        </div>
                    </div>

                    <div id="ember463" class="ember-notify-cn ember-notify-default ember-view">

                    </div>
                </div>
            </div>
        </div>
        <div id="push"></div>
    </div>

    <!-- The Modal -->
    <div id="myModal" class="modal">
        <div class="modal-content">
            <div class="modal-header">
                <span class="close">&times;</span>
                <h2>ARCHLINE.XP SOFTWARE LICENSE AGREEMENT</h2>
            </div>
            <div class="modal-body">
                <p><?= $introText ?></p>
            </div>
        </div>
    </div>

    <!-- Sign In Modal -->
    <?php if ($user->id <= 0) : ?>
        <div id="signInModal" class="modal">
            <div class="modal-content signin-container">
                <div class="modal-header">
                    <span class="signInClose">&times;</span>
                    <h2><?= $lang['signIn'] ?></h2>
                </div>
                <div class="modal-body-signIn">
                    <form action="/beiratkozas/login.php" method="post" id="login-form">
                        <div id="form-login-username" class="form-group">
                            <input id="modlgn-username" type="text" name="username" class="form-control" tabindex="0" size="18" placeholder="<?= $lang['username'] ?>" required>
                        </div>

                        <div id="form-login-password" class="form-group">
                            <div class="controls">
                                <input id="modlgn-passwd" type="password" name="password" class="form-control" tabindex="0" size="18" placeholder="<?= $lang['password'] ?>" required>
                            </div>
                        </div>

                        <div id="form-login-submit" class="form-group">
                            <button type="submit" tabindex="0" name="Submit" class="btn btn-primary"><?= $lang['signIn'] ?></button>
                            <a class="btn btn-success" href="/fiok-letrehozasa/" target="_blank"><?= $lang['createAccount'] ?> <span class="icon-arrow-right"></span></a>
                        </div>

                        <ul class="form-links">
                            <li>
                                <a href="<?= $lang['usernameLink'] ?>" target="_blank">
                                    <?= $lang['forgotUsername'] ?>
                                </a>
                            </li>

                            <li>
                                <a href="<?= $lang['passwordLink'] ?>" target="_blank">
                                    <?= $lang['forgotPassword'] ?>
                                </a>
                            </li>
                        </ul>

                        <input type="hidden" name="url" value="<?= $_SERVER['REQUEST_URI'] ?>">
                        <input type="hidden" name="option" value="com_users">
                        <input type="hidden" name="task" value="user.login">
                        <input type="hidden" name="return" value="aHR0cHM6Ly93d3cuYXJjaGxpbmUuaHUvYmVpcmF0a296YXMvdGFuZm9seWFtb2svYWxhcGZvayVDMyVCQS10YW5mb2x5YW0tMjAyMi9sZXRvbHRlc2Vr">
                        <input type="hidden" name="df7241a4fa1b3a72bef63402f1446320" value="1">
                    </form>
                </div>
            </div>
        </div>
    <?php endif; ?>

    <script>
        const progress_bars = document.querySelectorAll('.progress');
        var player;

        var modal = document.getElementById("myModal");

        var btn = document.getElementById("myBtn");

        var span = document.getElementsByClassName("close")[0];

        if (btn) {
            btn.onclick = function() {
                modal.style.display = "block";
            }
        }

        if (span) {
            span.onclick = function() {
                modal.style.display = "none";
            }
        }

        var signInModal = document.getElementById("signInModal");
        var signInBtn = document.getElementById("signInModalLink");
        var signInSpan = document.getElementsByClassName("signInClose")[0];

        if (signInBtn) {
            signInBtn.onclick = function() {
                signInModal.style.display = "block";
            }
        }

        if (signInSpan) {
            signInSpan.onclick = function() {
                signInModal.style.display = "none";
            }
        }

        window.onclick = function(event) {
            if (event.target == modal) {
                modal.style.display = "none";
            }
        }

        function onYouTubePlayerAPIReady() {
            player = new YT.Player('video', {
                height: '721',
                videoId: jQuery('#videoID').val(),
                playerVars: {
                    autoplay: 1,
                    controls: 1,
                    showinfo: 1,
                    autohide: 1,
                    modestbranding: 1,
                    origin: 'https://www.archline.hu'
                },
                events: {
                    'onReady': onPlayerReady,
                    'onStateChange': onPlayerStateChange
                }
            });
        }

        function onPlayerReady(event) {
            event.target.playVideo();
        }

        function onPlayerStateChange(event) {
            if (event.data === 0)
                jQuery('form#process-form').submit();
        }

        progress_bars.forEach(bar => {
            setTimeout(() => {
                const {
                    size
                } = bar.dataset;
                bar.style.width = `${size}%`
            }, 1000);
        });

        jQuery(document).ready(function() {
            jQuery('#download_link').html(jQuery('.phocadownloadfile32').html());

            jQuery('#enableMenu').click(function() {
                jQuery('._course-player__content_n1vbpj').toggleClass('left-drawer--open');
                jQuery('.course-player__top-bar').toggleClass('left-drawer--open');
            });

            jQuery('.accordion').click(function() {
                let dataId = jQuery(this).attr('data-id');

                jQuery('#icon-' + dataId).toggleClass('toga-icon-caret-stroke-up');
                jQuery('#icon-' + dataId).toggleClass('toga-icon-caret-stroke-down');
                jQuery('#ui-id-' + dataId).slideToggle();
            });

            jQuery('#elfogad').click(function() {
                jQuery('#enabled').toggleClass('phocadownloadfile32');
            });
        });
    </script>
</body>

</html>