[TASK] Merge pagegen.php to index_ts.php

pagegen.php contains rendering code and is called twice
in index_ts.php. The patch merged the content of this
file to index_ts.php to have all global code in one file.

The patch is a straight forward refactoring, only the
time tracking is a bit simplified and an obsolete if
is removed at the former second inclusion of the file.

Change-Id: Id8477423455281bd6df2ce32eb280809045e4541
Resolves: #51254
Releases: 6.2
Reviewed-on: https://review.typo3.org/23246
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters