You are here

public function FrxDataProvider::parseSQLFile in Forena Reports 6.2

Same name and namespace in other branches
  1. 7.2 FrxDataProvider.inc \FrxDataProvider::parseSQLFile()
1 call to FrxDataProvider::parseSQLFile()
FrxDataProvider::load_block in ./FrxDataProvider.inc
Default block load Loads the data block based on the block name from the file system. The classes that are derived from this will set the block_ext property, which in most cases is .sql but might be something different. The load of the block file…

File

./FrxDataProvider.inc, line 178
Class that defines default methods for access control in an FrxDataProvider

Class

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

Code

public function parseSQLFile($contents) {
  $comment = $this->comment_prefix;
  $trim = $this->comment_suffix;
  $lines = explode("\n", $contents);
  $cnt = count($lines);
  $access = '';
  $i = 0;
  $block = '';
  $parms = FrxData::instance()
    ->currentContext();
  $data = '';
  while ($i < $cnt) {
    $l = trim($lines[$i], "\r");
    @(list($d, $c) = explode($comment, $l, 2));
    if ($trim) {
      $c = trim($c, $trim);
    }
    if ($c) {
      @(list($a, $o) = explode('=', $c, 2));
      $a = trim($a);
      if ($a && $o || $c == 'END' || $c == 'ELSE') {
        switch ($a) {
          case 'ACCESS':
            $access = trim($o);
            break;
          case 'IF':
            $skip = !$this->te
              ->test(trim($o));
            break;
          case 'END':
            $skip = FALSE;
            break;
          case 'ELSE':
            $skip = !$skip;
            break;
        }
      }
    }
    if (!$skip) {
      if (strpos($l, $comment) !== 0 && $l) {
        $data .= "{$l}\n";
      }
    }
    $i++;
  }
  return array(
    'access' => $access,
    'source' => $data,
  );
}