Update gallery.js

Fix to stop js errors when logging in to admin.
Update GalleryHelper.php

Fixes to adhere to STRICT.
Add length check as per https://github.com/rchavik/gallery/pull/2#issuecomment-26611049
Merge branch 'pr/2' into 2.1
Merge branch '2.1' into wip-assets-refactor