Quarkonium production measurements and searches for exotic quarkonia at CMS