The drum I did above is sorta off. I have revised it since, but you get the idea. The tricky part is to find a motor to rotate the drum/pipe. I was thinking perhaps a DC motor, for variable speed, and then linking it via a rubber belt (large o-ring).
Or, the drum isnt really needed. If there was some mechanism that would bob the pipe, or even just a slotted strip of acrylic/plastic, up and down, that would work as well as far as controlling the flow of the pump.
But otherwise, there are two main things to control here with the pipe-valve (spool valve is the real term?). One is the flow of water into the box via gravity, and the other is the flow of water out of the box via the pump. When the pump is pushing water into the tank from the box, the flow into the box via gravity needs to be stopped. Then, when the flow of water from the box is open, the flow from the pump needs to be looped back into the box. This way, the water will either be from the box into the tank, or from the tank into the box. The rate is determined by how fast the valve moves.. thus the reason for a DC motor to power it. The only other thing to watch is that the valve doesnt rotate so slow that the pump is able to run dry when the inlet valve it shut and the pump is pumping into the tank.