| 1 |
<?php |
| 2 |
namespace Photonic_Plugin\Core; |
| 3 |
|
| 4 |
use Photonic_Plugin\Layouts\Core_Layout; |
| 5 |
use Photonic_Plugin\Layouts\Grid; |
| 6 |
use Photonic_Plugin\Layouts\Slideshow; |
| 7 |
use Photonic_Plugin\Modules\Core; |
| 8 |
use Photonic_Plugin\Modules\Flickr; |
| 9 |
use Photonic_Plugin\Modules\Google_Photos; |
| 10 |
use Photonic_Plugin\Modules\Instagram; |
| 11 |
use Photonic_Plugin\Modules\Native; |
| 12 |
use Photonic_Plugin\Modules\SmugMug; |
| 13 |
use Photonic_Plugin\Modules\Zenfolio; |
| 14 |
|
| 15 |
class Gallery { |
| 16 |
private $attr; |
| 17 |
/** @var Core */ |
| 18 |
private $module; |
| 19 |
|
| 20 |
/** @var Core_Layout */ |
| 21 |
private $layout; |
| 22 |
|
| 23 |
function __construct($attr) { |
| 24 |
$this->attr = $attr; |
| 25 |
$type = $this->attr['type']; |
| 26 |
|
| 27 |
$this->set_module($type); |
| 28 |
|
| 29 |
if ((!empty($attr['layout']) && in_array($type, ['flickr', 'smugmug', 'google', 'zenfolio', 'instagram']) && in_array($attr['layout'], ['strip-above', 'strip-below', 'strip-right', 'no-strip'])) || |
| 30 |
(!empty($attr['style']) && $type == 'default' && in_array($attr['style'], ['default', 'strip-above', 'strip-below', 'strip-right', 'no-strip']))) { |
| 31 |
require_once(PHOTONIC_PATH.'/Layouts/Slideshow.php'); |
| 32 |
$this->layout = Slideshow::get_instance(); |
| 33 |
} |
| 34 |
else { |
| 35 |
require_once(PHOTONIC_PATH.'/Layouts/Grid.php'); |
| 36 |
$this->layout = Grid::get_instance(); |
| 37 |
} |
| 38 |
} |
| 39 |
|
| 40 |
private function set_module($type) { |
| 41 |
if ($type == 'flickr') { |
| 42 |
require_once(PHOTONIC_PATH."/Modules/Flickr.php"); |
| 43 |
$this->module = Flickr::get_instance(); |
| 44 |
} |
| 45 |
else if ($type == 'smugmug' || $type == 'smug') { |
| 46 |
require_once(PHOTONIC_PATH."/Modules/SmugMug.php"); |
| 47 |
$this->module = SmugMug::get_instance(); |
| 48 |
} |
| 49 |
else if ($type == 'google') { |
| 50 |
require_once(PHOTONIC_PATH."/Modules/Google_Photos.php"); |
| 51 |
$this->module = Google_Photos::get_instance(); |
| 52 |
} |
| 53 |
else if ($type == 'instagram') { |
| 54 |
require_once(PHOTONIC_PATH."/Modules/Instagram.php"); |
| 55 |
$this->module = Instagram::get_instance(); |
| 56 |
} |
| 57 |
else if ($type == 'zenfolio') { |
| 58 |
require_once(PHOTONIC_PATH."/Modules/Zenfolio.php"); |
| 59 |
$this->module = Zenfolio::get_instance(); |
| 60 |
} |
| 61 |
else { |
| 62 |
require_once(PHOTONIC_PATH."/Modules/Native.php"); |
| 63 |
$this->module = Native::get_instance(); |
| 64 |
} |
| 65 |
} |
| 66 |
|
| 67 |
function get_contents() { |
| 68 |
return $this->module->get_gallery_images($this->attr); |
| 69 |
} |
| 70 |
|
| 71 |
function get_helper_contents() { |
| 72 |
return $this->module->execute_helper($this->attr); |
| 73 |
} |
| 74 |
} |