function FrxRepoMan::data in Forena Reports 7.4
Same name and namespace in other branches
- 7.3 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 190 - FrxRepoMan.inc Enter description here ... @author davidmetzler
Class
- FrxRepoMan
- @file FrxRepoMan.inc Enter description here ... @author davidmetzler
Code
function data($data_block, $raw_mode = FALSE) {
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)) {
if ($raw_mode) {
$block['options']['return_type'] = 'raw';
}
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'], $data);
break;
}
}
return $xml;
}
else {
return '';
}
}