YaWK  24.1
Yet another WebKit
YAWK\WIDGETS\GALLERY\IMAGES\gallery Class Reference

Embed a photo gallery on your website. More...

+ Inheritance diagram for YAWK\WIDGETS\GALLERY\IMAGES\gallery:

Public Member Functions

 __construct ($db)
 Load all widget settings from database and fill object. More...
 
 drawImageGallery ($db)
 Draw the gallery. More...
 
 init ($db)
 Init Gallery and load methods. More...
 
 loadJavascript ()
 Check if lightbox asset is loaded and set lightbox options. More...
 
 printObject ()
 Print all object data. More...
 
- Public Member Functions inherited from YAWK\widget
 getHeading ($heading, $subtext)
 Get widget heading and subtext, return headline. More...
 
 getWidgetSettingsArray ($db)
 Get widget settings and return it as array. More...
 

Public Attributes

 $filename = ''
 
 $galleryAlbumLabel = 'Image %1 of %2'
 
 $galleryDisableScrolling = false
 
 $galleryFadeDuration = '600'
 
 $galleryFitImagesInViewport = true
 
 $galleryHeading = ''
 
 $galleryID = ''
 
 $galleryImageClass = 'img-responsive img-rounded hvr-grow'
 
 $galleryImageFadeDuration = '600'
 
 $galleryLayoutRows = 3
 
 $galleryMaxHeight = ''
 
 $galleryMaxWidth = ''
 
 $galleryNavOnTouchDevices = false
 
 $galleryPositionFromTop = '50'
 
 $galleryResizeDuration = '700'
 
 $galleryShowImageNumberLabel = true
 
 $galleryShuffle = false
 
 $gallerySubtext = ''
 
 $galleryTnHeight = ''
 
 $galleryTnWidth = ''
 
 $galleryWidthMarkup = ''
 
 $galleryWrapAround = false
 
 $headline = ''
 
 $itemAuthor = ''
 
 $itemAuthorUrl = ''
 
 $itemID = ''
 
 $itemTitle = ''
 
 $widget = ''
 
- Public Attributes inherited from YAWK\widget
 $data
 
 $date_publish
 
 $date_unpublish
 
 $folder
 
 $id
 
 $marginBottom
 
 $marginTop
 
 $name
 
 $pageID
 
 $position
 
 $published
 
 $sort
 
 $widgetTitle
 
 $widgetType
 

Additional Inherited Members

- Static Public Member Functions inherited from YAWK\widget
static getAllSettingsIntoArray ($db, $widgetID)
 Returns an array with all widget settings data. More...
 
static getAllWidgetTypes ($db)
 Return all widget types as associative array. More...
 
static getCurrentWidgetPath ($db)
 return current widget path More...
 
static getFacebookLikeBox ()
 return the facebook likebox widget More...
 
static getLoginBox ()
 return the user login box widget More...
 
static loadWidgetsOfPage ($db, $page)
 Returns an array of all widgets that are linked with given page->id. More...
 

Detailed Description

Embed a photo gallery on your website.

Embed plugin: photo gallery

This is the widget to the gallery plugin. With this widget you can embed image galleries that you've created before using the gallery plugin. Simply set the ID of the photo gallery you would like to embed.

Author
Daniel Retzl danie.nosp@m.lret.nosp@m.zl@gm.nosp@m.ail..nosp@m.com
Version
1.0.0

Definition at line 16 of file gallery.php.

Constructor & Destructor Documentation

◆ __construct()

YAWK\WIDGETS\GALLERY\IMAGES\gallery::__construct (   $db)

Load all widget settings from database and fill object.

Parameters
object$dbDatabase Object

Load all widget settings on object init.

Definition at line 85 of file gallery.php.

