You are here

public function FeedsNodeProcessor::getMappingTargets in Feeds 7.2

Same name and namespace in other branches
  1. 6 plugins/FeedsNodeProcessor.inc \FeedsNodeProcessor::getMappingTargets()
  2. 7 plugins/FeedsNodeProcessor.inc \FeedsNodeProcessor::getMappingTargets()

Return available mapping targets.

Overrides FeedsProcessor::getMappingTargets

File

plugins/FeedsNodeProcessor.inc, line 343
Class definition of FeedsNodeProcessor.

Class

FeedsNodeProcessor
Creates nodes from feed items.

Code

public function getMappingTargets() {
  $type = node_type_get_type($this
    ->bundle());
  $targets = parent::getMappingTargets();
  if ($type && $type->has_title) {
    $targets['title'] = array(
      'name' => t('Title'),
      'description' => t('The title of the node.'),
      'optional_unique' => TRUE,
    );
  }
  $targets['nid'] = array(
    'name' => t('Node ID'),
    'description' => t('The nid of the node. NOTE: use this feature with care, node ids are usually assigned by Drupal.'),
    'optional_unique' => TRUE,
  );
  $targets['uid'] = array(
    'name' => t('User ID'),
    'description' => t('The Drupal user ID of the node author.'),
  );
  $targets['user_name'] = array(
    'name' => t('Username'),
    'description' => t('The Drupal username of the node author.'),
  );
  $targets['user_mail'] = array(
    'name' => t('User email'),
    'description' => t('The email address of the node author.'),
  );
  $targets['status'] = array(
    'name' => t('Published status'),
    'description' => t('Whether a node is published or not. 1 stands for published, 0 for not published.'),
  );
  $targets['created'] = array(
    'name' => t('Published date'),
    'description' => t('The UNIX time when a node has been published.'),
  );
  $targets['changed'] = array(
    'name' => t('Updated date'),
    'description' => t('The Unix timestamp when a node has been last updated.'),
  );
  $targets['promote'] = array(
    'name' => t('Promoted to front page'),
    'description' => t('Boolean value, whether or not node is promoted to front page. (1 = promoted, 0 = not promoted)'),
  );
  $targets['sticky'] = array(
    'name' => t('Sticky'),
    'description' => t('Boolean value, whether or not node is sticky at top of lists. (1 = sticky, 0 = not sticky)'),
  );

  // Include language field if Locale module is enabled.
  if (module_exists('locale')) {
    $targets['language'] = array(
      'name' => t('Language'),
      'description' => t('The two-character language code of the node.'),
    );
  }

  // Include comment field if Comment module is enabled.
  if (module_exists('comment')) {
    $targets['comment'] = array(
      'name' => t('Comments'),
      'description' => t('Whether comments are allowed on this node: 0 = no, 1 = read only, 2 = read/write.'),
    );
  }

  // If the target content type is a Feed node, expose its source field.
  if ($id = feeds_get_importer_id($this
    ->bundle())) {
    $name = feeds_importer($id)->config['name'];
    $targets['feeds_source'] = array(
      'name' => t('Feed source'),
      'description' => t('The content type created by this processor is a Feed Node, it represents a source itself. Depending on the fetcher selected on the importer "@importer", this field is expected to be for example a URL or a path to a file.', array(
        '@importer' => $name,
      )),
      'optional_unique' => TRUE,
    );
  }
  $this
    ->getHookTargets($targets);
  return $targets;
}