Weighted-density-functional approach to the structure of nonuniform fluids