You are here

function FrxRepoMan::data in Forena Reports 7.3

Same name and namespace in other branches
  1. 7.4 FrxRepoMan.inc \FrxRepoMan::data()

Extract the data by running a block

Parameters

$data_block String name ob block to load:

Return value

unknown

File

./FrxRepoMan.inc, line 191
FrxRepoMan.inc Enter description here ... @author davidmetzler

Class

FrxRepoMan
@file FrxRepoMan.inc Enter description here ... @author davidmetzler

Code

function data($data_block) {
  list($provider, $block_name) = explode('/', $data_block, 2);

  //Intstantiate the provider
  $o = $this
    ->repository($provider);
  $repos = @$this->repositories[$provider];
  if (isset($repos['enabled']) && !$repos['enabled']) {
    return '';
  }

  //Populate user callback.
  if (isset($repos['user callback'])) {
    $user_fn = $repos['user callback'];
    if (is_callable($user_fn)) {
      $current_user = $user_fn();
      Frx::Data()
        ->setValue('current_user', $current_user);
    }
  }
  $xml = '';
  if ($o) {
    $access = TRUE;
    $block = $this
      ->loadBlock($data_block);
    $right = @$block['access'];
    if ($block && $o
      ->access($right)) {
      switch ($block['type']) {
        case 'sql':
          $xml = $o
            ->sqlData($block['source'], @$block['options']);
          break;
        case 'xml':
          $xml = $o
            ->xmlData($block['source']);
          break;
        case 'php':
          $data = Frx::Data()
            ->currentContextArray();
          $xml = $o
            ->phpData($block['object'], $block['method'], $data);
          break;
      }
    }
    return $xml;
  }
  else {
    return '';
  }
}