Resonatingvalence-bond theory of phase transitions and superconductivity inLa2CuO4-based compounds