diff --git a/e107_handlers/news_class.php b/e107_handlers/news_class.php index 8ef56cae2..ad3c1b082 100644 --- a/e107_handlers/news_class.php +++ b/e107_handlers/news_class.php @@ -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); diff --git a/e107_plugins/news/templates/news_menu_template.php b/e107_plugins/news/templates/news_menu_template.php index a803c3bb8..5d9960ffc 100644 --- a/e107_plugins/news/templates/news_menu_template.php +++ b/e107_plugins/news/templates/news_menu_template.php @@ -19,14 +19,14 @@ global $sc_style; $NEWS_MENU_TEMPLATE['category']['start'] = ''; $NEWS_MENU_TEMPLATE['category']['item'] = ' -
  • {NEWS_CATEGORY_TITLE}{NEWS_CATEGORY_NEWS_COUNT}
  • +
  • {NEWS_CATEGORY_TITLE}{NEWS_CATEGORY_NEWS_COUNT}
  • '; -// months menu +// @deprecated months menu - use news archive instead. $NEWS_MENU_TEMPLATE['months']['start'] = ''; $NEWS_MENU_TEMPLATE['months']['item'] = ' @@ -130,7 +130,7 @@ $NEWS_MENU_TEMPLATE['carousel']['item'] = ' $NEWS_MENU_TEMPLATE['carousel']['nav'] = '
  • {NEWS_SUMMARY}
  • '; -// TODO + $NEWS_MENU_TEMPLATE['archive']['start'] = ''; diff --git a/e107_plugins/tagcloud/tagcloud_menu.php b/e107_plugins/tagcloud/tagcloud_menu.php index 2c8f8a209..cbda4d919 100644 --- a/e107_plugins/tagcloud/tagcloud_menu.php +++ b/e107_plugins/tagcloud/tagcloud_menu.php @@ -1,4 +1,3 @@ - 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 = "".$tag['tag']." "; + + 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 .= "
    "; 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 = "".$tag['tag']." "; - - 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 .= "
    "; 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'); -?> \ No newline at end of file diff --git a/e107_tests/tests/unit/e_parseTest.php b/e107_tests/tests/unit/e_parseTest.php index 696ea6e7e..73c8e0273 100644 --- a/e107_tests/tests/unit/e_parseTest.php +++ b/e107_tests/tests/unit/e_parseTest.php @@ -188,6 +188,16 @@ while($row = $sql->fetch()) $this->assertEmpty($result); } + public function testParseTemplateWithEvars() + { + $obj = new e_vars(array('ACTIVE' => "yes")); + $result = $this->tp->parseTemplate('
    something {ACTIVE}
    ', true, null, $obj); + $expected = '
    something yes
    '; + + $this->assertEquals($expected, $result); + + } + /* public function testCreateConstants() {