Version: current

     1 <?php
     2 //Создание папок в фотогалерее (не созданных из-за бага)
     3 class CorrectBadFoldersTask extends ScheduledTask {
     4     function process() {
     5         $galleries = DataObject::get('PhotoGalleryPage');
     6         if ($galleries) {
     7             foreach($galleries as $gallery) {
     8                 $newGalleryFolder = $gallery->createFolder();
     9                 if ($gallery->AllChildren()) {
    10                     foreach($gallery->AllChildren() as $album) {
    11                         $newAlbumFolder = $album->createFolder();
    12                         if ($album->Items()) {
    13                             foreach($album->Items() as $item) {
    14                                 $item->Image()->deleteFormattedImages();
    15                                 $item->Image()->setParentID($newAlbumFolder->ID);
    16                                 $item->Image()->write();
    17                             }
    18                         }
    19                     }
    20                 }
    21             }
    22         }
    23     }
    24 }

[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -