coder_upgrade_conversions_form($form, &$form_state)Form builder for the module conversion form.
sites/all/modules/coder/coder_upgrade/coder_upgrade.module, line 151
<?php
function coder_upgrade_conversions_form($form, &$form_state) {
// Set default values.
list($upgrades, $extensions, $directories, $modules) = coder_upgrade_conversions_form_defaults($form_state);
// 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'),
'description' => array('data' => t('Description'), 'field' => 'description'),
);
$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 comments available'),
);
// Build the file extension list.
$types = array(
'inc' => 'PHP code files',
'info' => 'Info files used with module installation',
'install' => 'PHP code files used with module installation, update and uninstallation',
'module' => 'PHP code files',
'php' => 'PHP code files',
'profile' => 'PHP code files used with site installation',
'test' => 'SimpleTest files',
'theme' => 'PHP code files used with theming',
);
$header = array(
'extension' => array('data' => t('Extension'), 'field' => 'extension'),
'description' => array('data' => t('Description'), 'field' => 'description'),
);
$i = 0;
$rows = array();
foreach ($types as $key => $description) {
$row = array();
$row['extension'] = $key;
$row['description'] = $description;
$row['#weight'] = ++$i;
$rows[$key] = $row;
}
$extension_fs = array(
'#type' => 'fieldset',
'#title' => t('Extensions'),
'#description' => t('... to files with the selected file extensions ...'),
'#tree' => TRUE,
);
$extension_fs['list'] = array(
'#type' => 'tableselect',
'#header' => $header,
'#options' => $rows,
'#default_value' => isset($extensions) ? $extensions : array(),
'#empty' => t('No comments available'),
);
// Build the directory list.
$path = realpath(file_directory_path() . '/' . variable_get('coder_upgrade_dir_old', DEADWOOD_OLD));
$dirs = coder_upgrade_scan_directory($path);
if (!$dirs) {
drupal_set_message(t('Please place modules to be converted in @path.', array('@path' => $path)), 'error');
}
$header = array(
'name' => array('data' => t('Name'), 'field' => 'name'),
'path' => array('data' => t('Location'), 'field' => 'path'),
);
$i = 0;
$rows = array();
foreach ($dirs as $dir) {
$row = array();
$row['name'] = isset($directories[$dir]) ? l($dir, coder_upgrade_patch_link($dir)) : $dir;
$row['path'] = file_directory_path() . '/' . $dir;
$row['#weight'] = ++$i;
$rows[$dir] = $row;
}
$directory_fs = array(
'#type' => 'fieldset',
'#title' => t('Directories'),
'#description' => t('... residing in the selected directories (beneath the files directory), or ...'),
'#tree' => TRUE,
);
$directory_fs['list'] = array(
'#type' => 'tableselect',
'#header' => $header,
'#options' => $rows,
'#default_value' => isset($directories) ? $directories : array(),
'#empty' => t('No comments available'),
);
// Build the module list.
$header = array(
'name' => array('data' => t('Name'), 'field' => 'name'),
'path' => array('data' => t('Location'), 'field' => 'path'),
);
$i = 0;
$rows = coder_upgrade_module_list();
foreach ($rows as $key => $row) {
$rows[$key]['name'] = isset($modules[$key]) ? l($row['name'], coder_upgrade_patch_link($key)) : $row['name'];
$rows[$key]['#weight'] = ++$i;
}
$module_fs = array(
'#type' => 'fieldset',
'#title' => t('Modules'),
'#description' => t('... residing in the selected modules (beneath the sites directory).'),
'#tree' => TRUE,
);
$module_fs['list'] = array(
'#type' => 'tableselect',
'#header' => $header,
'#options' => $rows,
'#default_value' => isset($modules) ? $modules : array(),
'#empty' => t('No comments available'),
);
// Build the form.
$form['tabs'] = array(
'#type' => 'vertical_tabs',
'#default_tab' => 'edit-directories',
);
$form['tabs']['upgrades'] = $upgrade_fs;
$form['tabs']['extensions'] = $extension_fs;
$form['tabs']['directories'] = $directory_fs;
$form['tabs']['modules'] = $module_fs;
$form['convert'] = array(
'#type' => 'submit',
'#value' => t('Convert files'),
'#disabled' => !$dirs,
);
return $form;
}
?>