Automad
 All Classes Functions Variables Pages
gallery.php
1 <?php
2 /*
3  * GALLERY
4  * Extension for Automad
5  *
6  * Copyright (c) 2014 by Marc Anton Dahmen
7  * http://marcdahmen.de
8  *
9  * Licensed under the MIT license.
10  * http://automad.org/license
11  */
12 
13 
14 namespace Extensions;
15 
16 
25 class Gallery {
26 
27 
60  public function Gallery($options, $Automad) {
61 
62  $defaults = array(
63  'files' => '*.jpg',
64  'width' => 200,
65  'height' => 200,
66  'crop' => true,
67  'order' => false,
68  'class' => false,
69  'firstWidth' => false,
70  'firstHeight' => false,
71  'firstClass' => false,
72  'enlargedWidth' => false,
73  'enlargedHeight' => false
74  );
75 
76  // Merge defaults with options
77  $options = array_merge($defaults, $options);
78 
79  // Get file list.
80  $files = \Automad\Core\Parse::fileDeclaration($options['files'], $Automad->Context->get());
81 
82  // Sort images.
83  if ($options['order'] == 'asc') {
84  sort($files, SORT_NATURAL);
85  }
86 
87  if ($options['order'] == 'desc') {
88  rsort($files, SORT_NATURAL);
89  }
90 
91  // Generate HTML
92  $html = '<div class="gallery">';
94  $files,
95  $options['width'],
96  $options['height'],
97  $options['crop'],
98  $options['class'],
99  $options['firstWidth'],
100  $options['firstHeight'],
101  $options['firstClass'],
102  $options['enlargedWidth'],
103  $options['enlargedHeight']
104  );
105  $html .= '</div>';
106 
107  return $html;
108 
109  }
110 
111 
112 }
113 
114 
115 ?>
static fileDeclaration($str, $Page, $stripBaseDir=false)
Definition: parse.php:116
static generateImageSet($files, $width=false, $height=false, $crop=false, $class=false, $firstWidth=false, $firstHeight=false, $firstClass=false, $enlargedWidth=false, $enlargedHeight=false)
Definition: html.php:297