diff --git a/tagadelic.module b/tagadelic.module index 9aee951..839f361 100644 --- a/tagadelic.module +++ b/tagadelic.module @@ -2,6 +2,12 @@ // $Id: tagadelic.module,v 1.40.2.4 2008/12/31 11:35:44 ber Exp $ /** + * @file + * + * Tagadelic makes weighted tag clouds from your taxonomy terms. + */ + +/** * Implementation of hook_help */ function tagadelic_help($path, $arg) { @@ -64,8 +70,15 @@ function tagadelic_menu() { * You will have a nice variable in $node available for processing tags! */ function tagadelic_nodeapi(&$node, $op, $teaser, $page) { - if ($op == 'load') { - $node->tags = tagadelic_node_get_terms($node); + switch ($op) { + case 'load': + $node->tags = tagadelic_node_get_terms($node); + break; + case 'presave': + if (variable_get('tagadelic_clear_on_save', 0) == 1) { + _tagadelic_clear_cache(); + } + break; } } @@ -95,6 +108,14 @@ function tagadelic_settings() { '#default_value' => variable_get('tagadelic_levels', 6), '#description' => t('The number of levels between the least popular tags and the most popular ones. Different levels will be assigned a different class to be themed in tagadelic.css'), ); + $form['tagadelic_clear_on_save'] = array( + '#type' => 'radios', + '#title' => t('Update blocks on save'), + '#default_value' => variable_get('tagadelic_clear_on_save', 0), + '#description' => t('By default tagadelic blocks are updated when cron runs. If you enable this setting it will also happen each time a post (any post) is saved.'), + '#options' => array(t('Update only on cron'), + t('Update on save and cron')), + ); return system_settings_form($form); } @@ -397,3 +418,11 @@ function tagadelic_theme() { 'tagadelic_weighted' => array('arguments' => array('terms' => NULL)) ); } + +/** + * Clear tagadelic cache + */ +function _tagadelic_clear_cache() { + db_query("DELETE FROM {cache} WHERE cid LIKE 'tagadelic_cache_%'"); +} +