You are here

protected function FrxDataSource::loadBlockFromFile in Forena Reports 7.3

Same name and namespace in other branches
  1. 7.4 FrxDataSource.inc \FrxDataSource::loadBlockFromFile()
1 call to FrxDataSource::loadBlockFromFile()
FrxDataSource::loadBlock in ./FrxDataSource.inc
Load blcok data from filesystem

File

./FrxDataSource.inc, line 99
Class that defines default methods for access control in an FrxDataSource

Class

FrxDataSource
@file Class that defines default methods for access control in an FrxDataSource

Code

protected function loadBlockFromFile($block_name) {
  $base_file = $this->block_path . '/' . $block_name;
  $parts = @explode('.', $block_name);
  $php_method = array_pop($parts);
  $php_class = implode('.', $parts);
  $php_file = $this->block_path . '/' . $php_class . '.inc';
  if (file_exists($base_file . '.sql')) {
    $contents = file_get_contents($base_file . '.sql');
    $block = $this
      ->parseSQLFile($contents);
    $block['type'] = 'sql';
  }
  elseif (file_exists($base_file . '.xml')) {
    $contents = file_get_contents($base_file . '.xml');
    $block = $this
      ->parseXMLFile($contents);
    $block['type'] = 'xml';
  }
  elseif (file_exists($php_file)) {
    require_once $php_file;
    if (class_exists($php_class)) {
      $o = new $php_class();
      $block['type'] = 'php';
      $block['access'] = @$o->access;
      $block['object'] = $o;
      $block['method'] = $php_method;
      if (method_exists($o, 'tokens')) {
        $block['tokens'] = $o
          ->tokens();
      }
      elseif (isset($o->tokens)) {
        $block['tokens'] = $o->tokens;
      }
      else {
        $block['tokens'] = array();
      }
    }
  }
  else {
    return array();
  }
  $block['locked'] = 1;
  return $block;
}