From d41b1848065889dd6eee15d0ca2c1d90cd5c832b Mon Sep 17 00:00:00 2001
From: Chris Leppanen <chris.leppanen@gmail.com>
Date: Thu, 18 Apr 2013 17:04:41 -0700
Subject: [PATCH] Issue #1166100 by twistor | Niklas Fiekas: Fixed Notices and
 warnings on mapping page, when no content type is selected for NodeProcessor.

---
 plugins/FeedsNodeProcessor.inc |  4 +---
 plugins/FeedsProcessor.inc     | 12 +++++++++++-
 plugins/FeedsTermProcessor.inc | 10 +---------
 3 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/plugins/FeedsNodeProcessor.inc b/plugins/FeedsNodeProcessor.inc
index f2db5963..519dfc5f 100644
--- a/plugins/FeedsNodeProcessor.inc
+++ b/plugins/FeedsNodeProcessor.inc
@@ -182,8 +182,6 @@ class FeedsNodeProcessor extends FeedsProcessor {
   public function configForm(&$form_state) {
     $form = parent::configForm($form_state);
 
-    $form['bundle']['#title'] = t('Content type');
-
     $author = user_load($this->config['author']);
     $form['author'] = array(
       '#type' => 'textfield',
@@ -273,7 +271,7 @@ class FeedsNodeProcessor extends FeedsProcessor {
     $type = node_type_get_type($this->bundle());
 
     $targets = parent::getMappingTargets();
-    if ($type->has_title) {
+    if ($type && $type->has_title) {
       $targets['title'] = array(
         'name' => t('Title'),
         'description' => t('The title of the node.'),
diff --git a/plugins/FeedsProcessor.inc b/plugins/FeedsProcessor.inc
index d90e5441..c2b0af53 100755
--- a/plugins/FeedsProcessor.inc
+++ b/plugins/FeedsProcessor.inc
@@ -552,7 +552,7 @@ abstract class FeedsProcessor extends FeedsPlugin {
       $form['bundle'] = array(
         '#type' => 'select',
         '#options' => $this->bundleOptions(),
-        '#title' => t('Bundle'),
+        '#title' => !empty($info['bundle name']) ? $info['bundle name'] : t('Bundle'),
         '#required' => TRUE,
         '#default_value' => $this->bundle(),
       );
@@ -619,6 +619,16 @@ abstract class FeedsProcessor extends FeedsPlugin {
    *   FALSE otherwise.
    */
   public function getMappingTargets() {
+
+    // The bundle has not been selected.
+    if (!$this->bundle()) {
+      $info = $this->entityInfo();
+      $bundle_name = !empty($info['bundle name']) ? drupal_strtolower($info['bundle name']) : t('bundle');
+      $plugin_key = feeds_importer($this->id)->config['processor']['plugin_key'];
+      $url = url('admin/structure/feeds/' . $this->id . '/settings/' . $plugin_key);
+      drupal_set_message(t('Please <a href="@url">select a @bundle_name</a>.', array('@url' => $url, '@bundle_name' => $bundle_name)), 'warning', FALSE);
+    }
+
     return array(
       'url' => array(
         'name' => t('URL'),
diff --git a/plugins/FeedsTermProcessor.inc b/plugins/FeedsTermProcessor.inc
index 830905b9..efbac620 100644
--- a/plugins/FeedsTermProcessor.inc
+++ b/plugins/FeedsTermProcessor.inc
@@ -22,6 +22,7 @@ class FeedsTermProcessor extends FeedsProcessor {
   protected function entityInfo() {
     $info = parent::entityInfo();
     $info['label plural'] = t('Terms');
+    $info['bundle name'] = t('Vocabulary');
     return $info;
   }
 
@@ -82,15 +83,6 @@ class FeedsTermProcessor extends FeedsProcessor {
     ) + parent::configDefaults();
   }
 
-  /**
-   * Override parent::configForm().
-   */
-  public function configForm(&$form_state) {
-    $form = parent::configForm($form_state);
-    $form['bundle']['#title'] = t('Vocabulary');
-    return $form;
-  }
-
   /**
    * Override setTargetElement to operate on a target item that is a taxonomy term.
    */
-- 
GitLab