mirror of
https://github.com/e107inc/e107.git
synced 2025-07-25 00:41:52 +02:00
Fixes #5156 Static URL issue.
This commit is contained in:
@@ -254,6 +254,8 @@ class e_parse
|
||||
private $bootstrap;
|
||||
private $fontawesome;
|
||||
|
||||
private $modRewriteMedia;
|
||||
|
||||
private $removedList = array();
|
||||
private $nodesToDelete = array();
|
||||
private $nodesToConvert = array();
|
||||
@@ -2487,7 +2489,6 @@ class e_parse
|
||||
*/
|
||||
public function setStaticUrl($url)
|
||||
{
|
||||
|
||||
$this->staticUrl = $url;
|
||||
}
|
||||
|
||||
@@ -2636,10 +2637,10 @@ class e_parse
|
||||
}
|
||||
|
||||
|
||||
if (e_MOD_REWRITE_MEDIA == true && empty($options['nosef']))// Experimental SEF URL support.
|
||||
if ($this->modRewriteMedia && empty($options['nosef']))// SEF URL support.
|
||||
{
|
||||
$options['full'] = $full;
|
||||
$options['ext'] = substr($url, -3);
|
||||
$options['ext'] = pathinfo($url, PATHINFO_EXTENSION);
|
||||
$options['thurl'] = $thurl;
|
||||
// $options['x'] = $this->thumbEncode();
|
||||
|
||||
@@ -3606,9 +3607,10 @@ class e_parse
|
||||
if (defined('BOOTSTRAP'))
|
||||
{
|
||||
$this->bootstrap = (int) BOOTSTRAP;
|
||||
|
||||
}
|
||||
|
||||
$this->modRewriteMedia = deftrue('e_MOD_REWRITE_MEDIA');
|
||||
|
||||
if (defined('e_HTTP_STATIC'))
|
||||
{
|
||||
$this->staticUrl = e_HTTP_STATIC;
|
||||
@@ -3781,7 +3783,6 @@ class e_parse
|
||||
*/
|
||||
public function setFontAwesome($version)
|
||||
{
|
||||
|
||||
$this->fontawesome = (int) $version;
|
||||
}
|
||||
|
||||
@@ -3790,10 +3791,13 @@ class e_parse
|
||||
*/
|
||||
public function setBootstrap($version)
|
||||
{
|
||||
|
||||
$this->bootstrap = (int) $version;
|
||||
}
|
||||
|
||||
public function setmodRewriteMedia($bool)
|
||||
{
|
||||
$this->modRewriteMedia = (bool) $bool;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add leading zeros to a number. eg. 3 might become 000003
|
||||
|
@@ -2266,7 +2266,7 @@ class e_jsmanager
|
||||
public function renderFavicon()
|
||||
{
|
||||
$sitetheme = $this->getCurrentTheme();
|
||||
|
||||
$tp = e107::getParser();
|
||||
$ret = '';
|
||||
|
||||
if(!empty($this->_favicon))
|
||||
@@ -2276,7 +2276,7 @@ class e_jsmanager
|
||||
foreach($iconSizes as $size => $rel)
|
||||
{
|
||||
$sizes = $size.'x'.$size;
|
||||
$url = e107::getParser()->thumbUrl($this->_favicon, ['w'=>$size, 'h'=>$size, 'crop'=>1]);
|
||||
$url = $tp->thumbUrl($this->_favicon, ['w'=>$size, 'h'=>$size, 'crop'=>1]);
|
||||
$ret .= "<link rel='$rel' type='image/png' sizes='$sizes' href='".$url."'>\n";
|
||||
}
|
||||
|
||||
@@ -2285,7 +2285,7 @@ class e_jsmanager
|
||||
|
||||
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";
|
||||
$ret = "<link rel='icon' href='" . $tp->staticUrl(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";
|
||||
}
|
||||
elseif(file_exists(e_MEDIA_ICON.'16x16_favicon.png'))
|
||||
{
|
||||
@@ -2294,13 +2294,14 @@ class e_jsmanager
|
||||
foreach($iconSizes as $size => $rel)
|
||||
{
|
||||
$sizes = $size.'x'.$size;
|
||||
$ret .= "<link rel='$rel' type='image/png' sizes='$sizes' href='".e_MEDIA_ICON_ABS.$sizes."_favicon.png'>\n";
|
||||
$href = $tp->staticUrl(e_MEDIA_ICON_ABS.$sizes."_favicon.png");
|
||||
$ret .= "<link rel='$rel' type='image/png' sizes='$sizes' href='$href'>\n";
|
||||
}
|
||||
|
||||
}
|
||||
elseif (file_exists(e_BASE."favicon.ico"))
|
||||
{
|
||||
$ret = "<link rel='icon' href='".SITEURL."favicon.ico' type='image/x-icon' />\n<link rel='shortcut icon' href='".SITEURL."favicon.ico' type='image/xicon' />\n";
|
||||
$ret = "<link rel='icon' href='".$tp->staticUrl(SITEURL."favicon.ico")."' type='image/x-icon' />\n<link rel='shortcut icon' href='".$tp->staticUrl(SITEURL."favicon.ico")."' type='image/xicon' />\n";
|
||||
}
|
||||
|
||||
|
||||
|
@@ -105,7 +105,7 @@ class siteinfo_shortcodes // must match the folder name of the plugin.
|
||||
// Paths to image file, link are relative to site base
|
||||
$tp = e107::getParser();
|
||||
|
||||
$logopref = e107::getConfig('core')->get('sitelogo');
|
||||
$logopref = e107::getConfig()->get('sitelogo');
|
||||
$logop = $tp->replaceConstants($logopref);
|
||||
|
||||
if(isset($parm['login'])) // Login Page. BC fix.
|
||||
@@ -138,9 +138,9 @@ class siteinfo_shortcodes // must match the folder name of the plugin.
|
||||
else
|
||||
{
|
||||
|
||||
if(vartrue($logopref) && is_readable($logop))
|
||||
if(!empty($logopref) && is_readable($logop))
|
||||
{
|
||||
$logo = $tp->replaceConstants($logopref,'abs');
|
||||
$logo = $logopref;
|
||||
$path = $tp->replaceConstants($logopref);
|
||||
}
|
||||
elseif (isset($file) && $file && is_readable($file))
|
||||
@@ -169,8 +169,8 @@ class siteinfo_shortcodes // must match the folder name of the plugin.
|
||||
|
||||
if((isset($parm['w']) || isset($parm['h'])))
|
||||
{
|
||||
//
|
||||
$dimensions[0] = isset($parm['w']) ? $parm['w'] : 0;
|
||||
|
||||
$dimensions[0] = $parm['w'] ?? 0;
|
||||
$dimensions[1] = !empty($parm['h']) ? $parm['h'] : 0;
|
||||
|
||||
if(empty($parm['noresize']) && !empty($logopref)) // resize by default - avoiding large files.
|
||||
|
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* @group plugins
|
||||
*/
|
||||
class siteinfo_shortcodesTest extends \Codeception\Test\Unit
|
||||
{
|
||||
|
||||
/** @var siteinfo_shortcodes */
|
||||
protected $sc;
|
||||
|
||||
protected function _before()
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
require_once(e_PLUGIN."siteinfo/e_shortcode.php");
|
||||
$this->sc = $this->make('siteinfo_shortcodes');
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
self::fail($e->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function testSc_sitename()
|
||||
{
|
||||
$result = $this->sc->sc_sitename();
|
||||
self::assertSame('e107', $result);
|
||||
|
||||
}
|
||||
|
||||
/* public function testSc_siteurl()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function testSc_sitedisclaimer()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function testSc_sitedescription()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function testSc_sitetag()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function testSc_sitebutton()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function testSc_sitelogo()
|
||||
{
|
||||
|
||||
}*/
|
||||
|
||||
public function testSc_logo()
|
||||
{
|
||||
$tp = e107::getParser();
|
||||
|
||||
$result = $this->sc->sc_logo(['w'=>200, 'h'=>100]);
|
||||
$expected = '<img class="logo img-responsive img-fluid" src="/thumb.php?src=e_IMAGE%2FlogoHD.png&w=200&h=100" alt="e107" srcset="/thumb.php?src=e_IMAGE%2FlogoHD.png&w=400&h=200 2x" width="200" height="100" />';
|
||||
self::assertSame($expected, $result);
|
||||
|
||||
$tp->setStaticUrl('https://my.cdn.com/');
|
||||
$result = $this->sc->sc_logo(['w'=>240, 'h'=>120]);
|
||||
$expected = '<img class="logo img-responsive img-fluid" src="https://my.cdn.com/thumb.php?src=e_IMAGE%2FlogoHD.png&w=240&h=120" alt="e107" srcset="https://my.cdn.com/thumb.php?src=e_IMAGE%2FlogoHD.png&w=480&h=240 2x" width="240" height="120" />';
|
||||
self::assertSame($expected, $result);
|
||||
|
||||
file_put_contents(e_MEDIA_IMAGE.'logo.png','dummy image content');
|
||||
e107::getConfig()->set('sitelogo', '{e_MEDIA_IMAGE}logo.png');
|
||||
$tp->setStaticUrl('https://my.cdn.com/');
|
||||
$tp->thumbWidth(100);
|
||||
$tp->thumbHeight(0);
|
||||
$tp->thumbCrop(0);
|
||||
$result = $this->sc->sc_logo();
|
||||
$expected = '<img class="logo img-responsive img-fluid" src="https://my.cdn.com/thumb.php?src=e_MEDIA_IMAGE%2Flogo.png&w=100&h=0" alt="e107" srcset="https://my.cdn.com/thumb.php?src=e_MEDIA_IMAGE%2Flogo.png&w=200&h=0 2x" width="100" />';
|
||||
self::assertSame($expected, $result);
|
||||
|
||||
|
||||
$tp->setmodRewriteMedia(true);
|
||||
$result = $this->sc->sc_logo(['w'=>240, 'h'=>120]);
|
||||
$expected = '<img class="logo img-responsive img-fluid" src="https://my.cdn.com/media/img/240x120/logo.png" alt="e107" srcset="https://my.cdn.com/media/img/480x240/logo.png 2x" width="240" height="120" />';
|
||||
|
||||
self::assertSame($expected, $result);
|
||||
|
||||
// Reset for other tests.
|
||||
$tp->setmodRewriteMedia(false);
|
||||
$tp->setStaticUrl(null);
|
||||
|
||||
}
|
||||
|
||||
/* public function testSc_theme_disclaimer()
|
||||
{
|
||||
$result = $this->sc->sc_theme_disclaimer();
|
||||
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user