View source
<?php
define('CLOUD_ZOOM_STORAGE_NORMAL', 0);
define('CLOUD_ZOOM_STORAGE_DEFAULT', 1);
define('CLOUD_ZOOM_STORAGE_OVERRIDE', 2);
function cloud_zoom_help($path, $args) {
switch ($path) {
case 'admin/settings/cloudzoom':
return t('Available fields are listed below. You can modify the settings for each by clicking edit');
}
}
function cloud_zoom_menu() {
$items = array();
$items['admin/settings/cloudzoom'] = array(
'title' => 'Cloud Zoom',
'description' => 'Configure the Cloud Zoom display features',
'page callback' => 'cloud_zoom_admin_overview',
'file' => 'cloud_zoom.admin.inc',
'access arguments' => array(
'configure cloud zoom field display',
),
);
$items['admin/settings/cloudzoom/overview'] = array(
'title' => 'Overview',
'access arguments' => array(
'configure cloud zoom field display',
),
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => -10,
);
$base = array(
'title callback' => 'cloud_zoom_admin_preset_title',
'access arguments' => array(
'configure cloud zoom field display',
),
'page callback' => 'drupal_get_form',
'file' => 'cloud_zoom.admin.inc',
'type' => MENU_CALLBACK,
);
$items['admin/settings/cloudzoom/add'] = array(
'title' => 'Add',
'title callback' => NULL,
'page arguments' => array(
'cloud_zoom_admin_preset_edit_form',
),
'type' => MENU_LOCAL_TASK,
) + $base;
$items['admin/settings/cloudzoom/%cloud_zoom_preset_name/edit'] = array(
'title arguments' => array(
3,
'Edit',
),
'page arguments' => array(
'cloud_zoom_admin_preset_edit_form',
3,
),
) + $base;
$items['admin/settings/cloudzoom/%cloud_zoom_preset_name/delete'] = array(
'title arguments' => array(
3,
'Delete',
),
'page arguments' => array(
'cloud_zoom_admin_preset_delete_confirm',
3,
),
) + $base;
$items['admin/settings/cloudzoom/%cloud_zoom_preset_name/revert'] = array(
'title arguments' => array(
3,
'Revert',
),
'page arguments' => array(
'cloud_zoom_admin_preset_revert_confirm',
3,
),
) + $base;
return $items;
}
function cloud_zoom_admin_preset_title($preset, $operation) {
return t('Cloud Zoom - @operation - @name', array(
'@operation' => t($operation),
'@name' => $preset['name'],
));
}
function cloud_zoom_preset_name_load($preset_name) {
return cloud_zoom_get_settings($preset_name);
}
function cloud_zoom_field_formatter_info() {
$formatters = array();
$settings = cloud_zoom_get_settings();
foreach ($settings as $key => $values) {
$formatters['imagefield__cloud_zoom__' . $key] = array(
'label' => t('Cloud Zoom: !presetname', array(
'!presetname' => $key,
)),
'field types' => array(
'filefield',
),
);
}
return $formatters;
}
function cloud_zoom_theme() {
$theme = array(
'cloud_zoom_formatter_imagefield' => array(
'arguments' => array(
'element' => NULL,
),
'file' => 'cloud_zoom.theme.inc',
),
'cloud_zoom_admin_settings_table' => array(
'arguments' => array(
'element' => NULL,
),
'file' => 'cloud_zoom.theme.inc',
),
);
$presets = cloud_zoom_get_settings();
foreach ($presets as $preset) {
$theme['cloud_zoom_formatter_imagefield__cloud_zoom__' . $preset['name']] = array(
'arguments' => array(
'element' => NULL,
),
'function' => 'theme_cloud_zoom_formatter_imagefield',
'file' => 'cloud_zoom.theme.inc',
);
}
return $theme;
}
function cloud_zoom_imagecache_default_presets() {
return array(
array(
'presetname' => 'cloud_zoom_small',
'actions' => array(
array(
'weight' => 0,
'module' => 'cloud_zoom',
'action' => 'imagecache_scale',
'data' => array(
'width' => 240,
'height' => '',
'upscale' => 0,
),
),
),
),
array(
'presetname' => 'cloud_zoom_large',
'actions' => array(
array(
'weight' => 0,
'module' => 'cloud_zoom',
'action' => 'imagecache_scale',
'data' => array(
'width' => 768,
'height' => '',
'upscale' => 0,
),
),
),
),
);
}
function _cloud_zoom_default_settings() {
return array(
'zoomWidth' => array(
'default' => 'auto',
'quoted' => TRUE,
'description' => 'The width of the zoom window in pixels. If \'auto\' is specified, the width will be the same as the small image.',
),
'zoomHeight' => array(
'default' => 'auto',
'quoted' => TRUE,
'description' => 'The height of the zoom window in pixels. If \'auto\' is specified, the height will be the same as the small image.',
),
'position' => array(
'default' => 'right',
'quoted' => TRUE,
'description' => 'Specifies the position of the zoom window relative to the small image. <br />Allowable values are \'left\', \'right\', \'top\', \'bottom\', \'inside\' or you can specifiy the id of an html element to place the zoom window in e.g. position: \'element1\'',
),
'adjustX' => array(
'default' => 0,
'quoted' => FALSE,
'description' => 'Allows you to fine tune the x-position of the zoom window in pixels.',
),
'adjustY' => array(
'default' => 0,
'quoted' => FALSE,
'description' => 'Allows you to fine tune the y-position of the zoom window in pixels.',
),
'tint' => array(
'default' => 'false',
'quoted' => FALSE,
'description' => 'Specifies a tint colour which will cover the small image. Colours should be specified in hex format, e.g. \'#aa00aa\'. Does not work with softFocus.',
),
'tintOpacity' => array(
'default' => 0.5,
'quoted' => FALSE,
'description' => 'Opacity of the tint, where 0 is fully transparent, and 1 is fully opaque.',
),
'lensOpacity' => array(
'default' => 0.5,
'quoted' => FALSE,
'description' => 'Opacity of the lens mouse pointer, where 0 is fully transparent, and 1 is fully opaque. In tint and soft-focus modes, it will always be transparent.',
),
'softFocus' => array(
'default' => 'false',
'quoted' => FALSE,
'description' => 'Applies a subtle blur effect to the small image. Set to true or false. Does not work with tint.',
),
'smoothMove' => array(
'default' => 3,
'quoted' => FALSE,
'description' => 'Amount of smoothness/drift of the zoom image as it moves. The higher the number, the smoother/more drifty the movement will be. 1 = no smoothing.',
),
'showTitle' => array(
'default' => 'true',
'quoted' => FALSE,
'description' => 'Shows the title tag of the image. True or false.',
),
'titleOpacity' => array(
'default' => 0.5,
'quoted' => FALSE,
'description' => 'Specifies the opacity of the title if displayed, where 0 is fully transparent, and 1 is fully opaque.',
),
);
}
function cloud_zoom_cloud_zoom_preset_info() {
return array(
'default' => array(
'name' => 'default',
'settings' => array(),
'view_preset' => 'cloud_zoom_small',
'zoom_preset' => 'cloud_zoom_large',
),
);
}
function cloud_zoom_get_settings($preset_name = NULL, $reset = FALSE) {
if (variable_get('cloud_zoom_schema_version', 0) < 6001) {
return array();
}
static $settings = NULL;
if ($reset) {
$settings = NULL;
cache_clear_all('cloud_zoom:presets', 'cache');
}
if (!isset($settings)) {
if (($cache = cache_get('cloud_zoom:presets', 'cache')) && is_array($cache->data)) {
$settings = $cache->data;
}
else {
$settings = array();
$result = db_query('SELECT * FROM {cloud_zoom_presets}');
while ($preset = db_fetch_array($result)) {
$preset['storage'] = CLOUD_ZOOM_STORAGE_NORMAL;
$preset['settings'] = unserialize($preset['settings']);
$settings[$preset['name']] = $preset;
}
$default_presets = module_invoke_all('cloud_zoom_preset_info');
drupal_alter('cloud_zoom_preset_info', $default_presets);
foreach ($default_presets as $preset) {
if (!empty($preset['name'])) {
if (isset($settings[$preset['name']])) {
$settings[$preset['name']]['storage'] = CLOUD_ZOOM_STORAGE_OVERRIDE;
}
else {
$preset['storage'] = CLOUD_ZOOM_STORAGE_DEFAULT;
$settings[$preset['name']] = $preset;
}
}
}
cache_set('cloud_zoom:presets', $settings);
}
}
if ($preset_name) {
return isset($settings[$preset_name]) ? $settings[$preset_name] : FALSE;
}
return $settings;
}
function cloud_zoom_features_api() {
return array(
'cloud_zoom_preset' => array(
'name' => t('Cloud Zoom Presets'),
'default_hook' => 'cloud_zoom_preset_info',
'default_file' => 'FEATURES_DEFAULTS_INCLUDED_COMMON',
'features_source' => TRUE,
'file' => drupal_get_path('module', 'cloud_zoom') . '/cloud_zoom.features.inc',
),
);
}