80 $widget = new \YAWK\widget();
81 $this->
settings = $widget->getWidgetSettingsArray(
$db);
106 if (isset($this->fbGalleryAppId) && (!empty($this->fbGalleryAppId)))
108 if (is_numeric($this->fbGalleryAppId))
114 die (
"app ID is set, but not a numeric value! Please check your app ID - it should contain numbers only.");
119 die (
"app ID is not set. Please add your app ID. You can obtain it from http://developers.facebook.com");
129 if (isset($this->fbGalleryAccessToken) && (!empty($this->fbGalleryAccessToken)))
131 if (is_string($this->fbGalleryAccessToken))
137 die (
"Access token is set, but not a string value! Please check your access token.");
142 die (
"Access token is not set. Please add your access token. You can obtain it from http://developers.facebook.com/apps");
152 if (isset($this->fbGalleryAlbumId) && (!empty($this->fbGalleryAlbumId)))
154 if (is_string($this->fbGalleryAlbumId))
160 die (
"Album ID is set, but not a string value! Please check your photo album ID.");
165 die (
"Album ID is not set. Please add your photo album ID.");
174 if ($this->jsSDKLoaded ==
'false')
218 if ($this->fbGalleryType ==
"all")
221 $this->sinceDate =
date(
'Y-01-01', strtotime(
'-' . $this->fbGalleryYearRange .
' years'));
222 $this->untilDate =
date(
'Y-01-01', strtotime(
'+' . $this->fbGalleryYearRange .
' years'));
224 elseif ($this->fbGalleryType ==
"future")
227 $this->sinceDate =
date(
'Y-m-d');
228 $this->untilDate =
date(
'Y-12-31', strtotime(
'+' . $this->fbGalleryYearRange .
' years'));
230 elseif ($this->fbGalleryType ==
"past")
233 $this->sinceDate =
date(
'Y-01-01', strtotime(
'-' . $this->fbGalleryYearRange .
' years'));
234 $this->untilDate =
date(
'Y-m-d');
239 $this->sinceDate =
date(
'Y-m-d');
240 $this->untilDate =
date(
'Y-12-31', strtotime(
'+' . $this->fbGalleryYearRange .
' years'));
244 if (isset($this->fbGalleryStartDate) && (!empty($this->fbGalleryStartDate))
245 && (isset($this->fbGalleryEndDate) && (!empty($this->fbGalleryEndDate))))
247 $this->sinceDate =
date($this->fbGalleryStartDate);
248 $this->untilDate =
date($this->fbGalleryEndDate);
252 $since_unix_timestamp = strtotime($this->sinceDate);
253 $until_unix_timestamp = strtotime($this->untilDate);
256 if (isset($this->fbGalleryFields) && (!empty($this->fbGalleryFields)))
258 $fieldsMarkup =
"?fields={$this->fbGalleryFields}";
266 $json_link =
"https://graph.facebook.com/v3.3/{$this->fbGalleryAlbumId}/photos$fieldsMarkup&access_token={$this->fbGalleryAccessToken}";
270 curl_setopt($curl, CURLOPT_URL, $json_link);
271 curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
272 $this->apiObject = json_decode(curl_exec($curl),
true, 512, JSON_BIGINT_AS_STRING);
286 if (isset($this->apiObject[
'data']) && (!empty($this->apiObject[
'data'])))
307 if (isset($this->apiObject[
'data']) && (!empty($this->apiObject))) {
310 if (is_string($this->fbGallerySortation) && ($this->fbGallerySortation ==
"desc"))
313 $this->apiObject[
'data'] = array_reverse($this->apiObject[
'data']);
317 elseif ($this->fbGallerySortation ==
"shuffle")
319 shuffle($this->apiObject[
'data']);
323 if ($this->fbGalleryLimit > 0 && ($this->fbGalleryLimit != 25))
325 $this->apiObject[
'data'] = array_slice($this->apiObject[
'data'], 0, $this->fbGalleryLimit);
329 if (!isset($this->fbGalleryLayout) || (empty($this->fbGalleryLayout)))
331 $this->fbGalleryLayout = 6;
335 if (isset($this->fbGalleryHeading) && (!empty($this->fbGalleryHeading)))
338 $this->fbGalleryHeading =
"$this->fbGalleryHeading";
342 $this->fbGalleryHeading =
'';
346 if (isset($this->fbGallerySubtext) && (!empty($this->fbGallerySubtext)))
349 $this->fbGallerySubtext =
"<small>$this->fbGallerySubtext</small>";
353 $this->fbGallerySubtext =
'';
357 echo
"<div class=\"row padding\"><div class=\"col-md-12\"><h1>$this->fbGalleryHeading $this->fbGallerySubtext</h1></div></div>";
362 echo
"<div class=\"row padding\">";
363 foreach ($this->apiObject[
'data'] as $property =>
$value)
366 if (isset(
$i) && (
$i <= 3))
368 $animateMarkup =
'animated fadeIn';
372 $animateMarkup =
"animate";
378 if (isset($this->fbGalleryImageInfo) && (!empty($this->fbGalleryImageInfo)))
381 $this->fbGalleryImageInfo =
$value[
'name'];
385 $this->fbGalleryImageInfo =
'';
389 $randomInt = rand(1,4);
392 $imgClass =
"img-lefty";
394 elseif ($randomInt == 2)
396 $imgClass =
"img-lefty-less";
398 elseif ($randomInt == 3)
400 $imgClass =
"img-righty";
402 elseif ($randomInt == 4)
404 $imgClass =
"img-righty-less";
418 $fn =
$value[
'images'][0][
'source'];
420 echo
"<div class=\"col-md-$this->fbGalleryLayout text-center $animateMarkup\">
421 <a href=\"$fn\" data-lightbox=\"example-set\" data-title=\"$value[name]\">
422 <img src=\"$fn\" alt=\"$value[name]\" style=\"width:auto; height:$this->fbGalleryFixedImageHeight;\" class=\"img-thumbnail img-fluid ".$imgClass.
" hvr-grow\">
423 </a><br><br><small>$this->fbGalleryImageInfo</small><br><br><hr></div>";
429 die(
"Unable to load Images from Facebook API because the apiObject is not set or empty.");
Settings class: get and set YaWK system settings.