/** * Get descriptive file type * * @return string */ public function getFileType() { return File::get_file_type($this->getName()); }
/** * Safely encodes the File object with all standard fields required * by the front end * * @param File|AssetContainer $file Object which contains a file * @return array Array encoded list of file attributes */ protected function encodeFileAttributes(AssetContainer $file) { // Collect all output data. $customised = $this->customiseFile($file); return array('id' => $file->ID, 'name' => basename($file->getFilename()), 'url' => $file->getURL(), 'thumbnail_url' => $customised->UploadFieldThumbnailURL, 'edit_url' => $customised->UploadFieldEditLink, 'size' => $file->getAbsoluteSize(), 'type' => File::get_file_type($file->getFilename()), 'buttons' => (string) $customised->UploadFieldFileButtons, 'fieldname' => $this->getName()); }
/** * Safely encodes the File object with all standard fields required * by the front end * * @param string $filename * @param string $hash * @param string $variant * @return array Encoded list of file attributes */ protected function encodeAssetAttributes($filename, $hash, $variant) { // Force regeneration of file thumbnail for this tuple (without saving into db) $object = DBFile::create(); $object->setValue(array('Filename' => $filename, 'Hash' => $hash, 'Variant' => $variant)); return array('filename' => $filename, 'hash' => $hash, 'variant' => $variant, 'name' => $object->getBasename(), 'url' => $object->getURL(), 'thumbnail_url' => $object->ThumbnailURL($this->getPreviewMaxWidth(), $this->getPreviewMaxHeight()), 'size' => $object->getAbsoluteSize(), 'type' => File::get_file_type($object->getFilename()), 'buttons' => (string) $this->renderWith($this->getTemplateFileButtons()), 'fieldname' => $this->getName()); }