This repository has been archived by the owner on Jan 23, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed a Bug that prevents the Plugin from Working with PHP7 (thanks t…
…o splitbrain). Implemented RRD binding mode to create SVG files showing values from the RRD database.
- Loading branch information
1 parent
073cd81
commit 5332dfa
Showing
7 changed files
with
437 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
/** | ||
* RRDGraph Plugin: Static class for mapping file extensions to content type | ||
* | ||
* @author Daniel Goß <[email protected]> | ||
* @license MIT | ||
*/ | ||
class ContentType | ||
{ | ||
/** | ||
* Contains an associative array mapping file extensions (key) to content type strings (value). | ||
* @var Array | ||
*/ | ||
const contentTypes = array( | ||
"png" => "image/png", | ||
"svg" => "image/svg+xml" | ||
); | ||
|
||
/** | ||
* Returns the content type to use for transmitting the given file name. The content type is | ||
* solely detected by the file extension. | ||
* @param String $fileName The file name to detect the content type for. | ||
* @return String The content type to use or null if the given file extension is not in the list of known file extensions. | ||
*/ | ||
public static function get_content_type($fileName) { | ||
$extension = strtolower(ltrim(strrchr($fileName, '.'), '.')); | ||
|
||
if (array_key_exists($extension, self::contentTypes)) { | ||
return self::contentTypes[$extension]; | ||
} else { | ||
return null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.