public function run($request)
 {
     // Migrate old ImageGalleryImage class to use Image object
     DB::query('UPDATE "File" SET "File"."ClassName" = \'Image\' WHERE "File"."ClassName" = \'ImageGalleryImage\'');
     // check that galleries exist
     $galleries = DataObject::get('MagnificGalleryPage');
     if (!$galleries || $galleries->count() === 0) {
         user_error('No image gallery pages found', E_USER_ERROR);
         return;
     }
     // check each gallery
     $count = 0;
     Debug::message("Importing, please wait....");
     foreach ($galleries as $gallery) {
         $albums = $gallery->Albums();
         if (!$albums || $albums->count() === 0) {
             Debug::message("Warning: no album found in gallery '{$gallery->Title}'");
             continue;
         }
         // Check each album in each gallery
         foreach ($albums as $album) {
             $album->write();
             // Ensures folder, URLSegment, etc are all prepared
             $folder = $album->Folder();
             $existing = $album->GalleryItems()->column('ImageID');
             foreach ($folder->Children() as $image) {
                 if (in_array($image->ID, $existing)) {
                     continue;
                 }
                 //Add to the album
                 $item = MagnificGalleryItem::create();
                 $item->GalleryPageID = $gallery->ID;
                 $item->AlbumID = $album->ID;
                 $item->ImageID = $image->ID;
                 $item->write();
                 $count++;
             }
         }
     }
     Debug::message("Imported {$count} images into galleries");
 }
 public function rss()
 {
     $rss = new RSSFeed($list = MagnificGalleryItem::get()->sort('Created DESC')->limit(10)->toArray(), $link = Director::absoluteURL($this->RssLink()), $title = _t('MagnificGalleryPage.RSS_TITLE', 'Recent images from %s', array(Siteconfig::current_site_config()->Title)), $description = _t('MagnificGalleryPage.RSS_DESCRIPTION', 'Get recents images from our website'));
     // Outputs the RSS feed to the user.
     return $rss->outputToBrowser();
 }