Theory of fluorescence in photonic crystals