summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDigidog2011-10-28 19:40:52 (GMT)
committer Digidog2011-10-28 19:40:52 (GMT)
commit6d2d904efc0bbca314a9bda9c917bc6ddf9124bc (patch)
tree349a4f5352666b196088443c9bb8d2a29ad87f48
parent88b8f344aee745158cfe87cd3da305be4330cfbe (diff)
Issue #1010850 by jcfiala, quartsize, raman2385, Bevan, eporama, das-peter, smithmilner, Digidog: Fixed MigrateFieldHandler to work with Migrate Module
-rw-r--r--link.info1
-rw-r--r--link.migrate.inc51
-rw-r--r--link.module7
3 files changed, 59 insertions, 0 deletions
diff --git a/link.info b/link.info
index 1f59fca..b07a2ae 100644
--- a/link.info
+++ b/link.info
@@ -3,4 +3,5 @@ description = Defines simple link field types.
dependencies[] = content
package = CCK
core = 6.x
+files[] = link.migrate.inc
diff --git a/link.migrate.inc b/link.migrate.inc
new file mode 100644
index 0000000..5f4ccb7
--- /dev/null
+++ b/link.migrate.inc
@@ -0,0 +1,51 @@
+<?php
+/**
+ * @file
+ * Support for migrate module
+ */
+
+class MigrateLinkFieldHandler extends MigrateFieldHandler {
+ public function __construct() {
+ $this->registerTypes(array('link'));
+ }
+
+ static function arguments($title = NULL, $attributes = NULL, $language = NULL) {
+ $arguments = array();
+ if (!is_null($title)) {
+ $arguments['title'] = $title;
+ }
+ if (!is_null($attributes)) {
+ $arguments['attributes'] = $attributes;
+ }
+ if (!is_null($language)) {
+ $arguments['language'] = $language;
+ }
+ return $arguments;
+ }
+
+ public function prepare($entity, array $instance, array $values) {
+ if (isset($values['arguments'])) {
+ $arguments = $values['arguments'];
+ unset($values['arguments']);
+ }
+ else {
+ $arguments = array();
+ }
+
+ $delta = 0;
+ foreach($values as $value) {
+ $item = array();
+ if (isset($arguments['title'])) {
+ $item['title'] = $arguments['title'];
+ }
+ if (isset($arguments['attributes'])) {
+ $item['attributes'] = $arguments['attributes'];
+ }
+ $item['url'] = $value;
+ $return[$delta] = $item;
+ $delta++;
+ }
+
+ return isset($return) ? $return : NULL;
+ }
+}
diff --git a/link.module b/link.module
index 4098ae0..2bea79a 100644
--- a/link.module
+++ b/link.module
@@ -449,3 +449,10 @@ function link_views_api() {
'path' => drupal_get_path('module', 'link') .'/views',
);
}
+/**
+ * Implements hook_migrate_api().
+ */
+function link_migrate_api() {
+ return array('api' => 2);
+}
+