Firefighters on Friday were working to bring under control a massive fire at Philadelphia Energy Solutions Inc’s refinery that has resulted in damage that could keep much of the complex shut for an extended period, according to Philadelphia city officials and company sources.