summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--devel_generate.inc13
-rw-r--r--devel_generate.module3
2 files changed, 14 insertions, 2 deletions
diff --git a/devel_generate.inc b/devel_generate.inc
index 60390fe..7c5529b 100644
--- a/devel_generate.inc
+++ b/devel_generate.inc
@@ -84,6 +84,11 @@ function devel_create_nodes($records, $users, $title_length = 8, $add_upload = F
devel_generate_add_terms($node);
}
+ // Populate any CCK fields in the content type
+ if (module_exists("content")) {
+ devel_generate_fields($node);
+ }
+
// Save the node:
node_save($node);
@@ -402,4 +407,12 @@ function devel_generate_add_upload(&$node) {
$_SESSION['upload_files'][$file->fid] = $file;
$node->files[$file->fid] = $file;
+}
+
+// Enrich the $node that is about to be saved with arbitrary information in each of its CCK fields.
+// Not yet implemented by CCK fields. See http://drupal.org/node/187599 for status.
+function devel_generate_fields(&$node) {
+ $return = _content_field_invoke('generate', $node);
+ $array_node = array_merge((array)$node, $return);
+ $node = (object)$array_node;
} \ No newline at end of file
diff --git a/devel_generate.module b/devel_generate.module
index 861f0d8..75fa1c5 100644
--- a/devel_generate.module
+++ b/devel_generate.module
@@ -71,13 +71,12 @@ function devel_generate_users_form_submit($form_id, &$form_state) {
function devel_generate_content_form() {
if (module_exists('content')) {
$types = content_types();
- $warn = '';
foreach ($types as $type) {
+ $warn = '';
if (count($type['fields'])) {
$warn = t('. <strong>Warning</strong>. This type contains CCK fields which won\'t be populated. See !url', array('!url' => l(t('this CCK issue.'), 'http://drupal.org/node/187599')));
}
$options[$type['type']] = t($type['name']). $warn;
- unset($warn);
}
}
else {