1 | <?php |
||
3 | class GalleryPage_Controller extends GalleryHub_Controller |
||
|
|||
4 | { |
||
5 | public function init() { |
||
8 | |||
9 | public function PaginatedImages() |
||
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 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.