create_document.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. use ChamiloSession as Session;
  4. /**
  5. * This file allows creating new html documents with an online WYSIWYG html editor.
  6. *
  7. * @package chamilo.document
  8. */
  9. require_once __DIR__.'/../inc/global.inc.php';
  10. $this_section = SECTION_COURSES;
  11. $groupRights = Session::read('group_member_with_upload_rights');
  12. $htmlHeadXtra[] = '
  13. <script>
  14. $(document).ready(function() {
  15. $(".scrollbar-light").scrollbar();
  16. expandColumnToogle("#hide_bar_template", {
  17. selector: "#template_col",
  18. width: 3
  19. }, {
  20. selector: "#doc_form",
  21. width: 9
  22. });
  23. CKEDITOR.on("instanceReady", function (e) {
  24. showTemplates();
  25. });
  26. });
  27. $(document).on("change", ".selectpicker", function () {
  28. var dirValue = $(this).val();
  29. $.ajax({
  30. contentType: "application/x-www-form-urlencoded",
  31. data: "dirValue="+dirValue,
  32. url: "' . api_get_path(WEB_AJAX_PATH).'document.ajax.php?a=document_destination",
  33. type: "POST",
  34. success: function(response) {
  35. $("[name=\'dirValue\']").val(response)
  36. }
  37. });
  38. });
  39. function setFocus() {
  40. $("#document_title").focus();
  41. }
  42. $(window).load(function () {
  43. setFocus();
  44. });
  45. </script>';
  46. //I'm in the certification module?
  47. $is_certificate_mode = false;
  48. if (isset($_REQUEST['certificate']) && $_REQUEST['certificate'] == 'true') {
  49. $is_certificate_mode = true;
  50. }
  51. if ($is_certificate_mode) {
  52. $nameTools = get_lang('CreateCertificate');
  53. } else {
  54. $nameTools = get_lang('CreateDocument');
  55. }
  56. /* Constants and variables */
  57. $doc_table = Database::get_course_table(TABLE_DOCUMENT);
  58. $course_id = api_get_course_int_id();
  59. $courseCode = api_get_course_id();
  60. $sessionId = api_get_session_id();
  61. $userId = api_get_user_id();
  62. $_course = api_get_course_info();
  63. $groupId = api_get_group_id();
  64. $document_data = array();
  65. if (isset($_REQUEST['id'])) {
  66. $document_data = DocumentManager::get_document_data_by_id(
  67. $_REQUEST['id'],
  68. $courseCode,
  69. true,
  70. 0
  71. );
  72. }
  73. if (!empty($sessionId) && empty($document_data)) {
  74. $document_data = DocumentManager::get_document_data_by_id(
  75. $_REQUEST['id'],
  76. $courseCode,
  77. true,
  78. $sessionId
  79. );
  80. }
  81. $groupIid = 0;
  82. $group_properties = [];
  83. if (!empty($groupId)) {
  84. $group_properties = GroupManager::get_group_properties($groupId);
  85. $groupIid = $group_properties['iid'];
  86. }
  87. if (empty($document_data)) {
  88. if (api_is_in_group()) {
  89. $document_id = DocumentManager::get_document_id($_course, $group_properties['directory']);
  90. $document_data = DocumentManager::get_document_data_by_id($document_id, api_get_course_id());
  91. $dir = $document_data['path'];
  92. $folder_id = $document_data['id'];
  93. } else {
  94. $dir = '/';
  95. $folder_id = 0;
  96. }
  97. } else {
  98. $folder_id = $document_data['id'];
  99. $dir = $document_data['path'];
  100. }
  101. /* MAIN CODE */
  102. // Please, do not modify this dirname formatting
  103. if (strstr($dir, '..')) {
  104. $dir = '/';
  105. }
  106. if ($dir[0] == '.') {
  107. $dir = substr($dir, 1);
  108. }
  109. if ($dir[0] != '/') {
  110. $dir = '/'.$dir;
  111. }
  112. if ($dir[strlen($dir) - 1] != '/') {
  113. $dir .= '/';
  114. }
  115. if ($is_certificate_mode) {
  116. $document_id = DocumentManager::get_document_id(
  117. api_get_course_info(),
  118. '/certificates'
  119. );
  120. $document_data = DocumentManager::get_document_data_by_id(
  121. $document_id,
  122. api_get_course_id(),
  123. true
  124. );
  125. $folder_id = $document_data['id'];
  126. $dir = '/certificates/';
  127. }
  128. $doc_tree = explode('/', $dir);
  129. $count_dir = count($doc_tree) - 2; // "2" because at the begin and end there are 2 "/"
  130. if (api_is_in_group()) {
  131. $group_properties = GroupManager::get_group_properties(api_get_group_id());
  132. // Level correction for group documents.
  133. if (!empty($group_properties['directory'])) {
  134. $count_dir = $count_dir > 0 ? $count_dir - 1 : 0;
  135. }
  136. }
  137. $relative_url = '';
  138. for ($i = 0; $i < ($count_dir); $i++) {
  139. $relative_url .= '../';
  140. }
  141. if ($relative_url == '') {
  142. $relative_url = '/';
  143. }
  144. $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
  145. $editorConfig = array(
  146. 'ToolbarSet' => ($is_allowed_to_edit ? 'Documents' : 'DocumentsStudent'),
  147. 'Width' => '100%',
  148. 'Height' => '400',
  149. 'cols-size' => [2, 10, 0],
  150. 'FullPage' => true,
  151. 'InDocument' => true,
  152. 'CreateDocumentDir' => $relative_url,
  153. 'CreateDocumentWebDir' => (empty($group_properties['directory']))
  154. ? api_get_path(WEB_COURSE_PATH).$_course['path'].'/document/'
  155. : api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document'.$group_properties['directory'].'/',
  156. 'BaseHref' => api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.$dir
  157. );
  158. if ($is_certificate_mode) {
  159. $editorConfig['CreateDocumentDir'] = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document/';
  160. $editorConfig['CreateDocumentWebDir'] = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document/';
  161. $editorConfig['BaseHref'] = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.$dir;
  162. }
  163. $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
  164. if (!is_dir($filepath)) {
  165. $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
  166. $dir = '/';
  167. }
  168. if (!$is_certificate_mode) {
  169. if (api_is_in_group()) {
  170. $interbreadcrumb[] = array(
  171. "url" => "../group/group_space.php?".api_get_cidreq(),
  172. "name" => get_lang('GroupSpace'),
  173. );
  174. $noPHP_SELF = true;
  175. $path = explode('/', $dir);
  176. if ('/'.$path[1] != $group_properties['directory']) {
  177. api_not_allowed(true);
  178. }
  179. }
  180. $interbreadcrumb[] = array(
  181. "url" => "./document.php?curdirpath=".urlencode($dir)."&".api_get_cidreq(),
  182. "name" => get_lang('Documents'),
  183. );
  184. } else {
  185. $interbreadcrumb[] = array(
  186. 'url' => Category::getUrl(),
  187. 'name' => get_lang('Gradebook'),
  188. );
  189. }
  190. if (!api_is_allowed_in_course()) {
  191. api_not_allowed(true);
  192. }
  193. if (!($is_allowed_to_edit ||
  194. $groupRights ||
  195. DocumentManager::is_my_shared_folder($userId, $dir, api_get_session_id()))
  196. ) {
  197. api_not_allowed(true);
  198. }
  199. /* Header */
  200. Event::event_access_tool(TOOL_DOCUMENT);
  201. $display_dir = $dir;
  202. if (isset($group_properties)) {
  203. $display_dir = explode('/', $dir);
  204. unset($display_dir[0]);
  205. unset($display_dir[1]);
  206. $display_dir = implode('/', $display_dir);
  207. }
  208. $select_cat = isset($_GET['selectcat']) ? intval($_GET['selectcat']) : null;
  209. $curDirPath = isset($_GET['curdirpath']) ? Security::remove_XSS($_GET['curdirpath']) : null;
  210. // Create a new form
  211. $form = new FormValidator(
  212. 'create_document',
  213. 'post',
  214. api_get_self().'?'.api_get_cidreq().'&dir='.Security::remove_XSS(urlencode($dir)).'&selectcat='.$select_cat,
  215. null
  216. );
  217. // form title
  218. $form->addElement('header', $nameTools);
  219. if ($is_certificate_mode) {//added condition for certicate in gradebook
  220. $form->addElement(
  221. 'hidden',
  222. 'certificate',
  223. 'true',
  224. array('id' => 'certificate')
  225. );
  226. if (isset($_GET['selectcat'])) {
  227. $form->addElement('hidden', 'selectcat', $select_cat);
  228. }
  229. }
  230. // Hidden element with current directory
  231. $form->addElement('hidden', 'id');
  232. $defaults = array();
  233. $defaults['id'] = $folder_id;
  234. // Filename
  235. $form->addElement('hidden', 'title_edited', 'false', 'id="title_edited"');
  236. /**
  237. * Check if a document width the chosen filename already exists
  238. */
  239. function document_exists($filename)
  240. {
  241. global $dir;
  242. $cleanName = api_replace_dangerous_char($filename);
  243. // No "dangerous" files
  244. $cleanName = disable_dangerous_file($cleanName);
  245. return !DocumentManager::documentExists(
  246. $dir.$cleanName.'.html',
  247. api_get_course_info(),
  248. api_get_session_id(),
  249. api_get_group_id()
  250. );
  251. }
  252. // Add group to the form
  253. if ($is_certificate_mode) {
  254. $form->addText(
  255. 'title',
  256. get_lang('CertificateName'),
  257. true,
  258. array('cols-size' => [2, 10, 0], 'autofocus')
  259. );
  260. } else {
  261. $form->addText(
  262. 'title',
  263. get_lang('Title'),
  264. true,
  265. array('cols-size' => [2, 10, 0], 'autofocus')
  266. );
  267. }
  268. // Show read-only box only in groups
  269. if (!empty($groupId)) {
  270. $group[] = $form->createElement(
  271. 'checkbox',
  272. 'readonly',
  273. '',
  274. get_lang('ReadOnly')
  275. );
  276. }
  277. $form->addRule('title', get_lang('ThisFieldIsRequired'), 'required');
  278. $form->addRule('title', get_lang('FileExists'), 'callback', 'document_exists');
  279. $current_session_id = api_get_session_id();
  280. $form->addHtmlEditor(
  281. 'content',
  282. get_lang('Content'),
  283. true,
  284. true,
  285. $editorConfig,
  286. true
  287. );
  288. // Comment-field
  289. $folders = DocumentManager::get_all_document_folders(
  290. $_course,
  291. $groupIid,
  292. $is_allowed_to_edit
  293. );
  294. // If we are not in the certificates creation, display a folder chooser for the
  295. // new document created
  296. if (!$is_certificate_mode &&
  297. !DocumentManager::is_my_shared_folder($userId, $dir, $current_session_id)
  298. ) {
  299. $folders = DocumentManager::get_all_document_folders(
  300. $_course,
  301. $groupIid,
  302. $is_allowed_to_edit
  303. );
  304. $parent_select = $form->addSelect(
  305. 'curdirpath',
  306. get_lang('DestinationDirectory'),
  307. null,
  308. array('cols-size' => [2, 10, 0])
  309. );
  310. $folder_titles = array();
  311. if (is_array($folders)) {
  312. $escaped_folders = array();
  313. foreach ($folders as $key => & $val) {
  314. // Hide some folders
  315. if ($val == '/HotPotatoes_files' || $val == '/certificates' || basename($val) == 'css') {
  316. continue;
  317. }
  318. // Admin setting for Hide/Show the folders of all users
  319. if (api_get_setting('show_users_folders') == 'false' &&
  320. (strstr($val, '/shared_folder') || strstr($val, 'shared_folder_session_'))
  321. ) {
  322. continue;
  323. }
  324. // Admin setting for Hide/Show Default folders to all users
  325. if (api_get_setting('show_default_folders') == 'false' && ($val == '/images' || $val == '/flash' || $val == '/audio' || $val == '/video' || strstr($val, '/images/gallery') || $val == '/video/flv')) {
  326. continue;
  327. }
  328. // Admin setting for Hide/Show chat history folder
  329. if (api_get_setting('show_chat_folder') == 'false' && $val == '/chat_files') {
  330. continue;
  331. }
  332. $escaped_folders[$key] = Database::escape_string($val);
  333. }
  334. $folder_sql = implode("','", $escaped_folders);
  335. $sql = "SELECT * FROM $doc_table
  336. WHERE
  337. c_id = $course_id AND
  338. filetype = 'folder' AND
  339. path IN ('".$folder_sql."')";
  340. $res = Database::query($sql);
  341. $folder_titles = array();
  342. while ($obj = Database::fetch_object($res)) {
  343. $folder_titles[$obj->path] = $obj->title;
  344. }
  345. }
  346. if (empty($group_dir)) {
  347. $parent_select -> addOption(get_lang('HomeDirectory'), '/');
  348. if (is_array($folders)) {
  349. foreach ($folders as & $folder) {
  350. //Hide some folders
  351. if ($folder == '/HotPotatoes_files' || $folder == '/certificates' || basename($folder) == 'css') {
  352. continue;
  353. }
  354. //Admin setting for Hide/Show the folders of all users
  355. if (api_get_setting('show_users_folders') == 'false' &&
  356. (strstr($folder, '/shared_folder') || strstr($folder, 'shared_folder_session_'))
  357. ) {
  358. continue;
  359. }
  360. //Admin setting for Hide/Show Default folders to all users
  361. if (api_get_setting('show_default_folders') == 'false' &&
  362. (
  363. $folder == '/images' ||
  364. $folder == '/flash' ||
  365. $folder == '/audio' ||
  366. $folder == '/video' ||
  367. strstr($folder, '/images/gallery') ||
  368. $folder == '/video/flv'
  369. )
  370. ) {
  371. continue;
  372. }
  373. //Admin setting for Hide/Show chat history folder
  374. if (api_get_setting('show_chat_folder') == 'false' &&
  375. $folder == '/chat_files'
  376. ) {
  377. continue;
  378. }
  379. $selected = (substr($dir, 0, -1) == $folder) ? ' selected="selected"' : '';
  380. $path_parts = explode('/', $folder);
  381. $folder_titles[$folder] = cut($folder_titles[$folder], 80);
  382. $space_counter = count($path_parts) - 2;
  383. if ($space_counter > 0) {
  384. $label = str_repeat('&nbsp;&nbsp;&nbsp;', $space_counter).' &mdash; '.$folder_titles[$folder];
  385. } else {
  386. $label = ' &mdash; '.$folder_titles[$folder];
  387. }
  388. $parent_select -> addOption($label, $folder);
  389. if ($selected != '') {
  390. $parent_select->setSelected($folder);
  391. }
  392. }
  393. }
  394. } else {
  395. if (is_array($folders) && !empty($folders)) {
  396. foreach ($folders as & $folder) {
  397. $selected = (substr($dir, 0, -1) == $folder) ? ' selected="selected"' : '';
  398. $label = $folder_titles[$folder];
  399. if ($folder == $group_dir) {
  400. $label = '/ ('.get_lang('HomeDirectory').')';
  401. } else {
  402. $path_parts = explode('/', str_replace($group_dir, '', $folder));
  403. $label = cut($label, 80);
  404. $label = str_repeat('&nbsp;&nbsp;&nbsp;', count($path_parts) - 2).' &mdash; '.$label;
  405. }
  406. $parent_select->addOption($label, $folder);
  407. if ($selected != '') {
  408. $parent_select->setSelected($folder);
  409. }
  410. }
  411. }
  412. }
  413. }
  414. $form->addHidden('dirValue', '');
  415. if ($is_certificate_mode) {
  416. $form->addButtonCreate(get_lang('CreateCertificate'));
  417. } else {
  418. $form->addButtonCreate(get_lang('CreateDoc'));
  419. }
  420. $form->setDefaults($defaults);
  421. // If form validates -> save the new document
  422. if ($form->validate()) {
  423. $values = $form->exportValues();
  424. $readonly = isset($values['readonly']) ? 1 : 0;
  425. $values['title'] = trim($values['title']);
  426. if (!empty($values['dirValue'])) {
  427. $dir = $values['dirValue'];
  428. }
  429. if ($dir[strlen($dir) - 1] != '/') {
  430. $dir .= '/';
  431. }
  432. $filepath = $filepath.$dir;
  433. // Setting the filename
  434. $filename = $values['title'];
  435. $filename = addslashes(trim($filename));
  436. $filename = Security::remove_XSS($filename);
  437. $filename = api_replace_dangerous_char($filename);
  438. $filename = disable_dangerous_file($filename);
  439. $filename .= DocumentManager::getDocumentSuffix(
  440. $_course,
  441. api_get_session_id(),
  442. api_get_group_id()
  443. );
  444. // Setting the title
  445. $title = $values['title'];
  446. // Setting the extension
  447. $extension = 'html';
  448. $content = Security::remove_XSS($values['content'], COURSEMANAGERLOWSECURITY);
  449. /*if (strpos($content, '/css/frames.css') == false) {
  450. $content = str_replace('</head>', '<link rel="stylesheet" href="./css/frames.css" type="text/css" /><style> body{margin:50px;}</style></head>', $content);
  451. }*/
  452. // Don't create file with the same name.
  453. if (file_exists($filepath.$filename.'.'.$extension)) {
  454. Display::addFlash(Display::return_message(get_lang('FileExists').' '.$title, 'error', false));
  455. Display:: display_header($nameTools, 'Doc');
  456. Display:: display_footer();
  457. exit;
  458. }
  459. if ($fp = @fopen($filepath.$filename.'.'.$extension, 'w')) {
  460. $content = str_replace(
  461. api_get_path(WEB_COURSE_PATH),
  462. api_get_configuration_value('url_append').api_get_path(REL_COURSE_PATH),
  463. $content
  464. );
  465. fputs($fp, $content);
  466. fclose($fp);
  467. chmod($filepath.$filename.'.'.$extension, api_get_permissions_for_new_files());
  468. $file_size = filesize($filepath.$filename.'.'.$extension);
  469. $save_file_path = $dir.$filename.'.'.$extension;
  470. $document_id = add_document(
  471. $_course,
  472. $save_file_path,
  473. 'file',
  474. $file_size,
  475. $title,
  476. null,
  477. $readonly
  478. );
  479. if ($document_id) {
  480. api_item_property_update(
  481. $_course,
  482. TOOL_DOCUMENT,
  483. $document_id,
  484. 'DocumentAdded',
  485. $userId,
  486. $group_properties,
  487. null,
  488. null,
  489. null,
  490. $current_session_id
  491. );
  492. // Update parent folders
  493. item_property_update_on_folder($_course, $dir, $userId);
  494. $new_comment = isset($_POST['comment']) ? trim($_POST['comment']) : '';
  495. $new_title = isset($_POST['title']) ? trim($_POST['title']) : '';
  496. $new_title = htmlspecialchars($new_title);
  497. if ($new_comment || $new_title) {
  498. $ct = '';
  499. $params = [];
  500. if ($new_comment) {
  501. $params['comment'] = $new_comment;
  502. }
  503. if ($new_title) {
  504. $params['title'] = $new_title;
  505. }
  506. if (!empty($params)) {
  507. Database::update(
  508. $doc_table,
  509. $params,
  510. ['c_id = ? AND id = ?' => [$course_id, $document_id]]
  511. );
  512. }
  513. }
  514. $dir = substr($dir, 0, -1);
  515. $selectcat = '';
  516. if (isset($_REQUEST['selectcat'])) {
  517. $selectcat = "&selectcat=".intval($_REQUEST['selectcat']);
  518. }
  519. $certificate_condition = '';
  520. if ($is_certificate_mode) {
  521. $df = DocumentManager::get_default_certificate_id($_course['code']);
  522. if (!isset($df)) {
  523. DocumentManager::attach_gradebook_certificate($_course['code'], $document_id);
  524. }
  525. $certificate_condition = '&certificate=true&curdirpath=/certificates';
  526. }
  527. Display::addFlash(Display::return_message(get_lang('ItemAdded')));
  528. header('Location: document.php?'.api_get_cidreq().'&id='.$folder_id.$selectcat.$certificate_condition);
  529. exit();
  530. } else {
  531. Display::addFlash(Display::return_message(get_lang('Impossible'), 'error'));
  532. Display :: display_header($nameTools, 'Doc');
  533. Display :: display_footer();
  534. }
  535. } else {
  536. Display::addFlash(Display::return_message(get_lang('Impossible'), 'error'));
  537. Display :: display_header($nameTools, 'Doc');
  538. Display :: display_footer();
  539. }
  540. } else {
  541. // Copied from document.php
  542. $dir_array = explode('/', $dir);
  543. $array_len = count($dir_array);
  544. // Breadcrumb for the current directory root path
  545. if (!empty($document_data)) {
  546. if (empty($document_data['parents'])) {
  547. $interbreadcrumb[] = array(
  548. 'url' => '#',
  549. 'name' => $document_data['title']
  550. );
  551. } else {
  552. foreach ($document_data['parents'] as $document_sub_data) {
  553. $interbreadcrumb[] = array(
  554. 'url' => $document_sub_data['document_url'],
  555. 'name' => $document_sub_data['title']
  556. );
  557. }
  558. }
  559. }
  560. Display :: display_header($nameTools, "Doc");
  561. // actions
  562. // link back to the documents overview
  563. if ($is_certificate_mode) {
  564. $actionsLeft = '<a href="document.php?certificate=true&id='.$folder_id.'&selectcat='.Security::remove_XSS($_GET['selectcat']).'">'.
  565. Display::return_icon('back.png', get_lang('Back').' '.get_lang('To').' '.get_lang('CertificateOverview'), '', ICON_SIZE_MEDIUM).'</a>';
  566. $actionsLeft .= '<a id="hide_bar_template" href="#" role="button">'.
  567. Display::return_icon('expand.png', get_lang('Back'), array('id'=>'expand'), ICON_SIZE_MEDIUM).Display::return_icon('contract.png', get_lang('Back'), array('id'=>'contract', 'class'=>'hide'), ICON_SIZE_MEDIUM).'</a>';
  568. } else {
  569. $actionsLeft = '<a href="document.php?curdirpath='.Security::remove_XSS($dir).'">'.
  570. Display::return_icon('back.png', get_lang('Back').' '.get_lang('To').' '.get_lang('DocumentsOverview'), '', ICON_SIZE_MEDIUM).'</a>';
  571. $actionsLeft .= '<a id="hide_bar_template" href="#" role="button">'.
  572. Display::return_icon('expand.png', get_lang('Expand'), array('id'=>'expand'), ICON_SIZE_MEDIUM).
  573. Display::return_icon('contract.png', get_lang('Collapse'), array('id'=>'contract', 'class'=>'hide'), ICON_SIZE_MEDIUM).'</a>';
  574. }
  575. echo $toolbar = Display::toolbarAction('actions-documents', array($actionsLeft));
  576. if ($is_certificate_mode) {
  577. $all_information_by_create_certificate = DocumentManager::get_all_info_to_certificate(
  578. api_get_user_id(),
  579. api_get_course_id()
  580. );
  581. $str_info = '';
  582. foreach ($all_information_by_create_certificate[0] as $info_value) {
  583. $str_info .= $info_value.'<br/>';
  584. }
  585. $create_certificate = get_lang('CreateCertificateWithTags');
  586. echo Display::return_message($create_certificate.': <br /><br/>'.$str_info, 'normal', false);
  587. }
  588. // HTML-editor
  589. echo '<div class="page-create">
  590. <div class="row" style="overflow:hidden">
  591. <div id="template_col" class="col-md-3">
  592. <div class="panel panel-default">
  593. <div class="panel-body">
  594. <div id="frmModel" class="items-templates scrollbar-light"></div>
  595. </div>
  596. </div>
  597. </div>
  598. <div id="doc_form" class="col-md-9">
  599. '.$form->returnForm().'
  600. </div>
  601. </div></div>';
  602. Display :: display_footer();
  603. }