upload.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614
  1. <?php // $Id: upload.php 22201 2009-07-17 19:57:03Z cfasanando $
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2004-2005 Dokeos S.A.
  6. Copyright (c) 2003 Ghent University (UGent)
  7. Copyright (c) 2001 Universite catholique de Louvain (UCL)
  8. Copyright (c) various contributors
  9. For a full list of contributors, see "credits.txt".
  10. The full license can be read in "license.txt".
  11. This program is free software; you can redistribute it and/or
  12. modify it under the terms of the GNU General Public License
  13. as published by the Free Software Foundation; either version 2
  14. of the License, or (at your option) any later version.
  15. See the GNU General Public License for more details.
  16. Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
  17. ==============================================================================
  18. */
  19. /**
  20. ==============================================================================
  21. * Main script for the documents tool
  22. *
  23. * This script allows the user to manage files and directories on a remote http server.
  24. *
  25. * The user can : - navigate through files and directories.
  26. * - upload a file
  27. * - delete, copy a file or a directory
  28. * - edit properties & content (name, comments, html content)
  29. *
  30. * The script is organised in four sections.
  31. *
  32. * 1) Execute the command called by the user
  33. * Note: somme commands of this section are organised in two steps.
  34. * The script always begins with the second step,
  35. * so it allows to return more easily to the first step.
  36. *
  37. * Note (March 2004) some editing functions (renaming, commenting)
  38. * are moved to a separate page, edit_document.php. This is also
  39. * where xml and other stuff should be added.
  40. *
  41. * 2) Define the directory to display
  42. *
  43. * 3) Read files and directories from the directory defined in part 2
  44. * 4) Display all of that on an HTML page
  45. *
  46. * @todo eliminate code duplication between
  47. * document/document.php, scormdocument.php
  48. *
  49. * @package dokeos.document
  50. ==============================================================================
  51. */
  52. // name of the language file that needs to be included
  53. $language_file = 'document';
  54. // including the global Dokeos file
  55. require_once "../inc/global.inc.php";
  56. // including additional libraries
  57. require_once api_get_path(LIBRARY_PATH) . 'fileUpload.lib.php';
  58. require_once api_get_path(LIBRARY_PATH) . 'document.lib.php';
  59. require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php';
  60. require_once api_get_path(LIBRARY_PATH) . 'formvalidator/FormValidator.class.php';
  61. require_once 'document.inc.php';
  62. // adding extra javascript to the form
  63. $htmlHeadXtra[] = '<script src="../inc/lib/javascript/jquery.js" type="text/javascript" language="javascript"></script>';
  64. $htmlHeadXtra[] = '<script type="text/javascript">
  65. function check_unzip() {
  66. if(document.upload.unzip.checked==true){
  67. document.upload.if_exists[0].disabled=true;
  68. document.upload.if_exists[1].checked=true;
  69. document.upload.if_exists[2].disabled=true;
  70. } else {
  71. document.upload.if_exists[0].checked=true;
  72. document.upload.if_exists[0].disabled=false;
  73. document.upload.if_exists[2].disabled=false;
  74. }
  75. }
  76. function advanced_parameters() {
  77. if(document.getElementById(\'options\').style.display == \'none\') {
  78. document.getElementById(\'options\').style.display = \'block\';
  79. document.getElementById(\'img_plus_and_minus\').innerHTML=\'&nbsp;<img style="vertical-align:middle;" src="../img/div_hide.gif" alt="" />&nbsp;'.get_lang('AdvancedParameters').'\';
  80. } else {
  81. document.getElementById(\'options\').style.display = \'none\';
  82. document.getElementById(\'img_plus_and_minus\').innerHTML=\'&nbsp;<img style="vertical-align:middle;" src="../img/div_show.gif" alt="" />&nbsp;'.get_lang('AdvancedParameters').'\';
  83. }
  84. }
  85. function setFocus(){
  86. $("#title").focus();
  87. }
  88. $(window).load(function () {
  89. setFocus();
  90. });
  91. </script>';
  92. /**
  93. * Obtains the text inside the file with the right parser
  94. */
  95. function get_text_content($doc_path, $doc_mime) {
  96. // TODO: review w$ compatibility
  97. // use usual exec output lines array to store stdout instead of a temp file
  98. // because we need to store it at RAM anyway before index on DokeosIndexer object
  99. $ret_val = NULL;
  100. switch ($doc_mime) {
  101. case 'text/plain':
  102. $handle = fopen($doc_path, "r");
  103. $output = array(fread($handle, filesize($doc_path)));
  104. fclose($handle);
  105. break;
  106. case 'application/pdf':
  107. exec("pdftotext $doc_path -", $output, $ret_val);
  108. break;
  109. case 'application/postscript':
  110. $temp_file = tempnam(sys_get_temp_dir(), 'dokeos');
  111. exec("ps2pdf $doc_path $temp_file", $output, $ret_val);
  112. if ($ret_val !== 0) { // shell fail, probably 127 (command not found)
  113. return FALSE;
  114. }
  115. exec("pdftotext $temp_file -", $output, $ret_val);
  116. unlink($temp_file);
  117. var_dump($output);
  118. break;
  119. case 'application/msword':
  120. exec("catdoc $doc_path", $output, $ret_val);
  121. var_dump($output);
  122. break;
  123. case 'text/html':
  124. exec("html2text $doc_path", $output, $ret_val);
  125. break;
  126. case 'text/rtf':
  127. // note: correct handling of code pages in unrtf
  128. // on debian lenny unrtf v0.19.2 can not, but unrtf v0.20.5 can
  129. exec("unrtf --text $doc_path", $output, $ret_val);
  130. if ($ret_val == 127) { // command not found
  131. return FALSE;
  132. }
  133. // avoid index unrtf comments
  134. if (is_array($output) && count($output)>1) {
  135. $parsed_output = array();
  136. foreach ($output as $line) {
  137. if (!preg_match('/^###/', $line, $matches)) {
  138. if (!empty($line)) {
  139. $parsed_output[] = $line;
  140. }
  141. }
  142. }
  143. $output = $parsed_output;
  144. }
  145. break;
  146. case 'application/vnd.ms-powerpoint':
  147. exec("catppt $doc_path", $output, $ret_val);
  148. break;
  149. case 'application/vnd.ms-excel':
  150. exec("xls2csv -c\" \" $doc_path", $output, $ret_val);
  151. break;
  152. }
  153. $content = '';
  154. if (!is_null($ret_val)) {
  155. if ($ret_val !== 0) { // shell fail, probably 127 (command not found)
  156. return FALSE;
  157. }
  158. }
  159. if (isset($output)) {
  160. foreach ( $output as $line ) {
  161. $content .= $line ."\n";
  162. }
  163. return $content;
  164. }
  165. else {
  166. return FALSE;
  167. }
  168. }
  169. // variables
  170. $is_allowed_to_edit = api_is_allowed_to_edit(null,true);
  171. $courseDir = $_course['path']."/document";
  172. $sys_course_path = api_get_path(SYS_COURSE_PATH);
  173. $base_work_dir = $sys_course_path.$courseDir;
  174. $noPHP_SELF=true;
  175. //what's the current path?
  176. if(isset($_GET['curdirpath']) && $_GET['curdirpath']!='')
  177. {
  178. $path = $_GET['curdirpath'];
  179. }
  180. elseif (isset($_POST['curdirpath']))
  181. {
  182. $path = $_POST['curdirpath'];
  183. }
  184. else
  185. {
  186. $path = '/';
  187. }
  188. //check the path: if the path is not found (no document id), set the path to /
  189. if(!DocumentManager::get_document_id($_course,$path))
  190. {
  191. $path = '/';
  192. }
  193. //this needs cleaning!
  194. if(isset($_SESSION['_gid']) && $_SESSION['_gid']!='') //if the group id is set, check if the user has the right to be here
  195. {
  196. //needed for group related stuff
  197. require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
  198. //get group info
  199. $group_properties = GroupManager::get_group_properties($_SESSION['_gid']);
  200. $noPHP_SELF=true;
  201. if($is_allowed_to_edit || GroupManager::is_user_in_group($_user['user_id'],$_SESSION['_gid'])) //only courseadmin or group members allowed
  202. {
  203. $to_group_id = $_SESSION['_gid'];
  204. $req_gid = '&amp;gidReq='.$_SESSION['_gid'];
  205. $interbreadcrumb[]= array ("url"=>"../group/group_space.php?gidReq=".$_SESSION['_gid'], "name"=> get_lang('GroupSpace'));
  206. }
  207. else
  208. {
  209. api_not_allowed(true);
  210. }
  211. }
  212. elseif($is_allowed_to_edit || is_my_shared_folder($_user['user_id'], $path)) //admin for "regular" upload, no group documents. And check if is my shared folder
  213. {
  214. $to_group_id = 0;
  215. $req_gid = '';
  216. }
  217. else //no course admin and no group member...
  218. {
  219. api_not_allowed(true);
  220. }
  221. //group docs can only be uploaded in the group directory
  222. if($to_group_id!=0 && $path=='/')
  223. {
  224. $path = $group_properties['directory'];
  225. }
  226. //if we want to unzip a file, we need the library
  227. if (isset($_POST['unzip']) && $_POST['unzip'] == 1)
  228. {
  229. require_once api_get_path(LIBRARY_PATH).'pclzip/pclzip.lib.php';
  230. }
  231. // variables
  232. $max_filled_space = DocumentManager::get_course_quota();
  233. // title of the tool
  234. if($to_group_id !=0) //add group name after for group documents
  235. {
  236. $add_group_to_title = ' ('.$group_properties['name'].')';
  237. }
  238. $nameTools = get_lang('UplUploadDocument').$add_group_to_title;
  239. // breadcrumbs
  240. $interbreadcrumb[] = array('url' =>'./document.php?curdirpath='.urlencode($path).$req_gid, 'name'=> get_lang('Documents'));
  241. // display the header
  242. Display::display_header($nameTools, 'Doc');
  243. /*
  244. -----------------------------------------------------------
  245. Here we do all the work
  246. -----------------------------------------------------------
  247. */
  248. //user has submitted a file
  249. if(isset($_FILES['user_upload']))
  250. {
  251. //echo("<pre>");
  252. //print_r($_FILES['user_upload']);
  253. //echo("</pre>");
  254. $upload_ok = process_uploaded_file($_FILES['user_upload']);
  255. if($upload_ok)
  256. {
  257. //file got on the server without problems, now process it
  258. $new_path = handle_uploaded_document($_course, $_FILES['user_upload'],$base_work_dir,$_POST['curdirpath'],$_user['user_id'],$to_group_id,$to_user_id,$max_filled_space,$_POST['unzip'],$_POST['if_exists']);
  259. $new_comment = isset($_POST['comment']) ? trim($_POST['comment']) : '';
  260. $new_title = isset($_POST['title']) ? trim($_POST['title']) : '';
  261. if ($new_path && ($new_comment || $new_title))
  262. if (($docid = DocumentManager::get_document_id($_course, $new_path)))
  263. {
  264. $table_document = Database::get_course_table(TABLE_DOCUMENT);
  265. $ct = '';
  266. if ($new_comment) $ct .= ", comment='$new_comment'";
  267. if ($new_title) $ct .= ", title='$new_title'";
  268. Database::query("UPDATE $table_document SET" . substr($ct, 1) .
  269. " WHERE id = '$docid'", __FILE__, __LINE__);
  270. }
  271. if ( (api_get_setting('search_enabled')=='true') && ($docid = DocumentManager::get_document_id($_course, $new_path))) {
  272. $table_document = Database::get_course_table(TABLE_DOCUMENT);
  273. $result = Database::query("SELECT * FROM $table_document WHERE id = '$docid' LIMIT 1", __FILE__, __LINE__);
  274. if (Database::num_rows($result) == 1) {
  275. $row = Database::fetch_array($result);
  276. $doc_path = api_get_path(SYS_COURSE_PATH) . $courseDir. $row['path'];
  277. //TODO: mime_content_type is deprecated, fileinfo php extension is enabled by default as of PHP 5.3.0
  278. // now versions of PHP on Debian testing(5.2.6-5) and Ubuntu(5.2.6-2ubuntu) are lower, so wait for a while
  279. $doc_mime = mime_content_type($doc_path);
  280. //echo $doc_mime;
  281. //TODO: more mime types
  282. $allowed_mime_types = array('text/plain', 'application/pdf', 'application/postscript', 'application/msword', 'text/html', 'text/rtf', 'application/vnd.ms-powerpoint', 'application/vnd.ms-excel');
  283. // mime_content_type does not detect correctly some formats that are going to be supported for index, so an extensions array is used by the moment
  284. if (empty($doc_mime)) {
  285. $allowed_extensions = array('ppt', 'pps', 'xls');
  286. $extensions = preg_split("/[\/\\.]/", $doc_path) ;
  287. $doc_ext = strtolower($extensions[count($extensions)-1]);
  288. if (in_array($doc_ext, $allowed_extensions)) {
  289. switch ($doc_ext) {
  290. case 'ppt':
  291. case 'pps':
  292. $doc_mime = 'application/vnd.ms-powerpoint';
  293. break;
  294. case 'xls':
  295. $doc_mime = 'application/vnd.ms-excel';
  296. break;
  297. }
  298. }
  299. }
  300. if (in_array($doc_mime, $allowed_mime_types) && isset($_POST['index_document']) && $_POST['index_document']) {
  301. $file_title = $row['title'];
  302. $file_content = get_text_content($doc_path, $doc_mime);
  303. $courseid = api_get_course_id();
  304. isset($_POST['language'])? $lang=Database::escape_string($_POST['language']): $lang = 'english';
  305. require_once api_get_path(LIBRARY_PATH).'search/DokeosIndexer.class.php';
  306. require_once api_get_path(LIBRARY_PATH).'search/IndexableChunk.class.php';
  307. $ic_slide = new IndexableChunk();
  308. $ic_slide->addValue("title", $file_title);
  309. $ic_slide->addCourseId($courseid);
  310. $ic_slide->addToolId(TOOL_DOCUMENT);
  311. $xapian_data = array(
  312. SE_COURSE_ID => $courseid,
  313. SE_TOOL_ID => TOOL_DOCUMENT,
  314. SE_DATA => array('doc_id' => (int)$docid),
  315. SE_USER => (int)api_get_user_id(),
  316. );
  317. $ic_slide->xapian_data = serialize($xapian_data);
  318. $di = new DokeosIndexer();
  319. $di->connectDb(NULL, NULL, $lang);
  320. $specific_fields = get_specific_field_list();
  321. // process different depending on what to do if file exists
  322. /**
  323. * FIXME: Find a way to really verify if the file had been
  324. * overwriten. Now all work is done at
  325. * handle_uploaded_document() and it's difficult to verify it
  326. */
  327. if (!empty($_POST['if_exists']) && $_POST['if_exists'] == 'overwrite') {
  328. // overwrite the file on search engine
  329. // actually, it consists on delete terms from db, insert new ones, create a new search engine document, and remove the old one
  330. // get search_did
  331. $tbl_se_ref = Database::get_main_table(TABLE_MAIN_SEARCH_ENGINE_REF);
  332. $sql = 'SELECT * FROM %s WHERE course_code=\'%s\' AND tool_id=\'%s\' AND ref_id_high_level=%s LIMIT 1';
  333. $sql = sprintf($sql, $tbl_se_ref, $courseid, TOOL_DOCUMENT, $docid);
  334. $res = Database::query($sql, __FILE__, __LINE__);
  335. if (Database::num_rows($res) > 0) {
  336. $se_ref = Database::fetch_array($res);
  337. $di->remove_document((int)$se_ref['search_did']);
  338. $all_specific_terms = '';
  339. foreach ($specific_fields as $specific_field) {
  340. delete_all_specific_field_value($courseid, $specific_field['id'], TOOL_DOCUMENT, $docid);
  341. //update search engine
  342. $sterms = trim($_REQUEST[$specific_field['code']]);
  343. $all_specific_terms .= ' '. $sterms;
  344. $sterms = explode(',', $sterms);
  345. foreach ($sterms as $sterm) {
  346. $sterm = trim($sterm);
  347. if (!empty($sterm)) {
  348. $ic_slide->addTerm($sterm, $specific_field['code']);
  349. add_specific_field_value($specific_field['id'], $courseid, TOOL_DOCUMENT, $docid, $value);
  350. }
  351. }
  352. }
  353. // add terms also to content to make terms findable by probabilistic search
  354. $file_content = $all_specific_terms .' '. $file_content;
  355. $ic_slide->addValue("content", $file_content);
  356. $di->addChunk($ic_slide);
  357. //index and return a new search engine document id
  358. $did = $di->index();
  359. if ($did) {
  360. // update the search_did on db
  361. $tbl_se_ref = Database::get_main_table(TABLE_MAIN_SEARCH_ENGINE_REF);
  362. $sql = 'UPDATE %s SET search_did=%d WHERE id=%d LIMIT 1';
  363. $sql = sprintf($sql, $tbl_se_ref, (int)$did, (int)$se_ref['id']);
  364. Database::query($sql,__FILE__,__LINE__);
  365. }
  366. }
  367. }
  368. else {
  369. // add all terms
  370. $all_specific_terms = '';
  371. foreach ($specific_fields as $specific_field) {
  372. if (isset($_REQUEST[$specific_field['code']])) {
  373. $sterms = trim($_REQUEST[$specific_field['code']]);
  374. $all_specific_terms .= ' '. $sterms;
  375. if (!empty($sterms)) {
  376. $sterms = explode(',', $sterms);
  377. foreach ($sterms as $sterm) {
  378. $ic_slide->addTerm(trim($sterm), $specific_field['code']);
  379. add_specific_field_value($specific_field['id'], $courseid, TOOL_DOCUMENT, $docid, $sterm);
  380. }
  381. }
  382. }
  383. }
  384. // add terms also to content to make terms findable by probabilistic search
  385. $file_content = $all_specific_terms .' '. $file_content;
  386. $ic_slide->addValue("content", $file_content);
  387. $di->addChunk($ic_slide);
  388. //index and return search engine document id
  389. $did = $di->index();
  390. if ($did) {
  391. // save it to db
  392. $tbl_se_ref = Database::get_main_table(TABLE_MAIN_SEARCH_ENGINE_REF);
  393. $sql = 'INSERT INTO %s (id, course_code, tool_id, ref_id_high_level, search_did)
  394. VALUES (NULL , \'%s\', \'%s\', %s, %s)';
  395. $sql = sprintf($sql, $tbl_se_ref, $courseid, TOOL_DOCUMENT, $docid, $did);
  396. Database::query($sql,__FILE__,__LINE__);
  397. }
  398. }
  399. }
  400. }
  401. }
  402. //check for missing images in html files
  403. $missing_files = check_for_missing_files($base_work_dir.$new_path);
  404. if($missing_files)
  405. {
  406. //show a form to upload the missing files
  407. Display::display_normal_message(build_missing_files_form($missing_files,$_POST['curdirpath'],$_FILES['user_upload']['name']),false);
  408. }
  409. }
  410. }
  411. //missing images are submitted
  412. if(isset($_POST['submit_image']))
  413. {
  414. $number_of_uploaded_images = count($_FILES['img_file']['name']);
  415. //if images are uploaded
  416. if ($number_of_uploaded_images > 0)
  417. {
  418. //we could also create a function for this, I'm not sure...
  419. //create a directory for the missing files
  420. $img_directory = str_replace('.','_',$_POST['related_file']."_files");
  421. $missing_files_dir = create_unexisting_directory($_course,$_user['user_id'],$to_group_id,$to_user_id,$base_work_dir,$img_directory);
  422. //put the uploaded files in the new directory and get the paths
  423. $paths_to_replace_in_file = move_uploaded_file_collection_into_directory($_course, $_FILES['img_file'],$base_work_dir,$missing_files_dir,$_user['user_id'],$to_group_id,$to_user_id,$max_filled_space);
  424. //open the html file and replace the paths
  425. replace_img_path_in_html_file($_POST['img_file_path'],$paths_to_replace_in_file,$base_work_dir.$_POST['related_file']);
  426. //update parent folders
  427. item_property_update_on_folder($_course,$_POST['curdirpath'],$_user['user_id']);
  428. }
  429. }
  430. //they want to create a directory
  431. if(isset($_POST['create_dir']) && $_POST['dirname']!='')
  432. {
  433. $added_slash = ($path=='/')?'':'/';
  434. $dir_name = $path.$added_slash.replace_dangerous_char($_POST['dirname']);
  435. $created_dir = create_unexisting_directory($_course,$_user['user_id'],$to_group_id,$to_user_id,$base_work_dir,$dir_name,$_POST['dirname']);
  436. if($created_dir)
  437. {
  438. Display::display_confirmation_message(get_lang('DirCr'),false);
  439. $path = $created_dir;
  440. }
  441. else
  442. {
  443. display_error(get_lang('CannotCreateDir'));
  444. }
  445. }
  446. //tracking not needed here?
  447. //event_access_tool(TOOL_DOCUMENT);
  448. /*============================================================================*/
  449. ?>
  450. <?php
  451. //=======================================//
  452. //they want to create a new directory//
  453. //=======================================//
  454. if(isset($_GET['createdir']))
  455. {
  456. //create the form that asks for the directory name
  457. $new_folder_text = '<form action="'.api_get_self().'" method="POST">';
  458. $new_folder_text .= '<input type="hidden" name="curdirpath" value="'.$path.'"/>';
  459. $new_folder_text .= get_lang('NewDir') .' ';
  460. $new_folder_text .= '<input type="text" name="dirname"/>';
  461. $new_folder_text .= '<button type="submit" class="save" name="create_dir">'.get_lang('CreateFolder').'</button>';
  462. $new_folder_text .= '</form>';
  463. //show the form
  464. //Display::display_normal_message($new_folder_text, false);
  465. echo create_dir_form();
  466. }
  467. // actions
  468. echo '<div class="actions">';
  469. // link back to the documents overview
  470. echo '<a href="document.php?curdirpath='.$path.'">'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('DocumentsOverview')).get_lang('BackTo').' '.get_lang('DocumentsOverview').'</a>';
  471. // link to create a folder
  472. if(!isset($_GET['createdir']) && !is_my_shared_folder($_user['user_id'], $path))
  473. {
  474. echo '<a href="'.api_get_self().'?path='.$path.'&amp;createdir=1">'.Display::return_icon('folder_new.gif', get_lang('CreateDir')).get_lang('CreateDir').'</a>';
  475. }
  476. echo '</div>';
  477. //form to select directory
  478. $folders = DocumentManager::get_all_document_folders($_course,$to_group_id,$is_allowed_to_edit);
  479. echo(build_directory_selector($folders,$path,$group_properties['directory']));
  480. ?>
  481. <!-- start upload form -->
  482. <?php
  483. $form = new FormValidator('upload','POST',api_get_self(),'','enctype="multipart/form-data"');
  484. // form title
  485. $form->addElement('header', '', $nameTools);
  486. $form->addElement('hidden','curdirpath',$path);
  487. $form->addElement('file','user_upload',get_lang('File'),'id="user_upload" size="45"');
  488. if(api_get_setting('use_document_title')=='true')
  489. {
  490. $form->addElement('text','title',get_lang('Title'),array('size'=>'20','style' => 'width:300px','id' => 'title'));
  491. $form->addElement('textarea','comment',get_lang('Comment'),'wrap="virtual" style="width:300px;"');
  492. }
  493. //Advanced parameters
  494. $form -> addElement('html','<div class="row">
  495. <div class="label">&nbsp;</div>
  496. <div class="formw">
  497. <a href="javascript://" onclick=" return advanced_parameters()"><span id="img_plus_and_minus"><div style="vertical-align:top;" ><img style="vertical-align:middle;" src="../img/div_show.gif" alt="" />&nbsp;'.get_lang('AdvancedParameters').'</div></span></a>
  498. </div>
  499. </div>');
  500. $form -> addElement('html','<div id="options" style="display:none">');
  501. //check box options
  502. $form->addElement('checkbox','unzip',get_lang('Options'),get_lang('Uncompress'),'onclick="check_unzip()" value="1"');
  503. if(api_get_setting('search_enabled')=='true')
  504. {
  505. //TODO: include language file
  506. $supported_formats = 'Supported formats for index: Text plain, PDF, Postscript, MS Word, HTML, RTF, MS Power Point';
  507. $form -> addElement ('checkbox', 'index_document','', get_lang('SearchFeatureDoIndexDocument') . '<div style="font-size: 80%" >'. $supported_formats .'</div>');
  508. $form -> addElement ('html','<br /><div class="row">');
  509. $form -> addElement ('html', '<div class="label">'. get_lang('SearchFeatureDocumentLanguage') .'</div>');
  510. $form -> addElement ('html', '<div class="formw">'. api_get_languages_combo() .'</div>');
  511. $form -> addElement ('html','</div><div class="sub-form">');
  512. $specific_fields = get_specific_field_list();
  513. foreach ($specific_fields as $specific_field) {
  514. $form -> addElement ('text', $specific_field['code'], $specific_field['name'].' : ');
  515. }
  516. $form -> addElement ('html','</div>');
  517. }
  518. $form->addElement('radio', 'if_exists', get_lang('UplWhatIfFileExists'), get_lang('UplDoNothing'), 'nothing');
  519. $form->addElement('radio', 'if_exists', '', get_lang('UplOverwriteLong'), 'overwrite');
  520. $form->addElement('radio', 'if_exists', '', get_lang('UplRenameLong'), 'rename');
  521. //close the java script and avoid the footer up
  522. $form -> addElement('html','</div>');
  523. //button send document
  524. $form->addElement('style_submit_button', 'submitDocument', get_lang('SendDocument'),'class="upload"');
  525. $form->add_real_progress_bar('DocumentUpload','user_upload');
  526. $defaults = array('index_document'=>'checked="checked"');
  527. $form->setDefaults($defaults);
  528. $form->display();
  529. ?>
  530. <!-- end upload form -->
  531. <?php
  532. // footer
  533. Display::display_footer();
  534. ?>