A theory of cosmic ray anisotropies of solar origin