edit_document.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  1. <?php // $Id: edit_document.php 18028 2009-01-27 15:13:17Z ivantcholakov $
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2004-2008 Dokeos SPRL
  6. Copyright (c) 2003 Ghent University (UGent)
  7. Copyright (c) 2001 Universite catholique de Louvain (UCL)
  8. Copyright (c) Olivier Brouckaert
  9. Copyright (c) Roan Embrechts
  10. Copyright (c) Rene Haentjens (RH) (update 2004/09/30)
  11. Copyright (c) Bart Mollet, Hogeschool Gent
  12. For a full list of contributors, see "credits.txt".
  13. The full license can be read in "license.txt".
  14. This program is free software; you can redistribute it and/or
  15. modify it under the terms of the GNU General Public License
  16. as published by the Free Software Foundation; either version 2
  17. of the License, or (at your option) any later version.
  18. See the GNU General Public License for more details.
  19. Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium, info@dokeos.com
  20. ==============================================================================
  21. */
  22. /**
  23. ==============================================================================
  24. * This file allows editing documents.
  25. *
  26. * Based on create_document, this file allows
  27. * - edit name
  28. * - edit comments
  29. * - edit metadata (requires a document table entry)
  30. * - edit html content (only for htm/html files)
  31. *
  32. * For all files
  33. * - show editable name field
  34. * - show editable comments field
  35. * Additionally, for html and text files
  36. * - show RTE
  37. *
  38. * Remember, all files and folders must always have an entry in the
  39. * database, regardless of wether they are visible/invisible, have
  40. * comments or not.
  41. *
  42. * @package dokeos.document
  43. * @todo improve script structure (FormValidator is used to display form, but
  44. * not for validation at the moment)
  45. ==============================================================================
  46. */
  47. // name of the language file that needs to be included
  48. $language_file = 'document';
  49. /*
  50. ------------------------------------------------------------------------------
  51. Included libraries
  52. ------------------------------------------------------------------------------
  53. */
  54. include('../inc/global.inc.php');
  55. // Template's javascript
  56. $htmlHeadXtra[] = '
  57. <script type="text/javascript">
  58. function InnerDialogLoaded()
  59. {
  60. var B=new window.frames[0].FCKToolbarButton(\'Templates\',window.frames[0].FCKLang.Templates);
  61. return B.ClickFrame();
  62. };
  63. function FCKeditor_OnComplete( editorInstance )
  64. {
  65. document.getElementById(\'frmModel\').innerHTML = "<iframe height=950px; width=100%; frameborder=0 src=\''.api_get_path(WEB_LIBRARY_PATH).'fckeditor/editor/fckdialogframe.html \'>";
  66. }
  67. </script>';
  68. $_SESSION['whereami'] = 'document/create';
  69. $this_section=SECTION_COURSES;
  70. include(api_get_path(LIBRARY_PATH).'fileManage.lib.php');
  71. include(api_get_path(LIBRARY_PATH).'fileUpload.lib.php');
  72. include(api_get_path(LIBRARY_PATH).'events.lib.inc.php');
  73. include(api_get_path(LIBRARY_PATH).'document.lib.php');
  74. include_once(api_get_path(LIBRARY_PATH) . 'groupmanager.lib.php');
  75. require_once(api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
  76. $fck_attribute['Width'] = '100%';
  77. $fck_attribute['Height'] = '950';
  78. $fck_attribute['ToolbarSet'] = 'Full';
  79. $fck_attribute['Config']['FullPage'] = true;
  80. /*
  81. ------------------------------------------------------------------------------
  82. Constants & Variables
  83. ------------------------------------------------------------------------------
  84. */
  85. if (api_is_in_group())
  86. {
  87. $group_properties = GroupManager::get_group_properties($_SESSION['_gid']);
  88. }
  89. $file = $_GET['file'];
  90. //echo('file: '.$file.'<br>');
  91. $doc=basename($file);
  92. //echo('doc: '.$doc.'<br>');
  93. $dir=$_GET['curdirpath'];
  94. //echo('dir: '.$dir.'<br>');
  95. $file_name = $doc;
  96. //echo('file_name: '.$file_name.'<br>');
  97. $baseServDir = api_get_path(SYS_COURSE_PATH);
  98. $baseServUrl = $_configuration['url_append']."/";
  99. $courseDir = $_course['path']."/document";
  100. $baseWorkDir = $baseServDir.$courseDir;
  101. $group_document = false;
  102. $doc_tree= explode('/', $file);
  103. $count_dir = count($doc_tree) -2; // "2" because at the begin and end there are 2 "/"
  104. // Level correction for group documents.
  105. if (!empty($group_properties['directory']))
  106. {
  107. $count_dir = $count_dir > 0 ? $count_dir - 1 : 0;
  108. }
  109. $relative_url='';
  110. for($i=0;$i<($count_dir);$i++)
  111. {
  112. $relative_url.='../';
  113. }
  114. $fck_attribute['Config']['InDocument'] = true;
  115. $fck_attribute['Config']['CreateDocumentDir'] = $relative_url;
  116. if (empty($group_properties['directory']))
  117. {
  118. $fck_attribute['Config']['CreateDocumentWebDir'] = api_get_path('WEB_COURSE_PATH').$_course['path'].'/document/';
  119. }
  120. else
  121. {
  122. $fck_attribute['Config']['CreateDocumentWebDir'] = api_get_path('WEB_COURSE_PATH').api_get_course_path().'/document'.$group_properties['directory'].'/';
  123. }
  124. $fck_attribute['Config']['BaseHref'] = api_get_path('WEB_COURSE_PATH').$_course['path'].'/document'.$dir;
  125. $use_document_title = (get_setting('use_document_title')=='true')?true:false;
  126. $noPHP_SELF=true;
  127. /*
  128. ------------------------------------------------------------------------------
  129. Other init code
  130. ------------------------------------------------------------------------------
  131. */
  132. /* please do not modify this dirname formatting */
  133. if(strstr($dir,'..'))
  134. {
  135. $dir='/';
  136. }
  137. if($dir[0] == '.')
  138. {
  139. $dir=substr($dir,1);
  140. }
  141. if($dir[0] != '/')
  142. {
  143. $dir='/'.$dir;
  144. }
  145. if($dir[strlen($dir)-1] != '/')
  146. {
  147. $dir.='/';
  148. }
  149. $filepath=api_get_path('SYS_COURSE_PATH').$_course['path'].'/document'.$dir;
  150. if(!is_dir($filepath))
  151. {
  152. $filepath=api_get_path('SYS_COURSE_PATH').$_course['path'].'/document/';
  153. $dir='/';
  154. }
  155. /**************************************************/
  156. $nameTools = get_lang('EditDocument');
  157. $dbTable = Database::get_course_table(TABLE_DOCUMENT);
  158. if(!empty($_SESSION['_gid']))
  159. {
  160. $req_gid = '&amp;gidReq='.$_SESSION['_gid'];
  161. $interbreadcrumb[]= array ("url"=>"../group/group_space.php?gidReq=".$_SESSION['_gid'], "name"=> get_lang('GroupSpace'));
  162. $group_document = true;
  163. $noPHP_SELF=true;
  164. }
  165. $interbreadcrumb[]=array("url"=>"./document.php?curdirpath=".urlencode($_GET['curdirpath']).$req_gid, "name"=> get_lang('Documents'));
  166. $is_allowedToEdit = is_allowed_to_edit() || $_SESSION['group_member_with_upload_rights'];
  167. if(!$is_allowedToEdit)
  168. {
  169. api_not_allowed(true);
  170. }
  171. $user_id = api_get_user_id();
  172. event_access_tool(TOOL_DOCUMENT);
  173. if (!is_allowed_to_edit())
  174. {
  175. if(DocumentManager::check_readonly($_course,$user_id,$file))
  176. {
  177. api_not_allowed();
  178. }
  179. }
  180. /*
  181. ==============================================================================
  182. MAIN TOOL CODE
  183. ==============================================================================
  184. */
  185. /*
  186. ------------------------------------------------------------------------------
  187. General functions
  188. ------------------------------------------------------------------------------
  189. */
  190. /*
  191. ------------------------------------------------------------------------------
  192. Workhorse functions
  193. These do the actual work that is expected from of this tool, other functions
  194. are only there to support these ones.
  195. ------------------------------------------------------------------------------
  196. */
  197. /**
  198. This function changes the name of a certain file.
  199. It needs no global variables, it takes all info from parameters.
  200. It returns nothing.
  201. */
  202. function change_name($baseWorkDir, $sourceFile, $renameTo, $dir, $doc)
  203. {
  204. $file_name_for_change = $baseWorkDir.$dir.$sourceFile;
  205. //api_display_debug_info("call my_rename: params $file_name_for_change, $renameTo");
  206. $renameTo = disable_dangerous_file($renameTo); //avoid renaming to .htaccess file
  207. $renameTo = my_rename($file_name_for_change, stripslashes($renameTo)); //fileManage API
  208. if ($renameTo)
  209. {
  210. if (isset($dir) && $dir != "")
  211. {
  212. $sourceFile = $dir.$sourceFile;
  213. $new_full_file_name = dirname($sourceFile)."/".$renameTo;
  214. }
  215. else
  216. {
  217. $sourceFile = "/".$sourceFile;
  218. $new_full_file_name = "/".$renameTo;
  219. }
  220. update_db_info("update", $sourceFile, $new_full_file_name); //fileManage API
  221. $name_changed = get_lang("ElRen");
  222. $info_message = get_lang('fileModified');
  223. $GLOBALS['file_name'] = $renameTo;
  224. $GLOBALS['doc'] = $renameTo;
  225. return $info_message;
  226. }
  227. else
  228. {
  229. $dialogBox = get_lang('FileExists');
  230. /* return to step 1 */
  231. $rename = $sourceFile;
  232. unset($sourceFile);
  233. }
  234. }
  235. /*
  236. ------------------------------------------------------------------------------
  237. Code to change the comment
  238. ------------------------------------------------------------------------------
  239. Step 2. React on POST data
  240. (Step 1 see below)
  241. */
  242. if (isset($_POST['newComment']))
  243. {
  244. //to try to fix the path if it is wrong
  245. $commentPath = str_replace("//", "/", Database::escape_string($_POST['commentPath']));
  246. $newComment = trim(Database::escape_string($_POST['newComment'])); // remove spaces
  247. $newTitle = trim(Database::escape_string($_POST['newTitle'])); // remove spaces
  248. // Check if there is already a record for this file in the DB
  249. $result = api_sql_query ("SELECT * FROM $dbTable WHERE path LIKE BINARY '".$commentPath."'",__FILE__,__LINE__);
  250. while($row = Database::fetch_array($result, 'ASSOC'))
  251. {
  252. $attribute['path' ] = $row['path' ];
  253. $attribute['comment' ] = $row['title'];
  254. }
  255. //Determine the correct query to the DB
  256. //new code always keeps document in database
  257. $query = "UPDATE $dbTable
  258. SET comment='".$newComment."', title='".$newTitle."'
  259. WHERE path
  260. LIKE BINARY '".$commentPath."'";
  261. api_sql_query($query,__FILE__,__LINE__);
  262. $oldComment = $newComment;
  263. $oldTitle = $newTitle;
  264. $comments_updated = get_lang('ComMod');
  265. $info_message = get_lang('fileModified');
  266. }
  267. /*
  268. ------------------------------------------------------------------------------
  269. Code to change the name
  270. ------------------------------------------------------------------------------
  271. Step 2. react on POST data - change the name
  272. (Step 1 see below)
  273. */
  274. if (isset($_POST['renameTo']))
  275. {
  276. $info_message = change_name($baseWorkDir, $_GET['sourceFile'], $_POST['renameTo'], $dir, $doc);
  277. //assume name change was successful
  278. }
  279. /*
  280. ------------------------------------------------------------------------------
  281. Code to change the comment
  282. ------------------------------------------------------------------------------
  283. Step 1. Create dialog box.
  284. */
  285. /** TODO check if this code is still used **/
  286. /* Search the old comment */ // RH: metadata: added 'id,'
  287. $result = api_sql_query("SELECT id,comment,title FROM $dbTable WHERE path LIKE BINARY '$dir$doc'",__FILE__,__LINE__);
  288. $message = "<i>Debug info</i><br>directory = $dir<br>";
  289. $message .= "document = $file_name<br>";
  290. $message .= "comments file = " . $file . "<br>";
  291. //Display::display_normal_message($message);
  292. while($row = Database::fetch_array($result, 'ASSOC'))
  293. {
  294. $oldComment = $row['comment'];
  295. $oldTitle = $row['title'];
  296. $docId = $row['id']; // RH: metadata
  297. }
  298. /*
  299. ------------------------------------------------------------------------------
  300. WYSIWYG HTML EDITOR - Program Logic
  301. ------------------------------------------------------------------------------
  302. */
  303. if($is_allowedToEdit)
  304. {
  305. if($_POST['formSent']==1)
  306. {
  307. if(isset($_POST['renameTo']))
  308. {
  309. $_POST['filename']=disable_dangerous_file($_POST['renameTo']);
  310. $extension=explode('.',$_POST['filename']);
  311. $extension=$extension[sizeof($extension)-1];
  312. $_POST['filename']=str_replace('.'.$extension,'',$_POST['filename']);
  313. }
  314. $filename=stripslashes($_POST['filename']);
  315. $texte=trim(str_replace(array("\r","\n"),"",stripslashes($_POST['texte'])));
  316. if(!strstr($texte,'/css/frames.css'))
  317. {
  318. $texte=str_replace('</title></head>','</title><link rel="stylesheet" href="../css/frames.css" type="text/css" /></head>',$texte);
  319. }
  320. // RH commented: $filename=replace_dangerous_char($filename,'strict');
  321. // What??
  322. //if($_POST['extension'] != 'htm' && $_POST['extension'] != 'html')
  323. //{
  324. //$extension='html';
  325. //}
  326. //else
  327. //{
  328. $extension = $_POST['extension'];
  329. //}
  330. $file=$dir.$filename.'.'.$extension;
  331. $read_only_flag=$_POST['readonly'];
  332. if (!empty($read_only_flag))
  333. {
  334. $read_only_flag=1;
  335. }
  336. else
  337. {
  338. $read_only_flag=0;
  339. }
  340. $show_edit=$_SESSION['showedit'];
  341. //unset($_SESSION['showedit']);
  342. api_session_unregister('showedit');
  343. if(empty($filename))
  344. {
  345. $msgError=get_lang('NoFileName');
  346. }
  347. else
  348. {
  349. if ($read_only_flag==0)
  350. {
  351. if (!empty($texte))
  352. {
  353. if($fp=@fopen($filepath.$filename.'.'.$extension,'w'))
  354. {
  355. $texte = text_filter($texte);
  356. //if flv player, change absolute paht temporarely to prevent from erasing it in the following lines
  357. $texte = str_replace('flv=h','flv=h|',$texte);
  358. $texte = str_replace('flv=/','flv=/|',$texte);
  359. // change the path of mp3 to absolute
  360. // first regexp deals with ../../../ urls
  361. // Disabled by Ivan Tcholakov.
  362. //$texte = preg_replace("|(flashvars=\"file=)(\.+/)+|","$1".api_get_path(REL_COURSE_PATH).$_course['path'].'/document/',$texte);
  363. //second regexp deals with audio/ urls
  364. // Disabled by Ivan Tcholakov.
  365. //$texte = preg_replace("|(flashvars=\"file=)([^/]+)/|","$1".api_get_path(REL_COURSE_PATH).$_course['path'].'/document/$2/',$texte);
  366. fputs($fp,$texte);
  367. fclose($fp);
  368. $perm = api_get_setting('permissions_for_new_directories');
  369. $perm = octdec(!empty($perm)?$perm:'0770');
  370. if(!is_dir($filepath.'css'))
  371. {
  372. mkdir($filepath.'css',$perm);
  373. $doc_id=add_document($_course,$dir.'css','folder',0,'css');
  374. api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'FolderCreated', $_user['user_id']);
  375. api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'invisible', $_user['user_id']);
  376. }
  377. if(!is_file($filepath.'css/frames.css'))
  378. {
  379. copy(api_get_path(SYS_CODE_PATH).'css/frames.css',$filepath.'css/frames.css');
  380. $doc_id=add_document($_course,$dir.'css/frames.css','file',filesize($filepath.'css/frames.css'),'frames.css');
  381. api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentAdded', $_user['user_id']);
  382. api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'invisible', $_user['user_id']);
  383. }
  384. // "WHAT'S NEW" notification: update table item_property (previously last_tooledit)
  385. $document_id = DocumentManager::get_document_id($_course,$file);
  386. if($document_id)
  387. {
  388. $file_size = filesize($filepath.$filename.'.'.$extension);
  389. update_existing_document($_course, $document_id,$file_size,$read_only_flag);
  390. api_item_property_update($_course, TOOL_DOCUMENT, $document_id, 'DocumentUpdated', $_user['user_id']);
  391. //update parent folders
  392. item_property_update_on_folder($_course,$dir,$_user['user_id']);
  393. $dir= substr($dir,0,-1);
  394. header('Location: document.php?curdirpath='.urlencode($dir));
  395. exit ();
  396. }
  397. else
  398. {
  399. //$msgError=get_lang('Impossible');
  400. }
  401. }
  402. else
  403. {
  404. $msgError=get_lang('Impossible');
  405. }
  406. }
  407. else
  408. {
  409. $file_size = filesize($filepath.$filename.'.'.$extension);
  410. $document_id = DocumentManager::get_document_id($_course,$file);
  411. if($document_id)
  412. {
  413. update_existing_document($_course, $document_id,$file_size,$read_only_flag);
  414. }
  415. }
  416. }
  417. else
  418. {
  419. $filepath.$filename.'.'.$extension;
  420. $file_size = filesize($filepath.$filename.'.'.$extension);
  421. $document_id = DocumentManager::get_document_id($_course,$file);
  422. if($document_id)
  423. {
  424. update_existing_document($_course, $document_id,$file_size,$read_only_flag);
  425. }
  426. if (empty($document_id)) //or if is folder
  427. {
  428. $folder=$_POST['file_path'];
  429. $document_id = DocumentManager::get_document_id($_course,$folder);
  430. if (DocumentManager::is_folder($_course, $document_id))
  431. {
  432. if($document_id)
  433. {
  434. update_existing_document($_course, $document_id,$file_size,$read_only_flag);
  435. }
  436. }
  437. }
  438. }
  439. }
  440. }
  441. }
  442. //replace relative paths by absolute web paths (e.g. "./" => "http://www.dokeos.com/courses/ABC/document/")
  443. if(file_exists($filepath.$doc))
  444. {
  445. $extension=explode('.',$doc);
  446. $extension=$extension[sizeof($extension)-1];
  447. $filename=str_replace('.'.$extension,'',$doc);
  448. $extension=strtolower($extension);
  449. /*if(!in_array($extension,array('html','htm'))) // that was wrong
  450. {
  451. $extension=$filename=$texte='';
  452. }*/
  453. if(in_array($extension,array('html','htm')))
  454. {
  455. $texte=file($filepath.$doc);
  456. $texte=implode('',$texte);
  457. $path_to_append=api_get_path('WEB_COURSE_PATH').$_course['path'].'/document'.$dir;
  458. $texte=str_replace('="./','="'.$path_to_append,$texte);
  459. $texte=str_replace('mp3player.swf?son=.%2F','mp3player.swf?son='.urlencode($path_to_append),$texte);
  460. }
  461. }
  462. /*
  463. ==============================================================================
  464. - display user interface
  465. ==============================================================================
  466. */
  467. Display::display_header($nameTools,"Doc");
  468. api_display_tool_title(get_lang("EditDocument") . ": $file_name");
  469. if(isset($msgError))
  470. {
  471. Display::display_error_message($msgError); //main API
  472. }
  473. if( isset($info_message))
  474. {
  475. Display::display_normal_message($info_message); //main API
  476. }
  477. // readonly
  478. $sql = 'SELECT id, readonly FROM '.$dbTable.' WHERE path LIKE BINARY "'.$dir.$doc.'"';
  479. $rs = api_sql_query($sql, __FILE__, __LINE__);
  480. $readonly = Database::result($rs,0,'readonly');
  481. $doc_id = Database::result($rs,0,'id');
  482. // owner
  483. $sql = 'SELECT insert_user_id FROM '.Database::get_course_table(TABLE_ITEM_PROPERTY).'
  484. WHERE tool LIKE "document"
  485. AND ref='.intval($doc_id);
  486. $rs = api_sql_query($sql, __FILE__, __LINE__);
  487. $owner_id = Database::result($rs,0,'insert_user_id');
  488. if ($owner_id == $_user['user_id'] || api_is_platform_admin() || api_is_allowed_to_edit() || GroupManager :: is_user_in_group($_user['user_id'],$_SESSION['_gid'] ))
  489. {
  490. $action = api_get_self().'?sourceFile='.urlencode($file_name).'&curdirpath='.urlencode($_GET['curdirpath']).'&file='.urlencode($_GET['file']).'&doc='.urlencode($doc);
  491. $form = new FormValidator('formEdit','post',$action);
  492. $form->addElement('hidden','filename');
  493. $form->addElement('hidden','extension');
  494. $form->addElement('hidden','file_path');
  495. $form->addElement('hidden','commentPath');
  496. $form->addElement('hidden','showedit');
  497. if($use_document_title)
  498. {
  499. $form->add_textfield('newTitle',get_lang('Title'));
  500. $defaults['newTitle'] = $oldTitle;
  501. }
  502. else
  503. {
  504. $form->addElement('hidden','renameTo');
  505. }
  506. $form->addElement('hidden','formSent');
  507. $defaults['formSent'] = 1;
  508. $read_only_flag=$_POST['readonly'];
  509. $defaults['texte'] = $texte;
  510. //if($extension == 'htm' || $extension == 'html')
  511. // HotPotatoes tests are html files, but they should not be edited in order their functionality to be preserved.
  512. if(($extension == 'htm' || $extension == 'html') && stripos($dir, '/HotPotatoes_files') === false)
  513. {
  514. if (empty($readonly) && $readonly==0)
  515. {
  516. $form->addElement('submit','submit',get_lang('SaveDocument'));
  517. $_SESSION['showedit']=1;
  518. $form->add_html_editor('texte','',false,true);
  519. }
  520. }
  521. if(!$group_document)
  522. {
  523. $metadata_link = '<a href="../metadata/index.php?eid='.urlencode('Document.'.$docId).'">'.get_lang('AddMetadata').'</a>';
  524. $form->addElement('static',null,get_lang('Metadata'),$metadata_link);
  525. }
  526. $form->addElement('textarea','newComment',get_lang('Comment'),'rows="3" style="width:300px;"');
  527. $renderer = $form->defaultRenderer();
  528. if ($owner_id == $_user['user_id'] || api_is_platform_admin())
  529. {
  530. $renderer->setElementTemplate('<div class="row"><div class="label"></div><div class="formw">{element}{label}</div></div>', 'readonly');
  531. $checked =&$form->addElement('checkbox','readonly',get_lang('ReadOnly'));
  532. if ($readonly==1)
  533. {
  534. $checked->setChecked(true);
  535. }
  536. }
  537. $form->addElement('submit','submit',get_lang('SaveDocument'));
  538. $defaults['filename'] = $filename;
  539. $defaults['extension'] = $extension;
  540. $defaults['file_path'] = $_GET['file'];
  541. $defaults['commentPath'] = $file;
  542. $defaults['renameTo'] = $file_name;
  543. $defaults['newComment'] = $oldComment;
  544. $form->setDefaults($defaults);
  545. // show templates
  546. $form->addElement('html','<div id="frmModel" style="display:block; height:950px;width:20%; position:absolute; top:135px; left:1px;"></div>');
  547. $form->display();
  548. //Display::display_error_message(get_lang('ReadOnlyFile')); //main API
  549. }
  550. /*
  551. ==============================================================================
  552. DOKEOS FOOTER
  553. ==============================================================================
  554. */
  555. Display::display_footer();
  556. ?>