You are here

protected function FileBase::scanInclude in Forena Reports 8

Same name and namespace in other branches
  1. 7.5 src/File/FileBase.php \Drupal\forena\File\FileBase::scanInclude()

Parse a drectory

Parameters

string $directory: Directory name to parse.

string $prefix a prefix to use in the base name:

1 call to FileBase::scanInclude()
FileBase::scan in src/File/FileBaseOld.php

File

src/File/FileBaseOld.php, line 61
FileSystemBase.inc File toolbox for manipulating files contained tn the report directory.

Class

FileBase

Namespace

Drupal\forena\File

Code

protected function scanInclude($directory, $prefix = '') {
  $default = strpos($directory, $this->dir) === 0;
  $files = array();
  $this
    ->scanDirectory($directory, $files);
  foreach ($files as $ext => $files_of_type) {
    foreach ($files_of_type as $file => $mtime) {
      $base_name = $prefix . substr($file, strlen($directory) + 1, -1 * (strlen($ext) + 1));
      if (!isset($this->cache[$ext][$base_name])) {
        $obj = new \stdClass();
        $obj->file = $file;
        $obj->mtime = $mtime;
        $obj->cache = NULL;
        $obj->include = !$default;
        $obj->override = FALSE;
        $this->cache[$ext][$base_name] = $obj;
      }
      else {

        // If its our first pas on this replace the entry
        $entry = $this->cache[$ext][$base_name];
        if (isset($this->filesToDelete[$ext][$base_name])) {
          if ($entry->file != $file) {
            $entry->file = $file;
            $entry->cache = NULL;
            $entry->mtime = $mtime;
            $entry->include = !$default;
            $entry->override = FALSE;
          }
        }
        else {
          if (!$entry->override) {
            if ($entry->file != $file && strpos($entry->file, $this->dir) === 0) {
              $entry->override = TRUE;
            }
          }
        }
        unset($this->filesToDelete[$ext][$base_name]);
      }
    }
  }
}