<?php
/**
 * 视频编辑
 * $Id: media_upload.php,v 1.1 2020/01/03 11:18:46  Exp $
 * @author lixq
 * @package manager.public_html
 */
// 底层包含
require_once("manager_include.inc");

// 登录检查
require_once("check_login.inc");

// 权限检查
if (!checkAuthority("11")) {
	// エラー表示
	$layout_pages = array();
	$layout_pages["left"] = "menu.inc";
	$layout_pages["right"] = "error.inc";
	$message = "权限不足，请联系系统管理员。";
	require_once(MANAGER_TEMPLATE_DIR_PATH . "/layout/leftmenu_layout.inc");
	exit;
}

$id = ParamUtil::getRequestString("id");
$course_media_dat = CourseMediaDat::getById($id);
if ($course_media_dat == null) {
  // エラー表示
  $message = "对象不存在.";
  $layout_pages = array();
  $layout_pages["left"] = "menu.inc";
  $layout_pages["right"] = "error.inc";
  require_once(MANAGER_TEMPLATE_DIR_PATH . "/layout/leftmenu_layout.inc");
  exit;
}


$param = [];
$param["delete_flg"] = false;
$media_tag_list = MediaTagDat::getList($param);

$course_list = CourseMst::getList($param);

$title = $course_media_dat->title;
$tags = implode(",", explode("|", $course_media_dat->tags));
$teacher = $course_media_dat->teacher;
$media_type = $course_media_dat->course_id == 0?"0":"1";
$media_kind = $course_media_dat->is_free?"false":"true";
$price = $course_media_dat->price;
$front_image = $course_media_dat->front_image;
$course_name = '';
$course_id = $course_media_dat->course_id;
if( $course_id != 0){
  $course_name = CourseMst::getById($course_id)->title;
}

error_log("parent_category_id-->" . $course_media_dat->parent_category_id);
error_log("sub_category_id-->" . $course_media_dat->sub_category_id);

$comment = $course_media_dat->comment;
$parent_category_id = $course_media_dat->parent_category_id;
$sub_category_id = $course_media_dat->sub_category_id;
$teacher_profile = $course_media_dat->teacher_profile;

$parent_category_list = CourseParentCategory::getList();
$param["delete_flg"] = false;
$sub_category_list = CourseCategoryDat::getList($param,"id");

$new_sub_category_list = [];
foreach ($sub_category_list as $tmp){
  if($tmp->parent_id == $parent_category_id){
    array_push($new_sub_category_list, $tmp);
  }
}
// JavaScriptページ
$_SCRIPT_FILE = array("scripts/validators.js", "scripts/media_upload.js","scripts/form_checkbox_common.js","scripts/form_radio_common.js");
// ページ
$layout_pages = array();
$layout_pages["left"] = "menu.inc";
$layout_pages["right"] = "media_edit_input.inc";
$layout_pages["menu_clicked"] = "4-2";
require_once(MANAGER_TEMPLATE_DIR_PATH . "/layout/leftmenu_layout.inc");
exit;