function wikiplugin_fancytable($data, $params)
{
    global $prefs;
    $tagremove = array();
    $pluginremove = array();
    static $iFancytable = 0;
    ++$iFancytable;
    extract($params, EXTR_SKIP);
    if (empty($sortable)) {
        $sortable = 'n';
    }
    $msg = '';
    if (isset($sortable) && $sortable != 'n') {
        include_once 'lib/jquery_tiki/tablesorter/tablesorter-helper.php';
        $tshelper = new tablesorterHelper();
        $tshelper->createCode('fancytable_' . $iFancytable, $sortable, isset($sortList) ? $sortList : null, isset($tsfilters) ? $tsfilters : null, isset($tsfilteroptions) ? $tsfilteroptions : null, isset($tspaginate) ? $tspaginate : null);
        $sort = $tshelper->code !== false ? true : false;
        $tshelper->loadJq();
        if ($sort === false) {
            $msg = tra('The JQuery Sortable Tables feature must be activated for the sort feature to work.');
        }
    } else {
        $sort = false;
    }
    //Start the table
    $wret = '<table class="normal" id="fancytable_' . $iFancytable . '">' . "\r\t";
    //Header
    if (isset($head)) {
        //set header class
        if (!empty($headclass)) {
            $tdhdr = "\r\t\t\t" . '<th class="' . $headclass;
            if (!$sort) {
                $tdhdr .= '"';
            }
        } else {
            $tdhdr = "\r\t\t\t<th";
        }
        //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($head, $tagremove, $pluginremove);
        if ($sort) {
            $type = 'hs';
        } else {
            $type = 'h';
        }
        //now create header table rows
        $headrows = process_section($head, $type, '>>', $tdhdr, '</th>', isset($colwidths) ? $colwidths : '', isset($headaligns) ? $headaligns : '', isset($headvaligns) ? $headvaligns : '', isset($tshelper) ? $tshelper : null);
        //restore original tags and plugin syntax
        postprocess_section($headrows, $tagremove, $pluginremove);
        $buttons = isset($tshelper) ? $tshelper->createThead() : '';
        $wret .= '<thead>' . $buttons . $headrows . "\r\t" . '</thead>' . "\r\t" . '<tbody>';
    }
    //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" . '<td', '</td>', isset($colwidths) ? $colwidths : '', isset($colaligns) ? $colaligns : '', isset($colvaligns) ? $colvaligns : '');
    //restore original tags and plugin syntax
    postprocess_section($bodyrows, $tagremove, $pluginremove);
    $wret .= $bodyrows;
    //end the table
    if (isset($head)) {
        $wret .= "\r\t" . '</tbody>';
    }
    $wret .= "\r" . '</table>' . "\r" . $msg;
    return $wret;
}
function wikiplugin_fancytable($data, $params)
{
    global $prefs;
    $tagremove = array();
    $pluginremove = array();
    static $iFancytable = 0;
    ++$iFancytable;
    extract($params, EXTR_SKIP);
    if (empty($sortable)) {
        $sortable = 'n';
    }
    $msg = '';
    if (isset($sortable) && $sortable != 'n') {
        $ts = new Table_Plugin();
        if ($ts->perms !== false) {
            $ts->setSettings('fancytable_' . $iFancytable, 'n', $sortable, isset($sortList) ? $sortList : null, isset($tsortcolumns) ? $tsortcolumns : null, isset($tsfilters) ? $tsfilters : null, isset($tsfilteroptions) ? $tsfilteroptions : null, isset($tspaginate) ? $tspaginate : null);
        } else {
            $sort = false;
        }
        if (is_array($ts->settings)) {
            Table_Factory::build('plugin', $ts->settings);
            $sort = true;
        } else {
            $sort = false;
        }
        if ($sort === false) {
            if ($prefs['feature_jquery_tablesorter'] === 'n') {
                $msg = '<em>' . tra('The jQuery Sortable Tables feature must be activated for the sort feature to work.') . '</em>';
            } elseif ($prefs['disableJavascript'] === 'y') {
                $msg = '<em>' . tra('Javascript must be enabled for the sort feature to work.') . '</em>';
            } else {
                $msg = '<em>' . tra('Unable to load the jQuery Sortable Tables feature.') . '</em>';
            }
        }
    } else {
        $sort = false;
    }
    //Start the table
    $style = $sort === true ? ' style="visibility:hidden"' : '';
    $wret = '<div id="fancytable_' . $iFancytable . '"' . $style . '>' . "\r\t";
    $wret .= '<table class="normal" id="fancytable_' . $iFancytable . '_table">' . "\r\t";
    //Header
    if (isset($head)) {
        //set header class
        if (!empty($headclass)) {
            $tdhdr = "\r\t\t\t" . '<th class="' . $headclass . '"';
        } else {
            $tdhdr = "\r\t\t\t<th";
        }
        //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($head, $tagremove, $pluginremove);
        if ($sort) {
            $type = 'hs';
        } else {
            $type = 'h';
        }
        //now create header table rows
        $headrows = process_section($head, $type, '>>', $tdhdr, '</th>', isset($colwidths) ? $colwidths : '', isset($headaligns) ? $headaligns : '', isset($headvaligns) ? $headvaligns : '');
        //restore original tags and plugin syntax
        postprocess_section($headrows, $tagremove, $pluginremove);
        $wret .= '<thead>' . $headrows . "\r\t" . '</thead>' . "\r\t" . '<tbody>';
    }
    //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" . '<td', '</td>', isset($colwidths) ? $colwidths : '', isset($colaligns) ? $colaligns : '', isset($colvaligns) ? $colvaligns : '');
    //restore original tags and plugin syntax
    postprocess_section($bodyrows, $tagremove, $pluginremove);
    $wret .= $bodyrows;
    //end the table
    if (isset($head)) {
        $wret .= "\r\t" . '</tbody>';
    }
    $wret .= "\r" . '</table></div>' . "\r" . $msg;
    return $wret;
}