You found it yourself. "Es gefällt mir" has as the grammatical subject the thing or person that is being liked. So "I like this shirt" becomes "Dieses Hemd gefällt mir". And what is the subject in the English sentence becomes an indirect object, hence the pronouns "mir, dir, ihm, ihr, uns, euch, ihnen/Ihnen".
As "Ich mag dieses Hemd" means almost the same, you can stick to that - for the time being - it behaves in exactly the same manner as its English counterpart.