diff --git a/e107_admin/prefs.php b/e107_admin/prefs.php
index 9ff6dbcef..f15a38f9b 100644
--- a/e107_admin/prefs.php
+++ b/e107_admin/prefs.php
@@ -200,10 +200,15 @@ if(isset($_POST['updateprefs']))
$core_pref->update($key, $newValue);
}
- if($core_pref->dataHasChanged())
+
+ $hasChanged = $core_pref->dataHasChanged();
+
+ if($hasChanged)
{
// Need to clear cache in order to refresh library information.
e107::getCache()->clearAll('system');
+
+
}
$core_pref->save(false);
@@ -221,6 +226,22 @@ if(isset($_POST['updateprefs']))
$session = new e_core_session(array('name' => $core_pref->get('cookie_name')));
$_SESSION = $s;
}
+
+ // build favicon files.
+ if(!empty($pref['sitebutton']) && $hasChanged)
+ {
+ $iconSizes = [32,16,48,192,167,180];
+ $media = e107::getMedia();
+ foreach($iconSizes as $size)
+ {
+ if($result = $media->resizeImage($pref['sitebutton'],'{e_MEDIA_ICON}/favicon.png', ['w'=>$size, 'h'=>$size, 'crop'=>true, 'overwrite'=>true]))
+ {
+ e107::getMessage()->addDebug("Created ".$result); // NO LAN.
+ }
+
+ }
+ }
+
}
if (e107::isInstalled('alt_auth'))
diff --git a/e107_core/templates/header_default.php b/e107_core/templates/header_default.php
index 99c4ec5e0..3955664ff 100644
--- a/e107_core/templates/header_default.php
+++ b/e107_core/templates/header_default.php
@@ -102,7 +102,7 @@ $js_body_onload = array(); // Legacy array of code to load with page.
//else
-function render_title()
+function renderTitle()
{
if(!defined('e_PAGETITLE') && ($_PAGE_TITLE = e107::getSingleton('eResponse')->getMetaTitle())) // use e107::title() to set.
{
@@ -155,7 +155,7 @@ echo "\n";
$htmlTag = "";
echo (defined('HTMLTAG') ? str_replace('THEME_LAYOUT', THEME_LAYOUT, HTMLTAG) : $htmlTag)."\n";
echo "
-".render_title()."
+".renderTitle()."
\n";
if(!empty($pref['meta_copyright'][e_LANGUAGE])) e107::meta('dcterms.rights',$pref['meta_copyright'][e_LANGUAGE]);
if(!empty($pref['meta_author'][e_LANGUAGE])) e107::meta('author',$pref['meta_author'][e_LANGUAGE]);
@@ -245,13 +245,7 @@ if (is_array($pref['e_meta_list']))
}
// -------- Generate Apple Touch Icon ---------
-
-if(isset($pref['sitebutton']))
-{
- $appleIcon = e107::getParser()->thumbUrl($pref['sitebutton'],'w=144&h=144&crop=1',null, true);
- echo "\n";
- unset($appleIcon);
-}
+echo renderFavicon();
@@ -403,12 +397,12 @@ if (isset($eplug_js) && $eplug_js)
$eplug_js_unique = array_unique($eplug_js);
foreach($eplug_js_unique as $kjs)
{
- echo ($kjs[0] == "<") ? $kjs : "\n"; // could be a .php file so leave the 'type'.
+ echo ($kjs[0] == "<") ? $kjs : "\n"; // could be a .php file so leave the 'type'.
}
}
else
{
- echo "\n"; // could be a .php file so leave the 'type'.
+ echo "\n"; // could be a .php file so leave the 'type'.
}
}
@@ -458,11 +452,17 @@ if(function_exists('theme_head'))
$diz_merge = (defined("META_MERGE") && META_MERGE != FALSE && $pref['meta_description'][e_LANGUAGE]) ? $pref['meta_description'][e_LANGUAGE]." " : "";
$key_merge = (defined("META_MERGE") && META_MERGE != FALSE && $pref['meta_keywords'][e_LANGUAGE]) ? $pref['meta_keywords'][e_LANGUAGE]."," : "";
+
+
+
+
+
+
/**
* @param $type
* @return string
*/
-function render_meta($type)
+function renderMeta($type)
{
$tp = e107::getParser();
$pref = e107::getPref();
@@ -491,6 +491,30 @@ function render_meta($type)
return $ret;
}
+function renderFavicon()
+{
+ // ---------- Favicon ---------
+ if (file_exists(THEME."favicon.ico"))
+ {
+ return "\n\n";
+ }
+ elseif(file_exists(e_MEDIA_ICON.'16x16_favicon.png'))
+ {
+ $iconSizes = [16 => 'icon',32 => 'icon',48 => 'icon',192 => 'icon',167 => 'apple-touch-icon',180 => 'apple-touch-icon'];
+ $text = '';
+ foreach($iconSizes as $size => $rel)
+ {
+ $sizes = $size.'x'.$size;
+ $text .= "\n";
+ }
+ return $text;
+ }
+ elseif (file_exists(e_BASE."favicon.ico"))
+ {
+ return "\n\n";
+ }
+
+}
// legay meta-tag checks.
/*
$isKeywords = e107::getUrl()->response()->getMetaKeywords();
@@ -503,28 +527,22 @@ $isDescription = e107::getSingleton('eResponse')->getMetaDescription();
if(empty($isKeywords))
{
- echo (defined("META_KEYWORDS")) ? "\n\n" : render_meta('keywords');
+ echo (defined("META_KEYWORDS")) ? "\n\n" : renderMeta('keywords');
}
if(empty($isDescription))
{
- echo (defined("META_DESCRIPTION")) ? "\n\n" : render_meta('description');
+ echo (defined("META_DESCRIPTION")) ? "\n\n" : renderMeta('description');
}
//echo render_meta('copyright');
//echo render_meta('author');
-echo render_meta('tag');
+echo renderMeta('tag');
+
unset($key_merge,$diz_merge,$isKeywords,$isDescription);
-// ---------- Favicon ---------
-if (file_exists(THEME."favicon.ico"))
-{
- echo "\n\n";
-}
-elseif (file_exists(e_BASE."favicon.ico"))
-{
- echo "\n\n";
-}
+
+
// Theme JS
/** const THEME_ONLOAD @deprecated */
@@ -645,8 +663,8 @@ echo "\n";
elseif($def && $def != "legacyCustom" && (isset($CUSTOMHEADER[$def]) || isset($CUSTOMFOOTER[$def]))) // 0.7/1.x themes
{
// echo " MODE 0.7";
- $HEADER = ($CUSTOMHEADER[$def]) ? $CUSTOMHEADER[$def] : $HEADER;
- $FOOTER = ($CUSTOMFOOTER[$def]) ? $CUSTOMFOOTER[$def] : $FOOTER;
+ $HEADER = isset($CUSTOMHEADER[$def]) ? $CUSTOMHEADER[$def] : $HEADER;
+ $FOOTER = isset($CUSTOMFOOTER[$def]) ? $CUSTOMFOOTER[$def] : $FOOTER;
}
elseif(!empty($def) && is_array($HEADER)) // 2.0 themes - we use only $HEADER and $FOOTER arrays.
{
@@ -669,7 +687,10 @@ echo "\n";
$body_onload .= " class='e-iframe'";
}
- $HEADER = str_replace("{e_PAGETITLE}",deftrue('e_PAGETITLE'),$HEADER);
+ if(!empty($HEADER))
+ {
+ $HEADER = str_replace("{e_PAGETITLE}",deftrue('e_PAGETITLE'),$HEADER);
+ }
//$body_onload .= " id='layout-".e107::getForm()->name2id(THEME_LAYOUT)."' ";
diff --git a/e107_handlers/media_class.php b/e107_handlers/media_class.php
index 3de716ebc..310f0d89c 100644
--- a/e107_handlers/media_class.php
+++ b/e107_handlers/media_class.php
@@ -1940,12 +1940,12 @@ class e_media
/**
* Resize an image.
- * @param $src
- * @param $dest
- * @param string $opts
+ * @param string $src
+ * @param string $dest
+ * @param string|array $opts
* @return bool
*/
- function resizeImage($src='',$dest='',$opts=null)
+ public function resizeImage($src='',$dest='',$opts=null)
{
$pref = e107::getPref();
$tp = e107::getParser();
@@ -1978,7 +1978,7 @@ class e_media
$destFilePath = $destDir."/".varset($opts['prefix'],$maxWidth.'x'.$maxHeight).'_'.$destFile;
- if(file_exists($destFilePath))
+ if(empty($opts['overwrite']) && file_exists($destFilePath))
{
return $destFilePath;
}
@@ -1986,11 +1986,21 @@ class e_media
try
{
$thumb = Intervension::make($src);
- $thumb->resize(vartrue($maxWidth, null), vartrue($maxHeight, null), function ($constraint)
+ if(!empty($opts['crop']))
{
- $constraint->aspectRatio();
- $constraint->upsize();
- });
+ $thumb->fit($maxWidth, $maxHeight, function ($constraint) {
+ $constraint->upsize();
+ });
+ }
+ else
+ {
+ $thumb->resize(vartrue($maxWidth, null), vartrue($maxHeight, null), function ($constraint)
+ {
+
+ $constraint->aspectRatio();
+ $constraint->upsize();
+ });
+ }
$thumb->save($destFilePath, $quality);
return $destFilePath;
@@ -2009,6 +2019,7 @@ class e_media
}
+
/**
* Convert an image to jpeg format.
* @param string $oldFile path to png or gif file.