function testFileMaskAndSubdir()
 {
     $fs = new MAX_FileScanner();
     $fs->addFileTypes(array('php', 'inc'));
     $fs->setFileMask('^.*/([a-zA-Z0-9\\-_]*)\\.plugin\\.php$');
     $fs->addDir(MAX_FILE_TEST_DIR);
     $this->assertIdentical($fs->getAllFiles(), array(MAX_FILE_TEST_DIR . '/test.plugin.php'));
 }
예제 #2
0
 /**
  * A private method to return a list list of files from a directory
  * (and subdirectories, if appropriate)  which match the defined
  * plugin file mask (MAX_PLUGINS_FILE_MASK).
  *
  * @static
  * @access private
  * @param string $directory The directory to search for files in.
  * @param mixed $recursive If the boolean 'true', returns all files in the given
  *                         directory and all subdirectories that match the file
  *                         mask.
  *                         If an integer, returns all files in the given
  *                         directory and subdirectories down to the depth
  *                         specified by the parameter that match the file mask.
  * @return array An array of the files found, indexed by "directory:filename",
  *               where "directory" is the relative directory path below the
  *               given directory parameter, and "filename" is the filename
  *               before the MAX_PLUGINS_EXTENSION extension of the file.
  */
 function _getPluginsFilesFromDirectory($directory, $recursive = 1)
 {
     if (is_readable($directory)) {
         $fileMask = self::_getFileMask();
         $oFileScanner = new MAX_FileScanner();
         $oFileScanner->addFileTypes(array('php', 'inc'));
         $oFileScanner->setFileMask($fileMask);
         $oFileScanner->addDir($directory, $recursive);
         return $oFileScanner->getAllFiles();
     } else {
         return array();
     }
 }
예제 #3
0
 /**
  * Reads list of files from plugins with affix (ini)
  *
  * @param string $affix
  * @return array
  */
 function getPluginsConfigFiles($module = OA_PLUGINS_ALL_MODULES, $affix = 'php')
 {
     $oFileScanner = new MAX_FileScanner();
     $oFileScanner->addFileTypes(array($affix));
     $readFromDir = MAX_PATH . '/var/plugins/config';
     if ($module != OA_PLUGINS_ALL_MODULES) {
         $readFromDir .= '/' . $module;
     }
     $oFileScanner->addDir($readFromDir, $recursive = true);
     return $oFileScanner->getAllFiles();
 }