Index: donations_thermometer.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/donations_thermometer/donations_thermometer.module,v retrieving revision 1.2 diff -u -p -r1.2 donations_thermometer.module --- donations_thermometer.module 13 May 2010 13:11:56 -0000 1.2 +++ donations_thermometer.module 13 May 2010 14:59:43 -0000 @@ -36,6 +36,17 @@ function donations_thermometer_perm() { return array('administer progress bar'); } // function onthisdate_perm() +/** + * Implementation of hook_theme(). + */ +function donations_thermometer_theme($existing, $type, $theme, $path) { + return array( + 'donations_thermometer' => array( + 'arguments' => array('amount' => NULL, 'target' => NULL, 'currency' => NULL, 'size' => NULL), + ), + ); +} + function donations_thermometer_block($op='list', $delta=0) { // listing of blocks, such as on the admin/block page if ($op == "list") { @@ -43,34 +54,33 @@ function donations_thermometer_block($op return $block; } else if ($op == 'view') { - - // set up the block - drupal_add_js(drupal_get_path('module', 'donations_thermometer') .'/donations_thermometer.js'); - drupal_add_css(drupal_get_path('module', 'donations_thermometer') .'/donations_thermometer.css'); - - - - $amount = variable_get('donations_thermometer_amount', 50); $target = variable_get('donations_thermometer_target', 100); - $percent = ($amount/$target)*100; $currency = variable_get('donations_thermometer_currency', '$'); $size = variable_get('donations_thermometer_size', 'large'); $block['subject'] = 'Donations Thermometer'; - $block['content'] = ' - -
+ $block['content'] = theme('donations_thermometer', $amount, $target, $currency, $size); + + return $block; + } +} + +/** + * Theme a donations thermometer. + */ +function theme_donations_thermometer($amount, $target, $currency, $size = 'large') { + drupal_add_js(drupal_get_path('module', 'donations_thermometer') .'/donations_thermometer.js'); + drupal_add_css(drupal_get_path('module', 'donations_thermometer') .'/donations_thermometer.css'); + + $percent = ($amount/$target)*100; + return '
-
+

'. $percent .'%

-

Current Amount: '. $currency . $amount .'

Target: '. $currency . $target - .'

';//$block_content; - return $block; - } +

Current Amount: '. $currency . $amount .'

Target: '. $currency . $target .'

'; } function donations_thermometer_admin() {