/
_dataTableCell.twig
42 lines (38 loc) · 2.62 KB
/
_dataTableCell.twig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
{% spaceless %}
{% set tooltipIndex = column ~ '_tooltip' %}
{% if row.getMetadata(tooltipIndex) %}<span class="cell-tooltip" data-tooltip="{{ row.getMetadata(tooltipIndex) }}">{% endif %}
{% if not row.getIdSubDataTable() and column=='label' and row.getMetadata('url') %}
<a target="_blank" href='{% if row.getMetadata('url')|slice(0,4) not in ['http','ftp:'] %}http://{% endif %}{{ row.getMetadata('url') }}'>
{% if not row.getMetadata('logo') %}
<img class="link" width="10" height="9" src="plugins/Zeitgeist/images/link.gif"/>
{% endif %}
{% endif %}
{% if column=='label' %}
{% import 'macros.twig' as piwik %}
{{ piwik.logoHtml(row.getMetadata(), row.getColumn('label')) }}
{% if row.getMetadata('html_label_prefix') %}<span class='label-prefix'>{{ row.getMetadata('html_label_prefix') | raw }} </span>{% endif -%}
<span class='label{% if row.getMetadata('is_aggregate') %} highlighted{% endif %}'
{% if properties is defined and properties.tooltip_metadata_name is not empty %}title="{{ row.getMetadata(properties.tooltip_metadata_name) }}"{% endif %}>
{%- if row.getMetadata('html_label_suffix') %}<span class='label-suffix'>{{ row.getMetadata('html_label_suffix') | raw }}</span>{% endif -%}
{% endif %}{% if row.getColumn(column) %}{{- row.getColumn(column)|raw -}}{% else %}-{% endif %}
{% if column=='label' %}</span>{% endif %}
{% if not row.getIdSubDataTable() and column=='label' and row.getMetadata('url') %}
</a>
{% endif %}
{% if row.getMetadata(tooltipIndex) %}</span>{% endif %}
{% set totals = dataTable.getMetadata('totals') %}
{% if column in totals|keys -%}
{% set labelColumn = columns_to_display|first %}
{% set reportTotal = totals[column] %}
{% set siteTotal = siteSummary.getFirstRow.getColumn(column) %}
{% set rowPercentage = row.getColumn(column)|percentage(reportTotal, 1) %}
{% set firstPartOfTooltip = ["'", row.getColumn(labelColumn)|truncate(40), "' represents ", rowPercentage, ' of ', reportTotal, ' ', translations[column]|default(column), ' with ', translations[labelColumn]|default(labelColumn), '.']|join %}
{% if siteTotal and siteTotal != reportTotal %}
{% set totalPercentage = row.getColumn(column)|percentage(siteTotal, 1) %}
{% set secondPartOfTooltip = ['This is ', totalPercentage, ' of all ', siteTotal, ' ', translations[column]|default(column), '.']|join %}
{% else %}
{% set secondPartOfTooltip = '' %}
{% endif %}
<span class="ratio" title="{{ firstPartOfTooltip|e('html_attr') }} {{ secondPartOfTooltip|e('html_attr') }}"> {{ rowPercentage }}</span>
{%- endif %}
{% endspaceless %}