Theory of Core-level Shifts of Clean and Covered Surfaces