static function collect_package( $package, $ext, $silent, $confname ){
	
		// get from cache for speed
		$cachekey = $package.'.'.$ext;
		if( isset(self::$dircache[$cachekey]) ){
			return self::$dircache[$cachekey];
		}

	
		$apath = explode( '.', $package );
		$type = $apath[0];   // e.g. "PLUG"
		$cname = array_pop( $apath );      // e.g. "PLUGSession"
	
		// force special extensions, in certain cases
		switch( $type ){
		case 'conf':
			$ext = 'conf.php';
			break;
		}
		
		// special rules for types of import
		switch( $ext ){
		case 'js':
			// Javascript under document root
			$dpath = PLUG_VIRTUAL_DIR.'/plug/js/'.implode( '/', $apath );
			break;
		case 'conf.php':
			// replace with target conf dir
			$apath[0] = $confname; 
			// fall through ....
		default:
			// regular PHP import from outside document root
			$dpath = PLUG_HOST_DIR .'/'. implode( '/', $apath );
		}
		
		$incs = array();	
	
		switch( $cname ){
		case '':
		case '*':
		//  import all files under directory
			if( !$silent && !self::check_dir( $dpath ) ){
				break;
			}
			$dhandle = opendir( $dpath );
			while( $f = readdir($dhandle) ){
				// skip dot files
				if( $f{0} === '.' ){
					continue;
				}
				$i = strpos( $f, ".$ext" ); 
				if( $i ){
					// file has correct extension
					if( substr($f,0,2) === '__' ){
						// skip file name starting "__"
						continue;
					}
					$cname = substr_replace( $f, '', $i );
					$incs[$cname] = "$dpath/$f";
				}
			}
			closedir($dhandle);
			break;
		
		default:
		//  assume single file exists with expected extension
			$path = "$dpath/$cname.$ext";
			if( !$silent && !self::check_file($path) ){
				break;
			}
			$incs[$cname] = $path;
		}
		
		// cache for next time
		self::$dircache[$cachekey] = $incs;
		return $incs;
	}