function views_content_cache_plugin_cache::options_form in Views content cache 6.2
Same name and namespace in other branches
- 7.3 views/views_content_cache_plugin_cache.inc \views_content_cache_plugin_cache::options_form()
File
- views/
views_content_cache_plugin_cache.inc, line 27
Class
- views_content_cache_plugin_cache
- Simple caching of query results for Views displays. Includes listening for changes/posts/deletions of certain node types.
Code
function options_form(&$form, &$form_state) {
$form['keys'] = array(
'#title' => t('Cache segments'),
'#type' => 'fieldset',
'#description' => t("Content cache keeps track of the time that the certain events occured on your site, the last time a node was commented on in a particular group, or the last time a vote was cast. Views can then use these times to work out whether to serve the view from cached data or not. You can specify which segments you want to be factored into computing the last time content was updated. For example, if your view is of the latest 'Page' nodes, then you can check the boxes to factor in the 'Page' node type, and then further restrict to just nodes that have been updated/created/deleted. Hard limts of min and max lifetimes are available below."),
);
foreach (views_content_cache_get_plugin() as $key_id => $plugin) {
$option_value = isset($this->options['keys'][$plugin
->clause_mode()][$key_id]) ? $this->options['keys'][$plugin
->clause_mode()][$key_id] : array();
$form['keys'][$plugin
->clause_mode()][$key_id] = $plugin
->options_form($option_value, $this);
}
// Add the descriptive fieldsets.
if (!empty($form['keys']['AND'])) {
$form['keys']['AND'] += array(
'#type' => 'fieldset',
'#title' => t('Conditions to AND'),
'#description' => t("The condiditons in this section will get AND'd together to further refine when to serve from the cache. For example, you can factor in when anything happens to a 'page' node or refine so that when a comment is posted on a 'page' node, or when a new 'page' node is created."),
);
}
if (!empty($form['keys']['OR'])) {
$form['keys']['OR'] += array(
'#type' => 'fieldset',
'#title' => t('Conditions to OR'),
'#description' => t("These conditions will get OR'd together with the ones above in the AND section. The most recent of all events will be used to determine the cache to use."),
);
}
$options = array(
60,
300,
1800,
3600,
21600,
518400,
);
$options = drupal_map_assoc($options, 'format_interval');
$min_options = array(
-1 => t('None'),
) + $options;
$max_options = array(
-1 => t('None'),
) + $options + array(
-2 => t('Never cache'),
);
$form['results_min_lifespan'] = array(
'#type' => 'select',
'#title' => t('Query results - Minimum lifetime'),
'#description' => t('Query results will be cached for <strong>at least</strong> this amount of time, even if a selected event has occured more recently.'),
'#options' => $min_options,
'#default_value' => $this->options['results_min_lifespan'],
);
$form['results_max_lifespan'] = array(
'#type' => 'select',
'#title' => t('Query results - Maximum lifetime'),
'#description' => t('Query results will be cached for <strong>at most</strong> this amount of time.'),
'#options' => $max_options,
'#default_value' => $this->options['results_max_lifespan'],
);
$form['output_min_lifespan'] = array(
'#type' => 'select',
'#title' => t('Rendered output - Minimum lifetime'),
'#description' => t('Rendered HTML output will be cached for <strong>at least</strong> this amount of time, even if a selected event has occured more recently.'),
'#options' => $min_options,
'#default_value' => $this->options['output_min_lifespan'],
);
$form['output_max_lifespan'] = array(
'#type' => 'select',
'#title' => t('Rendered output - Maximum lifetime'),
'#description' => t('Rendered HTML output will be cached for <strong>at most</strong> this amount of time.'),
'#options' => $max_options,
'#default_value' => $this->options['output_max_lifespan'],
);
}