Refactor cms toolbar post template populate code

I recently had to hack into the publishing mechanism and realized its quite hard to overwrite some toolbar elements. Also I noticed there is some unnecessary work done displaying the publishing button if the user has no publishing rights. So I refactored the code and splitted it in some more subfunctions making it easier to overwrite parts of it. Maybe you have a look at it and find it useful enough to merge ;)