How to find the phase spectrum of a rectangular pulse? (Fourier Transform)
For the rectangular pulse without shifting, the phase spectrum its quite simple to obtain, since its Fourier Transform $F(\omega)$ is a real function. Real functions may only lay on the real axis, thus having $0$ or $\pm \pi$ phases, depending on the positive or negative sign of the function, respectively. Try visualizing the complex plane to realize this.

Now, if you're new to DSP, for $g(t)$ it might be tricky. First, take into account the scale change when dividing by 2 in $g(t)$. This expands the spectrum by a proportion of 2, i.e. $f(t/2)$  transforms as: $2~F(2\omega)$. That's why the $sinc$ function in $g(t)$ is twice as wide as in $f(t)$. Then the amplitude is multiplied by 3, that's why $G(\omega) = 6$ for $\omega = 0$.

Due to time shifting, you'd need to multiply $F(\omega)$ by a complex exponential. Recall the time-shifting Fourier transform theorem: $f(t - t_0)$ transforms as $F(\omega)~e^{-j\omega t_0}$.

The amplitude spectrum isn't modified by a time shift (since $|e^{-j\omega t_0}| = 1$), but the phase spectrum is added to $-\omega t_0$, which is the phase of the complex exponential (i.e., $\angle e^{-j\omega t_0} = -\omega t_0$).

Finally, you'd only need to add to the phase spectrum of $f(t)$ the linear function of $\omega$: $\angle H(\omega) = -4\omega$ (since $t_0 = 4$ in this case), which has a negative slope.

That's why you have in Fig. (d) the sum of a negative-slope linear function and a rectangular pulse train of $\pm \pi$ values.

This is basic DSP, I'd recommend to take a look to these theorems at Wikipedia for a very first glance: https://en.wikipedia.org/wiki/Fourier_transform#Properties_of_the_Fourier_transform