1
0
mirror of https://github.com/e107inc/e107.git synced 2025-06-03 09:25:27 +02:00

templating tagcloud plugin

This commit is contained in:
Jimmi08 2018-01-02 15:23:23 +01:00
parent 2d9846272b
commit 732cf81101
2 changed files with 41 additions and 8 deletions

View File

@ -1,3 +1,4 @@
<?php
/*
* e107 website system
@ -23,15 +24,18 @@ require_once('tagcloud_class.php');
class tagcloud_menu
{
public $template = array();
function __construct()
{
$this->template = e107::getTemplate('tagcloud','tagcloud_menu','default');
}
function render($parm=null)
{
$cloud = new TagCloud();
$cloud = new TagCloud();
$sql = e107::getDb();
e107::getCache()->setMD5(e_LANGUAGE);
@ -65,7 +69,17 @@ class tagcloud_menu
$cloud->setHtmlizeTagFunction( function($tag, $size)
{
return "<a class='tag' href='".$tag['url']."'><span class='size".$size."'>".$tag['tag']."</span></a> ";
$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');
@ -78,7 +92,7 @@ class tagcloud_menu
e107::getCache()->set('tagcloud', $text, true);
$text .= "<div style='clear:both'></div>";
//$text .= "<div style='clear:both'></div>"; moved to $template['default']['end']
return $text;
@ -88,7 +102,7 @@ class tagcloud_menu
}
/* TODO: add template type as parm, now always default */
$tag = new tagcloud_menu;
$text = $tag->render($parm);
@ -106,9 +120,14 @@ else
$caption = LAN_PLUGIN_TAGCLOUD_NAME;
}
$var = array('TAGCLOUD_MENU_CAPTION' => $caption);
e107::getRender()->tablerender($caption, "<div class='tagcloud-menu'>".$text."</div>", '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

@ -0,0 +1,14 @@
<?php
$TAGCLOUD_MENU_TEMPLATE = array();
$TAGCLOUD_MENU_TEMPLATE['default']['caption'] = '{TAGCLOUD_MENU_CAPTION}';
$TAGCLOUD_MENU_TEMPLATE['default']['start'] = '<div class="tagcloud-menu">';
$TAGCLOUD_MENU_TEMPLATE['default']['item'] = "<a class='tag' href='{TAG_URL}'><span class='size{TAG_SIZE}'>{TAG_NAME}</span></a>";
$TAGCLOUD_MENU_TEMPLATE['default']['end'] = '<div style="clear:both"></div></div>';
/* example for the same size tag
$TAGCLOUD_MENU_TEMPLATE['default']['caption'] = '{TAGCLOUD_MENU_CAPTION}';
$TAGCLOUD_MENU_TEMPLATE['default']['start'] = '<div class="tag-cloud">';
$TAGCLOUD_MENU_TEMPLATE['default']['item'] = '<span class="badge"><a href="{TAG_URL}">{TAG_NAME}</a> ({TAG_COUNT})</span>';
$TAGCLOUD_MENU_TEMPLATE['default']['end'] = '</div>';
*/