GET['type']; // get media-type $real_path = MEDIA_STORAGE_ROOT . $file_path; // construct real path if (!file_exists($real_path)) { Render::view('error/404'); } else { Render::file($real_path, $media_type); } } } /** get_file_attributes * * returns attributes of a file * (medias are proxied for speed optimization) * * @param $path (string) : file path * @return $file attributes --or-- false */ private static function get_file_attributes($path) { $medias = Cache_service::files_attributes(); foreach($medias as $key => $medi) { if ($medi['path'] == $path) { return $medi; } } return false; } /** COURSES * ------------------------------------------------------------------------- */ public static function course($id) { $cache = Cache_service::courses_struct(); $tree = $cache['tree']; $breadcrumbs = $cache['breadcrumbs']; $lessons = Course_model::lessons_of_course(intval($id)); $id = intval($id); // print_r($breadcrumbs); die(); // find parent_ids of current category (to open the menu tree) $course_path = []; foreach($breadcrumbs[$id]['parents'] as $key => $parent) { $course_path[] = intval($parent['id']); } $course_path[] = intval($id); Render::view('templates/course', [ 'id' => $id, 'title' => $breadcrumbs[ $id ]['rec']['label'], 'categories' => $tree, 'breadcrumbs' => $breadcrumbs, 'lessons' => $lessons, 'course_path' => $course_path ]); } /** LESSONS * ------------------------------------------------------------------------ */ }