function skinr_context_ui_group_list_form in Skinr 8.2
Same name and namespace in other branches
- 7.2 skinr_context/skinr_context_ui.edit.inc \skinr_context_ui_group_list_form()
Form builder for the skin settings group listing.
1 string reference to 'skinr_context_ui_group_list_form'
- skinr_context_ui_group_list in skinr_context/
skinr_context_ui.edit.inc - Menu callback; lists skin settings groups for an element.
File
- skinr_context/
skinr_context_ui.edit.inc, line 204 - Page callbacks for the Skinr Context UI module related to editing skins and groups.
Code
function skinr_context_ui_group_list_form($form, $form_state, $groups) {
// Weights range from -delta to +delta, so delta should be at least half
// of the amount of blocks present. This makes sure all blocks in the same
// region get an unique weight.
$weight_delta = round(count($groups) / 2);
$form['groups'] = array();
$form['#tree'] = TRUE;
$form['#empty_text'] = t("You don't have any groups for this element.");
foreach ($groups as $gid => $group) {
$group = (array) $group;
$form['groups'][$gid]['info'] = array(
'#markup' => theme('skinr_context_ui_group_summary', array(
'title' => $group['title'],
'description' => $group['description'],
)),
);
$form['groups'][$gid]['status'] = array(
'#type' => 'checkbox',
'#default_value' => $group['status'],
'#title_display' => 'invisible',
'#title' => t('Enable @group group', array(
'@group' => $group['title'],
)),
);
$form['groups'][$gid]['weight'] = array(
'#type' => 'weight',
'#default_value' => $group['weight'],
'#delta' => $weight_delta,
'#title_display' => 'invisible',
'#title' => t('Weight for @group group', array(
'@group' => $group['title'],
)),
);
$destination = array();
if (isset($_GET['destination'])) {
$path = $_GET['q'];
$query = drupal_http_build_query(drupal_get_query_parameters());
if ($query != '') {
$path .= '?' . $query;
}
$destination = array(
'destination' => $path,
);
}
$operations = array();
$operations['edit'] = array(
'#type' => 'link',
'#title' => t('edit'),
'#href' => 'admin/structure/skinr/edit/' . $group['module'] . '/' . $group['element'] . '/' . $group['gid'],
'#options' => array(
'query' => $destination,
),
);
$operations['delete'] = array(
'#type' => 'link',
'#title' => t('delete'),
'#href' => 'admin/structure/skinr/edit/' . $group['module'] . '/' . $group['element'] . '/' . $group['gid'] . '/delete',
'#options' => array(
'query' => $destination,
),
);
$form['groups'][$gid]['operations'] = $operations;
}
// Prepare cancel link.
if (isset($_GET['destination'])) {
$options = drupal_parse_url(urldecode($_GET['destination']));
}
else {
$options = array(
'path' => 'admin/structure/skinr',
);
}
$form['actions'] = array(
'#tree' => FALSE,
'#type' => 'actions',
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save groups'),
);
$form['actions']['done'] = array(
'#type' => 'link',
'#title' => t('Done'),
'#href' => $options['path'],
'#options' => $options,
);
return $form;
}