1
0
mirror of https://github.com/e107inc/e107.git synced 2025-06-04 09:54:56 +02:00

library getPath() method added. Media class now caches local fontawesome file.

This commit is contained in:
Cameron 2017-02-03 08:36:49 -08:00
parent 71249c3f2c
commit 20b5db2cf9
2 changed files with 26 additions and 7 deletions

View File

@ -709,7 +709,7 @@ class e_library_manager
// Check whether the library exists.
if(!isset($library['library_path']))
{
$library['library_path'] = $this->getPath($library['machine_name']);
$library['library_path'] = $this->detectPath($library['machine_name']);
}
$libraryPath = e107::getParser()->replaceConstants($library['library_path']);
@ -1034,7 +1034,7 @@ class e_library_manager
* @return string
* The path to the specified library or FALSE if the library wasn't found.
*/
private function getPath($name)
private function detectPath($name)
{
static $libraries;
@ -1096,6 +1096,24 @@ class e_library_manager
return varset($lib[$property], false);
}
/**
* Return full path to a library in different formats.
* @param string $library
* The library name eg. bootstrap
*
* @param null $mode
* The mode: null | 'full' | 'abs'
*
* @return string
*/
public function getPath($library, $mode=null)
{
$path = self::getProperty($library, 'library_path').'/'. self::getProperty($library, 'path');
return e107::getParser()->replaceConstants($path,$mode).'/';
}
/**
* Returns information about registered libraries.
*

View File

@ -955,8 +955,8 @@ class e_media
$cache = e107::getCache();
$cachTag = !empty($addPrefix) ? "Glyphs_".$addPrefix."_".$type : "Glyphs_".$type;
$cachTag = !empty($addPrefix) ? "Glyphs_".$addPrefix."_".$type : "Glyphs_".$type;
if($data = $cache->retrieve($cachTag ,360,true,true))
@ -965,10 +965,11 @@ class e_media
}
if($type === 'fa4') // todo use e107::library
if($type === 'fa4')
{
$pattern = '/\.(fa-(?:\w+(?:-)?)+):before/';
$subject = e107::getFile()->getRemoteContent('http://netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.css');
$path = e107::getLibrary()->getPath('fontawesome');
$subject = file_get_contents($path.'css/font-awesome.css');
$prefix = 'fa-';
}
elseif($type === 'fa3')
@ -1009,9 +1010,9 @@ class e_media
return array();
}
$data = e107::serialize($icons);
$data = e107::serialize($icons,'json');
$cache->set_sys($cachTag ,$data,true);
$cache->set_sys($cachTag ,$data,true,true);
return $icons;