function coder_upgrade_upgrades_build in Coder 7
Same name and namespace in other branches
- 7.2 coder_upgrade/includes/conversion.inc \coder_upgrade_upgrades_build()
Returns form content for upgrades tab.
Parameters
array $upgrades: User selections or default values.
Return value
array Form item.
1 call to coder_upgrade_upgrades_build()
- coder_upgrade_conversions_form in coder_upgrade/
includes/ conversion.inc - Form builder for the module conversion form.
File
- coder_upgrade/
includes/ conversion.inc, line 52
Code
function coder_upgrade_upgrades_build(&$upgrades) {
// Create the list of upgrade options from the coder upgrade plug-ins.
// Maintain a secondary list based on title only, to make sorting possible.
$upgrades_all = _coder_upgrade_upgrades();
foreach ($upgrades_all as $name => $upgrade) {
$upgrade_options[$name] = isset($upgrade['link']) ? l($upgrade['title'], $upgrade['link']) : $upgrade['title'];
if (isset($upgrade['description'])) {
$upgrade_options[$name] .= ' (' . $upgrade['description'] . ')';
}
$upgrades_sort[$name] = $upgrade['title'];
}
// Sort the upgrades by title.
asort($upgrades_sort);
foreach ($upgrades_sort as $name => $upgrade) {
$upgrades_sort[$name] = $upgrade_options[$name];
}
// Build the upgrade list.
$header = array(
'category' => array(
'data' => t('Category'),
'field' => 'category',
),
);
$i = 0;
$rows = array();
foreach ($upgrades_sort as $name => $upgrade) {
$row = array();
$row['category'] = $upgrades_sort[$name];
$row['description'] = 'Missing';
$row['#weight'] = ++$i;
$rows[$name] = $row;
}
$upgrade_fs = array(
'#type' => 'fieldset',
'#title' => t('Upgrades'),
'#description' => t('Apply the selected conversion routines ...'),
'#tree' => TRUE,
);
$upgrade_fs['list'] = array(
'#type' => 'tableselect',
'#header' => $header,
'#options' => $rows,
'#default_value' => isset($upgrades) ? $upgrades : array(),
'#empty' => t('No routines available'),
);
return $upgrade_fs;
}