You are here

function cf_settings_administer_variables in Common Functionality 7.2

Display the system variables registry.

Parameters

int $variable_type_id: The numeric id of the variable type.

Return value

array A themed list of registry variables.

Related topics

1 string reference to 'cf_settings_administer_variables'
cf_settings_menu in modules/cf_settings/cf_settings.module
Implements hook_menu().

File

modules/cf_settings/pages/variables.admin.inc, line 22
Common Functionality - Settings - Administration Pages.

Code

function cf_settings_administer_variables($variable_type_id = NULL) {
  global $conf;
  $output = '';
  if ($variable_type_id == NULL) {
    $variable_types = cf_settings_get_variable_types();
    $output .= theme('cf_settings_view_registry', array(
      'variable_types' => $variable_types,
    ));
  }
  elseif (is_numeric($variable_type_id)) {
    $variable_type = cf_settings_get_variable_types($variable_type_id);
    drupal_set_title(t("%name Settings Registry", array(
      '%name' => $variable_type->human_name,
    )), PASS_THROUGH);
    $output .= '<div class="description">' . check_plain($variable_type->description) . '</div>';
    $variables = cf_settings_get_registered(array(
      'variable_type' => $variable_type->id,
    ), 'id');
    $rows = array();
    foreach ($variables as $variable_id => &$variable) {
      if (isset($rows[$variable->variable_name])) {
        $rows[$variable->variable_name][1] .= ', ' . $variable->module_name;
      }
      else {
        $row = array();
        $row[0] = $variable->variable_name;
        $row[1] = $variable->module_name;
        $rows[$variable->variable_name] = $row;
      }
    }
    asort($rows);
    $header = array(
      t("Variable Name"),
      t("Module Names"),
    );
    $output .= theme('table', array(
      'header' => $header,
      'rows' => $rows,
      'empty' => t("There are no variables of this type registered."),
    ));
  }
  return array(
    'content' => array(
      '#markup' => $output,
    ),
  );
}