create_document.php 22 KB

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