Move re-usable code from checkoutMediaWiki to checkoutMediaWiki.php

Change-Id: If45e33ae9b0ff68df8297ce851b973b4e249a542