edit_document.php 24 KB

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