The triac is a double thyristor, each thyristor acts like a diode when theres a gate signal present, 2 of these back to back acts like a switch, one that only needs a small gate current.
The photocell, resistor and diac are all part of the trigger circuit, dc (possibly from the green cap) goes to the diac and resistor, when the voltage accross the diac gets to about 20v it goes from open to short, providing the triac with gate current and it too turns on, switching on the load, when the ambient light increases the photcell resistance decreases and 'robs' drive current from the gate drive circuit just mentioned and the triac and therefor the load switch off.
The idea of the diac is so that the switch on point is the same either side (+ and -) of the mains waveform, this is important if the load uses a transformer, uneven switching is effectively dc and would burn out a tranny, it also gives a positive switch on for the gate drive further improving even triggering.
A better quality item would also have a couple of x rated caps or a choke to reduce rf interference from switching the mains, either that or some kind of zero crossing gate trigger circuit.