public function getCMSFields($cms)
 {
     $configuration = _t('ImageGalleryPage.CONFIGURATION', 'Configuration');
     $albums = _t('ImageGalleryPage.ALBUMS', 'Albums');
     $photos = _t('ImageGalleryPage.PHOTOS', 'Photos');
     $f = parent::getCMSFields($cms);
     $f->addFieldToTab("Root.Content.{$configuration}", new HeaderField($title = _t('ImageGalleryPage.ALBUMCOVERIMAGES', 'Album cover images'), $headingLevel = "6"));
     $f->addFieldToTab("Root.Content.{$configuration}", new FieldGroup(new NumericField('CoverImageWidth', 'Width'), new NumericField('CoverImageHeight', 'Height')));
     $f->addFieldToTab("Root.Content.{$configuration}", new NumericField('ThumbnailSize', _t('ImageGalleryPage.THUMBNAILHEIGHT', 'Thumbnail height (pixels)')));
     $f->addFieldToTab("Root.Content.{$configuration}", new CheckboxField('Square', _t('ImageGalleryPage.CROPTOSQUARE', 'Crop thumbnails to square')));
     $f->addFieldToTab("Root.Content.{$configuration}", new NumericField('MediumSize', _t('ImageGalleryPage.MEDIUMSIZE', 'Medium size (pixels)')));
     $f->addFieldToTab("Root.Content.{$configuration}", new NumericField('NormalSize', _t('ImageGalleryPage.NORMALSIZE', 'Normal width (pixels)')));
     $f->addFieldToTab("Root.Content.{$configuration}", new NumericField('NormalHeight', _t('ImageGalleryPage.NORMALHEIGHT', 'Normal height (pixels)')));
     $f->addFieldToTab("Root.Content.{$configuration}", new NumericField('MediaPerPage', _t('ImageGalleryPage.IMAGESPERPAGE', 'Number of images per page')));
     $popup_map = array();
     if ($ui_list = ClassInfo::subclassesFor("ImageGalleryUI")) {
         foreach ($ui_list as $ui) {
             if ($ui != "ImageGalleryUI") {
                 $ui_label = eval("return {$ui}::\$label;");
                 $demo_url = eval("return {$ui}::\$link_to_demo;");
                 $demo_link = !empty($demo_url) ? sprintf('<a href="%s" target="_blank">%s</a>', $demo_url, _t('ImageGalleryPage.VIEWDEMO', 'view demo')) : "";
                 $popup_map[$ui] = $ui_label . " " . $demo_link;
             }
         }
     }
     $f->addFieldToTab("Root.Content.{$configuration}", new OptionsetField('GalleryUI', _t('ImageGalleryPage.POPUPSTYLE', 'Popup style'), $popup_map));
     $f->addFieldToTab("Root.Content.{$configuration}", new NumericField('UploadLimit', _t('ImageGalleryPage.MAXFILES', 'Max files allowed in upload queue')));
     if ($this->RootFolderID) {
         $manager = new DataObjectManager($this, 'Albums', $this->albumClass, array('AlbumName' => _t('ImageGalleryAlbum.ALBUMNAME', 'Album Name'), 'Description' => _t('ImageGalleryAlbum.DESCRIPTION', 'Description')), 'getCMSFields_forPopup', "ImageGalleryPageID = {$this->ID}");
         $manager->setAddTitle(_t('ImageGalleryPage.ANALBUM', 'an Album'));
         $manager->setSingleTitle(_t('ImageGalleryPage.ALBUM', 'Album'));
         $manager->setParentClass('ImageGalleryPage');
         $f->addFieldToTab("Root.Content.{$albums}", $manager);
     } else {
         $f->addFieldToTab("Root.Content.{$albums}", new HeaderField($title = _t("ImageGalleryPage.ALBUMSNOTSAVED", "You may add albums to your gallery once you have saved the page for the first time."), $headingLevel = "3"));
     }
     if ($this->RootFolderID && $this->Albums()->Count() > 0) {
         $manager = new ImageGalleryManager($this, 'GalleryItems', $this->itemClass, 'Image', array('Caption' => _t('ImageGalleryItem.CAPTION', 'Caption')), 'getCMSFields_forPopup');
         $manager->setPluralTitle(_t('ImageGalleryPage.IMAGES', 'Images'));
         $manager->setParentClass("ImageGalleryPage");
         if ($this->UploadLimit) {
             $manager->setUploadLimit($this->UploadLimit);
         }
         $f->addFieldToTab("Root.Content.{$photos}", $manager);
     } elseif (!$this->RootFolderID) {
         $f->addFieldToTab("Root.Content.{$photos}", new HeaderField($title = _t("ImageGalleryPage.PHOTOSNOTSAVED", "You may add photos to your gallery once you have saved the page for the first time."), $headingLevel = "3"));
     } elseif ($this->Albums()->Count() == 0) {
         $f->addFieldToTab("Root.Content.{$photos}", new HeaderField($title = _t("ImageGalleryPage.NOALBUMS", "You have no albums. Click on the Albums tab to create at least one album before adding photos."), $headingLevel = "3"));
     }
     return $f;
 }