function cloud_zoom_get_settings in Cloud Zoom 6
Function to get the cloud_zoom settings Settings are cached both statically and in the cache table for performance.
12 calls to cloud_zoom_get_settings()
- cloud_zoom_admin_overview in ./
cloud_zoom.admin.inc - The admin overview page callback - provides a table of fields configured with the cloud_zoom display settings
- cloud_zoom_admin_preset_delete_confirm_submit in ./
cloud_zoom.admin.inc - Delete preset confirm form submit hanlder
- cloud_zoom_admin_preset_edit_form_submit_save in ./
cloud_zoom.admin.inc - Submit handler for the save button - this saves any settings which differ from the defaults. If there are no differing options, the sub-section is removed.
- cloud_zoom_admin_preset_edit_form_validate in ./
cloud_zoom.admin.inc - Validate handler for the above form
- cloud_zoom_field_formatter_info in ./
cloud_zoom.module - Implementation of hook_field_formatter().
File
- ./
cloud_zoom.module, line 229 - This module integrates the Cloud Zoom JQuery library from: http://www.professorcloud.com/mainsite/cloud-zoom.htm
Code
function cloud_zoom_get_settings($preset_name = NULL, $reset = FALSE) {
if (variable_get('cloud_zoom_schema_version', 0) < 6001) {
return array();
}
// Static settings cache variable
static $settings = NULL;
// If we're resetting, clear static and cache table
if ($reset) {
$settings = NULL;
cache_clear_all('cloud_zoom:presets', 'cache');
}
// If settings are not set, lets define them
if (!isset($settings)) {
// First, try to get from the cache table
if (($cache = cache_get('cloud_zoom:presets', 'cache')) && is_array($cache->data)) {
$settings = $cache->data;
}
else {
// Initialize the settings
$settings = array();
// Get anything we have defined from the DB
$result = db_query('SELECT * FROM {cloud_zoom_presets}');
while ($preset = db_fetch_array($result)) {
// Mark as "normal" items
$preset['storage'] = CLOUD_ZOOM_STORAGE_NORMAL;
$preset['settings'] = unserialize($preset['settings']);
// Store the preset
$settings[$preset['name']] = $preset;
}
// Now loop over the hook to get any module defined presets, using
// hook_cloud_zoom_default_presets().
$default_presets = module_invoke_all('cloud_zoom_preset_info');
// Allow other modules to alter the module-defined presets using:
// hook_cloud_zoom_default_presets_alter(&$default_presets)
drupal_alter('cloud_zoom_preset_info', $default_presets);
// Add each defined preset to our list...
foreach ($default_presets as $preset) {
// ... but only if a name is set!
if (!empty($preset['name'])) {
// If the name is already in our settings, then we have overridden a module-level item
if (isset($settings[$preset['name']])) {
// Set the preset as 'overridden', but do not store the module defined preset
$settings[$preset['name']]['storage'] = CLOUD_ZOOM_STORAGE_OVERRIDE;
}
else {
// Store the preset as a default store
$preset['storage'] = CLOUD_ZOOM_STORAGE_DEFAULT;
$settings[$preset['name']] = $preset;
}
}
}
// Cache it for later use
cache_set('cloud_zoom:presets', $settings);
}
}
// Did we ask for a SPECIFIC preset by name? If so, return it (or FALSE if
// it is not available)
if ($preset_name) {
return isset($settings[$preset_name]) ? $settings[$preset_name] : FALSE;
}
// Otherwise, return ALL settings
return $settings;
}