edit_document.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. use ChamiloSession as Session;
  4. /**
  5. * This file allows editing documents.
  6. *
  7. * Based on create_document, this file allows
  8. * - edit name
  9. * - edit comments
  10. * - edit metadata (requires a document table entry)
  11. * - edit html content (only for htm/html files)
  12. *
  13. * For all files
  14. * - show editable name field
  15. * - show editable comments field
  16. * Additionally, for html and text files
  17. * - show RTE
  18. *
  19. * Remember, all files and folders must always have an entry in the
  20. * database, regardless of wether they are visible/invisible, have
  21. * comments or not.
  22. *
  23. * @package chamilo.document
  24. *
  25. * @todo improve script structure (FormValidator is used to display form, but
  26. * not for validation at the moment)
  27. */
  28. require_once __DIR__.'/../inc/global.inc.php';
  29. $groupRights = Session::read('group_member_with_upload_rights');
  30. // Template's javascript
  31. $htmlHeadXtra[] = '
  32. <script>
  33. $(function() {
  34. $(".scrollbar-light").scrollbar();
  35. expandColumnToogle("#hide_bar_template", {
  36. selector: "#template_col",
  37. width: 3
  38. }, {
  39. selector: "#doc_form",
  40. width: 9
  41. });
  42. CKEDITOR.on("instanceReady", function (e) {
  43. showTemplates();
  44. });
  45. });
  46. </script>';
  47. $this_section = SECTION_COURSES;
  48. $lib_path = api_get_path(LIBRARY_PATH);
  49. $course_info = api_get_course_info();
  50. $group_id = api_get_group_id();
  51. $sessionId = api_get_session_id();
  52. $dir = '/';
  53. $currentDirPath = isset($_GET['curdirpath']) ? Security::remove_XSS($_GET['curdirpath']) : null;
  54. $readonly = false;
  55. if (isset($_GET['id'])) {
  56. $document_data = DocumentManager::get_document_data_by_id(
  57. $_GET['id'],
  58. api_get_course_id(),
  59. true,
  60. 0
  61. );
  62. if (!empty($sessionId) && empty($document_data)) {
  63. $document_data = DocumentManager::get_document_data_by_id(
  64. $_REQUEST['id'],
  65. api_get_course_id(),
  66. true,
  67. $sessionId
  68. );
  69. }
  70. $document_id = $document_data['id'];
  71. $file = $document_data['path'];
  72. $parent_id = DocumentManager::get_document_id($course_info, dirname($file));
  73. $dir = dirname($document_data['path']);
  74. $dir_original = $dir;
  75. $doc = basename($file);
  76. $readonly = $document_data['readonly'];
  77. $file_type = $document_data['filetype'];
  78. }
  79. if (empty($document_data)) {
  80. api_not_allowed(true);
  81. }
  82. if (api_is_in_group()) {
  83. $group_properties = GroupManager::get_group_properties($group_id);
  84. }
  85. $is_certificate_mode = DocumentManager::is_certificate_mode($dir);
  86. //Call from
  87. $call_from_tool = api_get_origin();
  88. $slide_id = isset($_GET['origin_opt']) ? Security::remove_XSS($_GET['origin_opt']) : null;
  89. $file_name = $doc;
  90. $group_document = false;
  91. $_course = api_get_course_info();
  92. $sessionId = api_get_session_id();
  93. $user_id = api_get_user_id();
  94. $doc_tree = explode('/', $file);
  95. $count_dir = count($doc_tree) - 2; // "2" because at the begin and end there are 2 "/"
  96. // Level correction for group documents.
  97. if (!empty($group_properties['directory'])) {
  98. $count_dir = $count_dir > 0 ? $count_dir - 1 : 0;
  99. }
  100. $relative_url = '';
  101. for ($i = 0; $i < ($count_dir); $i++) {
  102. $relative_url .= '../';
  103. }
  104. $editorConfig = [
  105. 'ToolbarSet' => (api_is_allowed_to_edit(null, true) ? 'Documents' : 'DocumentsStudent'),
  106. 'Width' => '100%',
  107. 'Height' => '400',
  108. 'cols-size' => [2, 10, 0],
  109. 'FullPage' => true,
  110. 'InDocument' => true,
  111. 'CreateDocumentDir' => $relative_url,
  112. 'CreateDocumentWebDir' => (empty($group_properties['directory']))
  113. ? api_get_path(WEB_COURSE_PATH).$_course['path'].'/document/'
  114. : api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document'.$group_properties['directory'].'/',
  115. 'BaseHref' => api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.$dir,
  116. ];
  117. if ($is_certificate_mode) {
  118. $editorConfig['CreateDocumentDir'] = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document/';
  119. $editorConfig['CreateDocumentWebDir'] = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document/';
  120. $editorConfig['BaseHref'] = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.$dir;
  121. }
  122. $is_allowed_to_edit = api_is_allowed_to_edit(null, true) || $groupRights ||
  123. DocumentManager::is_my_shared_folder(api_get_user_id(), $dir, $sessionId);
  124. $dbTable = Database::get_course_table(TABLE_DOCUMENT);
  125. $course_id = api_get_course_int_id();
  126. if (!empty($group_id)) {
  127. $interbreadcrumb[] = [
  128. 'url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?'.api_get_cidreq(),
  129. 'name' => get_lang('GroupSpace'),
  130. ];
  131. $group_document = true;
  132. }
  133. if (!$is_certificate_mode) {
  134. $interbreadcrumb[] = [
  135. "url" => api_get_path(WEB_CODE_PATH)."document/document.php?curdirpath=".urlencode($currentDirPath).'&'.api_get_cidreq(),
  136. "name" => get_lang('Documents'),
  137. ];
  138. } else {
  139. $interbreadcrumb[] = [
  140. 'url' => Category::getUrl(),
  141. 'name' => get_lang('Gradebook'),
  142. ];
  143. }
  144. if (empty($document_data['parents'])) {
  145. $interbreadcrumb[] = ['url' => '#', 'name' => $document_data['title']];
  146. } else {
  147. foreach ($document_data['parents'] as $document_sub_data) {
  148. if ($document_data['title'] == $document_sub_data['title']) {
  149. continue;
  150. }
  151. $interbreadcrumb[] = ['url' => $document_sub_data['document_url'], 'name' => $document_sub_data['title']];
  152. }
  153. }
  154. if (!($is_allowed_to_edit ||
  155. $groupRights ||
  156. DocumentManager::is_my_shared_folder($user_id, $dir, api_get_session_id()))
  157. ) {
  158. api_not_allowed(true);
  159. }
  160. Event::event_access_tool(TOOL_DOCUMENT);
  161. //TODO:check the below code and his funcionality
  162. if (!api_is_allowed_to_edit()) {
  163. if (DocumentManager::check_readonly($course_info, $user_id, $file)) {
  164. api_not_allowed();
  165. }
  166. }
  167. $document_info = api_get_item_property_info(
  168. api_get_course_int_id(),
  169. 'document',
  170. $document_id,
  171. 0
  172. );
  173. // Try to find this document in the session
  174. if (!empty($sessionId)) {
  175. $document_info = api_get_item_property_info(
  176. api_get_course_int_id(),
  177. 'document',
  178. $document_id,
  179. $sessionId
  180. );
  181. }
  182. if (api_is_in_group()) {
  183. $group_properties = GroupManager::get_group_properties($group_id);
  184. GroupManager::allowUploadEditDocument(
  185. api_get_user_id(),
  186. api_get_course_int_id(),
  187. $group_properties,
  188. $document_info,
  189. true
  190. );
  191. }
  192. /* MAIN TOOL CODE */
  193. /* Code to change the comment */
  194. if (isset($_POST['comment'])) {
  195. // Fixing the path if it is wrong
  196. $comment = trim($_POST['comment']);
  197. $title = trim($_POST['title']);
  198. // Just in case see BT#3525
  199. if (empty($title)) {
  200. $title = $document_data['title'];
  201. }
  202. if (empty($title)) {
  203. $title = get_document_title($_POST['filename']);
  204. }
  205. if (!empty($document_id)) {
  206. $linkExists = false;
  207. if ($file_type == 'link') {
  208. $linkExists = DocumentManager::cloudLinkExists($course_info, $file, $_POST['comment']);
  209. }
  210. if (!$linkExists || $linkExists == $document_id) {
  211. $params = [
  212. 'comment' => $comment,
  213. 'title' => $title,
  214. ];
  215. Database::update(
  216. $dbTable,
  217. $params,
  218. ['c_id = ? AND id = ?' => [$course_id, $document_id]]
  219. );
  220. if ($file_type != 'link') {
  221. Display::addFlash(Display::return_message(get_lang('fileModified')));
  222. } else {
  223. Display::addFlash(Display::return_message(get_lang('CloudLinkModified')));
  224. }
  225. } else {
  226. Display::addFlash(Display::return_message(get_lang('UrlAlreadyExists'), 'warning'));
  227. }
  228. }
  229. }
  230. /* WYSIWYG HTML EDITOR - Program Logic */
  231. if ($is_allowed_to_edit) {
  232. if (isset($_POST['formSent']) && $_POST['formSent'] == 1 && !empty($document_id)) {
  233. $content = isset($_POST['content']) ? trim(str_replace(["\r", "\n"], '', stripslashes($_POST['content']))) : null;
  234. $content = Security::remove_XSS($content, COURSEMANAGERLOWSECURITY);
  235. if ($dir == '/') {
  236. $dir = '';
  237. }
  238. $read_only_flag = isset($_POST['readonly']) ? $_POST['readonly'] : null;
  239. $read_only_flag = empty($read_only_flag) ? 0 : 1;
  240. if ($file_type != 'link') {
  241. $file_size = filesize($document_data['absolute_path']);
  242. }
  243. if ($read_only_flag == 0) {
  244. if (!empty($content)) {
  245. if ($fp = @fopen($document_data['absolute_path'], 'w')) {
  246. // For flv player, change absolute path temporarily to prevent
  247. // from erasing it in the following lines
  248. $content = str_replace(['flv=h', 'flv=/'], ['flv=h|', 'flv=/|'], $content);
  249. fputs($fp, $content);
  250. fclose($fp);
  251. $filepath = $document_data['absolute_parent_path'];
  252. update_existing_document(
  253. $_course,
  254. $document_id,
  255. $file_size,
  256. $read_only_flag
  257. );
  258. api_item_property_update(
  259. $_course,
  260. TOOL_DOCUMENT,
  261. $document_id,
  262. 'DocumentUpdated',
  263. api_get_user_id(),
  264. null,
  265. null,
  266. null,
  267. null,
  268. $sessionId
  269. );
  270. // Update parent folders
  271. item_property_update_on_folder(
  272. $_course,
  273. $dir,
  274. api_get_user_id()
  275. );
  276. } else {
  277. Display::addFlash(Display::return_message(get_lang('Impossible'), 'warning'));
  278. }
  279. } else {
  280. if ($document_id) {
  281. update_existing_document($_course, $document_id, $file_size, $read_only_flag);
  282. }
  283. }
  284. } else {
  285. if ($document_id) {
  286. update_existing_document($_course, $document_id, $file_size, $read_only_flag);
  287. }
  288. }
  289. header('Location: document.php?id='.$document_data['parent_id'].'&'.api_get_cidreq().($is_certificate_mode ? '&curdirpath=/certificates&selectcat=1' : ''));
  290. exit;
  291. }
  292. }
  293. // Replace relative paths by absolute web paths (e.g. './' => 'http://www.chamilo.org/courses/ABC/document/')
  294. $content = null;
  295. $extension = null;
  296. $filename = null;
  297. if (file_exists($document_data['absolute_path'])) {
  298. $path_info = pathinfo($document_data['absolute_path']);
  299. $filename = $path_info['filename'];
  300. if (is_file($document_data['absolute_path'])) {
  301. $extension = $path_info['extension'];
  302. if (in_array($extension, ['html', 'htm'])) {
  303. $content = file($document_data['absolute_path']);
  304. $content = implode('', $content);
  305. }
  306. }
  307. }
  308. // Display the header
  309. $nameTools = get_lang('EditDocument').': '.Security::remove_XSS($document_data['title']);
  310. Display::display_header($nameTools, 'Doc');
  311. $owner_id = $document_info['insert_user_id'];
  312. $last_edit_date = $document_info['lastedit_date'];
  313. $createdDate = $document_info['insert_date'];
  314. $groupInfo = GroupManager::get_group_properties(api_get_group_id());
  315. if ($owner_id == api_get_user_id() ||
  316. api_is_platform_admin() ||
  317. $is_allowed_to_edit || GroupManager:: is_user_in_group(
  318. api_get_user_id(),
  319. $groupInfo
  320. )
  321. ) {
  322. $action = api_get_self().'?id='.$document_data['id'].'&'.api_get_cidreq();
  323. if ($is_certificate_mode) {
  324. $action .= '&curdirpath=/certificates&selectcat=1';
  325. }
  326. $form = new FormValidator(
  327. 'formEdit',
  328. 'post',
  329. $action,
  330. null,
  331. ['class' => 'form-vertical']
  332. );
  333. // Form title
  334. $form->addHeader($nameTools);
  335. $key_label_title = $file_type != 'link' ? 'Title' : 'LinkName';
  336. $form->addText(
  337. 'title',
  338. get_lang($key_label_title),
  339. true,
  340. ['cols-size' => [2, 10, 0], 'autofocus']
  341. );
  342. $defaults['title'] = $document_data['title'];
  343. $read_only_flag = isset($_POST['readonly']) ? $_POST['readonly'] : null;
  344. // Desactivation of IE proprietary commenting tags inside the text before loading it on the online editor.
  345. // This fix has been proposed by Hubert Borderiou, see Bug #573, http://support.chamilo.org/issues/573
  346. $defaults['content'] = str_replace('<!--[', '<!-- [', $content);
  347. // HotPotatoes tests are html files, but they should not be edited in order their functionality to be preserved.
  348. $showSystemFolders = api_get_course_setting('show_system_folders');
  349. $condition = stripos($dir, '/HotPotatoes_files') === false;
  350. if ($showSystemFolders == 1) {
  351. $condition = true;
  352. }
  353. if (($extension == 'htm' || $extension == 'html') && $condition) {
  354. if (empty($readonly) && $readonly == 0) {
  355. $form->addHtmlEditor('content', get_lang('Content'), true, true, $editorConfig);
  356. }
  357. }
  358. if (!empty($createdDate)) {
  359. $form->addLabel(get_lang('CreatedOn'), Display::dateToStringAgoAndLongDate($createdDate));
  360. }
  361. if ($file_type != 'link') {
  362. if (!$group_document && !DocumentManager::is_my_shared_folder(api_get_user_id(), $currentDirPath, $sessionId)) {
  363. $form->addLabel(get_lang('UpdatedOn'), Display::dateToStringAgoAndLongDate($last_edit_date));
  364. }
  365. if (!empty($document_info['insert_user_id'])) {
  366. $insertByUserInfo = api_get_user_info($document_info['insert_user_id']);
  367. if (!empty($insertByUserInfo)) {
  368. $form->addLabel(get_lang('Author'), $insertByUserInfo['complete_name_with_message_link']);
  369. }
  370. }
  371. }
  372. if ($file_type == 'link') {
  373. // URLs in whitelist
  374. $urlWL = DocumentManager::getFileHostingWhiteList();
  375. sort($urlWL);
  376. //Matches any of the whitelisted urls preceded by // or .
  377. $urlWLRegEx = '/(\/\/|\.)('.implode('|', $urlWL).')/i';
  378. $urlWLText = "\n\t* ".implode("\n\t* ", $urlWL);
  379. $urlWLHTML = "<ul><li>".implode("</li><li>", $urlWL)."</li></ul>";
  380. $form->addText('comment', get_lang('Url'));
  381. $form->addElement(
  382. 'static',
  383. 'info',
  384. '',
  385. '<span class="text-primary" data-toggle="tooltip" title="'.$urlWLHTML.'">'.get_lang(
  386. 'ValidDomainList'
  387. ).' <span class="glyphicon glyphicon-question-sign"></span></span>'
  388. );
  389. } else {
  390. $form->addElement('textarea', 'comment', get_lang('Comment'), ['cols-size' => [2, 10, 0]]);
  391. }
  392. if ($file_type != 'link') {
  393. if ($owner_id == api_get_user_id() || api_is_platform_admin()) {
  394. $checked = &$form->addElement('checkbox', 'readonly', null, get_lang('ReadOnly'));
  395. if ($readonly == 1) {
  396. $checked->setChecked(true);
  397. }
  398. }
  399. }
  400. if ($file_type == 'link') {
  401. $form->addRule('title', get_lang('PleaseEnterCloudLinkName'), 'required');
  402. $form->addRule('comment', get_lang('PleaseEnterURL'), 'required');
  403. // Well formed url pattern (must have the protocol)
  404. $urlRegEx = DocumentManager::getWellFormedUrlRegex();
  405. $form->addRule('comment', get_lang('NotValidURL'), 'regex', $urlRegEx, 'client');
  406. $form->addRule('comment', get_lang('NotValidURL'), 'regex', $urlRegEx, 'server');
  407. $form->addRule('comment', get_lang('NotValidDomain').$urlWLText, 'regex', $urlWLRegEx, 'client');
  408. $form->addRule('comment', get_lang('NotValidDomain').$urlWLHTML, 'regex', $urlWLRegEx, 'server');
  409. }
  410. if ($is_certificate_mode) {
  411. $form->addButtonUpdate(get_lang('SaveCertificate'));
  412. } elseif ($file_type == 'link') {
  413. $form->addButtonUpdate(get_lang('SaveLink'));
  414. } else {
  415. $form->addButtonUpdate(get_lang('SaveDocument'));
  416. }
  417. $form->addHidden('formSent', 1);
  418. $form->addHidden('filename', $filename);
  419. $defaults['extension'] = $extension;
  420. $defaults['file_path'] = isset($_GET['file']) ? Security::remove_XSS($_GET['file']) : null;
  421. $defaults['commentPath'] = $file;
  422. $defaults['renameTo'] = $file_name;
  423. $defaults['comment'] = $document_data['comment'];
  424. $defaults['origin'] = api_get_origin();
  425. $defaults['origin_opt'] = isset($_GET['origin_opt']) ? Security::remove_XSS($_GET['origin_opt']) : null;
  426. $form->setDefaults($defaults);
  427. show_return(
  428. $parent_id,
  429. $dir_original,
  430. $call_from_tool,
  431. $slide_id,
  432. $is_certificate_mode
  433. );
  434. if ($is_certificate_mode) {
  435. $all_information_by_create_certificate = DocumentManager::get_all_info_to_certificate(
  436. api_get_user_id(),
  437. api_get_course_id()
  438. );
  439. $str_info = '';
  440. foreach ($all_information_by_create_certificate[0] as $info_value) {
  441. $str_info .= $info_value.'<br/>';
  442. }
  443. $create_certificate = get_lang('CreateCertificateWithTags');
  444. echo Display::return_message(
  445. $create_certificate.': <br /><br />'.$str_info,
  446. 'normal',
  447. false
  448. );
  449. }
  450. if ($extension == 'svg' && !api_browser_support('svg') &&
  451. api_get_setting('enabled_support_svg') == 'true'
  452. ) {
  453. echo Display::return_message(get_lang('BrowserDontSupportsSVG'), 'warning');
  454. }
  455. if ($file_type != 'link') {
  456. // HTML-editor
  457. echo '<div class="page-create">
  458. <div class="row" style="overflow:hidden">
  459. <div id="template_col" class="col-md-3">
  460. <div class="panel panel-default">
  461. <div class="panel-body">
  462. <div id="frmModel" class="items-templates scrollbar-light"></div>
  463. </div>
  464. </div>
  465. </div>
  466. <div id="doc_form" class="col-md-9">
  467. '.$form->returnForm().'
  468. </div>
  469. </div></div>';
  470. } else {
  471. // Add tooltip and correctly parse its inner HTML
  472. echo '<script>
  473. $(function() {
  474. $("[data-toggle=\'tooltip\']").tooltip(
  475. {
  476. content:
  477. function() {
  478. return $(this).attr("title");
  479. }
  480. }
  481. );
  482. });
  483. </script>';
  484. echo $form->returnForm();
  485. }
  486. }
  487. Display::display_footer();
  488. // return button back to
  489. function show_return($document_id, $path, $call_from_tool = '', $slide_id = 0, $is_certificate_mode = false)
  490. {
  491. $actionsLeft = null;
  492. global $parent_id;
  493. $url = api_get_path(WEB_CODE_PATH).'document/document.php?'.api_get_cidreq().'&id='.$parent_id;
  494. if ($is_certificate_mode) {
  495. $selectedCategory = (isset($_GET['curdirpath']) ? Security::remove_XSS($_GET['curdirpath']) : '');
  496. $actionsLeft .= '<a href="document.php?curdirpath='.$selectedCategory.'&selectcat='.$selectedCategory.'">'.
  497. Display::return_icon('back.png', get_lang('Back').' '.get_lang('To').' '.get_lang('CertificateOverview'), '', ICON_SIZE_MEDIUM).'</a>';
  498. $actionsLeft .= '<a id="hide_bar_template" href="#" role="button">'.Display::return_icon('expand.png', get_lang('Expand'), ['id' => 'expand'], ICON_SIZE_MEDIUM).Display::return_icon('contract.png', get_lang('Collapse'), ['id' => 'contract', 'class' => 'hide'], ICON_SIZE_MEDIUM).'</a>';
  499. } elseif ($call_from_tool == 'slideshow') {
  500. $actionsLeft .= '<a href="'.api_get_path(WEB_PATH).'main/document/slideshow.php?slide_id='.$slide_id.'&curdirpath='.Security::remove_XSS(urlencode($_GET['curdirpath'])).'">'.
  501. Display::return_icon('slideshow.png', get_lang('BackTo').' '.get_lang('ViewSlideshow'), '', ICON_SIZE_MEDIUM).'</a>';
  502. } elseif ($call_from_tool == 'editdraw') {
  503. $actionsLeft .= '<a href="'.$url.'">'.
  504. Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('DocumentsOverview'), '', ICON_SIZE_MEDIUM).'</a>';
  505. $actionsLeft .= '<a href="javascript:history.back(1)">'.Display::return_icon('draw.png', get_lang('BackTo').' '.get_lang('Draw'), [], 32).'</a>';
  506. } elseif ($call_from_tool == 'editodf') {
  507. $actionsLeft .= '<a href="'.$url.'">'.
  508. Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('DocumentsOverview'), '', ICON_SIZE_MEDIUM).'</a>';
  509. $actionsLeft .= '<a href="javascript:history.back(1)">'.Display::return_icon('draw.png', get_lang('BackTo').' '.get_lang('Write'), [], 32).'</a>';
  510. $actionsLeft .= '<a id="hide_bar_template" href="#" role="button">'.Display::return_icon('expand.png', get_lang('Expand'), ['id' => 'expand'], ICON_SIZE_MEDIUM).Display::return_icon('contract.png', get_lang('Collapse'), ['id' => 'contract', 'class' => 'hide'], ICON_SIZE_MEDIUM).'</a>';
  511. } elseif ($call_from_tool == 'editpaint' && api_get_setting('enabled_support_pixlr') === 'true') {
  512. $actionsLeft .= '<a href="'.$url.'">'.
  513. Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('DocumentsOverview'), [], ICON_SIZE_MEDIUM).'</a>';
  514. $actionsLeft .= '<a href="javascript:history.back(1)">'.Display::return_icon('paint.png', get_lang('BackTo').' '.get_lang('Paint'), [], 32).'</a>';
  515. } else {
  516. $actionsLeft .= '<a href="'.$url.'">'.
  517. Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('DocumentsOverview'), '', ICON_SIZE_MEDIUM).'</a>';
  518. $actionsLeft .= '<a id="hide_bar_template" href="#" role="button">'.Display::return_icon('expand.png', get_lang('Expand'), ['id' => 'expand'], ICON_SIZE_MEDIUM).Display::return_icon('contract.png', get_lang('Collapse'), ['id' => 'contract', 'class' => 'hide'], ICON_SIZE_MEDIUM).'</a>';
  519. }
  520. echo $toolbar = Display::toolbarAction('actions-documents', [$actionsLeft]);
  521. }