edit_document.php 23 KB

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