mirror of
https://github.com/e107inc/e107.git
synced 2025-07-29 02:40:25 +02:00
Support for theme glyphicons.
This commit is contained in:
@@ -99,7 +99,6 @@ loadJSAddons();
|
||||
|
||||
|
||||
|
||||
|
||||
// e107::js("core", "core/admin.js","prototype",3); // Load all default functions.
|
||||
|
||||
|
||||
@@ -198,6 +197,13 @@ if (!isset($no_core_css) || !$no_core_css)
|
||||
$e_js->otherCSS('{e_WEB_CSS}e107.css');
|
||||
}
|
||||
|
||||
|
||||
$custom = e107::getThemeGlyphs();
|
||||
foreach($custom as $val)
|
||||
{
|
||||
$e_js->otherCSS($val['path']);
|
||||
}
|
||||
|
||||
// Register Plugin specific CSS
|
||||
// DEPRECATED, use $e_js->pluginCSS('myplug', 'style/myplug.css'[, $media = 'all|screen|...']);
|
||||
if (isset($eplug_css) && $eplug_css)
|
||||
|
@@ -1408,8 +1408,6 @@ class media_admin_ui extends e_admin_ui
|
||||
|
||||
$items = array();
|
||||
|
||||
//TODO FIXME Upgrade to bs3 when Bootstrap3 Admin is ready.
|
||||
|
||||
$bs2 = e107::getMedia()->getGlyphs('bs3','glyphicon-');
|
||||
|
||||
foreach($bs2 as $val)
|
||||
@@ -1441,6 +1439,50 @@ class media_admin_ui extends e_admin_ui
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
$custom = e107::getThemeGlyphs();
|
||||
|
||||
if(!empty($custom))
|
||||
{
|
||||
foreach($custom as $glyphConfig)
|
||||
{
|
||||
|
||||
$tmp = e107::getMedia()->getGlyphs($glyphConfig,$glyphConfig['prefix']);
|
||||
|
||||
if(!empty($tmp))
|
||||
{
|
||||
foreach($tmp as $val)
|
||||
{
|
||||
$items[] = array(
|
||||
'previewUrl' => $val,
|
||||
'saveValue' => $val.'.glyph',
|
||||
'thumbUrl' => $val,
|
||||
'title' => $val,
|
||||
'slideCaption' => ucfirst($glyphConfig['name']),
|
||||
'slideCategory' => $glyphConfig['name']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if(vartrue($parm['search']))
|
||||
{
|
||||
|
@@ -1117,6 +1117,38 @@ class e107
|
||||
return e107::getConfig()->updatePref('sitetheme_pref/'.$pref_name, $pref_value, false);
|
||||
}
|
||||
|
||||
|
||||
public static function getThemeGlyphs()
|
||||
{
|
||||
|
||||
$custom = self::getConfig()->getPref('sitetheme_glyphicons', false);
|
||||
$theme = self::getConfig()->getPref('sitetheme', false);
|
||||
|
||||
$arr = array();
|
||||
|
||||
if(!empty($custom))
|
||||
{
|
||||
|
||||
foreach($custom as $glyphConfig)
|
||||
{
|
||||
|
||||
if(substr($glyphConfig['path'],0,4) !== 'http')
|
||||
{
|
||||
$glyphConfig['path'] = e_THEME."$theme/".$glyphConfig['path'];
|
||||
}
|
||||
|
||||
$arr[] = $glyphConfig;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $arr;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve text parser singleton object
|
||||
*
|
||||
|
@@ -871,13 +871,19 @@ class e_media
|
||||
|
||||
|
||||
/**
|
||||
* Get all Glyphs
|
||||
* @param string|array $type
|
||||
* @param $type['name']
|
||||
* @param $type[['type']
|
||||
* @param $type['path'] URL or e107 path {e_THEME} etc.
|
||||
* @param $type['prefix']
|
||||
* @param string $addPrefix
|
||||
* @return array
|
||||
*/
|
||||
function getGlyphs($type='fa4',$prefix = '')
|
||||
function getGlyphs($type='fa4', $addPrefix = '')
|
||||
{
|
||||
$icons = array();
|
||||
|
||||
if($type == 'bs2')
|
||||
if($type === 'bs2')
|
||||
{
|
||||
$matches = array(
|
||||
'glass','music','search','envelope','heart','star','star-empty','user','film','th-large','th','th-list','ok',
|
||||
@@ -899,13 +905,13 @@ class e_media
|
||||
|
||||
foreach($matches as $match)
|
||||
{
|
||||
$icons[] = $prefix.$match;
|
||||
$icons[] = $addPrefix.$match;
|
||||
}
|
||||
|
||||
return $icons;
|
||||
}
|
||||
|
||||
if($type == 'bs3')
|
||||
if($type === 'bs3')
|
||||
{
|
||||
$matches = array(
|
||||
'adjust','align-center','align-justify','align-left','align-right','arrow-down','arrow-left','arrow-right','arrow-up','asterisk','backward','ban-circle','barcode','bell','bold','book
|
||||
@@ -924,14 +930,27 @@ class e_media
|
||||
|
||||
foreach($matches as $match)
|
||||
{
|
||||
$icons[] = $prefix.$match;
|
||||
$icons[] = $addPrefix.$match;
|
||||
}
|
||||
|
||||
return $icons;
|
||||
}
|
||||
|
||||
|
||||
if(is_array($type))
|
||||
{
|
||||
$prefix = $type['prefix'];
|
||||
$pattern = $type['pattern'];
|
||||
$path = $type['path'];
|
||||
$type = $type['name'];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
$cache = e107::getCache();
|
||||
$cachTag = !empty($prefix) ? "Glyphs_".$prefix."_".$type : "Glyphs_".$type;
|
||||
$cachTag = !empty($addPrefix) ? "Glyphs_".$addPrefix."_".$type : "Glyphs_".$type;
|
||||
|
||||
|
||||
|
||||
if($data = $cache->retrieve($cachTag ,360,true,true))
|
||||
{
|
||||
@@ -939,25 +958,43 @@ class e_media
|
||||
}
|
||||
|
||||
|
||||
if($type == 'fa4')
|
||||
if($type === 'fa4')
|
||||
{
|
||||
$pattern = '/\.(fa-(?:\w+(?:-)?)+):before/';
|
||||
$subject = e107::getFile()->getRemoteContent('http://netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.css');
|
||||
// print_a($subject);
|
||||
$prefix = 'fa-';
|
||||
}
|
||||
elseif($type == 'fa3')
|
||||
elseif($type === 'fa3')
|
||||
{
|
||||
$pattern = '/\.(icon-(?:\w+(?:-)?)+):before/';
|
||||
$subject = file_get_contents(e_WEB_JS.'font-awesome/css/font-awesome.css');
|
||||
$prefix = 'fa-';
|
||||
}
|
||||
|
||||
elseif(!empty($pattern) && !empty($path))
|
||||
{
|
||||
$pattern = '/'.$pattern.'/';
|
||||
if(substr($path,0,4) === 'http')
|
||||
{
|
||||
$subject = e107::getFile()->getRemoteContent($path);
|
||||
}
|
||||
else
|
||||
{
|
||||
$path = e107::getParser()->replaceConstants($path);
|
||||
$subject = file_get_contents($path);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
$prefixLength = !empty($prefix) ? strlen($prefix) : 3;
|
||||
|
||||
preg_match_all($pattern, $subject, $matches, PREG_SET_ORDER);
|
||||
|
||||
|
||||
|
||||
|
||||
foreach($matches as $match)
|
||||
{
|
||||
$icons[] = $prefix.substr($match[1],3);
|
||||
$icons[] = $addPrefix.substr($match[1],$prefixLength);
|
||||
}
|
||||
|
||||
if(empty($icons)) // failed to produce a result so don't cache it. .
|
||||
@@ -975,6 +1012,7 @@ class e_media
|
||||
|
||||
|
||||
|
||||
|
||||
function getPath($mime, $path=null)
|
||||
{
|
||||
$mes = e107::getMessage();
|
||||
|
@@ -1785,12 +1785,14 @@ class themeHandler
|
||||
$deflayout = $this->findDefault($name);
|
||||
$customPages = $this->themeArray[$name]['custompages'];
|
||||
$version = $this->themeArray[$name]['version'];
|
||||
$glyphs = $this->themeArray[$name]['glyphs'];
|
||||
|
||||
$core->set('sitetheme', $name);
|
||||
$core->set('themecss', 'style.css');
|
||||
$core->set('sitetheme_layouts', $layout);
|
||||
$core->set('sitetheme_deflayout', $deflayout);
|
||||
$core->set('sitetheme_custompages', $customPages);
|
||||
$core->set('sitetheme_glyphicons', $glyphs);
|
||||
|
||||
$core->set('sitetheme_version', $version);
|
||||
|
||||
@@ -2293,7 +2295,29 @@ class themeHandler
|
||||
|
||||
unset($vars['stylesheets']);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$vars['glyphs'] = array();
|
||||
if(!empty($vars['glyphicons']['glyph']))
|
||||
{
|
||||
|
||||
foreach($vars['glyphicons']['glyph'] as $val)
|
||||
{
|
||||
$vars['glyphs'][] = array(
|
||||
'name' => $val['@attributes']['name'],
|
||||
'pattern' => $val['@attributes']['pattern'],
|
||||
'path' => $val['@attributes']['path'],
|
||||
'prefix' => $val['@attributes']['prefix'],
|
||||
'tag' => $val['@attributes']['tag'],
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
unset($vars['glyphicons']);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
|
||||
$mes = e107::getMessage(); // DEBUG
|
||||
@@ -2316,6 +2340,10 @@ class themeHandler
|
||||
return $vars;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
interface e_theme_config
|
||||
|
Reference in New Issue
Block a user