Try to use the project CRS when adding a layer from the browser

Currently, when a layer is added from the browser, the first valid CRS is used. With this patch, the project CRS is used if possible. Also, the last selected image format is used if possible.

At the same time, proper escaping and unescaping routines are introduced, removing the need for the `if ( parts[3] == "PG" )` workaround.

Funded by Sourcepole QGIS Enterprise.