From 48429eb82409aae98ec47d6e75a01068110e09db Mon Sep 17 00:00:00 2001
From: andrew morton <drewish@zivtech.com>
Date: Wed, 5 Oct 2011 02:07:00 -0400
Subject: [PATCH] Issue #1298424 by drewish: Revert "Accidental add revoke" that went too far.

This reverts commit 733eb6fdf0c92f37d425cb2c33e4a7073536f4bd.
---
 .../migrate_extras_pathauto.features.field.inc     |   86 ++++++++++++++++++++
 .../migrate_extras_pathauto.features.inc           |   18 ++++
 .../migrate_extras_pathauto.info                   |   12 +++
 .../migrate_extras_pathauto.migrate.inc            |   60 ++++++++++++++
 .../migrate_extras_pathauto.module                 |   13 +++
 .../migrate_extras_pathauto.xml                    |   13 +++
 .../migrate_extras_profile2.csv                    |    3 +
 .../migrate_extras_profile2.info                   |    7 ++
 .../migrate_extras_profile2.install                |   18 ++++
 .../migrate_extras_profile2.migrate.inc            |   49 +++++++++++
 .../migrate_extras_profile2.module                 |   11 +++
 11 files changed, 290 insertions(+), 0 deletions(-)
 create mode 100644 migrate_extras_examples/migrate_extras_pathauto/migrate_extras_pathauto.features.field.inc
 create mode 100644 migrate_extras_examples/migrate_extras_pathauto/migrate_extras_pathauto.features.inc
 create mode 100644 migrate_extras_examples/migrate_extras_pathauto/migrate_extras_pathauto.info
 create mode 100644 migrate_extras_examples/migrate_extras_pathauto/migrate_extras_pathauto.migrate.inc
 create mode 100644 migrate_extras_examples/migrate_extras_pathauto/migrate_extras_pathauto.module
 create mode 100644 migrate_extras_examples/migrate_extras_pathauto/migrate_extras_pathauto.xml
 create mode 100644 migrate_extras_examples/migrate_extras_profile2/migrate_extras_profile2.csv
 create mode 100644 migrate_extras_examples/migrate_extras_profile2/migrate_extras_profile2.info
 create mode 100644 migrate_extras_examples/migrate_extras_profile2/migrate_extras_profile2.install
 create mode 100644 migrate_extras_examples/migrate_extras_profile2/migrate_extras_profile2.migrate.inc
 create mode 100644 migrate_extras_examples/migrate_extras_profile2/migrate_extras_profile2.module

