Definition in file panels_simple_cache.module.
Go to the source code of this file.
Functions | |
| panels_simple_cache_admin () | |
| panels_simple_cache_clear_cache ($display) | |
| panels_simple_cache_get_cache ($conf, $display, $args, $contexts, $pane=NULL) | |
| panels_simple_cache_get_id ($conf, $display, $args, $contexts, $pane) | |
| panels_simple_cache_menu ($may_cache) | |
| panels_simple_cache_panels_cache () | |
| panels_simple_cache_set_cache ($conf, $content, $display, $args, $contexts, $pane=NULL) | |
| panels_simple_cache_settings_form ($conf, $display, $pid) | |
| panels_simple_cache_admin | ( | ) |
Page callback for the very short admin page.
Definition at line 31 of file panels_simple_cache.module.
00031 { 00032 $output = '<p>'; 00033 $output .= t('Panels simple cache does not have a normal administrative UI, such as panels pages or mini panels. With this module, you are given the option to add caching features to any panel display in panel pages, mini panels, panel nodes or any other displays provided by other modules or plugins. These options are available as an icon on each pane of the edit content pane.'); 00034 $output .= '</p><p>'; 00035 $output .= t('This module provides only very simple, time-based caching; it is not at all suitable if your content will change at all per user (and this can mean administrative additions that are just visible to you) as all users will see the same content; it is provided mostly as a reference implementation for other, smarter caching modules.'); 00036 $output .= '</p>'; 00037 return $output; 00038 }
| panels_simple_cache_clear_cache | ( | $ | display | ) |
Clear cached content.
Cache clears are always for an entire display, regardless of arguments.
Definition at line 86 of file panels_simple_cache.module.
00086 { 00087 $cid = 'panels_simple_cache'; 00088 00089 // This is used in case this is an in-code display, which means did will be something like 'new-1'. 00090 if (isset($display->owner) && isset($display->owner->id)) { 00091 $cid .= ':' . $display->owner->id; 00092 } 00093 $cid .= ':' . $display->did; 00094 00095 cache_clear_all($cid, 'cache', TRUE); 00096 }
| panels_simple_cache_get_cache | ( | $ | conf, | |
| $ | display, | |||
| $ | args, | |||
| $ | contexts, | |||
| $ | pane = NULL | |||
| ) |
Get cached content.
Definition at line 59 of file panels_simple_cache.module.
References panels_simple_cache_get_id().
00059 { 00060 $cid = panels_simple_cache_get_id($conf, $display, $args, $contexts, $pane); 00061 $cache = cache_get($cid, 'cache'); 00062 if (!$cache) { 00063 return FALSE; 00064 } 00065 00066 if ((time() - $cache->created) > $conf['lifetime']) { 00067 return FALSE; 00068 } 00069 00070 return unserialize($cache->data); 00071 }
| panels_simple_cache_get_id | ( | $ | conf, | |
| $ | display, | |||
| $ | args, | |||
| $ | contexts, | |||
| $ | pane | |||
| ) |
Figure out an id for our cache based upon input and settings.
Definition at line 101 of file panels_simple_cache.module.
Referenced by panels_simple_cache_get_cache(), and panels_simple_cache_set_cache().
00101 { 00102 $id = 'panels_simple_cache'; 00103 00104 // This is used in case this is an in-code display, which means did will be something like 'new-1'. 00105 if (isset($display->owner) && isset($display->owner->id)) { 00106 $id .= ':' . $display->owner->id; 00107 } 00108 $id .= ':' . $display->did; 00109 00110 if ($pane) { 00111 $id .= ':' . $pane->pid; 00112 } 00113 00114 if (user_access('view pane admin links')) { 00115 $id .= ':admin'; 00116 } 00117 00118 switch ($conf['granularity']) { 00119 case 'args': 00120 foreach ($args as $arg) { 00121 $id .= ':' . $arg; 00122 } 00123 break; 00124 00125 case 'context': 00126 if (!is_array($contexts)) { 00127 $contexts = array($contexts); 00128 } 00129 foreach ($contexts as $context) { 00130 if (isset($context->argument)) { 00131 $id .= ':' . $context->argument; 00132 } 00133 } 00134 } 00135 return $id; 00136 }
| panels_simple_cache_menu | ( | $ | may_cache | ) |
Implementation of hook_menu().
Definition at line 14 of file panels_simple_cache.module.
00014 { 00015 if ($may_cache) { 00016 $items[] = array( 00017 'path' => 'admin/panels/simple-cache', 00018 'title' => t('Simple cache'), 00019 'access' => user_access('access administration pages') && user_access('use panels caching features'), 00020 'type' => MENU_NORMAL_ITEM, 00021 'callback' => 'panels_simple_cache_admin', 00022 'description' => t('Information about Panels simple cache.'), 00023 ); 00024 return $items; 00025 } 00026 }
| panels_simple_cache_panels_cache | ( | ) |
Implementation of hook_panels_cache()
Definition at line 43 of file panels_simple_cache.module.
00043 { 00044 $cache['simple'] = array( 00045 'title' => t("Simple cache"), 00046 'description' => t('Simple caching is a time-based cache. This is a hard limit, and once cached it will remain that way until the time limit expires.'), 00047 'cache get' => 'panels_simple_cache_get_cache', 00048 'cache set' => 'panels_simple_cache_set_cache', 00049 'cache clear' => 'panels_simple_cache_clear_cache', 00050 'settings form' => 'panels_simple_cache_settings_form', 00051 'settings form submit' => 'panels_simple_cache_settings_form_submit', 00052 ); 00053 return $cache; 00054 }
| panels_simple_cache_set_cache | ( | $ | conf, | |
| $ | content, | |||
| $ | display, | |||
| $ | args, | |||
| $ | contexts, | |||
| $ | pane = NULL | |||
| ) |
Set cached content.
Definition at line 76 of file panels_simple_cache.module.
References panels_simple_cache_get_id().
00076 { 00077 $cid = panels_simple_cache_get_id($conf, $display, $args, $contexts, $pane); 00078 cache_set($cid, 'cache', serialize($content)); 00079 }
| panels_simple_cache_settings_form | ( | $ | conf, | |
| $ | display, | |||
| $ | pid | |||
| ) |
Definition at line 138 of file panels_simple_cache.module.
00138 { 00139 $options = drupal_map_assoc(array(15, 30, 60, 120, 180, 240, 300, 600, 900, 1200, 1800, 3600, 7200, 14400, 28800, 43200, 86400, 172800, 259200, 345600, 604800), 'format_interval'); 00140 $form['lifetime'] = array( 00141 '#title' => t('Lifetime'), 00142 '#type' => 'select', 00143 '#options' => $options, 00144 '#default_value' => $conf['lifetime'], 00145 ); 00146 00147 $form['granularity'] = array( 00148 '#title' => t('Granularity'), 00149 '#type' => t('select'), 00150 '#options' => array( 00151 'args' => t('Arguments'), 00152 'context' => t('Context'), 00153 'none' => t('None'), 00154 ), 00155 '#description' => t('If "arguments" are selected, this content will be cached per individual argument to the entire display; if "contexts" are selected, this content will be cached per unique context in the pane or display; if "neither" there will be only one cache for this pane.'), 00156 '#default_value' => $conf['granularity'], 00157 ); 00158 00159 return $form; 00160 }
1.5.6