From 382d8f26140ae08f94f2fa0349c07c62c2e28433 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Fri, 30 Jul 2010 01:28:00 +0000 Subject: - Patch #848368 by Stevel, Damien Tournoud: test updating for poll.module. --- scripts/generate-d6-content.sh | 169 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 169 insertions(+) create mode 100644 scripts/generate-d6-content.sh (limited to 'scripts/generate-d6-content.sh') diff --git a/scripts/generate-d6-content.sh b/scripts/generate-d6-content.sh new file mode 100644 index 000000000..e207b0fb0 --- /dev/null +++ b/scripts/generate-d6-content.sh @@ -0,0 +1,169 @@ +#!/usr/bin/env php + 11 ? array('page' => TRUE) : array(); + $vocabulary['multiple'] = $multiple[$i % 12]; + $vocabulary['required'] = $required[$i % 12]; + $vocabulary['relations'] = 1; + $vocabulary['hierarchy'] = $hierarchy[$i % 12]; + $vocabulary['weight'] = $i; + taxonomy_save_vocabulary($vocabulary); + $parents = array(); + // Vocabularies without hierarcy get one term, single parent vocabularies get + // one parent and one child term. Multiple parent vocabularies get three + // terms: t0, t1, t2 where t0 is a parent of both t1 and t2. + for ($j = 0; $j < $vocabulary['hierarchy'] + 1; $j++) { + $term = array(); + $term['vid'] = $vocabulary['vid']; + // For multiple parent vocabularies, omit the t0-t1 relation, otherwise + // every parent in the vocabulary is a parent. + $term['parent'] = $vocabulary['hierarchy'] == 2 && i == 1 ? array() : $parents; + $term['name'] = "term $j of vocabulary $i"; + $term['description'] = 'description of ' . $term['name']; + $term['weight'] = $i * 3 + $j; + taxonomy_save_term($term); + $terms[] = $term['tid']; + $parents[] = $term['tid']; + } +} + +module_load_include('inc', 'node', 'node.pages'); +for ($i = 0; $i < 24; $i++) { + $uid = intval($i / 8) + 3; + $user = user_load($uid); + $node = new stdClass; + $node->uid = $uid; + $node->type = $i < 12 ? 'page' : 'story'; + $node->sticky = 0; + $node->title = "node title $i"; + $type = node_get_types('type', $node->type); + if ($type->has_body) { + $node->body = str_repeat("node body ($node->type) - $i", 100); + $node->teaser = node_teaser($node->body); + $node->filter = variable_get('filter_default_format', 1); + $node->format = FILTER_FORMAT_DEFAULT; + } + $node->status = intval($i / 4) % 2; + $node->language = ''; + $node->revision = $i < 12; + $node->promote = $i % 2; + $node->created = $now + $i * 86400; + $node->log = "added $i node"; + $node->taxonomy = $terms; + // Just make every term association different a little. + unset($node->taxonomy[$i], $node->taxonomy[47 - $i]); + node_save($node); + path_set_alias("node/$node->nid", "content/$node->created"); + if ($node->revision) { + $user = user_load($uid + 3); + $node->title .= ' revision'; + $node->body = str_repeat("node revision body ($node->type) - $i", 100); + $node->log = "added $i revision"; + node_save($node); + } +} + +// Create poll content +for ($i = 0; $i < 12; $i++) { + $uid = intval($i / 4) + 3; + $user = user_load($uid); + $node = new stdClass; + $node->uid = $uid; + $node->type = 'poll'; + $node->sticky = 0; + $node->title = "poll title $i"; + $type = node_get_types('type', $node->type); + if ($type->has_body) { + $node->body = str_repeat("node body ($node->type) - $i", 100); + $node->teaser = node_teaser($node->body); + $node->filter = variable_get('filter_default_format', 1); + $node->format = FILTER_FORMAT_DEFAULT; + } + $node->status = intval($i / 2) % 2; + $node->language = ''; + $node->revision = 1; + $node->promote = $i % 2; + $node->created = $now + $i * 43200; + $node->log = "added $i poll"; + + $nbchoices = ($i % 4) + 2; + for ($c = 0; $c < $nbchoices; $c++) { + $node->choice[] = array('chtext' => "Choice $c for poll $i"); + } + node_save($node); + path_set_alias("node/$node->nid", "content/poll/$i"); + path_set_alias("node/$node->nid/results", "content/poll/$i/results"); + + // Add some votes + for ($v = 0; $v < ($i % 4) + 5; $v++) { + $c = $v % $nbchoices; + $form_state = array(); + $form_state['values']['choice'] = $c; + $form_state['values']['op'] = t('Vote'); + drupal_execute('poll_view_voting', $form_state, $node); + } +} -- cgit v1.2.3