The BD140 switches on the light when the power fails. As long as power is present, the voltage at the base of that PNP transistor is higher than its emitter. A PNP requires a voltage lower than its emitter. When the power fails, the base is brought low by the 560Ω resistor connected to ground. Then the BD140 conducts, and the lights come on.
The 12 LEDs are connected in parallel, with series resistors on each to limit current draw. The LM317 and the associated transistor network is a current-limited voltage regulator, and is used to charge the +4.5V battery safely from the +9V source. This +9V comes from the transformer and bridge circuit on the left, which gets its AC power from the wall outlet.