createParams();
$tsparams = $ts->params;
unset($tsparams['server']);
} else {
$tsparams = [];
}
$params = array_merge(
[
'head' => [
'required' => false,
'name' => tra('Heading Row'),
'description' => tr('Header rows of the table. Use %0 to separate multiple rows.', '>>'),
'default' => '',
'since' => '1'
],
'headclass' => [
'required' => false,
'name' => tra('Heading CSS Class'),
'description' => tra('CSS class to apply to the heading row.'),
'default' => '',
'since' => '1'
],
'headaligns' => [
'required' => false,
'name' => tra('Header Horizontal Alignment'),
'description' => tr(
'Horizontal alignments for header cells, separated by %0. Choices: %1',
'|',
'left, right, center, justify'
),
'default' => '',
'since' => '4.1',
'filter' => 'text',
],
'headvaligns' => [
'required' => false,
'name' => tra('Header Vertical Alignment'),
'description' => tr(
'Vertical alignments for header cells, separated by %0". Choices: %1',
'|',
'top, middle, bottom, baseline'
),
'default' => '',
'since' => '4.1',
'filter' => 'text',
],
'colwidths' => [
'required' => false,
'name' => tra('Column Widths'),
'description' => tr('Column widths followed by "px" for pixels or "%" for percentages. Each column
separated by %0.', '|'),
'default' => '',
'since' => '4.1'
],
'colaligns' => [
'required' => false,
'name' => tra('Cell Horizontal Align'),
'description' => tr(
'Table body column horizontal alignments, separated by %0. Choices: %1',
'|',
'left, right, center, justify'
),
'default' => '',
'since' => '4.1',
'filter' => 'text',
],
'colvaligns' => [
'required' => false,
'name' => tra('Cell Vertical Align'),
'description' => tr(
'Table body column vertical alignments, separated by %0. Choices: %1',
'|',
'top, middle, bottom, baseline'
),
'default' => '',
'since' => '4.1',
'filter' => 'text',
],
],
$tsparams
);
return [
'name' => tra('Fancy Table'),
'documentation' => 'PluginFancyTable',
'description' => tra('Create a formatted table that can be filtered and sorted'),
'prefs' => ['wikiplugin_fancytable'],
'body' => tr(
'Rows separated by %0 in the header; for the table body, one row per line. Cells separated by %1 (since Tiki4) or %2 in both cases.',
'>>',
'|',
'~|~'
),
'iconname' => 'table',
'introduced' => 1,
'tags' => [ 'basic' ],
'params' => $params,
];
}
function wikiplugin_fancytable($data, $params)
{
global $prefs;
$tagremove = [];
$pluginremove = [];
static $iFancytable = 0;
++$iFancytable;
extract($params, EXTR_SKIP);
if (empty($sortable)) {
$sortable = 'n';
}
$msg = '';
if ((isset($sortable) && $sortable != 'n')) {
if (Table_Check::isEnabled()) {
$ts = new Table_Plugin();
$ts->setSettings(
'wpfancytable' . $iFancytable,
'n',
$sortable,
isset($sortList) ? $sortList : null,
isset($tsortcolumns) ? $tsortcolumns : null,
isset($tsfilters) ? $tsfilters : null,
isset($tsfilteroptions) ? $tsfilteroptions : null,
isset($tspaginate) ? $tspaginate : null,
isset($tscolselect) ? $tscolselect : null,
null,
null,
isset($tstotals) ? $tstotals : null,
isset($tstotalformat) ? $tstotalformat : null,
isset($tstotaloptions) ? $tstotaloptions : null
);
if (is_array($ts->settings)) {
$ts->settings['resizable'] = true;
Table_Factory::build('plugin', $ts->settings);
$sort = true;
} else {
$sort = false;
}
} else {
$sort = false;
}
if ($sort === false) {
if ($prefs['feature_jquery_tablesorter'] === 'n') {
$msg = '' . tra('The jQuery Sortable Tables feature must be activated for the sort feature to work.')
. '';
} elseif ($prefs['javascript_enabled'] !== 'y') {
$msg = '' . tra('JavaScript must be enabled for the sort feature to work.') . '';
} else {
$msg = '' . tra('Unable to load the jQuery Sortable Tables feature.') . '';
}
}
} else {
$sort = false;
}
//Start the table
$style = $sort === true ? ' style="visibility:hidden"' : '';
$wret = '
| >', $tdhdr, ' | ', isset($colwidths) ? $colwidths : '', isset($headaligns) ? $headaligns : '', isset($headvaligns) ? $headvaligns : '' ); //restore original tags and plugin syntax $headhtml = $headrows['html']; postprocess_section($headhtml, $tagremove, $pluginremove); $wret .= '' . $headhtml . "\r\t" . '' . "\r\t"; } //Body //replace tiki tags, plugins and other enclosing characters with hash strings before creating table so that any //pipes (| or ~|~) inside aren't mistaken for cell dividers preprocess_section($data, $tagremove, $pluginremove); if ($sort) { $type = 'bs'; //sortable body rows - do not assign odd/even class to these since jquery will do it } else { $type = 'b'; //plain body rows } //now create table body rows $bodyrows = process_section( $data, $type, "\n", "\r\t\t\t" . '', isset($colwidths) ? $colwidths : '', isset($colaligns) ? $colaligns : '', isset($colvaligns) ? $colvaligns : '' ); //restore original tags and plugin syntax $bodyhtml = $bodyrows['html']; postprocess_section($bodyhtml, $tagremove, $pluginremove); //end the tbody $wret .= ' | ' . $bodyhtml . "\r\t" . ''; if (isset($ts->settings)) { $footer = Table_Totals::getTotalsHtml($ts->settings, $bodyrows['cols']); if ($footer) { $wret .= $footer; } } $wret .= "\r" . '
|---|