function _og_context_configure_form_table in Organic groups 7.2
Helper function to build a group context provider table.
1 call to _og_context_configure_form_table()
- og_context_configure_form in og_context/
og_context.admin.inc - Setting for language negotiation options
File
- og_context/
og_context.admin.inc, line 33 - Administration functions for OG context module.
Code
function _og_context_configure_form_table(&$form) {
$type = 'group_context';
$table_form = array(
'#title' => t('Group context detection'),
'#tree' => TRUE,
'#description' => t('Order of Group context detection methods.'),
'#group_context_providers' => array(),
'#show_operations' => FALSE,
'weight' => array(
'#tree' => TRUE,
),
'enabled' => array(
'#tree' => TRUE,
),
);
$group_context_providers = $form['#group_context_providers'];
// Enable url and node context handlers by default.
$defaults = array(
'url' => -5,
'node' => -4,
);
$enabled_providers = variable_get("og_context_negotiation_{$type}", $defaults);
$providers_weight = variable_get("og_context_providers_weight_{$type}", $defaults);
// Add missing data to the providers lists.
foreach ($group_context_providers as $id => $provider) {
if (!isset($providers_weight[$id])) {
$providers_weight[$id] = og_context_provider_weight($provider);
}
}
// Order providers list by weight.
asort($providers_weight);
foreach ($providers_weight as $id => $weight) {
$enabled = isset($enabled_providers[$id]);
$provider = $group_context_providers[$id];
$table_form['#group_context_providers'][$id] = $provider;
$table_form['weight'][$id] = array(
'#type' => 'weight',
'#default_value' => $weight,
'#attributes' => array(
'class' => array(
"group_context-provider-weight-{$type}",
),
),
);
$table_form['title'][$id] = array(
'#markup' => check_plain($provider['name']),
);
$table_form['enabled'][$id] = array(
'#type' => 'checkbox',
'#default_value' => $enabled,
);
$table_form['description'][$id] = array(
'#markup' => filter_xss_admin($provider['description']),
);
$config_op = array();
if (isset($provider['config'])) {
$config_op = array(
'#type' => 'link',
'#title' => t('Configure'),
'#href' => $provider['config'],
);
// If there is at least one operation enabled show the operation column.
$table_form['#show_operations'] = TRUE;
}
$table_form['operation'][$id] = $config_op;
}
$form['group_context'] = $table_form;
}