diff --git a/migrate_extras_examples/migrate_extras_pathauto/migrate_extras_pathauto.features.field.inc b/migrate_extras_examples/migrate_extras_pathauto/migrate_extras_pathauto.features.field.inc
new file mode 100644
index 0000000..8317075
--- /dev/null
+++ b/migrate_extras_examples/migrate_extras_pathauto/migrate_extras_pathauto.features.field.inc
@@ -0,0 +1,86 @@
+<?php
+
+/**
+ * Implementation of hook_field_default_fields().
+ */
+function migrate_extras_pathauto_field_default_fields() {
+  $fields = array();
+
+  // Exported field: 'node-migrate_example_pathauto-body'
+  $fields['node-migrate_example_pathauto-body'] = array(
+    'field_config' => array(
+      'active' => '1',
+      'cardinality' => '1',
+      'deleted' => '0',
+      'entity_types' => array(
+        '0' => 'node',
+      ),
+      'field_name' => 'body',
+      'foreign keys' => array(
+        'format' => array(
+          'columns' => array(
+            'format' => 'format',
+          ),
+          'table' => 'filter_format',
+        ),
+      ),
+      'indexes' => array(
+        'format' => array(
+          '0' => 'format',
+        ),
+      ),
+      'module' => 'text',
+      'settings' => array(),
+      'translatable' => '1',
+      'type' => 'text_with_summary',
+    ),
+    'field_instance' => array(
+      'bundle' => 'migrate_example_pathauto',
+      'default_value' => NULL,
+      'deleted' => '0',
+      'description' => '',
+      'display' => array(
+        'default' => array(
+          'label' => 'hidden',
+          'module' => 'text',
+          'settings' => array(),
+          'type' => 'text_default',
+          'weight' => 0,
+        ),
+        'teaser' => array(
+          'label' => 'hidden',
+          'module' => 'text',
+          'settings' => array(
+            'trim_length' => 600,
+          ),
+          'type' => 'text_summary_or_trimmed',
+          'weight' => 0,
+        ),
+      ),
+      'entity_type' => 'node',
+      'field_name' => 'body',
+      'label' => 'Body',
+      'required' => FALSE,
+      'settings' => array(
+        'display_summary' => TRUE,
+        'text_processing' => 1,
+        'user_register_form' => FALSE,
+      ),
+      'widget' => array(
+        'module' => 'text',
+        'settings' => array(
+          'rows' => 20,
+          'summary_rows' => 5,
+        ),
+        'type' => 'text_textarea_with_summary',
+        'weight' => -4,
+      ),
+    ),
+  );
+
+  // Translatables
+  // Included for use with string extractors like potx.
+  t('Body');
+
+  return $fields;
+}
diff --git a/migrate_extras_examples/migrate_extras_pathauto/migrate_extras_pathauto.features.inc b/migrate_extras_examples/migrate_extras_pathauto/migrate_extras_pathauto.features.inc
new file mode 100644
index 0000000..8504037
--- /dev/null
+++ b/migrate_extras_examples/migrate_extras_pathauto/migrate_extras_pathauto.features.inc
@@ -0,0 +1,18 @@
+<?php
+
+/**
+ * Implementation of hook_node_info().
+ */
+function migrate_extras_pathauto_node_info() {
+  $items = array(
+    'migrate_example_pathauto' => array(
+      'name' => t('Migrate example - pathauto'),
+      'base' => 'node_content',
+      'description' => t('This content type is used for demonstrating and testing Migrate Example support for the Pathauto module.'),
+      'has_title' => '1',
+      'title_label' => t('Title'),
+      'help' => '',
+    ),
+  );
+  return $items;
+}
diff --git a/migrate_extras_examples/migrate_extras_pathauto/migrate_extras_pathauto.info b/migrate_extras_examples/migrate_extras_pathauto/migrate_extras_pathauto.info
new file mode 100644
index 0000000..162e5d7
--- /dev/null
+++ b/migrate_extras_examples/migrate_extras_pathauto/migrate_extras_pathauto.info
@@ -0,0 +1,12 @@
+core = "7.x"
+dependencies[] = "features"
+dependencies[] = "migrate_extras"
+dependencies[] = "pathauto"
+description = "Examples of migrating with the Pathauto module"
+features[field][] = "node-migrate_example_pathauto-body"
+features[node][] = "migrate_example_pathauto"
+files[] = migrate_extras_pathauto.migrate.inc
+name = "Migrate Extras Pathauto Example"
+package = "Features"
+project = "migrate_extras_pathauto_example"
+version = "7.x-2.1-beta1"
diff --git a/migrate_extras_examples/migrate_extras_pathauto/migrate_extras_pathauto.migrate.inc b/migrate_extras_examples/migrate_extras_pathauto/migrate_extras_pathauto.migrate.inc
new file mode 100644
index 0000000..132c954
--- /dev/null
+++ b/migrate_extras_examples/migrate_extras_pathauto/migrate_extras_pathauto.migrate.inc
@@ -0,0 +1,60 @@
+<?php
+/**
+ * @file
+ * Examples and test fodder for migration with Pathauto enabled.
+ */
+
+/**
+ * Migration class to test import with Pathauto enabled.
+ */
+class MigrateExamplePathautoMigration extends XMLMigration {
+  public function __construct() {
+    parent::__construct();
+    $this->description = t('Example migration with Pathauto enabled');
+
+    $this->map = new MigrateSQLMap($this->machineName,
+      array(
+        'id' => array(
+          'type' => 'int',
+          'unsigned' => TRUE,
+          'not null' => TRUE,
+          'description' => 'Pathauto ID',
+        )
+      ),
+      MigrateDestinationNode::getKeySchema()
+    );
+
+    // Source fields available in the XML file.
+    $fields = array(
+      'id' => t('Source id'),
+      'title' => t('Title'),
+      'body' => t('Description'),
+    );
+
+    // Our test data is in an XML file
+    $xml_folder = drupal_get_path('module', 'migrate_extras_pathauto');
+    $items_url = $xml_folder . '/migrate_extras_pathauto.xml';
+    $item_xpath = '/source_data/item';
+    $item_ID_xpath = 'id';
+    $items_class = new MigrateItemsXML($items_url, $item_xpath, $item_ID_xpath);
+    $this->source = new MigrateSourceMultiItems($items_class, $fields);
+    $this->destination = new MigrateDestinationNode('migrate_example_pathauto');
+
+    // Basic fields
+    $this->addFieldMapping('title', 'title')
+         ->xpath('title');
+    $this->addFieldMapping('uid')
+         ->defaultValue(1);
+    $this->addFieldMapping('body', 'body')
+         ->xpath('body');
+
+    // Disable application of pathauto during migration
+    $this->addFieldMapping('pathauto')
+         ->defaultValue(FALSE);
+
+    // Unmapped destination fields
+    $this->addUnmigratedDestinations(array('is_new', 'status', 'promote',
+      'revision', 'language', 'sticky', 'created', 'changed', 'revision_uid',
+      'path'));
+  }
+}
diff --git a/migrate_extras_examples/migrate_extras_pathauto/migrate_extras_pathauto.module b/migrate_extras_examples/migrate_extras_pathauto/migrate_extras_pathauto.module
new file mode 100644
index 0000000..b9020d0
--- /dev/null
+++ b/migrate_extras_examples/migrate_extras_pathauto/migrate_extras_pathauto.module
@@ -0,0 +1,13 @@
+<?php
+
+include_once('migrate_extras_pathauto.features.inc');
+
+/*
+ * Implementation of hook_migrate_api().
+ */
+function migrate_extras_pathauto_migrate_api() {
+  $api = array(
+    'api' => 2,
+  );
+  return $api;
+}
diff --git a/migrate_extras_examples/migrate_extras_pathauto/migrate_extras_pathauto.xml b/migrate_extras_examples/migrate_extras_pathauto/migrate_extras_pathauto.xml
new file mode 100644
index 0000000..144cde0
--- /dev/null
+++ b/migrate_extras_examples/migrate_extras_pathauto/migrate_extras_pathauto.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<source_data>
+  <item>
+    <id>3</id>
+    <title>Simple example</title>
+    <body>This is pretty straight-forward.</body>
+  </item>
+  <item>
+    <id>8</id>
+    <title>Another example</title>
+    <body>So is this.</body>
+  </item>
+</source_data>
diff --git a/migrate_extras_examples/migrate_extras_profile2/migrate_extras_profile2.csv b/migrate_extras_examples/migrate_extras_profile2/migrate_extras_profile2.csv
new file mode 100644
index 0000000..e2616a7
--- /dev/null
+++ b/migrate_extras_examples/migrate_extras_profile2/migrate_extras_profile2.csv
@@ -0,0 +1,3 @@
+1,1
+2,1
+3,1
\ No newline at end of file
diff --git a/migrate_extras_examples/migrate_extras_profile2/migrate_extras_profile2.info b/migrate_extras_examples/migrate_extras_profile2/migrate_extras_profile2.info
new file mode 100644
index 0000000..f473399
--- /dev/null
+++ b/migrate_extras_examples/migrate_extras_profile2/migrate_extras_profile2.info
@@ -0,0 +1,7 @@
+core = "7.x"
+dependencies[] = "migrate_extras"
+dependencies[] = "profile2"
+description = "Examples of migrating into Profile2 entities"
+files[] = migrate_extras_profile2.migrate.inc
+name = "Migrate Extras Profile2 Example"
+package = "Development"
\ No newline at end of file
diff --git a/migrate_extras_examples/migrate_extras_profile2/migrate_extras_profile2.install b/migrate_extras_examples/migrate_extras_profile2/migrate_extras_profile2.install
new file mode 100644
index 0000000..97b39c6
--- /dev/null
+++ b/migrate_extras_examples/migrate_extras_profile2/migrate_extras_profile2.install
@@ -0,0 +1,18 @@
+<?php
+
+function migrate_extras_profile2_install() {
+  $type = entity_create('profile2_type', array(
+    'type' => 'migrate_extras_profile2',
+    'label' => t('migrate_extras_profile2'),
+    'weight' => 0,
+    'data' => array('registration' => FALSE, 'use_page' => TRUE),
+  ));
+  $type->save();
+}
+
+function migrate_extras_profile2_uninstall() {
+  if ($entities = entity_load_multiple_by_name('profile2_type', array('migrate_extras_profile2'))) {
+    list($id) = entity_extract_ids('profile2_type', reset($entities));
+    entity_delete('profile2_type', $id);
+  }
+}
\ No newline at end of file
diff --git a/migrate_extras_examples/migrate_extras_profile2/migrate_extras_profile2.migrate.inc b/migrate_extras_examples/migrate_extras_profile2/migrate_extras_profile2.migrate.inc
new file mode 100644
index 0000000..a3a7bcb
--- /dev/null
+++ b/migrate_extras_examples/migrate_extras_profile2/migrate_extras_profile2.migrate.inc
@@ -0,0 +1,49 @@
+<?php
+/**
+ * @file
+ * Examples and test fodder for migration into profile2 entities.
+ */
+
+/**
+ * Migration class to test import of various date fields.
+ */
+class MigrateExampleProfile2Migration extends Migration {
+  public function __construct() {
+    parent::__construct();
+    $this->description = t('Example migration into profile2 entities');
+
+    $this->map = new MigrateSQLMap($this->machineName,
+      array(
+        'id' => array(
+          'type' => 'int',
+          'unsigned' => TRUE,
+          'not null' => TRUE,
+        )
+      ),
+      MigrateDestinationProfile2::getKeySchema()
+    );
+
+    // Our test data is in a CSV file
+    $this->source = new MigrateSourceCSV(__DIR__ . '/migrate_extras_profile2.csv', $this->csvcolumns(), array(), $this->fields());
+    $this->destination = new MigrateDestinationProfile2('migrate_extras_profile2');
+
+    $this->addFieldMapping('uid')
+         ->defaultValue(1);
+
+    // Unmapped destination fields
+    $this->addUnmigratedDestinations(array('id'));
+  }
+
+  function csvcolumns() {
+    $columns[0] = array('id', 'Source ID');
+    $columns[1] = array('uid', 'User ID');
+    return $columns;
+  }
+
+  function fields() {
+    return array(
+      'id' => 'Source ID',
+      'uid' => 'User ID',
+    );
+  }
+}
diff --git a/migrate_extras_examples/migrate_extras_profile2/migrate_extras_profile2.module b/migrate_extras_examples/migrate_extras_profile2/migrate_extras_profile2.module
new file mode 100644
index 0000000..52490aa
--- /dev/null
+++ b/migrate_extras_examples/migrate_extras_profile2/migrate_extras_profile2.module
@@ -0,0 +1,11 @@
+<?php
+
+/*
+ * Implementation of hook_migrate_api().
+ */
+function migrate_extras_profile2_migrate_api() {
+  $api = array(
+    'api' => 2,
+  );
+  return $api;
+}
\ No newline at end of file
-- 
1.7.0.4

