src/wcmf/lib/util/I18nUtil.php
public static function getMessages($directory, $exclude, $pattern, $depth=0) {

    if ($depth == 0) {
      self::$baseDir = $directory;
    }
    if (substr($directory, -1) != '/') {
      $directory .= '/';
    }
    if (is_dir($directory)) {
      $d = dir($directory);
      $d->rewind();
      while(false !== ($file = $d->read())) {
        if($file != '.' && $file != '..' && !in_array($file, $exclude)) {
          if (is_dir($directory.$file)) {
            self::getMessages($directory.$file, $exclude, $pattern, ++$depth);
          }
          elseif (preg_match($pattern, $file)) {
            $messages = self::getMessagesFromFile($directory.$file);
            if (sizeof($messages) > 0) {
              $key = str_replace(self::$baseDir, '', $directory.$file);
              self::$result[$key] = $messages;
            }
          }
        }
      }
      $d->close();
    }
    else {
      throw new IllegalArgumentException("The directory '".$directory."' does not exist.");
    }
    return self::$result;
  }
public static function getMessages($directory, $exclude, $pattern, $depth=0) {

    if ($depth == 0) {
      self::$baseDir = $directory;
    }
    if (substr($directory, -1) != '/') {
      $directory .= '/';
    }
    if (is_dir($directory)) {
      $d = dir($directory);
      $d->rewind();
      while(false !== ($file = $d->read())) {
        if($file != '.' && $file != '..' && !in_array($file, $exclude)) {
          if (is_dir($directory.$file)) {
            self::getMessages($directory.$file, $exclude, $pattern, ++$depth);
          }
          elseif (preg_match($pattern, $file)) {
            $messages = self::getMessagesFromFile($directory.$file);
            if (sizeof($messages) > 0) {
              $key = str_replace(self::$baseDir, '', $directory.$file);
              self::$result[$key] = $messages;
            }
          }
        }
      }
      $d->close();
    }
    else {
      throw new IllegalArgumentException("The directory '".$directory."' does not exist.");
    }
    return self::$result;
  }
public static function getMessages ( $ directory , $ exclude , $ pattern , $ depth = 0 ) { if ( $ depth == 0 ) { self :: $ baseDir = $ directory ; } if ( substr ( $ directory , - 1 ) != '/' ) { $ directory .= '/' ; } if ( is_dir ( $ directory ) ) { $ d = dir ( $ directory ) ; $ d -> rewind ( ) ; while ( false !== ( $ file = $ d -> read ( ) ) ) { if ( $ file != '.' && $ file != '..' && ! in_array ( $ file , $ exclude ) ) { if ( is_dir ( $ directory . $ file ) ) { self :: getMessages ( $ directory . $ file , $ exclude , $ pattern , ++ $ depth ) ; } elseif ( preg_match ( $ pattern , $ file ) ) { $ messages = self :: getMessagesFromFile ( $ directory . $ file ) ; if ( sizeof ( $ messages ) > 0 ) { $ key = str_replace ( self :: $ baseDir , '' , $ directory . $ file ) ; self :: $ result [ $ key ] = $ messages ; } } } } $ d -> close ( ) ; } else { throw new IllegalArgumentException ( "The directory '" . $ directory . "' does not exist." ) ; } return self :: $ result ; }
Get all messages from a directory recursively.
@param $directory The directory to search in
@param $exclude Array of directory names that are excluded from search
@param $pattern The pattern the names of the files to search in must match
@param $depth Internal use only
@return An assoziative array with the filenames as keys and the values as
array of strings.
@see I18nUtil::getMessagesFromFile
Get all messages from a directory recursively .