1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-17 04:38:27 +01:00

Issue #4206 - news category menu {active} shortcode typo fix.

This commit is contained in:
Cameron 2020-07-03 13:49:12 -07:00
parent 07f92d92cc
commit 23f6a52f08
4 changed files with 101 additions and 90 deletions

View File

@ -1099,18 +1099,18 @@ class e_news_category_tree extends e_front_tree_model
if(e_PAGE == 'news.php')
{
$tmp = explode('.', e_QUERY);
if(vartrue($tmp[1])) $active = $tmp[1];
if(!empty($tmp[1])) $active = $tmp[1];
}
$bullet = defined('BULLET') ? THEME_ABS.'images/'.BULLET : THEME_ABS.'images/bullet2.gif';
$obj = new e_vars(array('bullet' => $bullet));
$obj = new e_vars(array('BULLET' => $bullet));
/** @var e_tree_model $cat */
foreach ($this->getTree() as $cat)
{
$obj->active = '';
$obj->ACTIVE = '';
if($active && $active == $cat->getId())
{
$obj->active = ' active';
$obj->ACTIVE = ' active';
}
$ret[] = $cat->toHTML($template['item'], $parsesc, $obj);

View File

@ -19,14 +19,14 @@ global $sc_style;
$NEWS_MENU_TEMPLATE['category']['start'] = '<ul class="news-menu-category">';
$NEWS_MENU_TEMPLATE['category']['end'] = '</ul>';
$NEWS_MENU_TEMPLATE['category']['item'] = '
<li><a class="e-menu-link newscats{active}" href="{NEWS_CATEGORY_URL}">{NEWS_CATEGORY_TITLE}{NEWS_CATEGORY_NEWS_COUNT}</a></li>
<li><a class="e-menu-link newscats{ACTIVE}" href="{NEWS_CATEGORY_URL}">{NEWS_CATEGORY_TITLE}{NEWS_CATEGORY_NEWS_COUNT}</a></li>
';
// months menu
// @deprecated months menu - use news archive instead.
$NEWS_MENU_TEMPLATE['months']['start'] = '<ul class="news-menu-months">';
$NEWS_MENU_TEMPLATE['months']['end'] = '</ul>';
$NEWS_MENU_TEMPLATE['months']['item'] = '
@ -130,7 +130,7 @@ $NEWS_MENU_TEMPLATE['carousel']['item'] = '<!-- Start Item -->
$NEWS_MENU_TEMPLATE['carousel']['nav'] = '<li data-target="#news-carousel" data-slide-to="{COUNT}" class="{ACTIVE}"><a href="#">{NEWS_SUMMARY}</a></li>';
// TODO
$NEWS_MENU_TEMPLATE['archive']['start'] = '<ul class="news-archive-menu">';
$NEWS_MENU_TEMPLATE['archive']['end'] = '</ul>';

View File

@ -1,4 +1,3 @@
<?php
/*
* e107 website system
@ -9,9 +8,12 @@
*
*/
if (!defined('e107_INIT')) { exit; }
if (!defined('e107_INIT'))
{
exit;
}
if (!e107::isInstalled('tagcloud'))
if (!e107::isInstalled('tagcloud'))
{
return '';
}
@ -20,99 +22,99 @@ require_once('tagcloud_class.php');
// http://lotsofcode.github.io/tag-cloud/
class tagcloud_menu
if (!class_exists('tagcloud_menu'))
{
public $template = array();
function __construct()
class tagcloud_menu
{
$this->template = e107::getTemplate('tagcloud','tagcloud_menu','default');
}
function render($parm=null)
{
$cloud = new TagCloud();
$sql = e107::getDb();
e107::getCache()->setMD5(e_LANGUAGE);
if($text = e107::getCache()->retrieve('tagcloud',5,false))
public $template = array();
function __construct()
{
return $text;
$this->template = e107::getTemplate('tagcloud', 'tagcloud_menu', 'default');
}
$nobody_regexp = "'(^|,)(".str_replace(",", "|", e_UC_NOBODY).")(,|$)'";
if($result = $sql->retrieve('news','news_id,news_meta_keywords', "news_meta_keywords !='' AND news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (news_class REGEXP ".$nobody_regexp.")
AND news_start < ".time()." AND (news_end=0 || news_end>".time().")", true))
function render($parm = null)
{
foreach($result as $row)
$cloud = new TagCloud();
$sql = e107::getDb();
e107::getCache()->setMD5(e_LANGUAGE);
if ($text = e107::getCache()->retrieve('tagcloud', 5, false))
{
$tmp = explode(",", $row['news_meta_keywords']);
foreach($tmp as $word)
{
//$newsUrlparms = array('id'=> $row['news_id'], 'name'=>'a name');
$url = e107::getUrl()->create('news/list/tag',array('tag'=>$word)); // SITEURL."news.php?tag=".$word;
$cloud->addTag(array('tag' => $word, 'url' => $url));
}
return $text;
}
$nobody_regexp = "'(^|,)(" . str_replace(",", "|", e_UC_NOBODY) . ")(,|$)'";
if ($result = $sql->retrieve('news', 'news_id,news_meta_keywords', "news_meta_keywords !='' AND news_class REGEXP '" . e_CLASS_REGEXP . "' AND NOT (news_class REGEXP " . $nobody_regexp . ")
AND news_start < " . time() . " AND (news_end=0 || news_end>" . time() . ")", true))
{
foreach ($result as $row)
{
$tmp = explode(",", $row['news_meta_keywords']);
foreach ($tmp as $word)
{
//$newsUrlparms = array('id'=> $row['news_id'], 'name'=>'a name');
$url = e107::getUrl()->create('news/list/tag', array('tag' => $word)); // SITEURL."news.php?tag=".$word;
$cloud->addTag(array('tag' => $word, 'url' => $url));
}
}
}
else
{
$text = "No tags Found";
}
$cloud->setHtmlizeTagFunction(function ($tag, $size)
{
$tp = e107::getParser();
$var = array('TAG_URL' => $tag['url'],
'TAG_SIZE' => $size,
'TAG_NAME' => $tag['tag'],
'TAG_COUNT' => $tag['size'],
);
$text = $tp->simpleParse($this->template['item'], $var);
//$text = "<a class='tag' href='".$tag['url']."'><span class='size".$size."'>".$tag['tag']."</span></a> ";
return $text;
});
$cloud->setOrder('size', 'DESC');
$limit = !empty($parm['tagcloud_limit']) ? intval($parm['tagcloud_limit']) : 50;
$cloud->setLimit($limit);
$text = $cloud->render();
e107::getCache()->set('tagcloud', $text, true);
//$text .= "<div style='clear:both'></div>"; moved to $template['default']['end']
return $text;
}
else
{
$text = "No tags Found";
}
$cloud->setHtmlizeTagFunction( function($tag, $size)
{
$tp = e107::getParser();
$var = array('TAG_URL' => $tag['url'],
'TAG_SIZE' => $size,
'TAG_NAME' => $tag['tag'],
'TAG_COUNT' => $tag['size'],
);
$text = $tp->simpleParse($this->template['item'], $var);
//$text = "<a class='tag' href='".$tag['url']."'><span class='size".$size."'>".$tag['tag']."</span></a> ";
return $text;
});
$cloud->setOrder('size','DESC');
$limit = !empty($parm['tagcloud_limit']) ? intval($parm['tagcloud_limit']) : 50;
$cloud->setLimit($limit);
$text = $cloud->render();
e107::getCache()->set('tagcloud', $text, true);
//$text .= "<div style='clear:both'></div>"; moved to $template['default']['end']
return $text;
}
}
/* TODO: add template type as parm, now always default */
$tag = new tagcloud_menu;
$text = $tag->render($parm);
if(!empty($parm))
if (!empty($parm))
{
if(isset($parm['tagcloud_caption'][e_LANGUAGE]))
if (isset($parm['tagcloud_caption'][e_LANGUAGE]))
{
$caption = $parm['tagcloud_caption'][e_LANGUAGE];
}
@ -124,14 +126,13 @@ else
$var = array('TAGCLOUD_MENU_CAPTION' => $caption);
$caption = e107::getParser()->simpleParse($tag->template['caption'], $var);
$start = $tag->template['start'];
$end = $tag->template['end'];
e107::getRender()->tablerender($caption, $start.$text.$end, 'tagcloud_menu');
$caption = e107::getParser()->simpleParse($tag->template['caption'], $var);
$start = $tag->template['start'];
$end = $tag->template['end'];
e107::getRender()->tablerender($caption, $start . $text . $end, 'tagcloud_menu');
?>

View File

@ -188,6 +188,16 @@ while(&#036;row = &#036;sql-&gt;fetch())
$this->assertEmpty($result);
}
public function testParseTemplateWithEvars()
{
$obj = new e_vars(array('ACTIVE' => "yes"));
$result = $this->tp->parseTemplate('<div>something {ACTIVE}</div>', true, null, $obj);
$expected = '<div>something yes</div>';
$this->assertEquals($expected, $result);
}
/*
public function testCreateConstants()
{