getFilename(), PATHINFO_EXTENSION); // list all file extensions which are supported to display them by HTML code $picture_extensions = array('gif', 'png', 'jpg', 'jpeg', 'bmp', 'svg', 'tif'); return in_array(strtolower($extension), $picture_extensions, true); } /******************************************************************************** * * Getters * *********************************************************************************/ /** * Get the element, associated with this Attachement (for example a "Part" object). * * @return DBElement The associated Element. */ public function getElement(): ?AttachmentContainingDBElement { return $this->element; } /** * Checks if the file in this attachement is existing. This works for files on the HDD, and for URLs * (it's not checked if the ressource behind the URL is really existing). * * @return bool True if the file is existing. */ public function isFileExisting(): bool { return file_exists($this->getFilename()) || isURL($this->getFilename()); } /** * Get the filename, relative to %BASE%. * * @return string */ public function getFilename(): string { return $this->filename; //return str_replace('%BASE%', BASE, $this->filename); } /** * Get the show_in_table attribute. * * @return bool true means, this attachement will be listed in the "Attachements" column of the HTML tables * false means, this attachement won't be listed in the "Attachements" column of the HTML tables */ public function getShowInTable(): bool { return (bool) $this->show_in_table; } /** * Get the type of this attachement. * * @return AttachmentType the type of this attachement * * @throws Exception if there was an error */ public function getType(): AttachmentType { //TODO throw new NotImplementedException('Not implemented yet!'); } /** * Returns the ID as an string, defined by the element class. * This should have a form like P000014, for a part with ID 14. * * @return string The ID as a string; */ public function getIDString(): string { return 'A'.sprintf('%09d', $this->getID()); } /***************************************************************************************************** * Setters ****************************************************************************************************/ /** * @param bool $show_in_table * * @return self */ public function setShowInTable(bool $show_in_table): self { $this->show_in_table = $show_in_table; return $this; } }