public static function get() { if (!self::$instance) { self::$instance = new self(); } return self::$instance; }
/** * Creates a docman file */ function createDocmanFile($sessionKey, $group_id, $parent_id, $title, $description, $ordering, $status, $obsolescence_date, $permissions, $metadata, $file_size, $file_name, $mime_type, $content, $chunk_offset, $chunk_size, $author, $date, $owner, $create_date, $update_date) { $content = base64_decode($content); //ignore mime type coming from the client, guess it instead //Write the content of the file into a temporary file //The best accurate results are got when the file has the real extension, therefore use the filename $tmp = tempnam(ForgeConfig::get('tmp_dir'), 'Mime-detect'); $tmpname = $tmp . '-' . basename($file_name); file_put_contents($tmpname, $content); $mime_type = MIME::instance()->type($tmpname); //remove both files created by tempnam() and file_put_contents() unlink($tmp); unlink($tmpname); $extraParams = array('chunk_offset' => $chunk_offset, 'chunk_size' => $chunk_size, 'file_size' => $file_size, 'file_name' => $file_name, 'mime_type' => $mime_type, 'upload_content' => $content, 'date' => $date, 'author' => _getUserIdByUserName($author)); return _createDocmanDocument($sessionKey, $group_id, $parent_id, $title, $description, $ordering, $status, $obsolescence_date, PLUGIN_DOCMAN_ITEM_TYPE_FILE, $permissions, $metadata, $owner, $create_date, $update_date, $extraParams); }
/** * Returns mime-type of the file * * @return String * * @see plugins/webdav/lib/Sabre/DAV/Sabre_DAV_File#getContentType() */ function getContentType() { if (file_exists($this->getFileLocation()) && filesize($this->getFileLocation())) { $mime = MIME::instance(); return $mime->type($this->getFileLocation()); } }