Move viewport data ob generation to a separate PHP class.

Allows determination of what to send to browser on-demand at the end of
a request.

Fixes issues where viewport objects were missing properties if using a
"basic" object rather than a "full" object, and later that object needs
additional information injected into it.