| 1 |
<?php |
<?php |
| 2 |
// $Id$ |
// $Id: flexiconvert.module,v 1.7 2008/05/07 21:26:47 aj045 Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 193 |
} |
} |
| 194 |
|
|
| 195 |
/** |
/** |
| 196 |
* Returns the form for converting Flexinode types to CCK type.s |
* Returns the form for converting Flexinode types to CCK types. |
| 197 |
* |
* |
| 198 |
* If CCK is not running correctly, an error message is set instead of a form. |
* If CCK is not running correctly, an error message is set instead of a form. |
| 199 |
*/ |
*/ |
| 338 |
$type = flexiconvert_get_type($ffield['title']); |
$type = flexiconvert_get_type($ffield['title']); |
| 339 |
foreach($type->fields as $fd) { |
foreach($type->fields as $fd) { |
| 340 |
// Much of the code that appears below is straight from the CCK module. |
// Much of the code that appears below is straight from the CCK module. |
| 341 |
// The code there is quite messy and a bit hard to read but it gets the job done. |
// The code is quite messy and a bit hard to read but it gets the job done. |
| 342 |
$field_name = trim($fd['label']); |
$field_name = trim($fd['label']); |
| 343 |
$field_name = drupal_strtolower($field_name); |
$field_name = drupal_strtolower($field_name); |
| 344 |
$field_name = str_replace(array(' ', '-'), '_', $field_name); |
$field_name = str_replace(array(' ', '-'), '_', $field_name); |
| 353 |
|
|
| 354 |
$cck_type = _flexiconvert_field_to_cck($fd['field_type']); |
$cck_type = _flexiconvert_field_to_cck($fd['field_type']); |
| 355 |
|
|
| 356 |
db_query("INSERT INTO {node_field} (field_name, type, global_settings, required, multiple, db_storage) VALUES ('%s', '%s', '%s', %d, %d, %d)", $field_name, $cck_type, serialize(array('text_processing' => '1', 'max_length' => '', 'allowed_values' => '', 'allowed_values_php' => '')), $fd['required'], 0, 1); |
db_query("INSERT INTO {node_field} (field_name, type, global_settings, required, multiple, db_storage) VALUES ('%s', '%s', '%s', %d, %d, %d)", |
| 357 |
db_query("INSERT INTO {node_field_instance} (field_name, type_name, weight, label, widget_type, widget_settings, display_settings, description) VALUES ('%s', '%s', %d, '%s', '%s', '%s', '%s', '%s')", $field_name, _flexiconvert_fix_single_type(strtolower($ffield['title'])), $fd['weight'], $fd['label'], $cck_type, serialize(array()), serialize(array()), ''); |
$field_name, |
| 358 |
|
$cck_type, |
| 359 |
|
serialize(array( |
| 360 |
|
'text_processing' => '1', |
| 361 |
|
'max_length' => '', |
| 362 |
|
'allowed_values' => '', |
| 363 |
|
'allowed_values_php' => '' |
| 364 |
|
)), |
| 365 |
|
$fd['required'], |
| 366 |
|
0, |
| 367 |
|
1 |
| 368 |
|
); |
| 369 |
|
db_query("INSERT INTO {node_field_instance} (field_name, type_name, weight, label, widget_type, widget_settings, display_settings, description) VALUES ('%s', '%s', %d, '%s', '%s', '%s', '%s', '%s')", |
| 370 |
|
$field_name, |
| 371 |
|
_flexiconvert_fix_single_type(strtolower($ffield['title'])), |
| 372 |
|
$fd['weight'], |
| 373 |
|
$fd['label'], |
| 374 |
|
$cck_type, |
| 375 |
|
serialize(array()), |
| 376 |
|
serialize(array()), |
| 377 |
|
'' |
| 378 |
|
); |
| 379 |
|
|
| 380 |
content_clear_type_cache(); |
content_clear_type_cache(); |
| 381 |
|
|