function _scanner_get_all_tables_map in Search and Replace Scanner 7
Same name and namespace in other branches
- 5.2 scanner.module \_scanner_get_all_tables_map()
- 6 scanner.module \_scanner_get_all_tables_map()
Get all text fields.
Return value
array List of all fields, each of which is an array containing relevant data used for diplaying/querying.
2 calls to _scanner_get_all_tables_map()
- scanner_admin_form in ./
scanner.admin.inc - The main settings form.
- _scanner_get_selected_tables_map in ./
scanner.module - Get the fields that have been selected for scanning.
File
- ./
scanner.module, line 1235 - Search and Replace Scanner - works on all nodes text content.
Code
function _scanner_get_all_tables_map() {
$tables_map = array();
// Build list of title fields for all node types.
foreach (node_type_get_types() as $type) {
if ($type->has_title) {
$tables_map[] = array(
'type' => $type->type,
'field' => 'title',
'field_label' => 'title',
'table' => 'node_revision',
);
}
}
$all_field_records = array();
// Trigger hook_scanner_field_types().
foreach (module_invoke_all('scanner_field_types') as $field_type) {
$query = db_select('field_config_instance', 'fci');
$query
->join('field_config', 'fc', 'fci.field_name = fc.field_name');
$query
->fields('fci', array(
'field_name',
));
$query
->fields('fc', array(
'module',
));
$query
->addField('fci', 'bundle', 'node_bundle');
$query
->condition('fci.entity_type', 'node');
$query
->condition('fc.module', $field_type, '=');
foreach ($query
->execute() as $record) {
$all_field_records[] = $record;
}
}
// Trigger hook_scanner_fields_alter().
drupal_alter('scanner_fields', $all_field_records);
if (!empty($all_field_records)) {
foreach ($all_field_records as $record) {
$tables_map[] = array(
'type' => $record->node_bundle,
'field' => $record->field_name,
'field_label' => (empty($record->field_collection_parents) ? '' : join('->', $record->field_collection_parents) . '->') . $record->field_name,
'table' => 'field_revision_' . $record->field_name,
'field_collection_parents' => isset($record->field_collection_parents) ? $record->field_collection_parents : NULL,
'module' => $record->module,
);
}
}
return $tables_map;
}