87  {
88  // load this widget settings from db
89  $this->widget = new \YAWK\widget();
90  $settings = $this->widget->getWidgetSettingsArray($db);
91  foreach ($settings as $property => $value) {
92  $this->$property = $value;
93  }
if(isset($_POST['save'])) $settings
$value

References $db, $settings, $value, and YAWK\widget\getWidgetSettingsArray().

Member Function Documentation

◆ drawImageGallery()

YAWK\PLUGINS\GALLERY\gallery::drawImageGallery (   $db)

Draw the gallery.

Parameters
dbobject Database object

(for development and testing purpose)

Parameters
object$dbdatabase
array$langlanguage array
int$galleryIDgallery ID to load
Parameters
$db\YAWK\db
$widget\YAWK\widget

Definition at line 155 of file gallery.php.

157  { /** @param $db \YAWK\db **/
158  if (!isset($this->galleryID) || (empty($this->galleryID)))
159  {
160  echo "Error: unable to load photo gallery because there is no gallery selected.";
161  }
162  if ($res = $db->query("SELECT folder from {plugin_gallery} WHERE id = '".$this->galleryID."'"))
163  {
164  while ($row = mysqli_fetch_assoc($res))
165  { // check if shuffle is enabled
166  if (isset($this->galleryShuffle) && ($this->galleryShuffle === 'true'))
167  { // randomize pictures
168  $order = "ORDER BY RAND()";
169  }
170  else
171  { // order by sortation
172  $order = "ORDER BY sort ASC";
173  }
174  if (!$getPreviewImages = $db->query("SELECT id, galleryID, sort, filename, title, author, authorUrl
175  from {plugin_gallery_items}
176  WHERE galleryID = '".$this->galleryID."' $order"))
177  { // store info msg, if files could not be retrieved
178  $previewError = "Sorry, could not get preview images";
179  }
180  if (isset($previewError))
181  { // if files could not be loaded from db
182  echo $previewError;
183  }
184  else
185  {
186  // prepare loop vars
187  $count = 0;
188  $divider = 3;
189  /** @param $widget \YAWK\widget */
190  // get headline
191  $this->headline = $this->getHeading($this->galleryHeading, $this->gallerySubtext);
192  // draw headline
193  echo $this->headline;
194  echo '<div class="container-fluid">
195  <div class="row text-center">';
196 
197  // check gallery layout (how many cols per row)
198  if ($this->galleryLayoutRows === "1")
199  {
200  $col = "col-md-12";
201  $divider = 1;
202  }
203  elseif ($this->galleryLayoutRows === "2")
204  {
205  $col = "col-md-6";
206  $divider = 2;
207  }
208  elseif ($this->galleryLayoutRows === "3")
209  {
210  $col = "col-md-4";
211  $divider = 3;
212  }
213  elseif ($this->galleryLayoutRows === "4")
214  {
215  $col = "col-md-3";
216  $divider = 4;
217  }
218  elseif ($this->galleryLayoutRows === "6")
219  {
220  $col = "col-md-2";
221  $divider = 6;
222  }
223  elseif ($this->galleryLayoutRows === "12")
224  {
225  $col = "col-md-1";
226  $divider = 12;
227  }
228  else
229  {
230  $col = "col-md-4";
231  }
232 
233  // check thumbnail width
234  if (isset($this->galleryTnWidth) && (!empty($this->galleryTnWidth)))
235  { // set tn width markup
236  $this->galleryWidthMarkup = "width=\"$this->galleryTnWidth\" ";
237  }
238  else
239  { // no width markup needed
240  $this->galleryWidthMarkup = '';
241  }
242 
243  foreach ($getPreviewImages as $property => $image)
244  { // display preview images
245  for ($i = 0; $i < mb_strlen($property); $i++)
246  {
247  $this->itemID = $image['id'];
248  $this->sort = $image['sort'];
249  $this->filename = $image['filename'];
250  $this->itemTitle = $image['title'];
251  $this->itemAuthor = $image['author'];
252  $this->itemAuthorUrl = $image['authorUrl'];
253  // $rnd = uniqid();
254 
255  echo "
256  <div class=\"$col text-center\" id=\"imgCol-".$this->itemID."\">
257  <a href=\"$row[folder]/$this->filename\" data-lightbox=\"$this->galleryID\" data-title=\"$this->itemTitle\"><img ".$this->galleryWidthMarkup."class=\"$this->galleryImageClass\" id=\"img-$this->itemID\" title=\"$this->itemTitle\" src=\"$row[folder]/$this->filename\"></a><br><br>
258  </div>
259  ";
260 
261  $count++;
262 
263  // close tag, but never before the first run
264  if ($count > 1)
265  {
266  if($count % $divider == 0) echo '
267  </div> <!-- end row -->
268 
269  <div class="row text-center">';
270 
271  }
272  }
273  }
274  echo "</div></div>";
275  }
276  }
277  }
getHeading($heading, $subtext)
Get widget heading and subtext, return headline.
Definition: widget.php:669
$i
Definition: gallery.php:161
$col
Definition: index.php:79

References $col, $db, YAWK\WIDGETS\GALLERY\IMAGES\gallery\$headline, $i, $res, and YAWK\widget\getHeading().

Referenced by YAWK\WIDGETS\GALLERY\IMAGES\gallery\init().

◆ init()

YAWK\WIDGETS\GALLERY\IMAGES\gallery::init (   $db)

Init Gallery and load methods.

load Javascript and draw image gallery

Definition at line 110 of file gallery.php.

112  {
113  $this->loadJavascript();
114  $this->drawImageGallery($db);
drawImageGallery($db)
Draw the gallery.
Definition: gallery.php:155
loadJavascript()
Check if lightbox asset is loaded and set lightbox options.
Definition: gallery.php:120

References $db, YAWK\WIDGETS\GALLERY\IMAGES\gallery\drawImageGallery(), and YAWK\WIDGETS\GALLERY\IMAGES\gallery\loadJavascript().

◆ loadJavascript()

YAWK\WIDGETS\GALLERY\IMAGES\gallery::loadJavascript ( )

Check if lightbox asset is loaded and set lightbox options.

check lightbox asset and set options

Definition at line 120 of file gallery.php.

122  {
123  // check if gallery max width is set
124  if (isset($this->galleryMaxWidth) && (empty($this->galleryMaxWidth)))
125  { // nope, no markup needed
126  $maxWidthMarkup = '';
127  }
128  else
129  { // set gallery markup
130  $maxWidthMarkup = "
131  'maxWidth': $this->galleryMaxWidth,";
132  }
133  echo "
134  <script type=\"text/javascript\">
135  lightbox.option({
136  'alwaysShowNavOnTouchDevices': $this->galleryNavOnTouchDevices,
137  'albumLabel': \"$this->galleryAlbumLabel\",
138  'disableScrolling': $this->galleryDisableScrolling,
139  'fadeDuration': $this->galleryFadeDuration,
140  'fitImagesInViewport': $this->galleryFitImagesInViewport,
141  'imageFadeDuration': $this->galleryImageFadeDuration,$maxWidthMarkup
142  'positionFromTop': $this->galleryPositionFromTop,
143  'resizeDuration': $this->galleryResizeDuration,
144  'showImageNumberLabel': $this->galleryShowImageNumberLabel,
145  'wrapAround': $this->galleryWrapAround
146  });
147  </script>";

Referenced by YAWK\WIDGETS\GALLERY\IMAGES\gallery\init().

◆ printObject()

YAWK\WIDGETS\GALLERY\IMAGES\gallery::printObject ( )

Print all object data.

(for development and testing purpose)

Reimplemented from YAWK\widget.

Definition at line 99 of file gallery.php.

101  {
102  echo "<pre>";
103  print_r($this);
104  echo "</pre>";

Member Data Documentation

◆ $filename

YAWK\WIDGETS\GALLERY\IMAGES\gallery::$filename = ''
Parameters
stringImage filename

Definition at line 30 of file gallery.php.

◆ $galleryAlbumLabel

YAWK\WIDGETS\GALLERY\IMAGES\gallery::$galleryAlbumLabel = 'Image %1 of %2'
Parameters
stringThe text displayed below the caption when viewing an image set. The default text shows the current image number and the total number of images in the set.

Definition at line 43 of file gallery.php.

◆ $galleryDisableScrolling

YAWK\WIDGETS\GALLERY\IMAGES\gallery::$galleryDisableScrolling = false
Parameters
boolIf true, prevent the page from scrolling while Lightbox is open. This works by settings overflow hidden on the body.

Definition at line 45 of file gallery.php.

◆ $galleryFadeDuration

YAWK\WIDGETS\GALLERY\IMAGES\gallery::$galleryFadeDuration = '600'
Parameters
stringThe time it takes for the Lightbox container and overlay to fade in and out, in milliseconds.

Definition at line 47 of file gallery.php.

◆ $galleryFitImagesInViewport

YAWK\WIDGETS\GALLERY\IMAGES\gallery::$galleryFitImagesInViewport = true
Parameters
boolIf true, resize images that would extend outside of the viewport so they fit neatly inside of it. This saves the user from having to scroll to see the entire image.

Definition at line 49 of file gallery.php.

◆ $galleryHeading

YAWK\WIDGETS\GALLERY\IMAGES\gallery::$galleryHeading = ''
Parameters
stringTitle that will be shown above widget

Definition at line 23 of file gallery.php.

◆ $galleryID

YAWK\WIDGETS\GALLERY\IMAGES\gallery::$galleryID = ''
Parameters
intGallery ID

Definition at line 21 of file gallery.php.

◆ $galleryImageClass

YAWK\WIDGETS\GALLERY\IMAGES\gallery::$galleryImageClass = 'img-responsive img-rounded hvr-grow'
Parameters
stringImage Class

Definition at line 77 of file gallery.php.

◆ $galleryImageFadeDuration

YAWK\WIDGETS\GALLERY\IMAGES\gallery::$galleryImageFadeDuration = '600'
Parameters
stringThe time it takes for the image to fade in once loaded, in milliseconds.

Definition at line 51 of file gallery.php.

◆ $galleryLayoutRows

YAWK\WIDGETS\GALLERY\IMAGES\gallery::$galleryLayoutRows = 3
Parameters
intHow many pictures should be drawn per row?

Definition at line 70 of file gallery.php.

◆ $galleryMaxHeight

YAWK\WIDGETS\GALLERY\IMAGES\gallery::$galleryMaxHeight = ''
Parameters
stringIf set, the image height will be limited to this number, in pixels. Aspect ratio will not be maintained.

Definition at line 55 of file gallery.php.

◆ $galleryMaxWidth

YAWK\WIDGETS\GALLERY\IMAGES\gallery::$galleryMaxWidth = ''
Parameters
stringIf set, the image width will be limited to this number, in pixels. Aspect ratio will not be maintained.

Definition at line 53 of file gallery.php.

◆ $galleryNavOnTouchDevices

YAWK\WIDGETS\GALLERY\IMAGES\gallery::$galleryNavOnTouchDevices = false
Parameters
boolgalleryNavOnTouchDevices If true, the left and right navigation arrows which appear on mouse hover when viewing image sets will always be visible on devices which support touch.

Definition at line 41 of file gallery.php.

◆ $galleryPositionFromTop

YAWK\WIDGETS\GALLERY\IMAGES\gallery::$galleryPositionFromTop = '50'
Parameters
stringThe distance from top of viewport that the Lightbox container will appear, in pixels

Definition at line 61 of file gallery.php.

◆ $galleryResizeDuration

YAWK\WIDGETS\GALLERY\IMAGES\gallery::$galleryResizeDuration = '700'
Parameters
stringThe time it takes for the Lightbox container to animate its width and height when transition between different size images, in milliseconds.

Definition at line 63 of file gallery.php.

◆ $galleryShowImageNumberLabel

YAWK\WIDGETS\GALLERY\IMAGES\gallery::$galleryShowImageNumberLabel = true
Parameters
boolIf false, the text indicating the current image number and the total number of images in set (Ex. "image 2 of 4") will be hidden.

Definition at line 65 of file gallery.php.

◆ $galleryShuffle

YAWK\WIDGETS\GALLERY\IMAGES\gallery::$galleryShuffle = false
Parameters
booltrue|false Shuffle Images

Definition at line 72 of file gallery.php.

◆ $gallerySubtext

YAWK\WIDGETS\GALLERY\IMAGES\gallery::$gallerySubtext = ''
Parameters
stringSubtext will be displayed beside title

Definition at line 25 of file gallery.php.

◆ $galleryTnHeight

YAWK\WIDGETS\GALLERY\IMAGES\gallery::$galleryTnHeight = ''
Parameters
stringIf set, the thumbnail image height will be limited to this number, in pixels. Aspect ratio will not be maintained.

Definition at line 59 of file gallery.php.

◆ $galleryTnWidth

YAWK\WIDGETS\GALLERY\IMAGES\gallery::$galleryTnWidth = ''
Parameters
stringIf set, the thumbnail image width will be limited to this number, in pixels. Aspect ratio will not be maintained.

Definition at line 57 of file gallery.php.

◆ $galleryWidthMarkup

YAWK\WIDGETS\GALLERY\IMAGES\gallery::$galleryWidthMarkup = ''
Parameters
string<img Width HTML Markup

Definition at line 75 of file gallery.php.

◆ $galleryWrapAround

YAWK\WIDGETS\GALLERY\IMAGES\gallery::$galleryWrapAround = false
Parameters
boolIf true, when a user reaches the last image in a set, the right navigation arrow will appear and they will be to continue moving forward which will take them back to the first image in the set.

Definition at line 67 of file gallery.php.

◆ $headline

YAWK\WIDGETS\GALLERY\IMAGES\gallery::$headline = ''
Parameters
stringHeadline above widget

Definition at line 38 of file gallery.php.

Referenced by YAWK\WIDGETS\GALLERY\IMAGES\gallery\drawImageGallery().

◆ $itemAuthor

YAWK\WIDGETS\GALLERY\IMAGES\gallery::$itemAuthor = ''
Parameters
stringImage Author (Copyright Notice)

Definition at line 34 of file gallery.php.

◆ $itemAuthorUrl

YAWK\WIDGETS\GALLERY\IMAGES\gallery::$itemAuthorUrl = ''
Parameters
stringImage Author URL

Definition at line 36 of file gallery.php.

◆ $itemID

YAWK\WIDGETS\GALLERY\IMAGES\gallery::$itemID = ''
Parameters
intImage Item ID

Definition at line 28 of file gallery.php.

◆ $itemTitle

YAWK\WIDGETS\GALLERY\IMAGES\gallery::$itemTitle = ''
Parameters
stringImage Description

Definition at line 32 of file gallery.php.

◆ $widget

YAWK\WIDGETS\GALLERY\IMAGES\gallery::$widget = ''
Parameters
objectglobal widget object data

Definition at line 19 of file gallery.php.


The documentation for this class was generated from the following file: