codebase reorg

centralized globally scoped php templating functions in one helper script.

these used to be all over the place, this should make it easier to find, maintain (and hopefully kill at some point) these functions.