You are here

function _patterns_io_analyze_scandir_messages in Patterns 7

Same name and namespace in other branches
  1. 7.2 includes/io/io.inc \_patterns_io_analyze_scandir_messages()

Analyzes the result of the patterns directories scan and displays relevant Drupal messages to the user.

See also

patterns_io_scan_directories()

1 call to _patterns_io_analyze_scandir_messages()
patterns_io_scan_directories in includes/io/io.inc
Scan directories looking for patterns files.

File

includes/io/io.inc, line 201
Functions related to input/output operations.

Code

function _patterns_io_analyze_scandir_messages($messages = NULL) {
  if (is_null($messages)) {
    return;
  }

  // TODO: fix these to be proper t().
  if (!empty($messages['found'])) {
    drupal_set_message(t('New patterns were found and added to the database:') . ' <br/>' . implode('<br/>', $messages['found']) . '<br/><br/>');
  }
  if (!empty($messages['updated'])) {
    drupal_set_message(t('The following patterns were updated to the newest version found in the file system:') . ' <br/>' . implode('<br/>', $messages['updated']) . '<br/><br/>');
  }
  if (!empty($messages['errors'])) {
    drupal_set_message(t('A generic error occurred while trying to load the following files:') . ' <br/>' . implode('<br/>', $messages['errors']) . '<br/><br/>', 'warning');
  }
  if (!empty($messages['invalid'])) {
    drupal_set_message(t('Some invalid patterns were found:') . ' <br/>' . implode('<br/>', $messages['invalid']) . '<br/><br/>', 'warning');
  }
  if (!empty($messages['skipped'])) {
    drupal_set_message(t('Patterns that are already enabled are not updated against changes in the file system. Please verify the following ones:') . ' <br/>' . implode('<br/>', $messages['skipped']) . '<br/><br/>', 'warning');
  }
  if (!empty($messages['permission'])) {
    drupal_set_message(t('Some pattern files could not be open for reading. Please verify the permission of:') . ' <br/>' . implode('<br/>', $messages['permission']) . '<br/><br/>', 'warning');
  }
  if (!empty($messages['error_found'])) {
    drupal_set_message(t('New patterns were found, but could not be saved in the database:') . ' <br/>' . implode('<br/>', $messages['error_found']) . '<br/><br/>', 'warning');
  }
  if (!empty($messages['error_updated'])) {
    drupal_set_message(t('A newer version of the following pattern was found, but could not be saved in the database:') . ' <br/>' . implode('<br/>', $messages['error_found']) . '<br/><br/>', 'warning');
  }
}