'admin/settings/table',
'title' => t('table'),
'callback' => 'drupal_get_form',
'callback arguments' => array('table_settings_page'),
'access' => TRUE
);
}
return $items;
}
function table_settings_page() {
$form = array(
'system' => array(
'#type' => 'table_table',
'#header' => array(
NULL,
array('data' => t('Filename'), 'field' => 'filename'),
array('data' => t('Name'), 'field' => 'name', 'sort' => 'asc'),
array('data' => t('Type'), 'field' => 'type'),
),
),
);
$result = pager_query('SELECT filename, name, type, status FROM {system}'. tablesort_sql($form['system']['#header']), 5);
while ($file = db_fetch_object($result)) {
$form['system'][] = array(
'status' => array(
'#type' => 'table_cell',
'status' => array(
'#type' => 'checkbox',
'#default_value' => $file->status,
),
),
'filename' => $file->filename,
'name' => $file->name,
'type' => $file->type,
);
}
$form['pager'] = array('#value' => theme('pager', NULL, 50, 0));
return $form;
}
function theme_table_table($element) {
$output = $element['#prefix'] .'
\n";
if (!empty($element['#caption'])) {
$output .= ''. $element['#caption'] ."\n";
}
if (!empty($element['#header'])) {
$output .= ''. drupal_render($element['#header']) ."\n";
}
$output .= "\n". $element['#children'] ."\n";
$output .= "
\n". $element['#suffix'];
return $output;
}
function theme_table_row($element) {
$output = '';
$output .= $element['#prefix'] . $element['#children'] . $element['#suffix'];
$output .= "
\n";
return $output;
}
function theme_table_cell($element) {
$tag = isset($element['#header']) && $element['#header'] ? 'th' : 'td';
$output = "<$tag". drupal_attributes($element['#attributes']) .'>';
$output .= $element['#prefix'] . $element['#value'] . $element['#children'] . $element['#suffix'];
$output .= "$tag>";
return $output;
}
function expand_table_table($element) {
if (isset($element['#summary'])) {
$element['#attributes']['summary'] = $element['#summary'];
unset($element['#summary']);
}
$column = NULL;
if (!empty($element['#header'])) {
$tablesort = tablesort_init($element['#header']);
foreach ($element['#header'] as $key => $cell) {
$cell = tablesort_header($cell, NULL, $tablesort);
$element['#header'][$key] = array(
'#type' => 'table_cell',
'#value' => $cell['data'],
'#header' => TRUE,
'#weight' => $key,
);
}
if (isset($tablesort['sql'])) {
$column = $tablesort['sql'];
}
}
foreach (element_children($element) as $i => $row) {
$element[$row]['#type'] = 'table_row';
$class = ($i % 2 == 1) ? 'even': 'odd';
if (isset($element[$row]['#attributes']['class'])) {
$element[$row]['#attributes']['class'] .= ' '. $class;
}
else {
$element[$row]['#attributes']['class'] = $class;
}
foreach (element_children($element[$row]) as $cell) {
if (!is_array($element[$row][$cell])) {
$element[$row][$cell] = array(
'#value' => $element[$row][$cell],
);
} elseif (isset($element[$row][$cell]['#type']) && $element[$row][$cell]['#type'] != 'table_cell') {
$element[$row][$cell] = array(
$cell => $element[$row][$cell],
);
}
$element[$row][$cell]['#type'] = 'table_cell';
if (!is_null($column) && $cell == $column) {
if (isset($element[$row][$cell]['#attributes']['class'])) {
$element[$row][$cell]['#attributes']['class'] .= ' active';
}
else {
$element[$row][$cell]['#attributes']['class'] = 'active';
}
}
if (isset($element[$row][$cell]['#colspan'])) {
$element[$row][$cell]['#attributes']['colspan'] = $element[$row][$cell]['#colspan'];
}
if (isset($element[$row][$cell]['#rowspan'])) {
$element[$row][$cell]['#attributes']['rowspan'] = $element[$row][$cell]['#rowspan'];
}
unset($element[$row][$cell]['#colspan'], $element[$row][$cell]['#rowspan']);
}
}
return $element;
}
function table_elements() {
return array(
'table_table' => array(
'#process' => array(
'expand_table_table' => array(),
),
),
'table_row' => array(),
'table_cell' => array(),
);
}