edit_document.php 21 KB

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