We study vortex patterns in a prototype nonlinear optical system: counterpropagating laser beams in a photorefractive crystal, with or without the background photonic lattice. The vortices are effectively planar and have two "flavors" because there are two opposite directions of beam propagation. In a certain parameter range, the vortices form stable equilibrium configurations which we study using the methods of statistical field theory and generalize the Berezinsky-Kosterlitz-Thouless transition of the XY model to the "two-flavor" case. In addition to the familiar conductor and insulator phases, we also have the perfect conductor (vortex proliferation in both beams/"flavors") and the frustrated insulator (energy costs of vortex proliferation and vortex annihilation balance each other). In the presence of disorder in the background lattice, a novel phase appears which shows long-range correlations and absence of long-range order, thus being analogous to glasses. An important benefit of this approach is that qualitative behavior of patterns can be known without intensive numerical work over large areas of the parameter space. The observed phases are analogous to those in magnetic systems, and make (classical) photorefractive optics a fruitful testing ground for (quantum) condensed matter systems. As an example, we map our system to a doped O(3) antiferromagnet with Z2 defects, which has the same structure of the phase diagram.