getRepository('ChamiloCourseBundle:CDocument'); // This page can only be shown from inside a learning path if (!$id && !$lpId) { api_not_allowed(true); } /** @var CDocument $document */ $document = $documentRepo->findOneBy(['cId' => $courseId, 'iid' => $id]); if (empty($document)) { // Try with normal id /** @var CDocument $document */ $document = $documentRepo->findOneBy(['cId' => $courseId, 'id' => $id]); if (empty($document)) { Display::return_message(get_lang('FileNotFound'), 'error'); exit; } } $documentPathInfo = pathinfo($document->getPath()); $coursePath = api_get_path(SYS_COURSE_PATH).$courseInfo['directory']; $documentPath = '/document'.$document->getPath(); $documentText = file_get_contents($coursePath.$documentPath); $documentText = api_remove_tags_with_space($documentText); $wordsInfo = preg_split('/ |\n/', $documentText, -1, PREG_SPLIT_OFFSET_CAPTURE); $words = []; foreach ($wordsInfo as $wordInfo) { $words[$wordInfo[1]] = nl2br($wordInfo[0]); } $htmlHeadXtra[] = ''; $htmlHeadXtra[] = api_get_js('readout_text/js/start.js'); $htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_JS_PATH).'readout_text/css/start.css'); $template = new Template(strip_tags($document->getTitle())); $template->display_blank_template();