function _scanner_get_all_tables_map in Search and Replace Scanner 6
Same name and namespace in other branches
- 5.2 scanner.module \_scanner_get_all_tables_map()
- 7 scanner.module \_scanner_get_all_tables_map()
Get all text fields. This is all very fragle based on how CCK stores fields. Works for CCK 1.6.
Return value
map of fields and tables.
2 calls to _scanner_get_all_tables_map()
- scanner_admin_form in ./
scanner.module - Search and Replace Settings form.
- _scanner_get_selected_tables_map in ./
scanner.module - Get the fields that have been selected for scanning.
File
- ./
scanner.module, line 1070 - Search and Replace Scanner - works on all nodes text content.
Code
function _scanner_get_all_tables_map() {
//note, each array in the multidim array that is returned should be in the
// following order: type, field, table.
//this ensures that we can use the sort() function to easily sort the array
// based on the nodetype.
//build list of title, body, teaser fields for all node types:
$ntypes = node_get_types();
foreach ($ntypes as $type) {
if ($type->has_title) {
$tables_map[] = array(
'type' => $type->type,
'field' => 'title',
'table' => 'node_revisions',
);
}
if ($type->has_body) {
$tables_map[] = array(
'type' => $type->type,
'field' => 'body',
'table' => 'node_revisions',
);
}
$tables_map[] = array(
'type' => $type->type,
'field' => 'teaser',
'table' => 'node_revisions',
);
}
//now build list of CCK-based text fields:
if (module_exists('content')) {
$results = db_query("SELECT nfi.field_name, nfi.type_name, nf.db_storage " . "FROM {content_node_field_instance} nfi INNER JOIN {content_node_field} nf USING (field_name) " . "WHERE nfi.widget_type IN ('text_textarea', 'text_textfield')");
while ($field = db_fetch_array($results)) {
if ($field['db_storage']) {
$table = 'content_type_' . $field['type_name'];
}
else {
$table = 'content_' . $field['field_name'];
}
$tables_map[] = array(
// Modify to match current CCK storage rules.
'type' => $field['type_name'],
'field' => $field['field_name'] . '_value',
'table' => $table,
);
}
}
return $tables_map;
}