You are here

function theme_facetapi_realm_settings_table in Facet API 6.3

Same name and namespace in other branches
  1. 7.2 facetapi.admin.inc \theme_facetapi_realm_settings_table()
  2. 7 facetapi.admin.inc \theme_facetapi_realm_settings_table()

Returns the realm settings table.

Parameters

$variables: An associative array containing:

  • element: A render element representing the form.
1 theme call to theme_facetapi_realm_settings_table()
facetapi_realm_settings_form in ./facetapi.admin.inc
Form constructor for the realm settings form.

File

./facetapi.admin.inc, line 226
Admin page callbacks for the Facet API module.

Code

function theme_facetapi_realm_settings_table($variables) {
  $output = '';

  // Adds CSS to ensure that the dropbutton looks nice.
  $path = drupal_get_path('module', 'facetapi');
  drupal_add_css($path . '/facetapi.admin.css');

  // Gets variables for code readability.
  $searcher = $variables['#facetapi']['adapter']
    ->getSearcher();
  $realm = $variables['#facetapi']['realm'];
  $header = array(
    'enabled' => array(
      'data' => t('Enabled'),
    ),
    'label' => array(
      'data' => t('Facet'),
      'sort' => 'asc',
    ),
    'operations' => array(
      'data' => t('Operations'),
    ),
  );
  if ($realm['sortable']) {
    $header['weight'] = array(
      'data' => t('Weight'),
    );
  }

  // Builds field options.
  $rows = array();
  $facet_info = $variables['#facetapi']['facet_info'];
  foreach ($facet_info as $facet_name => $facet) {

    // Builds rows.
    $rows[$facet_name] = array(
      'class' => $realm['sortable'] ? 'draggable' : '',
      'data' => array(
        drupal_render($variables['enabled_facets'][$facet_name]),
        check_plain($facet['label']) . "<div class='description'>" . filter_xss($facet['description']) . '</div>',
        array(
          'class' => 'facetapi-operations',
          'data' => drupal_render($variables['operations'][$facet_name]),
        ),
      ),
    );
    if ($realm['sortable']) {
      $rows[$facet_name]['data'][] = drupal_render($variables['weight'][$facet_name]);
    }
  }
  if ($realm['sortable']) {
    drupal_add_tabledrag('facetapi-realm-settings', 'order', 'sibling', 'facetapi-facet-weight');
  }

  //$output .= drupal_render_children($variables['element']);
  $output .= theme('table', $header, $rows, array(
    'id' => 'facetapi-realm-settings',
  ));
  return $output;
}