Formation of quark phases in compact stars and SN explosion