source: sipei/modules/views/plugins/views_plugin_cache_time.inc

drupal-6.x
Last change on this file was ffa4103, checked in by Luis Peña <lpena@…>, 12 años ago

Cambiando el nombre de modulos a modules

  • Propiedad mode establecida a 100755
File size: 1.5 KB
Línea 
1<?php
2// $Id: views_plugin_cache_time.inc,v 1.3 2009/06/30 21:57:22 merlinofchaos Exp $
3
4/**
5 * Simple caching of query results for Views displays.
6 */
7class views_plugin_cache_time extends views_plugin_cache {
8  function option_defaults(&$options) {
9    $options['results_lifespan'] = 3600;
10    $options['output_lifespan'] = 3600;
11  }
12
13  function options_form(&$form, &$form_state) {
14    $options = array(60, 300, 1800, 3600, 21600, 518400);
15    $options = drupal_map_assoc($options, 'format_interval');
16    $options = array(-1 => t('Never cache')) + $options;
17
18    $form['results_lifespan'] = array(
19      '#type' => 'select',
20      '#title' => t('Query results'),
21      '#description' => t('The length of time raw query results should be cached.'),
22      '#options' => $options,
23      '#default_value' => $this->options['results_lifespan'],
24    );
25    $form['output_lifespan'] = array(
26      '#type' => 'select',
27      '#title' => t('Rendered output'),
28      '#description' => t('The length of time rendered HTML output should be cached.'),
29      '#options' => $options,
30      '#default_value' => $this->options['output_lifespan'],
31    );
32  }
33
34  function summary_title() {
35    return format_interval($this->options['results_lifespan'], 1) . '/' . format_interval($this->options['output_lifespan'], 1);
36  }
37
38  function cache_expire($type) {
39    if ($lifespan = $this->options[$type . '_lifespan']) {
40      $cutoff = time() - $lifespan;
41      return $cutoff;
42    }
43    else {
44      return FALSE;
45    }
46  }
47
48}
Nota: Vea TracBrowser para ayuda de uso del navegador del repositorio.