123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317 |
- <?php
- $language_file = 'document';
- include_once('global.inc.php');
- include(api_get_path(SYS_CODE_PATH).'document/document.inc.php');
- if(!$is_in_admin){
- api_protect_course_script();
- }
- if(isset($_GET['id_session']))
- $_SESSION['id_session'] = $_GET['id_session'];
- $htmlHeadXtra[] =
- "<script type=\"text/javascript\">
- function confirmation (name)
- {
- if (confirm(\" ". get_lang("AreYouSureToDelete") ." \"+ name + \" ?\"))
- {return true;}
- else
- {return false;}
- }
- </script>";
- $sType = isset($sType)?$sType:"Image";
- if($sType=="MP3") $sType="audio";
- $sType = strtolower($sType);
- $course_dir = $_course['path']."/document/".$sType;
- $sys_course_path = api_get_path(SYS_COURSE_PATH);
- $base_work_dir = $sys_course_path.$course_dir;
- $http_www = api_get_path('WEB_COURSE_PATH').$_course['path'].'/document/'.$sType;
- $dbl_click_id = 0;
- $is_allowed_to_edit = api_is_allowed_to_edit();
- $to_group_id = 0;
- $req_gid = '';
- include_once(api_get_path(LIBRARY_PATH) . 'fileDisplay.lib.php');
- include_once(api_get_path(LIBRARY_PATH) . 'events.lib.inc.php');
- include_once(api_get_path(LIBRARY_PATH) . 'document.lib.php');
- include_once(api_get_path(LIBRARY_PATH) . 'tablesort.lib.php');
- $course_quota = DocumentManager::get_course_quota();
- $tool_name = get_lang("Doc");
- ?>
- <style type="text/css" media="screen, projection">
- @import "<?php echo api_get_path(WEB_CODE_PATH); ?>css/default/default.css";
- </style>
- <?php
- if(api_get_setting('stylesheets')<>'')
- {
- ?>
- <style type="text/css" media="screen, projection">
- @import "<?php echo api_get_path(WEB_CODE_PATH); ?>css/<?php echo api_get_setting('stylesheets');?>/default.css";
- </style>
- <?php
- }
- $is_allowed_to_edit = api_is_allowed_to_edit();
- if($is_allowed_to_edit)
- {
-
- if ( isset($_GET['delete']) )
- {
- include_once(api_get_path(LIBRARY_PATH) . 'fileManage.lib.php');
- if(DocumentManager::delete_document($_course,$_GET['delete'],$base_work_dir))
- {
- Display::display_normal_message(get_lang('DocDeleted'));
- }
- else
- {
- Display::display_normal_message(get_lang('DocDeleteError'));
- }
- }
- if( isset($_POST['action']))
- {
- switch($_POST['action'])
- {
- case 'delete':
- foreach($_POST['path'] as $index => $path)
- {
- DocumentManager::delete_document($_course,$path,$base_work_dir);
- }
- Display::display_normal_message(get_lang('DocDeleted'));
- break;
- }
- }
- }
- $docs_and_folders = getlist ($base_work_dir.'/');
- ?>
- <?php
- if($docs_and_folders)
- {
-
-
-
-
-
-
- $use_document_title = get_setting('use_document_title');
-
- $sortable_data = array();
- while (list ($key, $id) = each($docs_and_folders))
- {
- $row = array ();
-
-
- $invisibility_span_open = ($id['visibility']==0)?'<span class="invisible">':'';
- $invisibility_span_close = ($id['visibility']==0)?'</span>':'';
-
- $size = $id['filetype']=='folder' ? get_total_folder_size($id['path'],$is_allowed_to_edit) : $id[size];
-
- if ($use_document_title=='true' AND $id['title']<>'')
- {
- $document_name=$id['title'];
- }
- else
- {
- $document_name=basename($id['path']);
- }
-
-
-
-
- $row[]= build_document_icon_tag($id['filetype'],$id['path']);
-
- $row[] = '<a href="#" onclick="OpenFile(\''.$http_www.'/'.$id['title'].'\');return false;">'.$id['title'].'</a>';
-
-
- $display_size = format_file_size($size);
- $row[] = '<span style="display:none;">'.$size.'</span>'.$invisibility_span_open.$display_size.$invisibility_span_close;
-
- $display_date = format_date(strtotime($id['lastedit_date']));
- $row[] = '<span style="display:none;">'.$id['lastedit_date'].'</span>'.$invisibility_span_open.$display_date.$invisibility_span_close;
-
-
- $sortable_data[] = $row;
- }
-
- }
- else
- {
- $sortable_data=array();
-
- }
- $table = new SortableTableFromArray($sortable_data,4,10);
- $query_vars['curdirpath'] = $curdirpath;
- if(isset($_SESSION['_gid']))
- {
- $query_vars['gidReq'] = $_SESSION['_gid'];
- }
- $table->set_additional_parameters($query_vars);
- $column = 0;
- $table->set_header($column++,get_lang('Type'));
- $table->set_header($column++,get_lang('Title'));
- $table->set_header($column++,get_lang('Size'));
- $table->set_header($column++,get_lang('Date'));
- $table->display();
- echo $table_footer;
- function getlist ($directory) {
-
- if ($d = @opendir($directory)) {
- while (($filename = @readdir($d)) !== false) {
- $path = $directory . $filename;
- if ($filename != '..')
- if ($filename != '.')
- {
- $file = array(
- "lastedit_date" =>date ("Y-m-d H:i:s", filemtime($path)),
- "visibility" => 1,
- "path" => $path,
- "title" => basename($path),
- "filetype" => filetype($path),
- "size" => filesize ($path)
- );
- $files[] = $file;
- }
- }
- return $files;
- }
- else
- {
- return false;
- }
- }
- ?>
- <SCRIPT LANGUAGE="JavaScript">
- <!--
- function OpenFile( fileUrl )
- {
- SetUrl( fileUrl ) ;
- window.close() ;
- }
- </SCRIPT>
|