You are here

class FeedsForenaBlockFetcher in Forena Reports 7.3

Same name and namespace in other branches
  1. 7.5 feeds/FeedsForenaBlockFetcher.inc \FeedsForenaBlockFetcher
  2. 7.4 feeds/FeedsForenaBlockFetcher.inc \FeedsForenaBlockFetcher

Hierarchy

Expanded class hierarchy of FeedsForenaBlockFetcher

1 string reference to 'FeedsForenaBlockFetcher'
_forena_feeds_plugins in feeds/forena_feeds.inc

File

feeds/FeedsForenaBlockFetcher.inc, line 29

View source
class FeedsForenaBlockFetcher extends FeedsFetcher {

  // Implement data block fetch.
  public function fetch(FeedsSource $source) {
    $source_config = $source
      ->getConfigFor($this);

    // Just return a Block result if this is a Block.
    $r = Frx::RepoMan();
    $block = $source_config['source'];
    $data = @drupal_parse_info_format($source_config['data']);
    if ($r
      ->loadBlock($block)) {
      return new FeedsForenaBlockFetcherResult($block, $data);
    }
    throw new Exception('Source is not a valid Forena Data Block');
  }
  public function sourceForm($source_config) {
    $form = array();
    $form['source'] = array(
      '#type' => 'textfield',
      '#autocomplete_path' => 'forena/data_block/autocomplete',
      '#title' => 'Data Block',
      '#required' => TRUE,
      '#description' => t('Select an exising block.'),
      '#default_value' => isset($source_config['source']) ? $source_config['source'] : '',
    );
    $form['data'] = array(
      '#type' => 'textarea',
      '#title' => t('Parameters  '),
      '#description' => t('Specify one per line the key value pairs that will be used when fetching the data.   The format
          used is the same as in .info files.'),
      '#default_value' => isset($source_config['data']) ? $source_config['data'] : '',
      '#rows' => 20,
      '#maxlength' => NULL,
      '#required' => FALSE,
    );
    return $form;
  }
  public function sourceFormValidate(&$values) {
    $values['source'] = trim($values['source']);
    $block = @Frx::RepoMan()
      ->loadBlock($values['source']);
    if (!$block) {
      form_set_error('feeds][FeedsForenaBlockFetcher][source', t('The specified block does not exist.'));
    }
  }

}

Members