SVG Dispatch: allow for referencing material design icons
A SVG not found in the template or in the local media storage will now be looked up in the Material Design Icon library (via a cached HTTP request to the rawgit CDN).
This commit is contained in:
parent
09aeb71c54
commit
c24a2e1e52
1 changed files with 12 additions and 3 deletions
11
svg.php
11
svg.php
|
|
@ -86,6 +86,7 @@ class SVG {
|
|||
|
||||
const IMGDIR = __DIR__ . '/img/';
|
||||
const BACKGROUNDCLASS = 'sprintdoc-background';
|
||||
const CDNBASE = 'https://cdn.rawgit.com/Templarian/MaterialDesign/master/icons/svg/';
|
||||
|
||||
protected $file;
|
||||
|
||||
|
|
@ -101,9 +102,17 @@ class SVG {
|
|||
// try local file first
|
||||
$file = self::IMGDIR . $svg;
|
||||
if(!file_exists($file)) {
|
||||
// try media file
|
||||
$file = mediaFN($svg);
|
||||
if(file_exists($file)) {
|
||||
// media files are ACL protected
|
||||
if(auth_quickaclcheck($svg) < AUTH_READ) $this->abort(403);
|
||||
$file = mediaFN($svg);
|
||||
} else {
|
||||
// get it from material design icons
|
||||
$file = getCacheName($svg, '.svg');
|
||||
io_download(self::CDNBASE . $svg, $file);
|
||||
}
|
||||
|
||||
}
|
||||
// check if media exists
|
||||
if(!file_exists($file)) $this->abort(404);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue