ТДС облако тегов для ИС
<?php
if (Core::moduleIsActive('informationsystem') && Core::moduleIsActive('tag') && isset(Core_Page::instance()->libParams['informationsystemId']))
{
$informationsystem_id = Core_Page::instance()->libParams['informationsystemId'];
$xsl = Core_Array::get(Core_Page::instance()->widgetParams, 'xsl');
$Informationsystem_Controller_Tag_Show = new Informationsystem_Controller_Tag_Show(
Core_Entity::factory('Informationsystem', $informationsystem_id)
);
$Informationsystem_Controller_Tag_Show
->xsl(
Core_Entity::factory('Xsl')->getByName($xsl)
);
if (is_object(Core_Page::instance()->object)
&& get_class(Core_Page::instance()->object) == 'Informationsystem_Controller_Show'
&& Core_Page::instance()->object->group)
{
$Informationsystem_Controller_Tag_Show->group(Core_Page::instance()->object->group);
}
if (is_object(Core_Page::instance()->object)
&& get_class(Core_Page::instance()->object) == 'Informationsystem_Controller_Show')
{
$Informationsystem_Controller_Tag_Show->show();
}
}
?>
XSL шаблон
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE xsl:stylesheet>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:hostcms="http://www.hostcms.ru/"
exclude-result-prefixes="hostcms">
<xsl:output xmlns="http://www.w3.org/TR/xhtml1/strict" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" encoding="utf-8" indent="yes" method="html" omit-xml-declaration="no" version="1.0" media-type="text/xml"/>
<!-- ОблакоТэговИнформационнойСистемы -->
<xsl:template match="/">
<xsl:apply-templates select="/informationsystem"/>
</xsl:template>
<xsl:template match="/informationsystem">
<xsl:if test="count(tag) != 0">
<div class="title">Метки</div>
<xsl:variable name="max_tag_count" select="(/informationsystem/tag/count[not(. < /informationsystem/tag/count)])[1] - 1"/>
<xsl:variable name="max_size" select="16"/>
<xsl:variable name="min_size" select="9"/>
<xsl:variable name="coeff_size">
<xsl:choose>
<xsl:when test="$max_tag_count > 0">
<xsl:value-of select="($max_size - $min_size) div $max_tag_count"/>
</xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<div class="TagsCloud">
<xsl:apply-templates select="tag">
<xsl:with-param name="min_size" select="$min_size"/>
<xsl:with-param name="coeff_size" select="$coeff_size"/>
</xsl:apply-templates>
</div>
</xsl:if>
</xsl:template>
<!-- Запишем в константу ID структуры, данные для которой будут выводиться пользователю -->
<xsl:variable name="current_structure_id" select="/informationsystem/current_structure_id"/>
<!-- Облако из групп -->
<xsl:template match="tag">
<xsl:param name="min_size"/>
<xsl:param name="coeff_size" select="10"/>
<!-- Нужный размер шрифта вычисляется по формуле $min_size + количество * $coeff_size -->
<xsl:variable name="size" select="round($min_size + ((count - 1) * $coeff_size))"/>
<xsl:variable name="group_path"><xsl:if test="/informationsystem/ПутьКГруппе/node()"><xsl:value-of select="/informationsystem/ПутьКГруппе" /></xsl:if></xsl:variable>
<a name="current_link" href="{/informationsystem/url}{$group_path}tag/{urlencode}/" style="font-size: {$size}pt" hostcms:id="{@id}" hostcms:field="name" hostcms:entity="tag">
<xsl:value-of select="name"/>
</a><xsl:text> </xsl:text>
</xsl:template>
</xsl:stylesheet>