Unified the export framework for hazard and risk

See https://bugs.launchpad.net/oq-engine/+bug/1204955. 500+ lines of code duplication have been removed. The tests are running here: https://ci.openquake.org/job/zdevel_oq-engine/855
This has impact on the platform calculate tab, since the URLs have changed.
This also fixes https://bugs.launchpad.net/oq-engine/+bug/1363795 and https://bugs.launchpad.net/oq-engine/+bug/1221111.
I added the comment because I thought it was no working, but I checked again and it works as expected.