Commit 3f1b0beb authored by lindonb's avatar lindonb

[MRG] Automatic merge, branches/15.x 58026 to 58028

parent 6bb60d92
......@@ -169,6 +169,7 @@ class Search_Formatter_Builder
$GLOBALS['requestUri'],
$this->count,
isset($args['tstotals']) ? $args['tstotals'] : null,
isset($args['tstotalformat']) ? $args['tstotalformat'] : null,
isset($args['tstotaloptions']) ? $args['tstotaloptions'] : null
);
if (is_array($ts->settings)) {
......
......@@ -83,7 +83,7 @@ class Search_Formatter_Plugin_SmartyTemplate implements Search_Formatter_Plugin_
$tsettings = $entries->getTsSettings();
if (is_array($tsettings)) {
$smarty->assign('tstotals', $tsettings['math']['totals']);
$smarty->assign('tsignore', $tsettings['math']['ignore']);
$smarty->assign('tscols', $tsettings['columns']);
}
return $smarty->fetch($this->templateFile);
......
......@@ -34,16 +34,13 @@ class Table_Code_WidgetOptionsMath extends Table_Code_WidgetOptions
//page totals by default
$m[] = 'math_rowFilter : \':not(.filtered):visible\'';
//ignore
if (isset(parent::$s['math']['ignore'])) {
$ignore = [];
foreach(parent::$s['math']['ignore'] as $col) {
if (is_numeric($col)) {
$ignore[] = (int) $col;
}
}
if (count($ignore) > 0) {
$m[] = $this->iterate($ignore, 'math_ignore : [', ']', '', '', ',');
foreach (parent::$s['columns'] as $col => $info) {
if (isset($info['math']['ignore']) && $info['math']['ignore']) {
$ignore[] = $col;
}
}
if (isset($ignore) && count($ignore) > 0) {
$m[] = $this->iterate($ignore, 'math_ignore : [', ']', '', '', ',');
} else {
$m[] = 'math_ignore : [0]';
}
......
......@@ -241,17 +241,22 @@ class Table_Plugin
'filter' => 'striptags',
'advanced' => true,
),
'tstotalformat' => array(
'required' => false,
'name' => tra('Total Format'),
'description' => tr('Format for table totals (click %0 for patterns). Example:',
'<a href="http://mottie.github.io/tablesorter/docs/example-widget-math.html#mask_examples">here</a>')
. ' <code>format:#,###.</code><br>',
),
'tstotaloptions' => array(
'required' => false,
'name' => tra('Total Options'),
'description' => tr('Options for totals which are set in the %0 parameter:', '<code>tstotals</code>')
. '<br><strong>format</strong> - ' . tr('sets the number format (click %0 for patterns).
Example:', '<a href="http://mottie.github.io/tablesorter/docs/example-widget-math.html#mask_examples">here</a>')
. ' <code>format:$#,##0.00</code><br>'
. '<strong>ignore</strong> - ' . tr('indicate comma-separated columns (by number starting
with 0) that should be excluded from all total calculations set in the %0 parameter. Remember to
include any columns that will be added for row totals set in the %0 parameter. Example:',
'<code>tstotals</code>') . '<code>ignore:0,1,4</code><br>',
'description' => tr('Pipe-separated options for totals for each column which are set in the %0 parameter:',
'<code>tstotals</code>') . '<br><strong>format</strong> - '
. tr('overrides the default number format set in %0', 'tstotalformat') . '<br>'
. '<strong>ignore</strong> - ' . tr('column will be excluded from total calculations set in the %0
parameter. Remember to include any columns that will be added for row totals set in the %0
parameter.', '<code>tstotals</code>') . '<br>' . tr('Example:') . '<code>ignore|ignore|format:#,###.</code>',
'since' => '15.0',
'doctype' => 'tablesorter',
'default' => '',
......@@ -281,7 +286,7 @@ class Table_Plugin
*/
public function setSettings ($id = null, $server = 'n', $sortable = 'n', $sortList = null, $tsortcolumns = null,
$tsfilters = null, $tsfilteroptions = null, $tspaginate = null, $tscolselect = null, $ajaxurl = null,
$totalrows = null, $tstotals = null, $tstotaloptions = null)
$totalrows = null, $tstotals = null, $tstotalformat = null, $tstotaloptions = null)
{
$s = array();
......@@ -498,16 +503,20 @@ class Table_Plugin
}
}
//tstotalformat
if (!empty($tstotalformat)) {
$s['math']['format'] = $tstotalformat;
}
//tstotaloptions
if (!empty($tstotaloptions)) {
$tsto = Table_Check::parseParam($tstotaloptions);
if (is_array($tsto[0])) {
foreach($tsto[0] as $option => $string) {
if (in_array($option, ['format', 'ignore'])) {
if ($option == 'ignore') {
$string = explode(',', $string);
}
$s['math'][$option] = $string;
if (is_array($tsto)) {
foreach($tsto as $col => $option) {
if ($option === 'ignore') {
$s['columns'][$col]['math']['ignore'] = true;
} elseif (!empty($option)) {
$s['columns'][$col]['math']['format'] = $option;
}
}
}
......
......@@ -32,7 +32,7 @@ class Table_Totals
$smarty = TikiLib::lib('smarty');
$smarty->assign('fieldcount', $count);
$smarty->assign('tstotals', $s['math']['totals']);
$smarty->assign('tsignore', $s['math']['ignore']);
$smarty->assign('tscols', $s['columns']);
return $smarty->fetch('tablesorter/totals.tpl');
}
} else {
......@@ -49,7 +49,7 @@ class Table_Totals
if (!empty($s['math'])) {
$smarty = TikiLib::lib('smarty');
$smarty->assign('tstotals', $s['math']['totals']);
$smarty->assign('tsignore', $s['math']['ignore']);
$smarty->assign('tscols', $s['columns']);
}
}
}
......
......@@ -119,6 +119,7 @@ function wikiplugin_fancytable($data, $params)
null,
null,
isset($tstotals) ? $tstotals : null,
isset($tstotalformat) ? $tstotalformat : null,
isset($tstotaloptions) ? $tstotaloptions : null
);
if (is_array($ts->settings)) {
......
......@@ -1976,6 +1976,7 @@ function wikiplugin_trackerlist($data, $params)
$GLOBALS['requestUri'],
$items['cant'],
isset($tstotals) ? $tstotals : null,
isset($tstotalformat) ? $tstotalformat : null,
isset($tstotaloptions) ? $tstotaloptions : null
);
//loads the jquery tablesorter code
......
......@@ -24,12 +24,17 @@
{/if}
{for $i=1 to $fieldcount}
{$index = $i - 1 + $precols}
{if in_array($index, $tsignore)}
{if isset($tscols.$index.math.ignore) && $tscols.$index.math.ignore}
{$ignore = 1}
{$format = 0}
{elseif !empty($tscols.$index.math.format)}
{$ignore = 0}
{$format = " data-tsmath-mask='{$tscols.$index.math.format}'"}
{else}
{$ignore = 0}
{$format = 0}
{/if}
<th {if !empty($info.formula) && !$ignore}data-tsmath="col-{$info.formula|escape}" class="text-right"{if !empty($info.filter)} data-tsmath-filter="{$info.filter}"{/if}{/if} data-index="{$index}">
<th {if !empty($info.formula) && !$ignore}data-tsmath="col-{$info.formula|escape}" class="text-right"{if !empty($info.filter)} data-tsmath-filter="{$info.filter}"{/if}{if $format}{$format}{/if}{/if} data-index="{$index}">
{if $i === 1 && $ignore && empty($precols)}
{$info.label|escape}
{/if}
......@@ -55,7 +60,13 @@
<tr class="ts-foot-row">
{$allcols = $precols + $fieldcount + $postcols + $rowtotal}
{for $i=1 to $allcols}
<th {if $i == $allcols && !empty($tableinfo.formula)}data-tsmath="all-{$tableinfo.formula}" class="text-right"{if !empty($tableinfo.filter)} data-tsmath-filter="{$tableinfo.filter}"{/if}{/if}>
{$index = $i -1}
{if !empty($tscols.$index.math.format)}
{$format = " data-tsmath-mask='{$tscols.$index.math.format}'"}
{else}
{$format = 0}
{/if}
<th {if $i == $allcols && !empty($tableinfo.formula)}data-tsmath="all-{$tableinfo.formula}" class="text-right"{if !empty($tableinfo.filter)} data-tsmath-filter="{$tableinfo.filter}"{/if}{if $format}{$format}{/if}{/if}>
{if $i === 1}
{$tableinfo.label|escape}
{/if}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment