edit_document.php 20 KB

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