You are here

protected function FrxDataSource::loadBlockFromFile in Forena Reports 7.5

1 call to FrxDataSource::loadBlockFromFile()
FrxDataSource::loadBlock in src/Driver/FrxDataSource.php
Load blcok data from filesystem

File

src/Driver/FrxDataSource.php, line 61
Class that defines default methods for access control in an FrxDataSource

Class

FrxDataSource

Namespace

Drupal\forena\Driver

Code

protected function loadBlockFromFile($block_name) {
  $full_name = $this->name . '/' . $block_name;
  $php_class = $block_name;
  $php_file = $this->block_path . '/' . $php_class . '.php';
  if (Frx::DataFile()
    ->exists($full_name . '.sql')) {
    $contents = Frx::DataFile()
      ->contents($full_name . '.sql');
    $block = $this
      ->parseSQLFile($contents);
    $block['type'] = 'sql';
  }
  elseif (Frx::DataFile()
    ->exists($full_name . '.xml')) {
    $contents = Frx::DataFile()
      ->contents($full_name . '.xml');
    $block = $this
      ->parseXMLFile($contents);
    $block['type'] = 'xml';
  }
  elseif (Frx::DataFile()
    ->exists($full_name . '.php')) {
    include_once $php_file;
    if (class_exists($php_class)) {
      $o = new $php_class();
      $block['type'] = 'php';
      $block['access'] = @$o->access;
      $block['object'] = $o;
      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;
}