Foam in porous media: thermodynamic and hydrodynamic peculiarities