View source
<?php
namespace Drupal\elevatezoomplus\Entity;
use Drupal\slick\Entity\SlickBase;
class ElevateZoomPlus extends SlickBase implements ElevateZoomPlusInterface {
const TABLE = 'elevatezoomplus_optionset';
public static function create(array $values = []) {
ctools_include('export');
$optionset = ctools_export_crud_new(static::TABLE);
$optionset->options = $optionset->options['settings'] = [];
foreach (self::defaultProperties() as $key => $ignore) {
if (isset($values[$key])) {
$optionset->{$key} = $values[$key];
}
}
if (empty($values['label']) && isset($values['name'])) {
$optionset->label = $values['name'];
}
$defaults['settings'] = self::defaultSettings();
$optionset->options = $optionset->options + $defaults;
return $optionset;
}
public static function typecast(array &$settings = []) {
if (empty($settings)) {
return;
}
$defaults = self::defaultSettings();
foreach ($defaults as $name => $value) {
if (isset($settings[$name])) {
$type = gettype($defaults[$name]);
$type = $type == 'double' ? 'float' : $type;
if ($name == 'lensOpacity' || $name == 'tintOpacity') {
$type = $settings[$name] == '0' || $settings[$name] == '1' ? 'integer' : 'float';
}
settype($settings[$name], $type);
}
}
}
public static function defaultSettings() {
if (!isset(static::$defaultSettings)) {
static::$defaultSettings = [
'responsive' => FALSE,
'zoomType' => 'window',
'zoomWindowWidth' => 400,
'zoomWindowHeight' => 400,
'zoomWindowOffsetX' => 0,
'zoomWindowOffsetY' => 0,
'zoomWindowPosition' => '1',
'zoomWindowFadeIn' => FALSE,
'zoomWindowFadeOut' => FALSE,
'zoomTintFadeIn' => FALSE,
'zoomTintFadeOut' => FALSE,
'scrollZoom' => FALSE,
'easing' => FALSE,
'easingType' => 'zoomdefault',
'easingDuration' => 2000,
'borderSize' => 4,
'borderColour' => '#888',
'showLens' => TRUE,
'containLensZoom' => FALSE,
'lensBorder' => 1,
'lensShape' => 'square',
'lensSize' => 200,
'lensFadeIn' => FALSE,
'lensFadeOut' => FALSE,
'lensColour' => 'white',
'lensOpacity' => 0.4,
'lenszoom' => FALSE,
'tint' => FALSE,
'tintColour' => '#333',
'tintOpacity' => 0.4,
'constrainType' => '',
'constrainSize' => '',
'imageCrossfade' => FALSE,
'cursor' => 'default',
'loadingIcon' => '',
];
}
return static::$defaultSettings;
}
}