diff --git a/core/includes/date.inc b/core/includes/date.inc
index 01ab131..2d9ec5c 100644
--- a/core/includes/date.inc
+++ b/core/includes/date.inc
@@ -25,17 +25,44 @@ function system_default_date_formats() {
   $formats[] = array(
     'type' => 'short',
     'format' => 'd/m/Y - H:i',
-    'locales' => array('en-gb', 'en-hk', 'en-ie', 'el-gr', 'es-es', 'fr-be', 'fr-fr', 'fr-lu', 'it-it', 'nl-be', 'pt-pt'),
+    'locales' => array(
+      'en-gb',
+      'en-hk',
+      'en-ie',
+      'el-gr',
+      'es-es',
+      'fr-be',
+      'fr-fr',
+      'fr-lu',
+      'it-it',
+      'nl-be',
+      'pt-pt',
+    ),
   );
   $formats[] = array(
     'type' => 'short',
     'format' => 'Y/m/d - H:i',
-    'locales' => array('en-ca', 'fr-ca', 'no-no', 'sv-se'),
+    'locales' => array(
+      'en-ca',
+      'fr-ca',
+      'no-no',
+      'sv-se',
+    ),
   );
   $formats[] = array(
     'type' => 'short',
     'format' => 'd.m.Y - H:i',
-    'locales' => array('de-ch', 'de-de', 'de-lu', 'fi-fi', 'fr-ch', 'is-is', 'pl-pl', 'ro-ro', 'ru-ru'),
+    'locales' => array(
+      'de-ch',
+      'de-de',
+      'de-lu',
+      'fi-fi',
+      'fr-ch',
+      'is-is',
+      'pl-pl',
+      'ro-ro',
+      'ru-ru',
+    ),
   );
   $formats[] = array(
     'type' => 'short',
@@ -97,12 +124,29 @@ function system_default_date_formats() {
   $formats[] = array(
     'type' => 'medium',
     'format' => 'D, d/m/Y - H:i',
-    'locales' => array('en-gb', 'en-hk', 'en-ie', 'el-gr', 'es-es', 'fr-be', 'fr-fr', 'fr-lu', 'it-it', 'nl-be', 'pt-pt'),
+    'locales' => array(
+      'en-gb',
+      'en-hk',
+      'en-ie',
+      'el-gr',
+      'es-es',
+      'fr-be',
+      'fr-fr',
+      'fr-lu',
+      'it-it',
+      'nl-be',
+      'pt-pt',
+    ),
   );
   $formats[] = array(
     'type' => 'medium',
     'format' => 'D, Y/m/d - H:i',
-    'locales' => array('en-ca', 'fr-ca', 'no-no', 'sv-se'),
+    'locales' => array(
+      'en-ca',
+      'fr-ca',
+      'no-no',
+      'sv-se',
+    ),
   );
   $formats[] = array(
     'type' => 'medium',
diff --git a/core/includes/errors.inc b/core/includes/errors.inc
index 0524170..4aa43c9 100644
--- a/core/includes/errors.inc
+++ b/core/includes/errors.inc
@@ -108,7 +108,8 @@ function _drupal_decode_exception($exception) {
   // For PDOException errors, we try to return the initial caller,
   // skipping internal functions of the database layer.
   if ($exception instanceof PDOException) {
-    // The first element in the stack is the call, the second element gives us the caller.
+    // The first element in the stack is the call,
+    // the second element gives us the caller.
     // We skip calls that occurred in one of the classes of the database layer
     // or in one of its global functions.
     $db_functions = array('db_query',  'db_query_range');
@@ -184,7 +185,8 @@ function error_displayable($error = NULL) {
  */
 function _drupal_log_error($error, $fatal = FALSE) {
   // Initialize a maintenance theme if the boostrap was not complete.
-  // Do it early because drupal_set_message() triggers a drupal_theme_initialize().
+  // Do it early because drupal_set_message()
+  // triggers a drupal_theme_initialize().
   if ($fatal && (drupal_get_bootstrap_phase() != DRUPAL_BOOTSTRAP_FULL)) {
     unset($GLOBALS['theme']);
     if (!defined('MAINTENANCE_MODE')) {
@@ -222,7 +224,7 @@ function _drupal_log_error($error, $fatal = FALSE) {
   if (drupal_is_cli()) {
     if ($fatal) {
       // When called from CLI, simply output a plain text message.
-      print html_entity_decode(strip_tags(t('%type: !message in %function (line %line of %file).', $error))). "\n";
+      print html_entity_decode(strip_tags(t('%type: !message in %function (line %line of %file).', $error))) . "\n";
       exit;
     }
   }
@@ -252,8 +254,8 @@ function _drupal_log_error($error, $fatal = FALSE) {
 
     if ($fatal) {
       drupal_set_title(t('Error'));
-      // We fallback to a maintenance page at this point, because the page generation
-      // itself can generate errors.
+      // We fallback to a maintenance page at this point,
+      // because the page generation itself can generate errors.
       print theme('maintenance_page', array('content' => t('The website encountered an unexpected error. Please try again later.')));
       exit;
     }
@@ -272,7 +274,11 @@ function _drupal_log_error($error, $fatal = FALSE) {
 function _drupal_get_last_caller($backtrace) {
   // Errors that occur inside PHP internal functions do not generate
   // information about file and line. Ignore black listed functions.
-  $blacklist = array('debug', '_drupal_error_handler', '_drupal_exception_handler');
+  $blacklist = array(
+    'debug',
+    '_drupal_error_handler',
+    '_drupal_exception_handler',
+  );
   while (($backtrace && !isset($backtrace[0]['line'])) ||
          (isset($backtrace[1]['function']) && in_array($backtrace[1]['function'], $blacklist))) {
     array_shift($backtrace);
diff --git a/core/includes/file.inc b/core/includes/file.inc
index b476bc7..3ef06af 100644
--- a/core/includes/file.inc
+++ b/core/includes/file.inc
@@ -74,7 +74,8 @@ define('STREAM_WRAPPERS_READ_VISIBLE', STREAM_WRAPPERS_READ | STREAM_WRAPPERS_VI
 define('STREAM_WRAPPERS_NORMAL', STREAM_WRAPPERS_WRITE_VISIBLE);
 
 /**
- * Stream wrapper type flag -- visible, readable and writeable using local files.
+ * Stream wrapper type flag -- visible, readable and writeable using local
+ * files.
  */
 define('STREAM_WRAPPERS_LOCAL_NORMAL', STREAM_WRAPPERS_LOCAL | STREAM_WRAPPERS_NORMAL);
 
@@ -547,7 +548,7 @@ function file_save_htaccess($directory, $private = TRUE) {
   else {
     $directory = rtrim($directory, '/\\');
   }
-  $htaccess_path =  $directory . '/.htaccess';
+  $htaccess_path = $directory . '/.htaccess';
 
   if (file_exists($htaccess_path)) {
     // Short circuit if the .htaccess file already exists.
@@ -826,7 +827,11 @@ function file_usage_delete(stdClass $file, $module, $type = NULL, $id = NULL, $c
 function file_copy(stdClass $source, $destination = NULL, $replace = FILE_EXISTS_RENAME) {
   if (!file_valid_uri($destination)) {
     if (($realpath = drupal_realpath($source->uri)) !== FALSE) {
-      watchdog('file', 'File %file (%realpath) could not be copied because the destination %destination is invalid. This is often caused by improper use of file_copy() or a missing stream wrapper.', array('%file' => $source->uri, '%realpath' => $realpath, '%destination' => $destination));
+      watchdog('file', 'File %file (%realpath) could not be copied because the destination %destination is invalid. This is often caused by improper use of file_copy() or a missing stream wrapper.', array(
+        '%file' => $source->uri,
+        '%realpath' => $realpath,
+        '%destination' => $destination,
+      ));
     }
     else {
       watchdog('file', 'File %file could not be copied because the destination %destination is invalid. This is often caused by improper use of file_copy() or a missing stream wrapper.', array('%file' => $source->uri, '%destination' => $destination));
@@ -1075,7 +1080,11 @@ function file_destination($destination, $replace) {
 function file_move(stdClass $source, $destination = NULL, $replace = FILE_EXISTS_RENAME) {
   if (!file_valid_uri($destination)) {
     if (($realpath = drupal_realpath($source->uri)) !== FALSE) {
-      watchdog('file', 'File %file (%realpath) could not be moved because the destination %destination is invalid. This may be caused by improper use of file_move() or a missing stream wrapper.', array('%file' => $source->uri, '%realpath' => $realpath, '%destination' => $destination));
+      watchdog('file', 'File %file (%realpath) could not be moved because the destination %destination is invalid. This may be caused by improper use of file_move() or a missing stream wrapper.', array(
+        '%file' => $source->uri,
+        '%realpath' => $realpath,
+        '%destination' => $destination,
+      ));
     }
     else {
       watchdog('file', 'File %file could not be moved because the destination %destination is invalid. This may be caused by improper use of file_move() or a missing stream wrapper.', array('%file' => $source->uri, '%destination' => $destination));
@@ -1183,15 +1192,17 @@ function file_unmanaged_move($source, $destination = NULL, $replace = FILE_EXIST
 function file_munge_filename($filename, $extensions, $alerts = TRUE) {
   $original = $filename;
 
-  // Allow potentially insecure uploads for very savvy users and admin
+  // Allow potentially insecure uploads for very savvy users and admin.
   if (!variable_get('allow_insecure_uploads', 0)) {
     $whitelist = array_unique(explode(' ', trim($extensions)));
 
     // Split the filename up by periods. The first part becomes the basename
     // the last part the final extension.
     $filename_parts = explode('.', $filename);
-    $new_filename = array_shift($filename_parts); // Remove file basename.
-    $final_extension = array_pop($filename_parts); // Remove final extension.
+    // Remove file basename.
+    $new_filename = array_shift($filename_parts);
+    // Remove final extension.
+    $final_extension = array_pop($filename_parts);
 
     // Loop through the middle parts of the name and add an underscore to the
     // end of each section that could be a file extension but isn't in the list
@@ -1245,7 +1256,7 @@ function file_create_filename($basename, $directory) {
   // some filesystems, not many applications handle them well.
   $basename = preg_replace('/[\x00-\x1F]/u', '_', $basename);
   if (substr(PHP_OS, 0, 3) == 'WIN') {
-    // These characters are not allowed in Windows filenames
+    // These characters are not allowed in Windows filenames.
     $basename = str_replace(array(':', '*', '?', '"', '<', '>', '|'), '_', $basename);
   }
 
@@ -1513,8 +1524,8 @@ function file_save_upload($source, $validators = array(), $destination = FALSE,
         break;
       }
 
-    // Unknown error
     default:
+      // Unknown error.
       drupal_set_message(t('The file %file could not be saved. An unknown error has occurred.', array('%file' => $_FILES['files']['name'][$source])), 'error');
       return FALSE;
   }
@@ -2112,7 +2123,8 @@ function file_scan_directory($dir, $mask, $options = array(), $depth = 0) {
         $uri = "$dir/$filename";
         $uri = file_stream_wrapper_uri_normalize($uri);
         if (is_dir($uri) && $options['recurse']) {
-          // Give priority to files in this folder by merging them in after any subdirectory files.
+          // Give priority to files in this folder by
+          // merging them in after any subdirectory files.
           $files = array_merge(file_scan_directory($uri, $mask, $options, $depth + 1), $files);
         }
         elseif ($depth >= $options['min_depth'] && preg_match($mask, $filename)) {
@@ -2543,7 +2555,11 @@ function file_get_content_headers($file) {
   $name = mime_header_encode($file->filename);
   $type = mime_header_encode($file->filemime);
   // Serve images, text, and flash content for display rather than download.
-  $inline_types = variable_get('file_inline_types', array('^text/', '^image/', 'flash$'));
+  $inline_types = variable_get('file_inline_types', array(
+    '^text/',
+    '^image/',
+    'flash$',
+  ));
   $disposition = 'attachment';
   foreach ($inline_types as $inline_type) {
     // Exclamation marks are used as delimiters to avoid escaping slashes.
diff --git a/core/includes/form.inc b/core/includes/form.inc
index a555bf0..9f66ba5 100644
--- a/core/includes/form.inc
+++ b/core/includes/form.inc
@@ -402,7 +402,7 @@ function form_state_defaults() {
     'submitted' => FALSE,
     'executed' => FALSE,
     'programmed' => FALSE,
-    'cache'=> FALSE,
+    'cache' => FALSE,
     'method' => 'post',
     'groups' => array(),
     'buttons' => array(),
@@ -663,6 +663,7 @@ function form_load_include(&$form_state, $type, $module, $name = NULL) {
  *   $form_state['build_info']['args'] = array(&$object);
  *   drupal_form_submit('mymodule_form', $form_state);
  *   @endcode
+ *
  * For example:
  * @code
  * // register a new user
@@ -743,9 +744,10 @@ function drupal_retrieve_form($form_id, &$form_state) {
   // We first check to see if there's a function named after the $form_id.
   // If there is, we simply pass the arguments on to it to get the form.
   if (!function_exists($form_id)) {
-    // In cases where many form_ids need to share a central constructor function,
-    // such as the node editing form, modules can implement hook_forms(). It
-    // maps one or more form_ids to the correct constructor functions.
+    // In cases where many form_ids need to share a central constructor
+    // function, such as the node editing form, modules can implement
+    // hook_forms(). It maps one or more form_ids to the correct constructor
+    // functions.
     //
     // We cache the results of that hook to save time, but that only works
     // for modules that know all their form_ids in advance. (A module that
@@ -1763,8 +1765,8 @@ function form_builder($form_id, &$element, &$form_state) {
     $form_state['complete_form'] = &$element;
 
     // Set a flag if we have a correct form submission. This is always TRUE for
-    // programmed forms coming from drupal_form_submit(), or if the form_id coming
-    // from the POST data is set and matches the current form_id.
+    // programmed forms coming from drupal_form_submit(), or if the form_id
+    // coming from the POST data is set and matches the current form_id.
     if ($form_state['programmed'] || (!empty($form_state['input']) && (isset($form_state['input']['form_id']) && ($form_state['input']['form_id'] == $form_id)))) {
       $form_state['process_input'] = TRUE;
     }
@@ -1842,7 +1844,7 @@ function form_builder($form_id, &$element, &$form_state) {
 
     // Assign a decimal placeholder weight to preserve original array order.
     if (!isset($element[$key]['#weight'])) {
-      $element[$key]['#weight'] = $count/1000;
+      $element[$key]['#weight'] = $count / 1000;
     }
     else {
       // If one of the child elements has a weight then we will need to sort
@@ -1980,7 +1982,7 @@ function _form_builder_handle_input_element($form_id, &$element, &$form_state) {
     $value_callback = !empty($element['#value_callback']) ? $element['#value_callback'] : 'form_type_' . $element['#type'] . '_value';
     if ($process_input) {
       // Get the input for the current element. NULL values in the input need to
-      // be explicitly distinguished from missing input. (see below)
+      // be explicitly distinguished from missing input (see below).
       $input_exists = NULL;
       $input = drupal_array_get_nested_value($form_state['input'], $element['#parents'], $input_exists);
       // For browser-submitted forms, the submitted values do not contain values
@@ -2019,9 +2021,9 @@ function _form_builder_handle_input_element($form_id, &$element, &$form_state) {
       if (function_exists($value_callback)) {
         $element['#value'] = $value_callback($element, FALSE, $form_state);
       }
-      // Final catch. If we haven't set a value yet, use the explicit default value.
-      // Avoid image buttons (which come with garbage value), so we only get value
-      // for the button actually clicked.
+      // Final catch. If we haven't set a value yet, use the explicit default
+      // value. Avoid image buttons (which come with garbage value), so we only
+      // get value for the button actually clicked.
       if (!isset($element['#value']) && empty($element['#has_garbage_value'])) {
         $element['#value'] = isset($element['#default_value']) ? $element['#default_value'] : '';
       }
@@ -2204,7 +2206,7 @@ function form_type_image_button_value($form, $input, $form_state) {
       // in the same spot for its name, with '_x'.
       $input = $form_state['input'];
       foreach (explode('[', $form['#name']) as $element_name) {
-        // chop off the ] that may exist.
+        // Chop off the ] that may exist.
         if (substr($element_name, -1) == ']') {
           $element_name = substr($element_name, 0, -1);
         }
@@ -2225,7 +2227,7 @@ function form_type_image_button_value($form, $input, $form_state) {
 /**
  * Determines the value for a checkbox form element.
  *
- * @param $form
+ * @param $element
  *   The form element whose value is being populated.
  * @param $input
  *   The incoming input to populate the form element. If this is FALSE,
@@ -2662,8 +2664,8 @@ function form_select_options($element, $choices = NULL) {
   if (!isset($choices)) {
     $choices = $element['#options'];
   }
-  // array_key_exists() accommodates the rare event where $element['#value'] is NULL.
-  // isset() fails in this situation.
+  // isset() fails where $element['#value'] is NULL.
+  // array_key_exists() accommodates the rare event when isset() fails.
   $value_valid = isset($element['#value']) || array_key_exists('#value', $element);
   $value_is_array = $value_valid && is_array($element['#value']);
   $options = '';
@@ -2791,7 +2793,14 @@ function theme_fieldset($variables) {
 function theme_radio($variables) {
   $element = $variables['element'];
   $element['#attributes']['type'] = 'radio';
-  element_set_attributes($element, array('id', 'name', '#return_value' => 'value'));
+  element_set_attributes(
+    $element,
+    array(
+      'id',
+      'name',
+      '#return_value' => 'value',
+    )
+  );
 
   if (isset($element['#return_value']) && $element['#value'] !== FALSE && $element['#value'] == $element['#return_value']) {
     $element['#attributes']['checked'] = 'checked';
@@ -2832,14 +2841,14 @@ function theme_radios($variables) {
  * Expand a password_confirm field into two text boxes.
  */
 function form_process_password_confirm($element) {
-  $element['pass1'] =  array(
+  $element['pass1'] = array(
     '#type' => 'password',
     '#title' => t('Password'),
     '#value' => empty($element['#value']) ? NULL : $element['#value']['pass1'],
     '#required' => $element['#required'],
     '#attributes' => array('class' => array('password-field')),
   );
-  $element['pass2'] =  array(
+  $element['pass2'] = array(
     '#type' => 'password',
     '#title' => t('Confirm password'),
     '#value' => empty($element['#value']) ? NULL : $element['#value']['pass2'],
@@ -2911,7 +2920,7 @@ function theme_date($variables) {
  * Expands a date element into year, month, and day select elements.
  */
 function form_process_date($element) {
-  // Default to current date
+  // Default to current date.
   if (empty($element['#value'])) {
     $element['#value'] = array(
       'day' => format_date(REQUEST_TIME, 'custom', 'j'),
@@ -3058,7 +3067,14 @@ function theme_checkbox($variables) {
   $element = $variables['element'];
   $t = get_t();
   $element['#attributes']['type'] = 'checkbox';
-  element_set_attributes($element, array('id', 'name', '#return_value' => 'value'));
+  element_set_attributes(
+    $element,
+    array(
+      'id',
+      'name',
+      '#return_value' => 'value',
+    )
+  );
 
   // Unchecked checkbox has #value of integer 0.
   if (!empty($element['#checked'])) {
@@ -3667,7 +3683,7 @@ function form_pre_render_fieldset($element) {
     $element['#attributes']['class'] = array();
   }
 
-  // Collapsible fieldsets
+  // Collapsible fieldsets.
   if (!empty($element['#collapsible'])) {
     $element['#attached']['library'][] = array('system', 'drupal.collapse');
     $element['#attributes']['class'][] = 'collapsible';
@@ -3935,7 +3951,17 @@ function theme_hidden($variables) {
 function theme_textfield($variables) {
   $element = $variables['element'];
   $element['#attributes']['type'] = 'text';
-  element_set_attributes($element, array('id', 'name', 'value', 'size', 'maxlength', 'placeholder'));
+  element_set_attributes(
+    $element,
+    array(
+      'id',
+      'name',
+      'value',
+      'size',
+      'maxlength',
+      'placeholder',
+    )
+  );
   _form_set_class($element, array('form-text'));
 
   return '<input' . drupal_attributes($element['#attributes']) . ' />' . drupal_render_children($element);
@@ -3955,7 +3981,17 @@ function theme_textfield($variables) {
 function theme_email($variables) {
   $element = $variables['element'];
   $element['#attributes']['type'] = 'email';
-  element_set_attributes($element, array('id', 'name', 'value', 'size', 'maxlength', 'placeholder'));
+  element_set_attributes(
+    $element,
+    array(
+      'id',
+      'name',
+      'value',
+      'size',
+      'maxlength',
+      'placeholder',
+    )
+  );
   _form_set_class($element, array('form-email'));
 
   return '<input' . drupal_attributes($element['#attributes']) . ' />' . drupal_render_children($element);
@@ -3989,7 +4025,17 @@ function form_validate_email(&$element, &$form_state) {
 function theme_tel($variables) {
   $element = $variables['element'];
   $element['#attributes']['type'] = 'tel';
-  element_set_attributes($element, array('id', 'name', 'value', 'size', 'maxlength', 'placeholder'));
+  element_set_attributes(
+    $element,
+    array(
+      'id',
+      'name',
+      'value',
+      'size',
+      'maxlength',
+      'placeholder',
+    )
+  );
   _form_set_class($element, array('form-tel'));
 
   return '<input' . drupal_attributes($element['#attributes']) . ' />' . drupal_render_children($element);
@@ -4033,7 +4079,17 @@ function theme_range($variables) {
   $element = $variables['element'];
 
   $element['#attributes']['type'] = 'range';
-  element_set_attributes($element, array('id', 'name', 'value', 'step', 'min', 'max'));
+  element_set_attributes(
+    $element,
+    array(
+      'id',
+      'name',
+      'value',
+      'step',
+      'min',
+      'max',
+    )
+  );
   _form_set_class($element, array('form-range'));
 
   $output = '<input' . drupal_attributes($element['#attributes']) . ' />';
@@ -4125,7 +4181,17 @@ function form_type_range_value($element, $input = FALSE) {
 function theme_url($variables) {
   $element = $variables['element'];
   $element['#attributes']['type'] = 'url';
-  element_set_attributes($element, array('id', 'name', 'value', 'size', 'maxlength', 'placeholder'));
+  element_set_attributes(
+    $element,
+    array(
+      'id',
+      'name',
+      'value',
+      'size',
+      'maxlength',
+      'placeholder',
+    )
+  );
   _form_set_class($element, array('form-url'));
 
   return '<input' . drupal_attributes($element['#attributes']) . ' />' . drupal_render_children($element);
@@ -4145,7 +4211,17 @@ function theme_url($variables) {
 function theme_search($variables) {
   $element = $variables['element'];
   $element['#attributes']['type'] = 'search';
-  element_set_attributes($element, array('id', 'name', 'value', 'size', 'maxlength', 'placeholder'));
+  element_set_attributes(
+    $element,
+    array(
+      'id',
+      'name',
+      'value',
+      'size',
+      'maxlength',
+      'placeholder',
+    )
+  );
   _form_set_class($element, array('form-search'));
 
   return '<input' . drupal_attributes($element['#attributes']) . ' />' . drupal_render_children($element);
@@ -4201,7 +4277,16 @@ function theme_form($variables) {
  */
 function theme_textarea($variables) {
   $element = $variables['element'];
-  element_set_attributes($element, array('id', 'name', 'rows', 'cols', 'placeholder'));
+  element_set_attributes(
+    $element,
+    array(
+      'id',
+      'name',
+      'rows',
+      'cols',
+      'placeholder',
+    )
+  );
   _form_set_class($element, array('form-textarea'));
 
   $wrapper_attributes = array(
@@ -4233,7 +4318,16 @@ function theme_textarea($variables) {
 function theme_password($variables) {
   $element = $variables['element'];
   $element['#attributes']['type'] = 'password';
-  element_set_attributes($element, array('id', 'name', 'size', 'maxlength', 'placeholder'));
+  element_set_attributes(
+    $element,
+    array(
+      'id',
+      'name',
+      'size',
+      'maxlength',
+      'placeholder',
+    )
+  );
   _form_set_class($element, array('form-text'));
 
   return '<input' . drupal_attributes($element['#attributes']) . ' />';
@@ -4485,7 +4579,7 @@ function theme_form_element_label($variables) {
  *
  * @param $element
  *   The form element.
- * @param $name
+ * @param $class
  *   Array of new class names to be added.
  */
 function _form_set_class(&$element, $class = array()) {
@@ -4556,8 +4650,8 @@ function _form_set_class(&$element, $class = array()) {
  * @code
  * // Simple and artificial: load a node of a given type for a given user
  * function my_function_1($uid, $type, &$context) {
- *   // The $context array gathers batch context information about the execution (read),
- *   // as well as 'return values' for the current operation (write)
+ *   // The $context array gathers batch context information about the execution
+ *   // (read), as well as 'return values' for the current operation (write)
  *   // The following keys are provided :
  *   // 'results' (read / write): The array of results gathered so far by
  *   //   the batch processing, for the current operation to append its own.
@@ -4756,7 +4850,7 @@ function batch_process($redirect = NULL, $url = 'batch', $redirect_callback = 'd
   drupal_theme_initialize();
 
   if (isset($batch)) {
-    // Add process information
+    // Add process information.
     $process_info = array(
       'current_set' => 0,
       'progressive' => TRUE,
@@ -4808,7 +4902,8 @@ function batch_process($redirect = NULL, $url = 'batch', $redirect_callback = 'd
         ))
         ->execute();
 
-      // Set the batch number in the session to guarantee that it will stay alive.
+      // Set the batch number in the session
+      // to guarantee that it will stay alive.
       $_SESSION['batches'][$batch['id']] = TRUE;
 
       // Redirect for processing.
diff --git a/core/includes/gettext.inc b/core/includes/gettext.inc
index 2355157..528f972 100644
--- a/core/includes/gettext.inc
+++ b/core/includes/gettext.inc
@@ -42,7 +42,8 @@ function _locale_import_po($file, $langcode, $overwrite_options, $customized = L
     return FALSE;
   }
 
-  // Get strings from file (returns on failure after a partial import, or on success)
+  // Get strings from file (returns on failure after a partial import, or on
+  // success)
   $status = _locale_import_read_po('db-store', $file, $overwrite_options, $langcode, $customized);
   if ($status === FALSE) {
     // Error messages are set in _locale_import_read_po().
@@ -63,8 +64,18 @@ function _locale_import_po($file, $langcode, $overwrite_options, $customized = L
   // Rebuild the menu, strings may have changed.
   menu_router_rebuild();
 
-  drupal_set_message(t('The translation was successfully imported. There are %number newly created translated strings, %update strings were updated and %delete strings were removed.', array('%number' => $additions, '%update' => $updates, '%delete' => $deletes)));
-  watchdog('locale', 'Imported %file into %locale: %number new strings added, %update updated and %delete removed.', array('%file' => $file->filename, '%locale' => $langcode, '%number' => $additions, '%update' => $updates, '%delete' => $deletes));
+  drupal_set_message(t('The translation was successfully imported. There are %number newly created translated strings, %update strings were updated and %delete strings were removed.', array(
+    '%number' => $additions,
+    '%update' => $updates,
+    '%delete' => $deletes,
+  )));
+  watchdog('locale', 'Imported %file into %locale: %number new strings added, %update updated and %delete removed.', array(
+    '%file' => $file->filename,
+    '%locale' => $langcode,
+    '%number' => $additions,
+    '%update' => $updates,
+    '%delete' => $deletes,
+  ));
   if ($skips) {
     if (module_exists('dblog')) {
       $skip_message = format_plural($skips, 'A translation string was skipped because of disallowed or malformed HTML. <a href="@url">See the log</a> for details.', '@count translation strings were skipped because of disallowed or malformed HTML. <a href="@url">See the log</a> for details.', array('@url' => url('admin/reports/dblog')));
@@ -140,7 +151,6 @@ function _locale_import_read_po($op, $file, $overwrite_options = NULL, $lang = N
 
     if (!strncmp('#', $line, 1)) {
       // Lines starting with '#' are comments.
-
       if ($context == 'COMMENT') {
         // Already in comment token, insert the comment.
         $current['#'][] = substr($line, 1);
@@ -163,7 +173,6 @@ function _locale_import_read_po($op, $file, $overwrite_options = NULL, $lang = N
     }
     elseif (!strncmp('msgid_plural', $line, 12)) {
       // A plural form for the current message.
-
       if ($context != 'MSGID') {
         // A plural form cannot be added to anything else but the id directly.
         _locale_import_message('The translation file %filename contains an error: "msgid_plural" was expected but not found on line %line.', $file, $lineno);
@@ -173,7 +182,6 @@ function _locale_import_read_po($op, $file, $overwrite_options = NULL, $lang = N
       // Remove 'msgid_plural' and trim away whitespace.
       $line = trim(substr($line, 12));
       // At this point, $line should now contain only the plural form.
-
       $quoted = _locale_import_parse_quoted($line);
       if ($quoted === FALSE) {
         // The plural form must be wrapped in quotes.
@@ -188,7 +196,6 @@ function _locale_import_read_po($op, $file, $overwrite_options = NULL, $lang = N
     }
     elseif (!strncmp('msgid', $line, 5)) {
       // Starting a new message.
-
       if (($context == 'MSGSTR') || ($context == 'MSGSTR_ARR')) {
         // We are currently in a message string, close it out.
         _locale_import_one_string($op, $current, $overwrite_options, $lang, $file, $customized);
@@ -197,7 +204,8 @@ function _locale_import_read_po($op, $file, $overwrite_options = NULL, $lang = N
         $current = array();
       }
       elseif ($context == 'MSGID') {
-        // We are currently already in the context, meaning we passed an id with no data.
+        // We are currently already in the context, meaning we passed an id with
+        // no data.
         _locale_import_message('The translation file %filename contains an error: "msgid" is unexpected on line %line.', $file, $lineno);
         return FALSE;
       }
@@ -205,7 +213,6 @@ function _locale_import_read_po($op, $file, $overwrite_options = NULL, $lang = N
       // Remove 'msgid' and trim away whitespace.
       $line = trim(substr($line, 5));
       // At this point, $line should now contain only the message id.
-
       $quoted = _locale_import_parse_quoted($line);
       if ($quoted === FALSE) {
         // The message id must be wrapped in quotes.
@@ -218,7 +225,6 @@ function _locale_import_read_po($op, $file, $overwrite_options = NULL, $lang = N
     }
     elseif (!strncmp('msgctxt', $line, 7)) {
       // Starting a new context.
-
       if (($context == 'MSGSTR') || ($context == 'MSGSTR_ARR')) {
         // We are currently in a message, start a new one.
         _locale_import_one_string($op, $current, $overwrite_options, $lang, $file, $customized);
@@ -233,7 +239,6 @@ function _locale_import_read_po($op, $file, $overwrite_options = NULL, $lang = N
       // Remove 'msgctxt' and trim away whitespaces.
       $line = trim(substr($line, 7));
       // At this point, $line should now contain the context.
-
       $quoted = _locale_import_parse_quoted($line);
       if ($quoted === FALSE) {
         // The context string must be quoted.
@@ -247,9 +252,9 @@ function _locale_import_read_po($op, $file, $overwrite_options = NULL, $lang = N
     }
     elseif (!strncmp('msgstr[', $line, 7)) {
       // A message string for a specific plurality.
-
       if (($context != 'MSGID') && ($context != 'MSGCTXT') && ($context != 'MSGID_PLURAL') && ($context != 'MSGSTR_ARR')) {
-        // Message strings must come after msgid, msgxtxt, msgid_plural, or other msgstr[] entries.
+        // Message strings must come after msgid, msgxtxt, msgid_plural, or
+        // other msgstr[] entries.
         _locale_import_message('The translation file %filename contains an error: "msgstr[]" is unexpected on line %line.', $file, $lineno);
         return FALSE;
       }
@@ -264,7 +269,8 @@ function _locale_import_read_po($op, $file, $overwrite_options = NULL, $lang = N
       $frombracket = strstr($line, '[');
       $plural = substr($frombracket, 1, strpos($frombracket, ']') - 1);
 
-      // Skip to the next whitespace and trim away any further whitespace, bringing $line to the message data.
+      // Skip to the next whitespace and trim away any further whitespace,
+      // bringing $line to the message data.
       $line = trim(strstr($line, " "));
 
       $quoted = _locale_import_parse_quoted($line);
@@ -280,7 +286,6 @@ function _locale_import_read_po($op, $file, $overwrite_options = NULL, $lang = N
     }
     elseif (!strncmp("msgstr", $line, 6)) {
       // A string for the an id or context.
-
       if (($context != 'MSGID') && ($context != 'MSGCTXT')) {
         // Strings are only valid within an id or context scope.
         _locale_import_message('The translation file %filename contains an error: "msgstr" is unexpected on line %line.', $file, $lineno);
@@ -290,7 +295,6 @@ function _locale_import_read_po($op, $file, $overwrite_options = NULL, $lang = N
       // Remove 'msgstr' and trim away away whitespaces.
       $line = trim(substr($line, 6));
       // At this point, $line should now contain the message.
-
       $quoted = _locale_import_parse_quoted($line);
       if ($quoted === FALSE) {
         // The string must be quoted.
@@ -304,7 +308,6 @@ function _locale_import_read_po($op, $file, $overwrite_options = NULL, $lang = N
     }
     elseif ($line != '') {
       // Anything that is not a token may be a continuation of a previous token.
-
       $quoted = _locale_import_parse_quoted($line);
       if ($quoted === FALSE) {
         // The string must be quoted.
@@ -354,9 +357,9 @@ function _locale_import_read_po($op, $file, $overwrite_options = NULL, $lang = N
  *   An optional line number argument.
  */
 function _locale_import_message($message, $file, $lineno = NULL) {
-  $vars = array('%filename' => $file->filename);
+  $vars = array('%filename' => check_plain($file->filename));
   if (isset($lineno)) {
-    $vars['%line'] = $lineno;
+    $vars['%line'] = check_plain($lineno);
   }
   $t = get_t();
   drupal_set_message($t($message, $vars), 'error');
@@ -383,23 +386,34 @@ function _locale_import_message($message, $file, $lineno = NULL) {
  *   Use LOCALE_CUSTOMIZED or LOCALE_NOT_CUSTOMIZED.
  */
 function _locale_import_one_string($op, $value = NULL, $overwrite_options = NULL, $lang = NULL, $file = NULL, $customized = LOCALE_NOT_CUSTOMIZED) {
-  $report = &drupal_static(__FUNCTION__, array('additions' => 0, 'updates' => 0, 'deletes' => 0, 'skips' => 0));
+  $report = &drupal_static(__FUNCTION__, array(
+    'additions' => 0,
+    'updates' => 0,
+    'deletes' => 0,
+    'skips' => 0,
+  ));
   $header_done = &drupal_static(__FUNCTION__ . ':header_done', FALSE);
   $strings = &drupal_static(__FUNCTION__ . ':strings', array());
 
   switch ($op) {
-    // Return stored strings
+    // Return stored strings.
     case 'mem-report':
       return $strings;
 
-    // Store string in memory (only supports single strings)
+    // Store string in memory (only supports single strings).
     case 'mem-store':
       $strings[isset($value['msgctxt']) ? $value['msgctxt'] : ''][$value['msgid']] = $value['msgstr'];
       return;
 
-    // Called at end of import to inform the user
+    // Called at end of import to inform the user.
     case 'db-report':
-      return array($header_done, $report['additions'], $report['updates'], $report['deletes'], $report['skips']);
+      return array(
+        $header_done,
+        $report['additions'],
+        $report['updates'],
+        $report['deletes'],
+        $report['skips'],
+      );
 
     // Store the string we got in the database.
     case 'db-store':
@@ -449,7 +463,7 @@ function _locale_import_one_string($op, $value = NULL, $overwrite_options = NULL
           $customized
         );
       }
-  } // end of db-store operation
+  } // End of db-store operation.
 }
 
 /**
@@ -473,8 +487,8 @@ function _locale_import_one_string($op, $value = NULL, $overwrite_options = NULL
  *   - not_customized: not customized strings should be overwritten.
  *   - customized: customized strings should be overwritten.
  * @param $customized
- *   (optional) Whether the strings being imported should be saved as customized.
- *   Use LOCALE_CUSTOMIZED or LOCALE_NOT_CUSTOMIZED.
+ *   (optional) Whether the strings being imported should be saved as
+ *   customized. Use LOCALE_CUSTOMIZED or LOCALE_NOT_CUSTOMIZED.
  *
  * @return
  *   The string ID of the existing string modified or the new string added.
@@ -608,10 +622,10 @@ function _locale_import_parse_header($header) {
  *   formula in PHP for computing the plural form.
  */
 function _locale_import_parse_plural_forms($pluralforms, $filepath) {
-  // First, delete all whitespace
+  // First, delete all whitespace.
   $pluralforms = strtr($pluralforms, array(" " => "", "\t" => ""));
 
-  // Select the parts that define nplurals and plural
+  // Select the parts that define nplurals and plural.
   $nplurals = strstr($pluralforms, "nplurals=");
   if (strpos($nplurals, ";")) {
     $nplurals = substr($nplurals, 9, strpos($nplurals, ";") - 9);
@@ -627,7 +641,7 @@ function _locale_import_parse_plural_forms($pluralforms, $filepath) {
     return FALSE;
   }
 
-  // Get PHP version of the plural formula
+  // Get PHP version of the plural formula.
   $plural = _locale_import_parse_arithmetic($plural);
 
   if ($plural !== FALSE) {
@@ -652,23 +666,23 @@ function _locale_import_parse_plural_forms($pluralforms, $filepath) {
  *   The PHP version of the formula.
  */
 function _locale_import_parse_arithmetic($string) {
-  // Operator precedence table
+  // Operator precedence table.
   $precedence = array("(" => -1, ")" => -1, "?" => 1, ":" => 1, "||" => 3, "&&" => 4, "==" => 5, "!=" => 5, "<" => 6, ">" => 6, "<=" => 6, ">=" => 6, "+" => 7, "-" => 7, "*" => 8, "/" => 8, "%" => 8);
-  // Right associativity
+  // Right associativity.
   $right_associativity = array("?" => 1, ":" => 1);
 
   $tokens = _locale_import_tokenize_formula($string);
 
-  // Parse by converting into infix notation then back into postfix
-  // Operator stack - holds math operators and symbols
+  // Parse by converting into infix notation then back into postfix.
+  // Operator stack - holds math operators and symbols.
   $operator_stack = array();
-  // Element Stack - holds data to be operated on
+  // Element Stack - holds data to be operated on.
   $element_stack = array();
 
   foreach ($tokens as $token) {
     $current_token = $token;
 
-    // Numbers and the $n variable are simply pushed into $element_stack
+    // Numbers and the $n variable are simply pushed into $element_stack.
     if (is_numeric($token)) {
       $element_stack[] = $current_token;
     }
@@ -686,31 +700,34 @@ function _locale_import_parse_arithmetic($string) {
       }
     }
     elseif (!empty($precedence[$current_token])) {
-      // If it's an operator, then pop from $operator_stack into $element_stack until the
-      // precedence in $operator_stack is less than current, then push into $operator_stack
+      // If it's an operator, then pop from $operator_stack into $element_stack
+      // until the precedence in $operator_stack is less than current,
+      // then push into $operator_stack.
       $topop = array_pop($operator_stack);
       while (isset($topop) && ($precedence[$topop] >= $precedence[$current_token]) && !(($precedence[$topop] == $precedence[$current_token]) && !empty($right_associativity[$topop]) && !empty($right_associativity[$current_token]))) {
         $element_stack[] = $topop;
         $topop = array_pop($operator_stack);
       }
       if ($topop) {
-        $operator_stack[] = $topop;   // Return element to top
+        // Return element to top.
+        $operator_stack[] = $topop;
       }
-      $operator_stack[] = $current_token;      // Parentheses are not needed
+      // Parentheses are not needed.
+      $operator_stack[] = $current_token;
     }
     else {
       return FALSE;
     }
   }
 
-  // Flush operator stack
+  // Flush operator stack.
   $topop = array_pop($operator_stack);
   while ($topop != NULL) {
     $element_stack[] = $topop;
     $topop = array_pop($operator_stack);
   }
 
-  // Now extract formula from stack
+  // Now extract formula from stack.
   $previous_size = count($element_stack) + 1;
   while (count($element_stack) < $previous_size) {
     $previous_size = count($element_stack);
@@ -733,7 +750,7 @@ function _locale_import_parse_arithmetic($string) {
     }
   }
 
-  // If only one element is left, the number of operators is appropriate
+  // If only one element is left, the number of operators is appropriate.
   if (count($element_stack) == 1) {
     return $element_stack[0];
   }
@@ -745,7 +762,7 @@ function _locale_import_parse_arithmetic($string) {
 /**
  * Provides backward-compatible formula parsing for token_get_all().
  *
- * @param $string
+ * @param string $formula
  *   A string containing the arithmetic formula.
  *
  * @return
@@ -765,7 +782,8 @@ function _locale_import_tokenize_formula($formula) {
       $i = $j - 1;
       $tokens[] = $num;
     }
-    elseif ($pos = strpos(" =<>!&|", $formula[$i])) { // We won't have a space
+    // We won't have a space.
+    elseif ($pos = strpos(" =<>!&|", $formula[$i])) {
       $next = $formula[$i + 1];
       switch ($pos) {
         case 1:
@@ -780,6 +798,7 @@ function _locale_import_tokenize_formula($formula) {
             $tokens[] = $formula[$i];
           }
           break;
+
         case 5:
           if ($next == '&') {
             $tokens[] = '&&';
@@ -789,6 +808,7 @@ function _locale_import_tokenize_formula($formula) {
             $tokens[] = $formula[$i];
           }
           break;
+
         case 6:
           if ($next == '|') {
             $tokens[] = '||';
@@ -841,18 +861,22 @@ function _locale_import_shorten_comments($comment) {
  */
 function _locale_import_parse_quoted($string) {
   if (substr($string, 0, 1) != substr($string, -1, 1)) {
-    return FALSE;   // Start and end quotes must be the same
+    // Start and end quotes must be the same.
+    return FALSE;
   }
   $quote = substr($string, 0, 1);
   $string = substr($string, 1, -1);
-  if ($quote == '"') {        // Double quotes: strip slashes
+  if ($quote == '"') {
+    // Double quotes: strip slashes.
     return stripcslashes($string);
   }
-  elseif ($quote == "'") {  // Simple quote: return as-is
+  elseif ($quote == "'") {
+    // Simple quote: return as-is.
     return $string;
   }
   else {
-    return FALSE;             // Unrecognized quote
+    // Unrecognized quote.
+    return FALSE;
   }
 }
 
@@ -1069,7 +1093,7 @@ function _locale_export_string($str) {
   $stri = addcslashes($str, "\0..\37\\\"");
   $parts = array();
 
-  // Cut text into several lines
+  // Cut text into several lines.
   while ($stri != "") {
     $i = strpos($stri, "\\n");
     if ($i === FALSE) {
@@ -1084,15 +1108,15 @@ function _locale_export_string($str) {
     $parts = array_merge($parts, $curparts);
   }
 
-  // Multiline string
+  // Multiline string.
   if (count($parts) > 1) {
     return "\"\"\n\"" . implode("\"\n\"", $parts) . "\"\n";
   }
-  // Single line string
+  // Single line string.
   elseif (count($parts) == 1) {
     return "\"$parts[0]\"\n";
   }
-  // No translation
+  // No translation.
   else {
     return "\"\"\n";
   }
