array('og_context_configure_form_submit'), '#theme' => 'og_context_configure_form', '#group_context_providers' => og_context_negotiation_info(), ); _group_context_configure_form_table($form); $form['actions'] = array('#type' => 'actions'); $form['actions']['submit'] = array( '#type' => 'submit', '#value' => t('Save settings'), ); return $form; } /** * Helper function to build a group context provider table. */ function _group_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; } /** * Returns HTML for a group context configuration form. * * @param $variables * An associative array containing: * - form: A render element representing the form. * * @ingroup themeable */ function theme_og_context_configure_form($variables) { $form = $variables['form']; $output = ''; $type = 'group_context'; $rows = array(); $title = ''; $description = '