function transliteration_retroactive in Transliteration 6.3
Same name and namespace in other branches
- 7.3 transliteration.admin.inc \transliteration_retroactive()
Form builder function; generate retroactive transliteration confirm form.
See also
transliteration_retroactive_submit()
1 string reference to 'transliteration_retroactive'
- transliteration_menu in ./
transliteration.module - Implements hook_menu().
File
- ./
transliteration.admin.inc, line 14 - Retroactive transliteration and admin settings UI.
Code
function transliteration_retroactive() {
if (!($query = transliteration_file_query(TRUE))) {
drupal_set_message(t('Database not supported.'), 'error');
$form['description']['#value'] = t('Retroactive transliteration is not supported for the database system of this Drupal installation. If you think this should be fixed please <a href="@issues-url">file an issue</a> in the project issue queue.', array(
'@issues-url' => 'http://drupal.org/project/issues/transliteration',
));
return $form;
}
$count = db_result(db_query($query));
if (!$count) {
drupal_set_message(t('Transliteration is not required.'), 'status');
$form['description']['#value'] = t('There are currently no files names containing non-ASCII characters.');
return $form;
}
$form['#redirect'] = 'admin/settings/file-system/settings';
$question = t('Are you sure you want to transliterate existing file names?');
// Generate a sample list.
$rows = array();
$header = array(
t('Original file name'),
t('Transliterated file name'),
);
$result = db_query_range(transliteration_file_query(), 0, 10);
while ($file = db_fetch_object($result)) {
$filename = basename($file->filepath);
$rows[] = array(
l($filename, file_create_url($file->filepath)),
transliteration_clean_filename($filename),
);
}
$description = '<p><strong>' . t('The database currently lists @x_filenames containing non-ASCII characters.', array(
'@x_filenames' => format_plural($count, '1 file name', '@count file names'),
)) . '</strong><br />';
$description .= t('This count might be inaccurate, though, since some files may not need to be renamed.') . '</p>';
$description .= theme('table', $header, $rows);
if ($count > 10) {
$description .= '<p>' . t('Note: table shows only the first 10 entries.') . '</p>';
}
$description .= '<p>' . t('<strong>WARNING:</strong> if you have manually entered image or file paths in text fields (for example, text areas or WYSIWYG editors), renaming the files will break these references. Since there is currently no automated way to also fix referenced files in textual contents, it is a very good idea to backup the database and %files directory beforehand. Modules accessing files using their internal system ids are not affected.', array(
'%files' => file_directory_path(),
)) . '</p>';
$description .= '<p style="color: red; font-weight: bold; font-size: 18px;">' . t('This action cannot be undone.') . '</p>';
return confirm_form($form, $question, 'admin/settings/file-system/settings', $description, t('Transliterate'));
}