Optical Phase Transitions in Photonic Networks: a Spin-System Formulation