GalleryPage_Controller::PaginatedImages()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
3
class GalleryPage_Controller extends GalleryHub_Controller
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
4
{
5
    public function init() {
6
        parent::init();
7
    }
8
9
    public function PaginatedImages()
10
    {
11
        $list = $this->SortedImages();
12
        $limit = $this->ThumbnailsPerPage;
13
14
        $pages = PaginatedList::create($list, $this->getRequest());
15
        $pages->setpageLength($limit);
16
17
        return $pages;
18
    }
19
20
    protected function GalleryImage(Image $image)
21
    {
22
        return $this->ScaledImage($image);
23
    }
24
25
    protected function GalleryThumbnail(Image $image)
26
    {
27
        return $this->ScaledImage($image, true);
28
    }
29
30
    /**
31
     * Generate an image gallery from the Gallery template, if no images are
32
     * available, then return an empty string.
33
     *
34
     * @return string
35
     */
36
    public function Gallery()
37
    {
38
        if ($this->Images()->exists()) {
39
40
            // Create a list of images with generated gallery image and thumbnail
41
            $images = ArrayList::create();
42
            $pages = $this->PaginatedImages();
43
            foreach ($this->PaginatedImages() as $image) {
44
                $image_data = $image->toMap();
45
                $image_data["GalleryImage"] = $this->GalleryImage($image);
46
                $image_data["GalleryThumbnail"] = $this->GalleryThumbnail($image);
47
                $images->add(ArrayData::create($image_data));
48
            }
49
            
50
            $vars = array(
51
                'PaginatedImages' => $pages,
52
                'Images' => $images,
53
                'Width' => $this->ImageWidth,
54
                'Height' => $this->ImageHeight
55
            );
56
57
            return $this->renderWith('Gallery',$vars);
58
        } else {
59
            return "";
60
        }
61
    }
62
}
63