관리-도구
편집 파일: manage_courses.php
<?php global $mysqli; if( isset( $_GET['cfcourse_id'] ) && !empty($_GET['cfcourse_id']) && $_GET['cfcourse_id'] != 0 ) { if( is_numeric( $_GET['cfcourse_id'] ) ) { $course_id = $_GET['cfcourse_id']; } $course_id = $mysqli->real_escape_string( $course_id ); $section = $this->load("section"); $quiz = $this->load("quiz"); $assign = $this->load("assignment"); $content = $this->load("lecture"); $s_data = $section->getSectionData( $course_id ); $s_count = $section->getSectionCount( $course_id ); $course_d = $section->getCourseDetails( $course_id ); $install_url=get_option('install_url'); if( empty( $course_d ) ) { header("Location:".$install_url."/index.php?page=cfcourse_all_course"); } $show_url=$install_url."/index.php?page=cfcourse_preview&id=".$course_id."&admin=is_admin"; ?> <div class="cf-course-manage w-100"> <nav class="navbar w-100 cf-course-navbar-custom align-self-sm-center d-flex justify-content-lg-between justify-content-center navbar-expand-lg " id="cf-course-navbar-custom" > <a class="navbar-brand ms-sm-5 text-white" href="javascript:void(0)"> <span class="font-weight-bold d-inline"><?= t('Course Name'); ?>: </span> <?= ucfirst($course_d['title']); ?> </a> <div class="collapse me-lg-5 align-self-sm-center d-flex justify-content-center justify-content-lg-end navbar-collapse" id="navbarNavDropdown"> <ul class="navbar-nav me-lg-5 "> <li class="nav-item order-1 order-lg-0 me-lg-4 my-2 my-lg-0"> <button class="btn border btn-sm btn-success" data-cid="<?=$course_id;?>" id="cfcourse-save-all"><?= t('Save changes'); ?></button> </li> <li class="nav-item order-0 order-lg-1 dropdown my-2 my-lg-0 "> <a class="nav-link p-0 py-1 px-2 border rounded btn-sm dropdown-toggle" href="#" id="navbarDropdownMenuLink" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> <?= t('More'); ?> </a> <div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink"> <a class="dropdown-item" href="<?=$install_url; ?>/index.php?page=cfcourse_popup_course&cfcourse_id=<?=$course_id ?>"> <i class="fas fa-pencil-alt" ></i> <?= t('Edit Course'); ?></a> <a class="dropdown-item" target="_blank" href="<?=$show_url; ?>" ><i class="fas fa-eye" ></i> <?= t('Preview'); ?></a> </div> </li> </ul> </div> </nav> </div> <input type="hidden" id="cfcourse-ajax" value="<?php echo get_option('install_url')."/index.php?page=ajax"; ?>" /> <input type="hidden" value="1" id="cfcourse_course_id"> <div class="container-fluid bg-white" id="cf-course-manage"> <?php if( count( $s_data ) > 0 ) { $getLastId = array_reverse($s_data); $sectionlast_id = $getLastId[0]['section_position_id']; echo ' <div class="cfcourse-add-section-c add-section-top text-center d-none mt-4" data-c-id="'.$course_id.'" style="display:block !important"> <div class="cfcourse-a-s-c cfcourse-o-a-s p-1" > <button class="btn btn-primary cfcourse-o-a-s" title="'.t('Add Section').'">+</button> </div> </div> <div class="cfcourse-f-c cfcourse-section-sortable" id="cfcourse-f-c">'; foreach( $s_data as $s_d ) { $s_title = htmlspecialchars( stripslashes( $s_d['title'] ) ); $s_id = $s_d['id']; $title_len = strlen( $s_title ); ?> <div class="cfcourse-s-c cfcourse-s-c-short ui-state-default" > <input type="hidden" class="cfcourse-section-position" name=position[section][] value="<?=$s_id; ?>" /> <div class="cfcourse-s p-1 px-sm-2 py-2" id="cfcourse-s-<?=$s_id; ?>" data-sid="<?=$s_id; ?>"> <div class="cfcource-section " tabindex="-1" > <div class="cfcourse-section-c cf--c--srtab"> <div class="d-flex cf--c--srtab justify-content-between justify-content-md-between align-items-center my-1 my-sm-0 flex-column flex-sm-row"> <div class="cf--course-stitle"> <span style="font-weight:bold" ><?= t('Section'); ?>. <span class="cfcourse-s-count"></span>: </span> <span class="cfcourse-s-t-t " > <?php echo ( ( strlen( $s_title ) > 120) ? substr( $s_title, 0 , 120 ).'...' : $s_title ); ?> <span> </div> <div style="cursor: initial;" class="cfcourse-s-action cfcourse-s-action pt-2 pt-sm-0 p-sm-0 "> <div class="d-flex"> <div class="p-1 cfcourse-open-s-btn" data-bs-toggle="collapse" data-bs-target="#cf-course-secop-<?=$s_id; ?>"><button class="cfcourse-open-s-btn btn btn-primary d-inline-block" id="" title="<?= t('Open Section'); ?>"> <i class="fas fa-angle-down cfcourse-s-d-arr d-inline-block cfcourse-open-s-btn" ></i></button></div> <div class="p-1 cfcourse-edit-s-btn"> <button class=" cfcourse-edit-s-btn btn btn-success d-inline-block" title="<?= t('Edit Section'); ?>"> <i class="fas fa-edit d-inline-block cfcourse-edit-s-btn"></i> </button></div> <div class="p-1 cfcourse-del-s-btn cfcourse-del-s" data-s-id="<?= $s_id; ?>"><button class=" cfcourse-del-s-btn btn btn-danger" title="<?= t('Delete Section'); ?>"> <i class="fas fa-trash cfcourse-del-s-btn"></i> </button></div> </div> </div> </div> </div> <div class="cfcourse-update-s-d"> <div class="cfcourse-s-d "> <form action="" class="cfcourse-add-section" method="" autocomplete="off"> <input type="hidden" name="cfcourse_section_action" value="update_section" /> <input type="hidden" name="cfcourse_section_id" value="<?= $s_id; ?>" /> <input type="hidden" name="cfcourse_course_id" value="<?= $course_id; ?>" /> <p class="p-1 text-primary text-center font-weight-bold"><?= t('Update Section'); ?> </p> <div class="mb-3 mb-1 "> <label class="text-primary font-weight-bold" ><?= t('Title'); ?>*</label> <div class="cfcourse-a-s-i justify-content-center flex-sm-row flex-column d-flex"> <input type="text" placeholder="<?= t('Title'); ?>" value="<?= $s_title; ?>" name="cfcourse_seciton" class="flex-2 form-control cf-course-sec-edit cfcourse_a_t_i" /> </div> </div> <div class="cfcourse-title-e"> </div> <div class="text-center mt-3 d-flex justify-content-center"> <div class="mx-1"> <button type="button" class="btn btn-danger cfcourse-cancel-s-btn"><?= t('Cancel'); ?> </button> </div> <div class="mx-1"> <button type="submit" class="btn btn-primary"><?= t('Save Changes'); ?></button> </div> </div> </form> </div> </div> </div> <div class="cfcourse-options-f-c collapse" id="cf-course-secop-<?=$s_id; ?>"> <div class="cfcourse-o-a-o cfcourse-a-a-t text-center mt-4" data-c-id="<?= $course_id; ?>" data-s-id="<?= $s_id; ?>"> <div class="cfcourse-a-o-c cfcourse-a-o" > <div class="cfcourse-a-o" title="<?= t('Add Content'); ?>"><button class="btn btn-primary cfcourse-a-o cfcourse-a-o-btn"><span class="cfcourse-a-o cfcourse-a-o-text">+</span></button></div> </div> </div> <div class="cfcourse-options-c pt-1 pt-sm-3 cfcourse-options-sortable px-1 px-sm-5"> <?php $c_data = $content->getContentData( $course_id, $s_id ); if( count( $c_data ) > 0 ) { foreach( $c_data as $c_d ) { $type = $c_d['option_type']; if( $type == "lecture" ) { echo '<div class="ui-state-default cfcourse-options-i-c" tabindex="-1">'; echo $content->getLectureHtml( $c_d, 1 ); echo '</div>'; }else if( $type == "quiz" ){ echo '<div class="ui-state-default cfcourse-options-i-c" tabindex="-1" >'; echo $quiz->getQuizHtml( $c_d , 1); echo '</div>'; }else if( $type == "assign" ) { echo '<div class="ui-state-default cfcourse-options-i-c" tabindex="-1">'; echo $assign->getAssignHtml( $c_d ,1); echo '</div>'; } else if( $type == "test" ) { echo '<div class="ui-state-default cfcourse-options-i-c" tabindex="-1">'; echo $assign->getAssignHtml( $c_d ,1); echo '</div>'; } } } ?> </div> </div> </div> <div class="cfcourse-add-section-c add-section-bottom text-center mt-1" data-c-id="<?= $course_id; ?>" > <div class="cfcourse-a-s-c p-1 cfcourse-o-a-s add-section-bottom"> <button class="btn btn-primary cfcourse-o-a-s" title="<?= t('Add Section'); ?>">+</button> </div> </div> </div> <?php } echo '</div>'; if( $s_count > 5) { echo '<hr> <div class="w-100 my-5 text-center"> <button type="button" class="btn btn-outline-success" data-sid="'.$sectionlast_id.'" data-cid="'.$course_id.'" id="cfcourse-section-add-more">'.t('Load More').'</button> </div>'; } }else{ ?> <div class="row" id="cf-course-no-section-av"> <div class="col-sm-12"> <h1 class="text-center pt-5" style="opacity:0.5;"><?= t('No Sections Available, Please Create Section'); ?></h1> </div> </div> <div class="cfcourse-add-section-c add-section-top text-center d-none mt-4" data-c-id="<?= $course_id; ?>" title="<?= t('Add Section'); ?>" style="display:block !important"> <div class="cfcourse-a-s-c cfcourse-o-a-s p-1" title="Add Section" > <button class="btn btn-primary cfcourse-o-a-s p-2 "><?= t('Create Section'); ?></button> </div> </div> <div class="cfcourse-f-c cfcourse-section-sortable" id="cfcourse-f-c"></div> <?php } ?> </div> <!-- Modal --> <!-- The cf_course_drip_model --> <div id="mycf_course_drip_model" class="cf_course_drip_model" style="border-radius:5px"> <!-- cf_course_drip_model content --> <div class="cf_course_drip_model-content"> <div class="alert alert-danger"> <span class="cf-course-close-drip cf-course-close-drip-btn">×</span> <h2><?= t('Information'); ?></h2> </div> <div class="cf_course_drip_model-body"> </div> <div class="modal-footer"> <button type="button" class="btn btn-primary cf-course-close-drip-btn "><?= t('Close'); ?></button> </div> </div> </div> <div id="cf-course-snackbar-admin-top"> <div class="alert alert-success alert-dismissible "> <a href="#" class="close" data-bs-dismiss="alert" aria-label="close">×</a> <i class="fas fa-check-circle"></i> <span id="cf-course-snackbar-admin-text"><?= t('Saved'); ?></span> </div> </div> <!--Model end --> <!-- The cf_course_drip_model --> <div id="mycf_course_drip_delete_assign" class="cf_course_drip_model" style="border-radius:5px"> <!-- cf_course_drip_model content --> <div class="cf_course_model_w_anim"> <div class="alert alert-info pb-1 mb-0 "> <span class="cf-course-close-drip cf-course-close-drip-btn">×</span> <h5 id="cf-course-delete-he "><?= t('Please Confirm'); ?></h5> </div> <div class="cf_course_drip_model-body py-3 cf_course_drip_model-del-body"> <?= t('Do you really want to delete this section'); ?>? </div> <input type="hidden" id="cf-course-delete-section" value=""> <input type="hidden" id="cf-course-delete-content" value=""> <div class="modal-footer"> <button type="button" class="btn btn-primary btn-sm cf-course-close-drip-btn"><?= t('Cancel'); ?></button> <button type="button" class="btn btn-danger btn-sm cf-course-remove-section" ><?= t('Delete'); ?></button> <button type="button" class="btn btn-danger btn-sm cf-course-remove-content" ><?= t('Delete'); ?></button> <button type="button" class="btn btn-danger btn-sm cf-course-remove-resource" ><?= t('Delete'); ?></button> </div> </div> </div> <!--Model end --> <div id="cf-course-snackbar-admin"><?= t('Course Deleted'); ?>.</div> <?php }else{ $cfcourse_install_url = get_option("install_url"); $no_permission = $cfcourse_install_url."/index.php?page=cfcourse_all_course"; header( "Location:".$no_permission."" ); } ?> <script> $(function(){ cfCourseTinyEditorAssignment('.cfcourse_s_t_i_des',200); let cfType = $("#cf_option_type").val(); if( cfType == "cfcourselat" ) { cfCourseTinyMinimize('.cfcourselat',200); $(".cfcourse-l-art").show(); } // this function preview of youtube video $(".cfcourse_l_you_id").on("focusout",function(eve){ let srcValue = $(this).val(); $(".cfcourse-l-youpr").attr("src","https://www.youtube.com/embed/"+srcValue.trim() ); }); // this function preview of vimeo video $(".cfcourse_l_vm_id").on("focusout",function(eve){ let srcValue = $(this).val(); $(".cfcourse-l-vimpr").attr("src","https://player.vimeo.com/video/"+srcValue.trim() ); }); // this function preview of video $("#cfcourse-l-vurl").on("change",function(eve){ let srcValue = $(this).val(); var pos = srcValue.lastIndexOf("."); var strlen = content.length; if ( pos != -1 && strlen != pos + 1 ) { var ext = content.split("."); var len = ext.length; var extension = ext[len - 1].toLowerCase(); } else { extension = "No extension found"; } if(extension=="mp4") { $("#cfcourse-l-video").attr({src: srcValue.trim(),"type":"video/mp4" }); } else if(extension=="ogg") { $("#cfcourse-l-video").attr({src: srcValue.trim(),"type":"video/ogg" }); } else if(extension=="webm") { $("#cfcourse-l-video").attr({src: srcValue.trim(),"type":"video/webm" }); }else{ } $("#cfcourse-l-video").attr("src",srcValue.trim() ); }); $(document).on("click", function(eve){ let targetEl = eve.target; if( $( targetEl ).hasClass("cfcourse-open-doc") ) { let pElem = $(targetEl).parents(".cfcourse-l-doc"); let elem = $(pElem).find(".cfcourse-l-doc-i"); let eleImg = $(pElem).find(".cfcourse-l-docpr"); let error = $("#cfcourse-doc-err"); $(error).html(""); cfCourseOpenMedia( $(elem), $(eleImg),'doc', false,$(error) ); }else if( $( targetEl ).hasClass("cfcourse-open-thumbnail") ) { let pElem = $(targetEl).parents(".cfcourse-l-thumbnail"); let elem = $(pElem).find(".cfcourse-l-v-thmb"); let eleVid = $("#cfcourse-l-video"); let error = $("#cfcourse-vid-err"); $(error).html(""); cfCourseOpenMedia( $(elem), $(eleVid),'vid', false,$(error) ); } else if( $( targetEl ).hasClass("cfcourse-open-video") ) { let pElem = $(targetEl).parents(".cfcourse-l-v "); let elem = $(pElem).find(".cfcourse-l-v-i"); let eleVid = $("#cfcourse-a-video"); let error = $("#cfcourse-vid-err"); $(error).html(""); cfCourseOpenMedia( $(elem), $(eleVid),'vid', false,$(error) ); } else if( $( targetEl ).hasClass("cfcourse-open-audio") ) { let pElem = $(targetEl).parents(".cfcourse-l-a"); let elem = $(pElem).find(".cfcourse-l-a-i"); let eleVid = $("#cfcourse-a-video"); let error = $("#cfcourse-vid-err"); $(error).html(""); cfCourseOpenMedia( $(elem), $(eleVid),'aid', false,$(error) ); } else if( $( targetEl ).hasClass("cfcourse-l-o-img") ) { let pElem = $(targetEl).parents(".cfcourse-l-img"); let elem = $(pElem).find(".cfcourse-l-img-i"); let eleImg = $(pElem).find(".cfcourse-l-imgpr"); let error = $("#cfcourse-img-err"); $(error).html(""); cfCourseOpenMedia( $(elem), $(eleImg),'img', false, $(error) ); } else if( $( targetEl ).hasClass("cfcourse-l-v-help") ) { let pElem = $(targetEl).parents(".cf-course-upload-h-v"); let elem = $(pElem).find(".cfcourse-lo-he-v"); cfCourseOpenMedia( $(elem), '','v_url', false ); } else if( $( targetEl ).hasClass("cfcourse-l-d-help") ) { let pElem = $(targetEl).parents(".cf-course-upload-h-d"); let elem = $(pElem).find(".cfcourse-lo-he-d"); cfCourseOpenMedia( $(elem), '','d_url', false ); } }); }); function cfCourseOpenMedia( selector=null, cont=null, type=null, html,error=null ) { try { //here calling open media openMedia( function( content ){ try { selector[0].value = content; }catch(err){console.log(err);} }, html); }catch(err){console.log(err)} } window.onscroll = function() { cfCourseStickyNavbar()}; function cfCourseStickyNavbar() { var navbar = document.getElementById("cf-course-navbar-custom"); var sticky = navbar.offsetTop+10; if (window.pageYOffset >= sticky) { navbar.classList.add("cf-course-sticky-navbar") } else { navbar.classList.remove("cf-course-sticky-navbar"); } } </script> <?php //here we are imporing cf_media cf_media(); ?>