Fix the "addHeader($tag, $attributes, $text)" methods to not ignore the $text parameter

Rebased version of https://github.com/owncloud/core/pull/7316 - I also deduplicated the logic into template.php

Fixes https://github.com/owncloud/core/issues/11046

@PVince81 @KenBW2 @icewind1991  Please review - thanks.
I fixed this here and in another place. Thanks for spotting.

https://github.com/owncloud/core/commit/72431545b7673007dfa9510af3ba11aaa9afd66d