diff --git a/e107_core/shortcodes/single/sublinks.php b/e107_core/shortcodes/single/sublinks.php index 1b8210b81..788abf8b6 100644 --- a/e107_core/shortcodes/single/sublinks.php +++ b/e107_core/shortcodes/single/sublinks.php @@ -5,7 +5,8 @@ function sublinks_shortcode($parm) { - global $sql, $linkstyle;; + $sql = e107::getDb(); + $linkstyle = varset($GLOBALS['linkstyle'], array()); if($parm) { @@ -28,7 +29,7 @@ function sublinks_shortcode($parm) } $text = "\n\n\n\n"; - $text .= $style['prelink']; + $text .= varset($style['prelink']); if($sql->select("links", "link_id", "link_url= '{$page}' AND link_category = {$cat} LIMIT 1")) { $row = $sql->fetch(); @@ -37,10 +38,10 @@ function sublinks_shortcode($parm) $link_total = $sql->select("links", "*", "link_class IN (" . USERCLASS_LIST . ") AND link_parent={$parent} ORDER BY link_order ASC"); while($linkInfo = $sql->fetch()) { - $text .= $sublinks->makeLink($linkInfo, true, $style, false); + $text .= $sublinks->makeLink($linkInfo, true, $style); } - $text .= $style['postlink']; + $text .= varset($style['postlink']); } $text .= "\n\n\n\n"; diff --git a/e107_tests/tests/unit/e_parse_shortcodeTest.php b/e107_tests/tests/unit/e_parse_shortcodeTest.php index a9dce322b..0b908120d 100644 --- a/e107_tests/tests/unit/e_parse_shortcodeTest.php +++ b/e107_tests/tests/unit/e_parse_shortcodeTest.php @@ -105,6 +105,32 @@ class e_parse_shortcodeTest extends \Codeception\Test\Unit } + public function testParseCodesWithMagicShortcodes() + { + $template = '{SITENAME} {---BREADCRUMB---}'; + $expected = 'e107 {---BREADCRUMB---}'; + + $result = $this->scParser->parseCodes($template, true); + $this->assertSame($expected, $result); + + $array = array( + 'LINK_TEXT' => 'Content', + 'LINK_URL' => '#', + 'ONCLICK' => '', + 'SUB_HEAD' => '', + 'SUB_MENU' => '', + ); + + $result = $this->scParser->parseCodes($template, true, $array); + $this->assertSame($expected, $result); + + $sc = e107::getScBatch('_blank', true, '_blank'); + $this->assertIsObject($sc); + $result = $this->scParser->parseCodes($template, true, $sc); + $this->assertSame($expected, $result); + + } + public function testParseCodesWithClass() { diff --git a/e107_tests/tests/unit/e_themeTest.php b/e107_tests/tests/unit/e_themeTest.php index be49ec427..ee8d27d92 100644 --- a/e107_tests/tests/unit/e_themeTest.php +++ b/e107_tests/tests/unit/e_themeTest.php @@ -515,11 +515,13 @@ ); + $themeObj = $this->tm; + foreach($tests as $item=>$var) { $var['script'] = isset($var['script']) ? $var['script'] : null; - $result = $this->tm::getThemeLayout($pref, $defaultLayout, $var); + $result = $themeObj::getThemeLayout($pref, $defaultLayout, $var); $this->assertEquals($var['expected'],$result, "Wrong theme layout returned for item [".$item."] ".$var['url']); // echo $var['url']."\t\t\t".$result."\n\n"; }