edit_document.php 24 KB

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