You are here

function override_css_settings_table in Override css 7

Page with settings table.

1 call to override_css_settings_table()
override_css_settings_page in override_css_settings/override_css_settings.module

File

override_css_settings/override_css_settings.module, line 80

Code

function override_css_settings_table() {
  drupal_add_css(drupal_get_path('module', 'override_css_settings') . '/override_css_settings.css');
  $groups = override_css_selector_load_all();

  // Generate header of table
  $header = array(
    t('Title'),
    t('Description'),
    t('Actions'),
  );

  // Bundle all groups
  $bundles = array();
  foreach ($groups as $name => $group) {
    if (variable_get('override_css_bundle_enabled', FALSE)) {
      $bundles[$group['bundle']][$name] = $group;
    }
    else {
      $bundles[][$name] = $group;
    }
  }
  ksort($bundles);

  // Generate rows of table
  $rows = array();
  $active_bundle_name = '';
  foreach ($bundles as $bundle_name => $groups) {
    if (variable_get('override_css_bundle_enabled', FALSE) && $active_bundle_name != $bundle_name) {
      $rows[] = array(
        array(
          'data' => $bundle_name,
          'colspan' => array(
            3,
          ),
          'class' => 'bundle-row',
        ),
      );
      $active_bundle_name = $bundle_name;
    }
    foreach ($groups as $name => $group) {
      $actions = array(
        l(t('edit'), variable_get('override_css_settings_path', OVERRIDE_CSS_SETTINGS_PATH) . '/' . $name . '/values'),
      );

      // Only show reset button if properties are set.
      if (count($group['properties_values'])) {
        $actions[] = l(t('reset'), variable_get('override_css_settings_path', OVERRIDE_CSS_SETTINGS_PATH) . '/' . $name . '/reset');
      }
      $rows[] = array(
        (variable_get('override_css_bundle_enabled', FALSE) ? ' - ' : '') . $group['title'],
        $group['description'],
        theme('item_list', array(
          'items' => $actions,
          'attributes' => array(
            'class' => 'inline',
          ),
        )),
      );
    }
  }
  return theme('table', array(
    'header' => $header,
    'rows' => $rows,
    'empty' => t('No selector groups defined.'),
  ));
}