diff --git a/e107_handlers/e_parse_class.php b/e107_handlers/e_parse_class.php index 73d7b1b2a..c6ef77033 100644 --- a/e107_handlers/e_parse_class.php +++ b/e107_handlers/e_parse_class.php @@ -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 diff --git a/e107_handlers/js_manager.php b/e107_handlers/js_manager.php index 3d80f6cd1..4f87d09eb 100644 --- a/e107_handlers/js_manager.php +++ b/e107_handlers/js_manager.php @@ -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 .= "\n"; } @@ -2285,7 +2285,7 @@ class e_jsmanager if(file_exists(e_THEME . $sitetheme . "/favicon.ico")) { - $ret = "\n\n"; + $ret = "\n\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 .= "\n"; + $href = $tp->staticUrl(e_MEDIA_ICON_ABS.$sizes."_favicon.png"); + $ret .= "\n"; } } elseif (file_exists(e_BASE."favicon.ico")) { - $ret = "\n\n"; + $ret = "\n\n"; } diff --git a/e107_plugins/siteinfo/e_shortcode.php b/e107_plugins/siteinfo/e_shortcode.php index 0046eea9a..b3fb4b763 100644 --- a/e107_plugins/siteinfo/e_shortcode.php +++ b/e107_plugins/siteinfo/e_shortcode.php @@ -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. diff --git a/e107_tests/tests/unit/plugins/siteinfo/siteinfo_shortcodesTest.php b/e107_tests/tests/unit/plugins/siteinfo/siteinfo_shortcodesTest.php new file mode 100644 index 000000000..7aaf885b0 --- /dev/null +++ b/e107_tests/tests/unit/plugins/siteinfo/siteinfo_shortcodesTest.php @@ -0,0 +1,109 @@ +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 = ''; + self::assertSame($expected, $result); + + $tp->setStaticUrl('https://my.cdn.com/'); + $result = $this->sc->sc_logo(['w'=>240, 'h'=>120]); + $expected = ''; + 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 = ''; + self::assertSame($expected, $result); + + + $tp->setmodRewriteMedia(true); + $result = $this->sc->sc_logo(['w'=>240, 'h'=>120]); + $expected = ''; + + 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(); + + }*/ + + + +}