📄 document.lib.php
字号:
<?php/*============================================================================== Dokeos - elearning and course management software Copyright (c) 2004-2008 Dokeos SPRL Copyright (c) 2003 Ghent University (UGent) Copyright (c) Roan Embrechts, Vrije Universiteit Brussel For a full list of contributors, see "credits.txt". The full license can be read in "license.txt". This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. See the GNU General Public License for more details. Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium Mail: info@dokeos.com==============================================================================*//**============================================================================== * This is the document library for Dokeos.* It is / will be used to provide a service layer to all document-using tools.* and eliminate code duplication fro group documents, scorm documents, main documents.* Include/require it in your code to use its functionality.** @version 1.1, January 2005* @package dokeos.library============================================================================== *//*============================================================================== DOCUMENTATION use the functions like this: DocumentManager::get_course_quota()============================================================================== *//*============================================================================== CONSTANTS============================================================================== */define("DISK_QUOTA_FIELD", "disk_quota"); //name of the database field/** default quota for the course documents folder */define("DEFAULT_DOCUMENT_QUOTA", get_setting('default_document_quotum'));/*============================================================================== VARIABLES============================================================================== */$sys_course_path = api_get_path(SYS_COURSE_PATH);$baseServDir = api_get_path(SYS_PATH);$baseServUrl = $_configuration['url_append']."/";$baseWorkDir = $sys_course_path.(!empty($courseDir)?$courseDir:'');/*============================================================================== DocumentManager CLASS the class and its functions============================================================================== *//** * @package dokeos.library */class DocumentManager{ /** * @return the document folder quuta of the current course, in bytes * @todo eliminate globals */ function get_course_quota() { global $_course, $maxFilledSpace; $course_code = $_course['sysCode']; $course_table = Database :: get_main_table(TABLE_MAIN_COURSE); $sql_query = "SELECT `".DISK_QUOTA_FIELD."` FROM $course_table WHERE `code` = '$course_code'"; $sql_result = api_sql_query($sql_query, __FILE__, __LINE__); $result = Database::fetch_array($sql_result); $course_quota = $result[DISK_QUOTA_FIELD]; if ($course_quota == NULL) { //course table entry for quota was null //use default value $course_quota = DEFAULT_DOCUMENT_QUOTA; } return $course_quota; } /** * Get the content type of a file by checking the extension * We could use mime_content_type() with php-versions > 4.3, * but this doesn't work as it should on Windows installations * * @param string $filename or boolean TRUE to return complete array * @author ? first version * @author Bert Vanderkimpen * */ function file_get_mime_type($filename) { //all mime types in an array (from 1.6, this is the authorative source) //please keep this alphabetical if you add something to this list!!! $mime_types=array( "ai" => "application/postscript", "aif" => "audio/x-aiff", "aifc" => "audio/x-aiff", "aiff" => "audio/x-aiff", "asf" => "video/x-ms-asf", "asc" => "text/plain", "au" => "audio/basic", "avi" => "video/x-msvideo", "bcpio" => "application/x-bcpio", "bin" => "application/octet-stream", "bmp" => "image/bmp", "cdf" => "application/x-netcdf", "class" => "application/octet-stream", "cpio" => "application/x-cpio", "cpt" => "application/mac-compactpro", "csh" => "application/x-csh", "css" => "text/css", "dcr" => "application/x-director", "dir" => "application/x-director", "djv" => "image/vnd.djvu", "djvu" => "image/vnd.djvu", "dll" => "application/octet-stream", "dmg" => "application/x-diskcopy", "dms" => "application/octet-stream", "doc" => "application/msword", "dvi" => "application/x-dvi", "dwg" => "application/vnd.dwg", "dxf" => "application/vnd.dxf", "dxr" => "application/x-director", "eps" => "application/postscript", "etx" => "text/x-setext", "exe" => "application/octet-stream", "ez" => "application/andrew-inset", "gif" => "image/gif", "gtar" => "application/x-gtar", "gz" => "application/x-gzip", "hdf" => "application/x-hdf", "hqx" => "application/mac-binhex40", "htm" => "text/html", "html" => "text/html", "ice" => "x-conference-xcooltalk", "ief" => "image/ief", "iges" => "model/iges", "igs" => "model/iges", "jar" => "application/java-archiver", "jpe" => "image/jpeg", "jpeg" => "image/jpeg", "jpg" => "image/jpeg", "js" => "application/x-javascript", "kar" => "audio/midi", "latex" => "application/x-latex", "lha" => "application/octet-stream", "lzh" => "application/octet-stream", "m1a" => "audio/mpeg", "m2a" => "audio/mpeg", "m3u" => "audio/x-mpegurl", "man" => "application/x-troff-man", "me" => "application/x-troff-me", "mesh" => "model/mesh", "mid" => "audio/midi", "midi" => "audio/midi", "mov" => "video/quicktime", "movie" => "video/x-sgi-movie", "mp2" => "audio/mpeg", "mp3" => "audio/mpeg", "mp4" => "video/mpeg4-generic", "mpa" => "audio/mpeg", "mpe" => "video/mpeg", "mpeg" => "video/mpeg", "mpg" => "video/mpeg", "mpga" => "audio/mpeg", "ms" => "application/x-troff-ms", "msh" => "model/mesh", "mxu" => "video/vnd.mpegurl", "nc" => "application/x-netcdf", "oda" => "application/oda", "pbm" => "image/x-portable-bitmap", "pct" => "image/pict", "pdb" => "chemical/x-pdb", "pdf" => "application/pdf", "pgm" => "image/x-portable-graymap", "pgn" => "application/x-chess-pgn", "pict" => "image/pict", "png" => "image/png", "pnm" => "image/x-portable-anymap", "ppm" => "image/x-portable-pixmap", "ppt" => "application/vnd.ms-powerpoint", "pps" => "application/vnd.ms-powerpoint", "ps" => "application/postscript", "qt" => "video/quicktime", "ra" => "audio/x-realaudio", "ram" => "audio/x-pn-realaudio", "rar" => "image/x-rar-compressed", "ras" => "image/x-cmu-raster", "rgb" => "image/x-rgb", "rm" => "audio/x-pn-realaudio", "roff" => "application/x-troff", "rpm" => "audio/x-pn-realaudio-plugin", "rtf" => "text/rtf", "rtx" => "text/richtext", "sgm" => "text/sgml", "sgml" => "text/sgml", "sh" => "application/x-sh", "shar" => "application/x-shar", "silo" => "model/mesh", "sib" => "application/X-Sibelius-Score", "sit" => "application/x-stuffit", "skd" => "application/x-koan", "skm" => "application/x-koan", "skp" => "application/x-koan", "skt" => "application/x-koan", "smi" => "application/smil", "smil" => "application/smil", "snd" => "audio/basic", "so" => "application/octet-stream", "spl" => "application/x-futuresplash", "src" => "application/x-wais-source", "sv4cpio" => "application/x-sv4cpio", "sv4crc" => "application/x-sv4crc", "svf" => "application/vnd.svf", "swf" => "application/x-shockwave-flash", "sxc" => "application/vnd.sun.xml.calc", "sxi" => "application/vnd.sun.xml.impress", "sxw" => "application/vnd.sun.xml.writer", "t" => "application/x-troff", "tar" => "application/x-tar", "tcl" => "application/x-tcl", "tex" => "application/x-tex", "texi" => "application/x-texinfo", "texinfo" => "application/x-texinfo", "tga" => "image/x-targa", "tif" => "image/tif", "tiff" => "image/tiff", "tr" => "application/x-troff", "tsv" => "text/tab-seperated-values", "txt" => "text/plain", "ustar" => "application/x-ustar", "vcd" => "application/x-cdlink", "vrml" => "model/vrml", "wav" => "audio/x-wav", "wbmp" => "image/vnd.wap.wbmp", "wbxml" => "application/vnd.wap.wbxml", "wml" => "text/vnd.wap.wml", "wmlc" => "application/vnd.wap.wmlc", "wmls" => "text/vnd.wap.wmlscript", "wmlsc" => "application/vnd.wap.wmlscriptc", "wma" => "video/x-ms-wma", "wmv" => "audio/x-ms-wmv", "wrl" => "model/vrml", "xbm" => "image/x-xbitmap", "xht" => "application/xhtml+xml", "xhtml" => "application/xhtml+xml", "xls" => "application/vnd.ms-excel", "xml" => "text/xml", "xpm" => "image/x-xpixmap", "xsl" => "text/xml", "xwd" => "image/x-windowdump", "xyz" => "chemical/x-xyz", "zip" => "application/zip" ); if ($filename === TRUE) { return $mime_types; } //get the extension of the file $extension = explode('.', $filename); //$filename will be an array if a . was found if (is_array($extension)) { $extension = (strtolower($extension[sizeof($extension) - 1])); } //file without extension else { $extension = 'empty';
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -