mirror of
https://github.com/e107inc/e107.git
synced 2025-07-26 01:11:28 +02:00
Issue #5119 setFavicon() method added.
This commit is contained in:
@@ -187,6 +187,8 @@ class e_jsmanager
|
||||
|
||||
protected $_theme_css_processor = false;
|
||||
|
||||
private $_favicon = null;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@@ -2246,6 +2248,16 @@ class e_jsmanager
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a custom favicon (must be a .png file)
|
||||
* @param string $path to a png file. eg. {e_PLUGIN}gallery/images/icon_32.png
|
||||
* @return e_jsmanager
|
||||
*/
|
||||
public function setFavicon($path)
|
||||
{
|
||||
$this->_favicon = $path;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render favicon HTML code - used in header.php and header_default.php
|
||||
@@ -2257,6 +2269,20 @@ class e_jsmanager
|
||||
|
||||
$ret = '';
|
||||
|
||||
if(!empty($this->_favicon))
|
||||
{
|
||||
$iconSizes = [16 => 'icon',32 => 'icon',48 => 'icon',192 => 'icon',167 => 'apple-touch-icon',180 => 'apple-touch-icon'];
|
||||
|
||||
foreach($iconSizes as $size => $rel)
|
||||
{
|
||||
$sizes = $size.'x'.$size;
|
||||
$url = e107::getParser()->thumbUrl($this->_favicon, ['w'=>$size, 'h'=>$size, 'crop'=>1]);
|
||||
$ret .= "<link rel='$rel' type='image/png' sizes='$sizes' href='".$url."'>\n";
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
if(file_exists(e_THEME . $sitetheme . "/favicon.ico"))
|
||||
{
|
||||
$ret = "<link rel='icon' href='" . e_THEME_ABS . $sitetheme . "/favicon.ico' type='image/x-icon' />\n<link rel='shortcut icon' href='" . e_THEME_ABS . $sitetheme . "/favicon.ico' type='image/xicon' />\n";
|
||||
|
@@ -378,7 +378,7 @@ class e_plugin
|
||||
|
||||
if($opt === 'path')
|
||||
{
|
||||
return e107::getParser()->createConstants(e_PLUGIN_ABS.$this->_plugdir.'/'.$link[$key]);
|
||||
return e107::getParser()->createConstants(e_PLUGIN_ABS.$this->_plugdir.'/'.$link[$key], 2);
|
||||
}
|
||||
|
||||
return "<img src='".e_PLUGIN.$this->_plugdir.'/'.$link[$key] ."' alt=\"".$caption."\" class='icon S".$size."' />";
|
||||
|
@@ -46,6 +46,7 @@
|
||||
$this->assertFalse($result);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
public function testRequireCoreLib()
|
||||
{
|
||||
@@ -275,6 +276,7 @@
|
||||
$this->assertStringContainsString('priority #4', $result);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
public function testSetDependency()
|
||||
{
|
||||
@@ -406,4 +408,13 @@
|
||||
*/
|
||||
|
||||
|
||||
function testRenderFavicon()
|
||||
{
|
||||
$file = e_PLUGIN."gsitemap/images/icon.png";
|
||||
$result = $this->js->renderFavicon($file);
|
||||
self::assertNotEmpty($result);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user