Variational formulations and a consistent finite-element procedure for a class of nonlocal elastic continua