How can a broken gate be repaired?
You can't if you're playing "vanilla" x3. In vanilla x3 they are just there to sit around.
If however you're playing a modded out version of x3, there's a script on their official scripting forum, that allows you to repair and link broken gates.