You are here

function transliteration_file_query in Transliteration 7.3

Same name and namespace in other branches
  1. 6.3 transliteration.admin.inc \transliteration_file_query()

File query.

Builds a query that returns all file names from the database containing non-ASCII characters.

Return value

mixed SelectQuery

2 calls to transliteration_file_query()
transliteration_install in ./transliteration.install
Implements hook_install().
transliteration_retroactive in ./transliteration.admin.inc
Form builder function; generates retroactive transliteration confirm form.

File

./transliteration.admin.inc, line 141
Retroactive transliteration and admin settings UI.

Code

function transliteration_file_query() {

  // Regular expressions are not supported by Drupal's database layer and
  // operators differ between manufacturers.
  switch (db_driver()) {
    case 'mysql':
    case 'mysqli':
      $operator = 'NOT REGEXP';
      if (variable_get('transliteration_file_lowercase', TRUE)) {
        $operator .= ' BINARY';
      }
      $regex = '/[a-z0-9_.-]+$';
      break;
    case 'pgsql':
      $operator = '!~*';
      $regex = '/[a-z0-9_.-]+$';
      break;
    case 'mssql':
      $operator = 'LIKE';
      $regex = '%[^a-z0-9_.-]%';
      break;
    default:
      return FALSE;
  }
  return db_select('file_managed')
    ->fields('file_managed')
    ->condition('uri', $regex, $operator);
}