diff options
Diffstat (limited to 'includes')
-rw-r--r-- | includes/file.inc | 46 | ||||
-rw-r--r-- | includes/locale.inc | 49 | ||||
-rw-r--r-- | includes/theme.inc | 13 |
3 files changed, 49 insertions, 59 deletions
diff --git a/includes/file.inc b/includes/file.inc index c074b632a..8126a772b 100644 --- a/includes/file.inc +++ b/includes/file.inc @@ -76,7 +76,7 @@ function file_check_directory(&$directory, $mode = 0, $form_item = NULL) { // Check if directory exists. if (!is_dir($directory)) { if (($mode & FILE_CREATE_DIRECTORY) && @mkdir($directory, 0760)) { - drupal_set_message(t('Created directory %directory.', array('%directory' => theme('placeholder', $directory)))); + drupal_set_message(t('The directory %directory has been created.', array('%directory' => theme('placeholder', $directory)))); } else { if ($form_item) { @@ -89,10 +89,11 @@ function file_check_directory(&$directory, $mode = 0, $form_item = NULL) { // Check to see if the directory is writable. if (!is_writable($directory)) { if (($mode & FILE_MODIFY_PERMISSIONS) && @chmod($directory, 0760)) { - drupal_set_message(t('Modified permissions on directory %directory.', array('%directory' => theme('placeholder', $directory)))); + drupal_set_message(t('The permissions of directory %directory have been changed to make it writable.', array('%directory' => theme('placeholder', $directory)))); } else { - form_set_error($form_item, t('The directory %directory is not writable.', array('%directory' => theme('placeholder', $directory)))); + form_set_error($form_item, t('The directory %directory is not writable', array('%directory' => theme('placeholder', $directory)))); + watchdog('file system', t('The directory %directory is not writable, because it does not have the correct permissions set.', array('%directory' => theme('placeholder', $directory))), WATCHDOG_ERROR); return false; } } @@ -199,7 +200,8 @@ function file_copy(&$source, $dest = 0, $replace = FILE_EXISTS_RENAME) { // Make sure we at least have a valid directory. if ($basename === false) { - drupal_set_message(t('File copy failed: no directory configured, or it could not be accessed.'), 'error'); + drupal_set_message(t('The selected file %file could not be uploaded, because the destination %directory is not properly configured.', array('%file' => theme('placeholder', $source), '%directory' => theme('placeholder', $dest))), 'error'); + watchdog('file system', t('The selected file %file could not not be uploaded, because the destination %directory could not be found, or because its permissions do not allow the file to be written.', array('%file' => theme('placeholder', $source), '%directory' => theme('placeholder', $dest))), WATCHDOG_ERROR); return 0; } @@ -214,11 +216,11 @@ function file_copy(&$source, $dest = 0, $replace = FILE_EXISTS_RENAME) { $source = realpath($source); if (!file_exists($source)) { - drupal_set_message(t('File copy failed: source file does not exist.'), 'error'); + drupal_set_message(t('The selected file %file could not be copied, because no file by that name exists. Please check that you supplied the correct filename.', array('%file' => theme('placeholder', $source))), 'error'); return 0; } - // If destination file is not specified then use filename of source file. + // If the destination file is not specified then use the filename of the source file. $basename = $basename ? $basename : basename($source); $dest = $directory .'/'. $basename; @@ -246,7 +248,7 @@ function file_copy(&$source, $dest = 0, $replace = FILE_EXISTS_RENAME) { break; case FILE_EXISTS_ERROR: - drupal_set_message(t('File copy failed. File already exists.'), 'error'); + drupal_set_message(t('The selected file %file could not be copied, because a file by that name already exists in the destination.', array('%file' => theme('placeholder', $source))), 'error'); return 0; case FILE_EXISTS_REPLACE: @@ -255,7 +257,7 @@ function file_copy(&$source, $dest = 0, $replace = FILE_EXISTS_RENAME) { } if (!@copy($source, $dest)) { - drupal_set_message(t('File copy failed.'), 'error'); + drupal_set_message(t('The selected file %file could not be copied.', array('%file' => theme('placeholder', $source))), 'error'); return 0; } } @@ -299,7 +301,7 @@ function file_move(&$source, $dest = 0, $replace = FILE_EXISTS_RENAME) { if ($path_original == $path_current || file_delete($path_original)) { return 1; } - drupal_set_message(t('Removing original file failed.'), 'error'); + drupal_set_message(t('The removal of the original file %file has failed.', array('%file' => theme('placeholder', $source))), 'error'); } return 0; } @@ -358,25 +360,25 @@ function file_save_upload($source, $dest = 0, $replace = FILE_EXISTS_RENAME) { } if (!user_access('bypass input data check') && !valid_input_data($file)) { - watchdog('security', t('Possible exploit abuse: invalid data.'), WATCHDOG_WARNING); - drupal_set_message(t('File upload failed: invalid data.'), 'error'); + watchdog('security', t('The file %file has not been saved, because it may contain a possible attempt to exploit or abuse this system.', array('%file' => theme('placeholder', $source))), WATCHDOG_WARNING); + drupal_set_message(t('The file %file has not been saved, because it contains invalid data.', array('%file' => theme('placeholder', $source))), 'error'); return 0; } // Check for file upload errors. switch ($file->error) { - case 0: // UPLOAD_ERR_OK + case 0: // UPLOAD_ERR_OK: File uploaded successfully break; - case 1: // UPLOAD_ERR_INI_SIZE - case 2: // UPLOAD_ERR_FORM_SIZE - drupal_set_message(t('File upload failed: file size too big.'), 'error'); + case 1: // UPLOAD_ERR_INI_SIZE: File size exceeded php.ini value + case 2: // UPLOAD_ERR_FORM_SIZE: File size exceeded MAX_FILE_SIZE form value + drupal_set_message(t('The file %file could not be saved, because it exceeds the maximum allowed size for uploads.', array('%file' => theme('placeholder', $source))), 'error'); return 0; - case 3: // UPLOAD_ERR_PARTIAL - case 4: // UPLOAD_ERR_NO_FILE - drupal_set_message(t('File upload failed: incomplete upload.'), 'error'); + case 3: // UPLOAD_ERR_PARTIAL: File was only partially uploaded + case 4: // UPLOAD_ERR_NO_FILE: No file was uploaded + drupal_set_message(t('The file %file could not be saved, because the upload did not complete.', array('%file' => theme('placeholder', $source))), 'error'); return 0; default: // Unknown error - drupal_set_message(t('File upload failed: unknown error.'), 'error'); + drupal_set_message(t('The file %file could not be saved. An unknown error has occurred.', array('%file' => theme('placeholder', $source))),'error'); return 0; } @@ -402,15 +404,15 @@ function file_save_upload($source, $dest = 0, $replace = FILE_EXISTS_RENAME) { */ function file_save_data($data, $dest, $replace = FILE_EXISTS_RENAME) { if (!user_access('bypass input data check') && !valid_input_data($data)) { - watchdog('security', t('Possible exploit abuse: invalid data.'), WATCHDOG_WARNING); - drupal_set_message(t('File upload failed: invalid data.'), 'error'); + watchdog('security', t('The file has not been saved, because it may contain a possible attempt to exploit or abuse this system.'), WATCHDOG_WARNING); + drupal_set_message(t('The file has not been saved, because it contains invalid data.'), 'error'); return 0; } $temp = variable_get('file_directory_temp', FILE_DIRECTORY_TEMP); $file = tempnam($temp, 'file'); if (!$fp = fopen($file, 'wb')) { - drupal_set_message(t('Unable to create file.'), 'error'); + drupal_set_message(t('The file could not be created.'), 'error'); return 0; } fwrite($fp, $data); diff --git a/includes/locale.inc b/includes/locale.inc index 1a764c6cc..79a3d8148 100644 --- a/includes/locale.inc +++ b/includes/locale.inc @@ -23,14 +23,13 @@ function _locale_add_language($code, $name, $onlylanguage = TRUE) { // the language addition, we need to inform the user on how to start // a translation if ($onlylanguage) { - $message = t('%locale language added. You can now import a translation. See the <a href="%locale-help">help screen</a> for more information.', array('%locale' => theme('placeholder', t($name)), '%locale-help' => url('admin/help/locale'))); + drupal_set_message(t('The language %locale has been created, and can now be used to import a translation. More information is available in the <a href="%locale-help">help screen</a>.', array('%locale' => theme('placeholder', t($name)), '%locale-help' => url('admin/help/locale'))); } else { - $message = t('%locale language added.', array('%locale' => theme('placeholder', t($name)))); + drupal_set_message(t('The language %locale has been created.', array('%locale' => theme('placeholder', t($name))))); } - drupal_set_message($message); - watchdog('locale', t('%language language (%locale) added.', array('%language' => theme('placeholder', $name), '%locale' => theme('placeholder', $code)))); + watchdog('locale', t('The %language language (%locale) has been created.', array('%language' => theme('placeholder', $name), '%locale' => theme('placeholder', $code)))); } /** @@ -126,13 +125,13 @@ function _locale_import_po($file, $lang, $mode) { // Check if we have the language already in the database if (!db_fetch_object(db_query("SELECT locale FROM {locales_meta} WHERE locale = '%s'", $lang))) { - drupal_set_message(t('Unsupported language selected for import.'), 'error'); + drupal_set_message(t('The language selected for import is not supported.'), 'error'); return FALSE; } // Check if we can get the strings from the file if (!($strings = _locale_import_read_po($file))) { - drupal_set_message(t('Translation file %filename broken: Could not be read.', array('%filename' => theme('placeholder', $file->filename))), 'error'); + drupal_set_message(t('The translation file %filename appears to contain errors and could not be read.', array('%filename' => theme('placeholder', $file->filename))), 'error'); return FALSE; } @@ -154,7 +153,7 @@ function _locale_import_po($file, $lang, $mode) { } } else { - drupal_set_message(t('Translation file %filename broken: No header.', array('%filename' => theme('placeholder', $file->filename))), 'error'); + drupal_set_message(t('The translation file %filename appears to have a missing or malformed header.', array('%filename' => theme('placeholder', $file->filename))), 'error'); return FALSE; } @@ -256,7 +255,7 @@ function _locale_import_po($file, $lang, $mode) { // rebuild the menu, strings may have changed menu_rebuild(); - drupal_set_message(t('Translation successfully imported. %number translated strings added to language, %update strings updated.', array('%number' => $additions, '%update' => $updates))); + drupal_set_message(t('The translation was successfully imported. There are %number newly created translated strings and %update strings were updated.', array('%number' => $additions, '%update' => $updates))); watchdog('locale', t('Imported %file into %locale: %number new strings added and %update updated.', array('%file' => theme('placeholder', $file->filename), '%locale' => theme('placeholder', $lang), '%number' => $additions, '%update' => $updates))); return TRUE; } @@ -272,7 +271,7 @@ function _locale_import_read_po($file) { $message = theme('placeholder', $file->filename); $fd = fopen($file->filepath, "rb"); if (!$fd) { - drupal_set_message(t('Translation import failed: file %filename cannot be read.', array('%filename' => $message)), 'error'); + drupal_set_message(t('The translation import failed, because the file %filename could not be read.', array('%filename' => $message)), 'error'); return FALSE; } $info = fstat($fd); @@ -304,19 +303,19 @@ function _locale_import_read_po($file) { $context = "COMMENT"; } else { // Parse error - drupal_set_message(t("Translation file %filename broken: expected 'msgstr' in line %line.", array('%filename' => $message, '%line' => $lineno)), 'error'); + drupal_set_message(t('The translation file %filename contains an error: "msgstr" was expected but not found on line %line.', array('%filename' => $message, '%line' => $lineno)), 'error'); return FALSE; } } elseif (!strncmp("msgid_plural", $line, 12)) { if ($context != "MSGID") { // Must be plural form for current entry - drupal_set_message(t("Translation file %filename broken: unexpected 'msgid_plural' in line %line.", array('%filename' => $message, '%line' => $lineno)), 'error'); + drupal_set_message(t('The translation file %filename contains an error: "msgid_plural" was expected but not found on line %line.', array('%filename' => $message, '%line' => $lineno)), 'error'); return FALSE; } $line = trim(substr($line, 12)); $quoted = _locale_import_parse_quoted($line); if ($quoted === false) { - drupal_set_message(t('Translation file %filename broken: syntax error in line %line.', array('%filename' => $message, '%line' => $lineno)), 'error'); + drupal_set_message(t('The translation file %filename contains a syntax error on line %line.', array('%filename' => $message, '%line' => $lineno)), 'error'); return FALSE; } $current["msgid"] = $current["msgid"] ."\0". $quoted; @@ -328,13 +327,13 @@ function _locale_import_read_po($file) { $current = array(); } elseif ($context == "MSGID") { // Already in this context? Parse error - drupal_set_message(t("Translation file %filename broken: unexpected 'msgid' in line %line.", array('%filename' => $message, '%line' => $lineno)), 'error'); + drupal_set_message(t('The translation file %filename contains an error: "msgid" is unexpected on line %line.', array('%filename' => $message, '%line' => $lineno)), 'error'); return FALSE; } $line = trim(substr($line, 5)); $quoted = _locale_import_parse_quoted($line); if ($quoted === false) { - drupal_set_message(t('Translation file %filename broken: syntax error in line %line.', array('%filename' => $message, '%line' => $lineno)), 'error'); + drupal_set_message(t('The translation file %filename contains a syntax error on line %line.', array('%filename' => $message, '%line' => $lineno)), 'error'); return FALSE; } $current["msgid"] = $quoted; @@ -342,11 +341,11 @@ function _locale_import_read_po($file) { } elseif (!strncmp("msgstr[", $line, 7)) { if (($context != "MSGID") && ($context != "MSGID_PLURAL") && ($context != "MSGSTR_ARR")) { // Must come after msgid, msgid_plural, or msgstr[] - drupal_set_message(t("Translation file %filename broken: unexpected 'msgstr[]' in line %line.", array('%filename' => $message, '%line' => $lineno)), 'error'); + drupal_set_message(t('The translation file %filename contains an error: "msgstr[]" is unexpected on line %line.', array('%filename' => $message, '%line' => $lineno)), 'error'); return FALSE; } if (strpos($line, "]") === false) { - drupal_set_message(t('Translation file %filename broken: syntax error in line %line.', array('%filename' => $message, '%line' => $lineno)), 'error'); + drupal_set_message(t('The translation file %filename contains a syntax error on line %line.', array('%filename' => $message, '%line' => $lineno)), 'error'); return FALSE; } $frombracket = strstr($line, "["); @@ -354,7 +353,7 @@ function _locale_import_read_po($file) { $line = trim(strstr($line, " ")); $quoted = _locale_import_parse_quoted($line); if ($quoted === false) { - drupal_set_message(t('Translation file %filename broken: syntax error in line %line.', array('%filename' => $message, '%line' => $lineno)), 'error'); + drupal_set_message(t('The translation file %filename contains a syntax error on line %line.', array('%filename' => $message, '%line' => $lineno)), 'error'); return FALSE; } $current["msgstr"][$plural] = $quoted; @@ -362,13 +361,13 @@ function _locale_import_read_po($file) { } elseif (!strncmp("msgstr", $line, 6)) { if ($context != "MSGID") { // Should come just after a msgid block - drupal_set_message(t("Translation file %filename broken: unexpected 'msgstr' in line %line.", array('%filename' => $message, '%line' => $lineno)), 'error'); + drupal_set_message(t('The translation file %filename contains an error: "msgstr" is unexpected on line %line.', array('%filename' => $message, '%line' => $lineno)), 'error'); return FALSE; } $line = trim(substr($line, 6)); $quoted = _locale_import_parse_quoted($line); if ($quoted === false) { - drupal_set_message(t('Translation file %filename broken: syntax error in line %line.', array('%filename' => $message, '%line' => $lineno)), 'error'); + drupal_set_message(t('The translation file %filename contains a syntax error on line %line.', array('%filename' => $message, '%line' => $lineno)), 'error'); return FALSE; } $current["msgstr"] = $quoted; @@ -377,7 +376,7 @@ function _locale_import_read_po($file) { elseif ($line != "") { $quoted = _locale_import_parse_quoted($line); if ($quoted === false) { - drupal_set_message(t('Translation file %filename broken: syntax error in line %line.', array('%filename' => $message, '%line' => $lineno)), 'error'); + drupal_set_message(t('The translation file %filename contains a syntax error on line %line.', array('%filename' => $message, '%line' => $lineno)), 'error'); return FALSE; } if (($context == "MSGID") || ($context == "MSGID_PLURAL")) { @@ -390,7 +389,7 @@ function _locale_import_read_po($file) { $current["msgstr"][$plural] .= $quoted; } else { - drupal_set_message(t('Translation file %filename broken: unexpected string in line %line.', array('%filename' => $message, '%line' => $lineno)), 'error'); + drupal_set_message(t('The translation file %filename contains an error: there is an unexpected string on line %line.', array('%filename' => $message, '%line' => $lineno)), 'error'); return FALSE; } } @@ -401,7 +400,7 @@ function _locale_import_read_po($file) { $strings[$current["msgid"]] = $current; } elseif ($context != "COMMENT") { - drupal_set_message(t('Translation file %filename broken: unexpected end of file at line %line.', array('%filename' => $message, '%line' => $lineno)), 'error'); + drupal_set_message(t('The translation file %filename ended unexpectedly at line %line.', array('%filename' => $message, '%line' => $lineno)), 'error'); return FALSE; } @@ -466,7 +465,7 @@ function _locale_import_parse_plural_forms($pluralforms, $filename) { return array($nplurals, $plural); } else { - drupal_set_message(t("Translation file %filename broken: plural formula couldn't get parsed.", array('%filename' => theme('placeholder', $filename))), 'error'); + drupal_set_message(t('The translation file %filename contains an error: the plural formula could not be parsed.', array('%filename' => theme('placeholder', $filename))), 'error'); return FALSE; } } @@ -905,7 +904,7 @@ function _locale_string_delete($lid) { db_query('DELETE FROM {locales_source} WHERE lid = %d', $lid); db_query('DELETE FROM {locales_target} WHERE lid = %d', $lid); locale_refresh_cache(); - drupal_set_message(t('Deleted string')); + drupal_set_message(t('The string has been removed.')); } /** @@ -932,7 +931,7 @@ function _locale_string_save($lid) { // delete form data so it will remember where it came from $edit = ''; - drupal_set_message(t('Saved string')); + drupal_set_message(t('The string has been saved.')); } /** diff --git a/includes/theme.inc b/includes/theme.inc index 6b210c55e..e61c606cb 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -814,19 +814,8 @@ function theme_item_list($items = array(), $title = NULL) { } /** - * Return a themed error message. - * REMOVE: this function is deprecated an no longer used in core. - * - * @param $message - * The error message to be themed. - * - * @return - * A string containing the error output. + * Returns code that emits the 'more help'-link. */ -function theme_error($message) { - return '<div class="error">'. $message .'</div>'; -} - function theme_more_help_link($url) { return '<div class="more-help-link">' . t('[<a href="%link">more help...</a>]', array('%link' => $url)) . '</div>'; } |