[layertree] Fix #10347 - save also old <legend> tag

QGIS server does not use QgsProject for loading of QGIS project.
In order to allow reading of new projects, let's also write the original <legend> tag to the project.
Ideally the server should be ported to new layer tree implementation, but that requires
non-trivial changes to the server components.
The <legend> tag is ignored by QGIS application in >= 2.4 and this way also the new project files
can be opened in older versions of QGIS without loosing information about layer groups.