コード例 #1
0
 /**
  * Tests tablesort_init().
  */
 function testTableSortInit()
 {
     // Test simple table headers.
     $headers = array('foo', 'bar', 'baz');
     // Reset $request->query to prevent parameters from Simpletest and Batch API
     // ending up in $ts['query'].
     $expected_ts = array('name' => 'foo', 'sql' => '', 'sort' => 'asc', 'query' => array());
     $request = Request::createFromGlobals();
     $request->query->replace(array());
     \Drupal::getContainer()->get('request_stack')->push($request);
     $ts = tablesort_init($headers);
     $this->verbose(strtr('$ts: <pre>!ts</pre>', array('!ts' => Html::escape(var_export($ts, TRUE)))));
     $this->assertEqual($ts, $expected_ts, 'Simple table headers sorted correctly.');
     // Test with simple table headers plus $_GET parameters that should _not_
     // override the default.
     $request = Request::createFromGlobals();
     $request->query->replace(array('order' => 'bar'));
     \Drupal::getContainer()->get('request_stack')->push($request);
     $ts = tablesort_init($headers);
     $this->verbose(strtr('$ts: <pre>!ts</pre>', array('!ts' => Html::escape(var_export($ts, TRUE)))));
     $this->assertEqual($ts, $expected_ts, 'Simple table headers plus non-overriding $_GET parameters sorted correctly.');
     // Test with simple table headers plus $_GET parameters that _should_
     // override the default.
     $request = Request::createFromGlobals();
     $request->query->replace(array('sort' => 'DESC', 'alpha' => 'beta'));
     \Drupal::getContainer()->get('request_stack')->push($request);
     $expected_ts['sort'] = 'desc';
     $expected_ts['query'] = array('alpha' => 'beta');
     $ts = tablesort_init($headers);
     $this->verbose(strtr('$ts: <pre>!ts</pre>', array('!ts' => Html::escape(var_export($ts, TRUE)))));
     $this->assertEqual($ts, $expected_ts, 'Simple table headers plus $_GET parameters sorted correctly.');
     // Test complex table headers.
     $headers = array('foo', array('data' => '1', 'field' => 'one', 'sort' => 'asc', 'colspan' => 1), array('data' => '2', 'field' => 'two', 'sort' => 'desc'));
     // Reset $_GET from previous assertion.
     $request = Request::createFromGlobals();
     $request->query->replace(array('order' => '2'));
     \Drupal::getContainer()->get('request_stack')->push($request);
     $ts = tablesort_init($headers);
     $expected_ts = array('name' => '2', 'sql' => 'two', 'sort' => 'desc', 'query' => array());
     $this->verbose(strtr('$ts: <pre>!ts</pre>', array('!ts' => Html::escape(var_export($ts, TRUE)))));
     $this->assertEqual($ts, $expected_ts, 'Complex table headers sorted correctly.');
     // Test complex table headers plus $_GET parameters that should _not_
     // override the default.
     $request = Request::createFromGlobals();
     $request->query->replace(array('order' => 'bar'));
     \Drupal::getContainer()->get('request_stack')->push($request);
     $ts = tablesort_init($headers);
     $expected_ts = array('name' => '1', 'sql' => 'one', 'sort' => 'asc', 'query' => array());
     $this->verbose(strtr('$ts: <pre>!ts</pre>', array('!ts' => Html::escape(var_export($ts, TRUE)))));
     $this->assertEqual($ts, $expected_ts, 'Complex table headers plus non-overriding $_GET parameters sorted correctly.');
     // Test complex table headers plus $_GET parameters that _should_
     // override the default.
     $request = Request::createFromGlobals();
     $request->query->replace(array('order' => '1', 'sort' => 'ASC', 'alpha' => 'beta'));
     \Drupal::getContainer()->get('request_stack')->push($request);
     $expected_ts = array('name' => '1', 'sql' => 'one', 'sort' => 'asc', 'query' => array('alpha' => 'beta'));
     $ts = tablesort_init($headers);
     $this->verbose(strtr('$ts: <pre>!ts</pre>', array('!ts' => Html::escape(var_export($ts, TRUE)))));
     $this->assertEqual($ts, $expected_ts, 'Complex table headers plus $_GET parameters sorted correctly.');
 }
コード例 #2
0
ファイル: template.php プロジェクト: Frantsuzzz/drupal.ru
/**
 * Preprocesses variables for forum-topic-list.tpl.php.
 *
 * @param $variables
 *   An array containing the following elements:
 *   - tid: Taxonomy term ID of the current forum.
 *   - topics: An array of all the topics in the current forum.
 *   - forum_per_page: The maximum number of topics to display per page.
 *
 * @see forum-topic-list.tpl.php
 * @see theme_forum_topic_list()
 */
function alpha_preprocess_forum_topic_list(&$variables)
{
    global $forum_topic_list_header;
    $ts = tablesort_init($forum_topic_list_header);
    $sort_header = '';
    $current_active = '';
    foreach ($forum_topic_list_header as $cell) {
        $html = _forum_tablesort_header($cell, $forum_topic_list_header, $ts);
        $sort_header .= '<li>' . $html['data'] . '</li>';
        if (isset($html['class'])) {
            $title_class = $html['sort'] == 'asc' ? 'sort-desc' : 'sort-asc';
            $current_active = '<span class="' . $title_class . '">' . $cell['data'] . '</span>';
        }
    }
    $variables['sort_header'] = '<div class="btn-group">
  <button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">' . $current_active . ' <span class="caret"></span></button>
<ul class="dropdown-menu"> 
' . $sort_header . '
</ul> </div>';
    foreach ($variables['topics'] as $key => $topic) {
        $variables['topics'][$key]->time = format_interval(REQUEST_TIME - $topic->last_comment_timestamp);
    }
}
コード例 #3
0
ファイル: template.php プロジェクト: rtdean93/tbytam
/**
 * Implements hook_preprocess_forum_topic_list
 */

