1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-06 14:46:56 +02:00

PHP error fixes.

This commit is contained in:
Cameron
2021-02-22 12:22:50 -08:00
parent 340ff05fcd
commit 52a554987b
3 changed files with 34 additions and 5 deletions

View File

@@ -5,7 +5,8 @@
function sublinks_shortcode($parm) function sublinks_shortcode($parm)
{ {
global $sql, $linkstyle;; $sql = e107::getDb();
$linkstyle = varset($GLOBALS['linkstyle'], array());
if($parm) if($parm)
{ {
@@ -28,7 +29,7 @@ function sublinks_shortcode($parm)
} }
$text = "\n\n<!-- Sublinks Start -->\n\n"; $text = "\n\n<!-- Sublinks Start -->\n\n";
$text .= $style['prelink']; $text .= varset($style['prelink']);
if($sql->select("links", "link_id", "link_url= '{$page}' AND link_category = {$cat} LIMIT 1")) if($sql->select("links", "link_id", "link_url= '{$page}' AND link_category = {$cat} LIMIT 1"))
{ {
$row = $sql->fetch(); $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"); $link_total = $sql->select("links", "*", "link_class IN (" . USERCLASS_LIST . ") AND link_parent={$parent} ORDER BY link_order ASC");
while($linkInfo = $sql->fetch()) 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<!-- Sublinks End -->\n\n"; $text .= "\n\n<!-- Sublinks End -->\n\n";

View File

@@ -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() public function testParseCodesWithClass()
{ {

View File

@@ -515,11 +515,13 @@
); );
$themeObj = $this->tm;
foreach($tests as $item=>$var) foreach($tests as $item=>$var)
{ {
$var['script'] = isset($var['script']) ? $var['script'] : null; $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']); $this->assertEquals($var['expected'],$result, "Wrong theme layout returned for item [".$item."] ".$var['url']);
// echo $var['url']."\t\t\t".$result."\n\n"; // echo $var['url']."\t\t\t".$result."\n\n";
} }