You are here

public function GatherContentCurl::mapToDropdown in GatherContent 7.2

Generate dropdown for entity fields.

File

includes/curl.inc, line 421
Contains functions used to process and retrieve data from GatherContent.

Class

GatherContentCurl
@file Contains functions used to process and retrieve data from GatherContent.

Code

public function mapToDropdown() {
  $html = '
      <li data-post-type="all" class="live_filter">
        <input type="text" class="live_filter" placeholder="' . check_plain(t('Search...')) . '" />
      </li>';
  foreach ($this->post_types as $name => $title) {
    $instances = field_info_instances('node', $name);
    if (isset($instances['body'])) {
      unset($instances['body']);
      $html .= '
      <li data-post-type="' . $name . '" data-search="body">
        <a href="#" data-value="body">' . t('Body') . '</a>
      </li>';
    }
    if (isset($this->hasTitles[$name])) {
      $html .= '
      <li data-post-type="' . $name . '" data-search="' . check_plain($this->hasTitles[$name]) . '">
        <a href="#" data-value="title">' . $this->hasTitles[$name] . '</a>
      </li>';
    }
    foreach ($instances as $field => $info) {
      $text = $info['label'];
      if (strlen($text) > 30) {
        $text = substr($text, 0, 30) . '...';
      }
      $html .= '
      <li data-post-type="' . $name . '" data-search="' . check_plain($info['label']) . '">
        <a href="#" data-value="' . $field . '">' . check_plain($text) . '</a>
      </li>';
    }
  }
  $html .= '
      <li class="divider" data-post-type="all"></li>
      <li data-post-type="all" data-search="' . t('Do Not Import') . '">
        <a href="#" data-value="_dont_import_">' . t('Do Not Import') . '</a>
      </li>';
  $this->data['map_to_select'] = $html;
}