function carbon_preprocess_forum_topic_list(&$vars) {
  // Recreate the topic list header
  $list = array(
    array('data' => t('Topic'), 'field' => 'f.title'),
    array('data' => t('Replies'), 'field' => 'f.comment_count'),
    array('data' => t('Created'), 'field' => 't.created'),
    array('data' => t('Last reply'), 'field' => 'f.last_comment_timestamp'),
  );
  
  $ts = tablesort_init($list);
  $header = '';
  foreach ($list as $cell) {
    $cell = tablesort_header($cell, $list, $ts);
    $header .= _theme_table_cell($cell, TRUE);
  }
  $vars['header'] = $header;
}
コード例 #4
0
ファイル: template.php プロジェクト: hoangbktech/bhl-bits
function phptemplate_table($header, $rows, $attributes = array(), $caption = NULL)
{
    $output = '<div class="tablewrapper">';
    $output .= '<table' . drupal_attributes($attributes) . " class=\"tableclass\">\n";
    if (isset($caption)) {
        $output .= '<caption>' . $caption . "</caption>\n";
    }
    // Format the table header:
    if (count($header)) {
        $ts = tablesort_init($header);
        $output .= ' <thead><tr>';
        foreach ($header as $cell) {
            $cell = tablesort_header($cell, $header, $ts);
            $output .= _theme_table_cell($cell, TRUE);
        }
        $output .= " </tr></thead>\n";
    }
    // Format the table rows:
    $output .= "<tbody>\n";
    if (count($rows)) {
        $flip = array('even' => 'odd', 'odd' => 'even');
        $class = 'even';
        foreach ($rows as $number => $row) {
            $attributes = array();
            // Check if we're dealing with a simple or complex row
            if (isset($row['data'])) {
                foreach ($row as $key => $value) {
                    if ($key == 'data') {
                        $cells = $value;
                    } else {
                        $attributes[$key] = $value;
                    }
                }
            } else {
                $cells = $row;
            }
            // Add odd/even class
            $class = $flip[$class];
            if (isset($attributes['class'])) {
                $attributes['class'] .= ' ' . $class;
            } else {
                $attributes['class'] = $class;
            }
            // Build row
            $output .= ' <tr' . drupal_attributes($attributes) . '>';
            $i = 0;
            foreach ($cells as $cell) {
                $cell = tablesort_cell($cell, $header, $ts, $i++);
                $output .= _theme_table_cell($cell);
            }
            $output .= " </tr>\n";
        }
    }
    $output .= "</tbody></table>\n";
    $output .= "</div>\n";
    return $output;
}
コード例 #5
0
ファイル: table.tpl.php プロジェクト: kimlop/platform-dev
}
// Add the 'empty' row message if available.
if (!count($rows) && $empty) {
    $header_count = 0;
    foreach ($header as $header_cell) {
        if (is_array($header_cell)) {
            $header_count += isset($header_cell['colspan']) ? $header_cell['colspan'] : 1;
        } else {
            $header_count++;
        }
    }
    $rows[] = array(array('data' => $empty, 'colspan' => $header_count, 'class' => array('empty', 'message')));
}
// Format the table header:
if (count($header)) {
    $ts = tablesort_init($header);
    // HTML requires that the thead tag has tr tags in it followed by tbody
    // tags. Using ternary operator to check and see if we have any rows.
    $output .= count($rows) ? ' <thead><tr>' : ' <tr>';
    foreach ($header as $cell) {
        $cell = tablesort_header($cell, $header, $ts);
        $output .= _theme_table_cell($cell, TRUE);
    }
    // Using ternary operator to close the tags based on whether or not there are rows
    $output .= count($rows) ? " </tr></thead>\n" : "</tr>\n";
} else {
    $ts = array();
}
// Format the table rows:
if (count($rows)) {
    $output .= "<tbody>\n";
コード例 #6
0
ファイル: template.php プロジェクト: ec-europa/platform-dev
/**
 * Implements theme_table().
 */
function ec_resp_table($variables)
{
    $header = $variables['header'];
    $rows = $variables['rows'];
    $attributes = $variables['attributes'];
    $caption = $variables['caption'];
    $colgroups = $variables['colgroups'];
    $sticky = $variables['sticky'];
    $empty = $variables['empty'];
    // Add sticky headers, if applicable.
    if (count($header) && $sticky) {
        drupal_add_js('misc/tableheader.js');
        // Add 'sticky-enabled' class to the table to identify it for JS.
        // This is needed to target tables constructed by this function.
        $attributes['class'][] = 'sticky-enabled table table-striped';
    }
    $output = '<table' . drupal_attributes($attributes) . ">\n";
    if (isset($caption)) {
        $output .= '<caption>' . $caption . "</caption>\n";
    }
    // Format the table columns:
    if (count($colgroups)) {
        foreach ($colgroups as $number => $colgroup) {
            $attributes = array();
            // Check if we're dealing with a simple or complex column.
            if (isset($colgroup['data'])) {
                foreach ($colgroup as $key => $value) {
                    if ($key == 'data') {
                        $cols = $value;
                    } else {
                        $attributes[$key] = $value;
                    }
                }
            } else {
                $cols = $colgroup;
            }
            // Build colgroup.
            if (is_array($cols) && count($cols)) {
                $output .= ' <colgroup' . drupal_attributes($attributes) . '>';
                $i = 0;
                foreach ($cols as $col) {
                    $output .= ' <col' . drupal_attributes($col) . ' />';
                }
                $output .= " </colgroup>\n";
            } else {
                $output .= ' <colgroup' . drupal_attributes($attributes) . " />\n";
            }
        }
    }
    // Add the 'empty' row message if available.
    if (!count($rows) && $empty) {
        $header_count = 0;
        foreach ($header as $header_cell) {
            if (is_array($header_cell)) {
                $header_count += isset($header_cell['colspan']) ? $header_cell['colspan'] : 1;
            } else {
                $header_count++;
            }
        }
        $rows[] = array(array('data' => $empty, 'colspan' => $header_count, 'class' => array('empty', 'message')));
    }
    // Format the table header:
    if (count($header)) {
        $ts = tablesort_init($header);
        // HTML requires that the thead tag has tr tags in it followed by tbody
        // tags. Using ternary operator to check and see if we have any rows.
        $output .= count($rows) ? ' <thead><tr>' : ' <tr>';
        foreach ($header as $cell) {
            $cell = tablesort_header($cell, $header, $ts);
            $output .= _theme_table_cell($cell, TRUE);
        }
        // Using ternary operator to close the tags based on whether
        // or not there are rows.
        $output .= count($rows) ? " </tr></thead>\n" : "</tr>\n";
    } else {
        $ts = array();
    }
    // Format the table rows:
    if (count($rows)) {
        $output .= "<tbody>\n";
        $flip = array('even' => 'odd', 'odd' => 'even');
        $class = 'even';
        foreach ($rows as $number => $row) {
            // Check if we're dealing with a simple or complex row.
            if (isset($row['data'])) {
                foreach ($row as $key => $value) {
                    if ($key == 'data') {
                        $cells = $value;
                    } else {
                        $attributes[$key] = $value;
                    }
                }
            } else {
                $cells = $row;
            }
            if (count($cells)) {
                // Add odd/even class.
                if (empty($row['no_striping'])) {
                    $class = $flip[$class];
                    $attributes['class'][] = $class;
                }
                // Build row.
                $output .= ' <tr' . drupal_attributes($attributes) . '>';
                $i = 0;
                foreach ($cells as $cell) {
                    $cell = tablesort_cell($cell, $header, $ts, $i++);
                    $output .= _theme_table_cell($cell);
                }
                $output .= " </tr>\n";
            }
        }
        $output .= "</tbody>\n";
    }
    $output .= "</table>\n";
    return $output;
}
コード例 #7
0
ファイル: template.table.php プロジェクト: Joanl/ding
function mothership_table($header, $rows, $attributes = array(), $caption = NULL)
{
    // Add sticky headers, if applicable.
    if (count($header)) {
        drupal_add_js('misc/tableheader.js');
        // Add 'sticky-enabled' class to the table to identify it for JS.
        // This is needed to target tables constructed by this function.
        $attributes['class'] = empty($attributes['class']) ? 'sticky-enabled' : $attributes['class'] . ' sticky-enabled';
    }
    $output = '<table' . drupal_attributes($attributes) . ">\n";
    if (isset($caption)) {
        $output .= '<caption>' . $caption . "</caption>\n";
    }
    // Format the table header:
    if (count($header)) {
        $ts = tablesort_init($header);
        // HTML requires that the thead tag has tr tags in it follwed by tbody
        // tags. Using ternary operator to check and see if we have any rows.
        $output .= count($rows) ? ' <thead><tr>' : ' <tr>';
        foreach ($header as $cell) {
            $cell = tablesort_header($cell, $header, $ts);
            $output .= _theme_table_cell($cell, TRUE);
        }
        // Using ternary operator to close the tags based on whether or not there are rows
        $output .= count($rows) ? " </tr></thead>\n" : "</tr>\n";
    } else {
        $ts = array();
    }
    // Format the table rows:
    if (count($rows)) {
        $output .= "<tbody>\n";
        $flip = array('even' => 'odd', 'odd' => 'even');
        $class = 'even';
        foreach ($rows as $number => $row) {
            $attributes = array();
            // Check if we're dealing with a simple or complex row
            if (isset($row['data'])) {
                foreach ($row as $key => $value) {
                    if ($key == 'data') {
                        $cells = $value;
                    } else {
                        $attributes[$key] = $value;
                    }
                }
            } else {
                $cells = $row;
            }
            if (count($cells)) {
                // Add odd/even class
                $class = $flip[$class];
                if (isset($attributes['class'])) {
                    $attributes['class'] .= ' ' . $class;
                } else {
                    $attributes['class'] = $class;
                }
                // Build row
                $output .= ' <tr' . drupal_attributes($attributes) . '>';
                $i = 0;
                foreach ($cells as $cell) {
                    $cell = tablesort_cell($cell, $header, $ts, $i++);
                    $output .= _theme_table_cell($cell);
                }
                $output .= " </tr>\n";
            }
        }
        $output .= "</tbody>\n";
    }
    $output .= "</table>\n";
    return $output;
}
コード例 #8
0
ファイル: template.php プロジェクト: reload/dynamo
/**
 * Overrides table theme function with support for colgroups
 * based on Drupal 7 theme function.
 */
function dynamo_table($header, $rows, $attributes = array(), $caption = NULL)
{
    // Get colgroups out if attributes
    $colgroups = $attributes['colgroups'];
    if (!empty($attributes['colgroups'])) {
        unset($attributes['colgroups']);
    }
    // Add sticky headers, if applicable.
    if (count($header)) {
        drupal_add_js('misc/tableheader.js');
        // Add 'sticky-enabled' class to the table to identify it for JS.
        // This is needed to target tables constructed by this function.
        array_push($attributes['class'], 'sticky-enabled');
    }
    $output = '<table' . drupal_attributes($attributes) . ">\n";
    if (isset($caption)) {
        $output .= '<caption>' . $caption . "</caption>\n";
    }
    // Format the table columns:
    if (count($colgroups)) {
        foreach ($colgroups as $number => $colgroup) {
            $attributes = array();
            // Check if we're dealing with a simple or complex column
            if (isset($colgroup['data'])) {
                foreach ($colgroup as $key => $value) {
                    if ($key == 'data') {
                        $cols = $value;
                    } else {
                        $attributes[$key] = $value;
                    }
                }
            } else {
                $cols = $colgroup;
            }
            // Build colgroup
            if (is_array($cols) && count($cols)) {
                $output .= ' <colgroup' . drupal_attributes($attributes) . '>';
                $i = 0;
                foreach ($cols as $col) {
                    $output .= ' <col' . drupal_attributes($col) . ' />';
                }
                $output .= " </colgroup>\n";
            } else {
                $output .= ' <colgroup' . drupal_attributes($attributes) . " />\n";
            }
        }
    }
    // Format the table header:
    if (count($header)) {
        $ts = tablesort_init($header);
        // HTML requires that the thead tag has tr tags in it followed by tbody
        // tags. Using ternary operator to check and see if we have any rows.
        $output .= count($rows) ? ' <thead><tr>' : ' <tr>';
        foreach ($header as $cell) {
            $cell = tablesort_header($cell, $header, $ts);
            $output .= _theme_table_cell($cell, TRUE);
        }
        // Using ternary operator to close the tags based on whether or not there are rows
        $output .= count($rows) ? " </tr></thead>\n" : "</tr>\n";
    } else {
        $ts = array();
    }
    // Format the table rows:
    if (count($rows)) {
        $output .= "<tbody>\n";
        $flip = array('even' => 'odd', 'odd' => 'even');
        $class = 'even';
        foreach ($rows as $number => $row) {
            $attributes = array();
            // Check if we're dealing with a simple or complex row
            if (isset($row['data'])) {
                foreach ($row as $key => $value) {
                    if ($key == 'data') {
                        $cells = $value;
                    } else {
                        $attributes[$key] = $value;
                    }
                }
            } else {
                $cells = $row;
            }
            if (count($cells)) {
                // Add odd/even class
                $class = $flip[$class];
                // TODO: This code looks broken. I've added the is_array check
                // to prevent errors, but I don't know if it'll ever be true.
                // mikl, 2010-05-24
                if (is_array($attributes['class'])) {
                    array_push($attributes['class'], $class);
                }
                // Build row
                $output .= ' <tr' . drupal_attributes($attributes) . '>';
                $i = 0;
                foreach ($cells as $cell) {
                    $cell = tablesort_cell($cell, $header, $ts, $i++);
                    $output .= _theme_table_cell($cell);
                }
                $output .= " </tr>\n";
            }
        }
        $output .= "</tbody>\n";
    }
    $output .= "</table>\n";
    return $output;
}
コード例 #9
0
ファイル: template.php プロジェクト: pounard/drupal-badm
/**
 * Overrides theme_table().
 */
function badm_table($variables)
{
    $header = $variables['header'];
    $rows = $variables['rows'];
    $attributes = $variables['attributes'];
    $caption = $variables['caption'];
    $colgroups = $variables['colgroups'];
    $empty = $variables['empty'];
    $attributes['class'][] = 'table';
    $attributes['class'][] = 'table-striped';
    $output = '<table' . drupal_attributes($attributes) . ">\n";
    if (isset($caption)) {
        $output .= '<caption>' . $caption . "</caption>\n";
    }
    // Format the table columns:
    if (count($colgroups)) {
        foreach ($colgroups as $colgroup) {
            $attributes = array();
            // Check if we're dealing with a simple or complex column
            if (isset($colgroup['data'])) {
                foreach ($colgroup as $key => $value) {
                    if ($key == 'data') {
                        $cols = $value;
                    } else {
                        $attributes[$key] = $value;
                    }
                }
            } else {
                $cols = $colgroup;
            }
            // Build colgroup
            if (is_array($cols) && count($cols)) {
                $output .= ' <colgroup' . drupal_attributes($attributes) . '>';
                $i = 0;
                foreach ($cols as $col) {
                    $output .= ' <col' . drupal_attributes($col) . ' />';
                }
                $output .= " </colgroup>\n";
            } else {
                $output .= ' <colgroup' . drupal_attributes($attributes) . " />\n";
            }
        }
    }
    // Add the 'empty' row message if available.
    if (!count($rows) && $empty) {
        $header_count = 0;
        foreach ($header as $header_cell) {
            if (is_array($header_cell)) {
                $header_count += isset($header_cell['colspan']) ? $header_cell['colspan'] : 1;
            } else {
                $header_count++;
            }
        }
        $rows[] = array(array('data' => $empty, 'colspan' => $header_count, 'class' => array('empty', 'message')));
    }
    // Format the table header:
    if (count($header)) {
        $ts = tablesort_init($header);
        // HTML requires that the thead tag has tr tags in it followed by tbody
        // tags. Using ternary operator to check and see if we have any rows.
        $output .= count($rows) ? ' <thead><tr>' : ' <tr>';
        foreach ($header as $cell) {
            $cell = tablesort_header($cell, $header, $ts);
            $output .= _theme_table_cell($cell, TRUE);
        }
        // Using ternary operator to close the tags based on whether or not there are rows
        $output .= count($rows) ? " </tr></thead>\n" : "</tr>\n";
    } else {
        $ts = array();
    }
    // Format the table rows:
    if (count($rows)) {
        $output .= "<tbody>\n";
        foreach ($rows as $row) {
            $attributes = array();
            // Check if we're dealing with a simple or complex row
            if (isset($row['data'])) {
                foreach ($row as $key => $value) {
                    if ($key == 'data') {
                        $cells = $value;
                    } else {
                        $attributes[$key] = $value;
                    }
                }
            } else {
                $cells = $row;
            }
            if (count($cells)) {
                // Build row
                $output .= ' <tr' . drupal_attributes($attributes) . '>';
                $i = 0;
                foreach ($cells as $cell) {
                    $cell = tablesort_cell($cell, $header, $ts, $i++);
                    $output .= _theme_table_cell($cell);
                }
                $output .= " </tr>\n";
            }
        }
        $output .= "</tbody>\n";
    }
    $output .= "</table>\n";
    return $output;
}
コード例 #10
0
ファイル: template.php プロジェクト: makinacorpus/drupal-badm
/**
 * Implements hook_preprocess_HOOK().
 */
function badm_preprocess_table(&$vars)
{
    // Make it bootstrap yeah!
    if (isset($vars['attributes']['class']) && is_string($vars['attributes']['class'])) {
        $vars['attributes']['class'] = array($vars['attributes']['class']);
    }
    $vars['attributes']['class'][] = 'table';
    if (empty($vars['attributes']['no_strip'])) {
        $vars['attributes']['class'][] = 'table-striped';
    }
    $vars['attributes']['class'][] = 'table-condensed';
    // Count header for later, better here than over there.
    $header_count = 0;
    if (!empty($vars['header'])) {
        foreach ($vars['header'] as &$header_cell) {
            if (is_array($header_cell)) {
                $header_count += isset($header_cell['colspan']) ? $header_cell['colspan'] : 1;
            } else {
                $header_count++;
            }
        }
    }
    // Need this in template.
    $vars['header_count'] = $header_count;
    if ($header_count) {
        $vars['sortheader'] = tablesort_init($vars['header']);
    } else {
        $vars['sortheader'] = [];
    }
    if (!empty($vars['header'])) {
        foreach ($vars['header'] as &$header_cell) {
            $header_cell = tablesort_header($header_cell, $vars['header'], $vars['sortheader']);
        }
    }
    if (!empty($vars['rows'])) {
        foreach ($vars['rows'] as &$row) {
            $i = 0;
            foreach ($row as &$cell) {
                $cell = tablesort_cell($cell, $vars['header'], $vars['sortheader'], $i);
                $i++;
            }
        }
    }
    // Add the 'empty' row message if available.
    if ($vars['empty'] && empty($vars['rows'])) {
        $vars['rows'][] = [['data' => $vars['empty'], 'colspan' => $header_count, 'class' => ['empty', 'message']]];
    }
    // Manage main attributes
    if (isset($vars['colgroups'])) {
        _badm_extract_data_from_attributes($vars, 'colgroups');
    }
    if (isset($vars['header'])) {
        _badm_extract_data_from_attributes($vars, 'header');
    }
    if (isset($vars['rows'])) {
        _badm_extract_data_from_attributes($vars, 'rows');
    }
    // Manage cells attributes, because they are deeper.
    $vars['cells_attributes'] = [];
    foreach ($vars['rows'] as $row_index => &$row) {
        if (is_array($row)) {
            foreach ($row as $cell_index => &$cell) {
                $vars['cells_attributes'][$row_index][$cell_index] = [];
                if (isset($cell['data']) || is_array($cell) && count(element_properties($cell)) == 0) {
                    $temp_real_value = '';
                    foreach ($cell as $key => $value) {
                        if ($key == 'data') {
                            $temp_real_value = $value;
                        } else {
                            $vars['cells_attributes'][$row_index][$cell_index][$key] = $value;
                        }
                    }
                    $cell = $temp_real_value;
                }
            }
        }
    }
    $vars['theme_hook_suggestions'][] = 'table';
}