Add new optionals hook.

Mulgara seems to break when running with multiple OPTIONAL
statements... Crazy UNIONs to workaround.
Avoid outputting OPTIONAL bit when we have none.
Merge pull request #103 from adam-vessey/7.x-ISLANDORA-945

Add new optionals hook.