Nigel Farage has apologised for 17 breaches of the MPs' code of conduct after failing to declare external earnings.