edit_document.php 25 KB

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