? d7.patch
Index: fivestar.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/fivestar/fivestar.info,v
retrieving revision 1.3
diff -u -p -r1.3 fivestar.info
--- fivestar.info	14 Jan 2008 08:28:21 -0000	1.3
+++ fivestar.info	26 Jan 2010 02:01:01 -0000
@@ -2,5 +2,9 @@
 name = Fivestar
 description = A simple five-star voting widget for nodes.
 package = Voting
-core = 6.x
-dependencies[] = votingapi
\ No newline at end of file
+core = 7.x
+dependencies[] = votingapi
+files[] = includes/fivestar.admin.inc
+files[] = includes/fivestar.color.inc
+files[] = includes/fivestar.field.inc
+files[] = fivestar.module
Index: fivestar.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/fivestar/fivestar.module,v
retrieving revision 1.32
diff -u -p -r1.32 fivestar.module
--- fivestar.module	3 Nov 2009 04:34:29 -0000	1.32
+++ fivestar.module	26 Jan 2010 02:01:01 -0000
@@ -19,7 +19,7 @@ function fivestar_help($path, $arg) {
         t('Go to <a href="!types">admin/content/types</a> and edit the type you would like to rate.', array('!types' => url('admin/content/types'))),
         t('On the settings page for the content type, a set of options is available for fivestar, where you can enable rating for that type and set rating options.'),
       );
-      $output .= theme('item_list', $steps, NULL, 'ol');
+      $output .= theme('item_list', array('items' => $steps, 'type' => 'ol'));
       break;
     case 'admin/content/node-type/'. $arg[3] .'/fivestar':
       $arg[5] = 'vote';
@@ -70,7 +70,7 @@ function fivestar_menu() {
   // We can't yet add it to the "operations" column in content types, due to a TODO in CCK
   // (content.admin.inc line 32)
 
-  foreach (node_get_types() as $type) {
+  foreach (node_type_get_types() as $type) {
     $type_name = $type->type;
     $type_url_str = str_replace('_', '-', $type_name);
     $items['admin/content/node-type/'. $type_url_str .'/fivestar'] = array(
@@ -105,9 +105,7 @@ function fivestar_menu() {
  * These includes do not need to be loaded for cached pages.
  */
 function fivestar_init() {
-  if (module_exists('content')) {
-    module_load_include('inc', 'fivestar', 'includes/fivestar.field');
-  }
+  module_load_include('inc', 'fivestar', 'includes/fivestar.field');
 
   // Add necessary CSS and JS.
   // TODO: These shouldn't be loaded on every page, but block caching omits
@@ -117,13 +115,22 @@ function fivestar_init() {
 }
 
 /**
- * Implementation of hook_perm().
+ * Implementation of hook_permission().
  *
  * Exposes permissions for rating content, viewing aggregate ratings, and using PHP
  * snippets when configuring fivestar CCK fields.
  */
-function fivestar_perm() {
-  return array('rate content', 'use PHP for fivestar target');
+function fivestar_permission() {
+  return array(
+    'rate content' => array(
+      'title' => t('rate content'),
+      'description' => 'TODO: write description for rate content',
+    ),
+    'use PHP for fivestar target' => array(
+      'title' => t('use PHP for fivestar target'),
+      'description' => 'TODO: write description for use PHP for fivestar target',
+    ),
+  );
 }
 
 /**
@@ -133,26 +140,26 @@ function fivestar_theme() {
   return array(
     // Fivestar theme functions.
     'fivestar' => array(
-      'arguments' => array('element' => NULL),
+      'render element' => 'element',
     ),
     'fivestar_select' => array(
-      'arguments' => array('element' => NULL),
+      'render element' => 'element',
     ),
     'fivestar_static' => array(
-      'arguments' => array('rating' => NULL, 'stars' => 5),
+      'arguments' => array('rating' => NULL, 'stars' => 5, 'tag' => 'vote'),
     ),
     'fivestar_static_element' => array(
       'arguments' => array('star_display' => NULL, 'title' => NULL, 'description' => NULL),
     ),
     'fivestar_summary' => array(
-      'arguments' => array('user_rating' => NULL, 'average_rating' => NULL, 'votes' => 0, 'stars' => 5),
+      'arguments' => array('user_rating' => NULL, 'average_rating' => NULL, 'votes' => 0, 'stars' => 5, 'feedback_enable' => TRUE),
     ),
     'fivestar_widget' => array(
-      'arguments' => array('form' => NULL),
+      'render element' => 'form',
     ),
     // fivestar.admin.inc.
     'fivestar_preview' => array(
-      'arguments' => array('style' => NULL, 'text' => NULL, 'stars' => NULL, 'unvote' => NULL, 'title' => NULL, 'labels_enable' => TRUE, 'labels' => array()),
+      'arguments' => array('style' => NULL, 'text' => NULL, 'stars' => NULL, 'unvote' => NULL, 'title' => NULL, 'feedback_enable' => TRUE, 'labels_enable' => TRUE, 'labels' => array()),
       'file' => 'includes/fivestar.admin.inc',
     ),
     'fivestar_preview_widget' => array(
@@ -164,49 +171,52 @@ function fivestar_theme() {
       'file' => 'includes/fivestar.admin.inc',
     ),
     'fivestar_settings' => array(
-      'arguments' => array('form' => NULL),
+      'render element' => 'form',
       'file' => 'includes/fivestar.admin.inc',
     ),
     'fivestar_node_type_tag_form' => array(
-      'arguments' => array('form' => NULL),
+      'render element' => 'form',
       'file' => 'includes/fivestar.admin.inc',
     ),
     // fivestar.color.inc.
     'fivestar_color_form' => array(
-      'arguments' => array('form' => NULL),
+      'render element' => 'form',
     ),
     // fivestar.field.inc.
     'fivestar_formatter_default' => array(
-      'arguments' => array('element' => NULL),
+      'render element' => 'element',
     ),
     'fivestar_formatter_rating' => array(
-      'arguments' => array('element' => NULL),
+      'render element' => 'element',
     ),
     'fivestar_formatter_percentage' => array(
-      'arguments' => array('element' => NULL),
+      'render element' => 'element',
     ),
   );
 }
 
 /**
- * Implementation of hook_node_types().
+ * Implementation of hook_node_type_delete().
  */
-function fivestar_node_type($op, $info) {
+function fivestar_node_type_delete($info) {
   $type = $info->type;
-  $variables = array('fivestar', 'fivestar_unvote', 'fivestar_style', 'fivestar_stars', 'fivestar_comment', 'fivestar_position', 'fivestar_position_teaser', 'fivestar_labels_enable', 'fivestar_labels', 'fivestar_text', 'fivestar_title', 'fivestar_feedback');
 
   // Be responsible and cleanup unneeded variables.
-  if ($op == 'delete') {
-    foreach ($variables as $variable) {
-      foreach (fivestar_get_tags() as $tag) {
-        $suffix = fivestar_get_suffix($type, $tag);
-        variable_del($variable . '_' . $suffix);
-      }
+  foreach (_fivestar_variables() as $variable) {
+    foreach (fivestar_get_tags() as $tag) {
+      $suffix = fivestar_get_suffix($type, $tag);
+      variable_del($variable . '_' . $suffix);
     }
   }
+}
+
+/**
+ * Implementation of hook_node_type_update().
+ */
+function fivestar_node_type_update($info) {
   // When changing the type name, update the variables.
-  elseif ($op == 'update' && !empty($info->old_type) && $info->old_type != $info->type) {
-    foreach ($variables as $variable) {
+  if (!empty($info->old_type) && $info->old_type != $info->type) {
+    foreach (_fivestar_variables() as $variable) {
       foreach (fivestar_get_tags() as $tag) {
         $oldvarname = $variable . '_' . fivestar_get_suffix($info->old_type, $tag);
         $newvarname = $variable . '_' . fivestar_get_suffix($info->type, $tag);
@@ -220,6 +230,10 @@ function fivestar_node_type($op, $info) 
   }
 }
 
+function _fivestar_variables() {
+  return array('fivestar', 'fivestar_unvote', 'fivestar_style', 'fivestar_stars', 'fivestar_comment', 'fivestar_position', 'fivestar_position_teaser', 'fivestar_labels_enable', 'fivestar_labels', 'fivestar_text', 'fivestar_title', 'fivestar_feedback');
+}
+
 /**
  * Callback function for fivestar/vote.
  *
@@ -269,13 +283,25 @@ function fivestar_vote($type, $cid, $tag
       }
     }
   }
+  $arguments = array(
+    'user_rating' => $value,
+    'average_rating' => $summary[$tag]['average'],
+    'votes' => $summary[$tag]['count'],
+    'stars' => $stars,
+    'feedback_enable' => $feedback_enable,
+  );
+  $skip_map = array(
+    'average' => array('user_rating', 'votes'),
+    'average_count' => array('user_rating'),
+    'user' => array('average_rating', 'votes'),
+    'user_count' => array('average_rating'),
+    'combo' => array(),
+    'count' => array('user_rating', 'average_rating'),
+  );
   $output .= '<summary>';
-  $output .= '<average><![CDATA['. theme('fivestar_summary', NULL, $summary[$tag]['average'], NULL, $stars, $feedback_enable) .']]></average>';
-  $output .= '<average_count><![CDATA['. theme('fivestar_summary', NULL, $summary[$tag]['average'], $summary[$tag]['count'], $stars, $feedback_enable) .']]></average_count>';
-  $output .= '<user><![CDATA['. theme('fivestar_summary', $value, NULL, NULL, $stars, $feedback_enable) .']]></user>';
-  $output .= '<user_count><![CDATA['. theme('fivestar_summary', $value, NULL, $summary[$tag]['count'], $stars, $feedback_enable) .']]></user_count>';
-  $output .= '<combo><![CDATA['. theme('fivestar_summary', $value, $summary[$tag]['average'], $summary[$tag]['count'], $stars, $feedback_enable) .']]></combo>';
-  $output .= '<count><![CDATA['. theme('fivestar_summary', NULL, NULL, $summary[$tag]['count'], $stars, $feedback_enable) .']]></count>';
+  foreach ($skip_map as $tag => $skip) {
+    $output .= "<$tag>![CDATA[". theme('fivestar_summary', array_diff_key($arguments, array_flip($skip))) . "]]></$tag>";
+  }
   $output .= '</summary>';
   $output .= '</result>';
 
@@ -468,12 +494,12 @@ function fivestar_fivestar_access($type,
  */
 function fivestar_fivestar_widgets() {
   $widgets_directory = drupal_get_path('module', 'fivestar') .'/widgets';
-  $files = file_scan_directory($widgets_directory, '\.css$');
+  $files = file_scan_directory($widgets_directory, '/\.css$/');
 
   $widgets = array();
   foreach ($files as $file) {
     if (strpos($file->filename, '-rtl.css') === FALSE) {
-      $widgets[$file->filename] = drupal_ucfirst(str_replace('-color', '', $file->name));
+      $widgets[$file->uri] = drupal_ucfirst(str_replace('-color', '', $file->name));
     }
   }
   return $widgets;
@@ -770,8 +796,17 @@ function fivestar_static($content_type, 
     $count_value = $votes['count']['value'];
   }
 
-  $star_display = theme('fivestar_static', $star_value, $stars);
-  $text_display = $settings['text_display'] == 'none' ? NULL : theme('fivestar_summary', $user_value, $average_value, $count_value, $stars, FALSE);
+  $star_display = theme('fivestar_static', array(
+    'rating' => $star_value,
+    'stars' => $stars,
+  ));
+  $text_display = $settings['text_display'] == 'none' ? NULL : theme('fivestar_summary', array(
+    'user_rating' => $user_value,
+    'average_rating' => $average_value,
+    'votes' => $count_value,
+    'stars'=> $stars,
+    'feedback_enable' =>FALSE,
+  ));
 
   return theme('fivestar_static_element', $star_display, $title, $text_display);
 }
@@ -815,7 +850,7 @@ function fivestar_static($content_type, 
  */
 function fivestar_custom_widget(&$form_state, $values, $settings) {
   $form = array(
-    '#attributes' => array('class' => 'fivestar-widget'),
+    '#attributes' => array('class' => array('fivestar-widget')),
     '#redirect' => FALSE,
     '#theme' => 'fivestar_widget',
   );
@@ -866,27 +901,50 @@ function fivestar_custom_widget(&$form_s
   $form['fivestar_submit'] = array(
     '#type' => 'submit',
     '#value' => t('Rate'),
-    '#attributes' => array('class' => 'fivestar-submit'),
+    '#attributes' => array('class' => array('fivestar-submit')),
   );
 
-  $form['vote']['#attributes']['class'] = isset($form['vote']['#attributes']['class']) ? $form['vote']['#attributes']['class'] : '';
+  $form['vote']['#attributes']['class'] = isset($form['vote']['#attributes']['class']) ? $form['vote']['#attributes']['class'] : array();
   $settings['feedback_enable'] = isset($settings['feedback_enable']) ? $settings['feedback_enable'] : TRUE;
   switch ($settings['text']) {
     case 'user':
-      $form['vote']['#description'] = theme('fivestar_summary', $values['user'], NULL, $settings['style'] == 'dual' ? NULL : $values['count'], $settings['stars'], $settings['feedback_enable']);
-      $form['vote']['#attributes']['class'] .= ' fivestar-user-text';
+      $form['vote']['#description'] = theme('fivestar_summary', array(
+        'user_rating' => $values['user'],
+        'votes' => $settings['style'] == 'dual' ? NULL : $values['count'],
+        'stars' => $settings['stars'],
+        'feedback_enable' => $settings['feedback_enable'],
+      ));
+      $form['vote']['#attributes']['class'][] = 'fivestar-user-text';
       break;
     case 'average':
-      $form['vote']['#description'] = $settings['style'] == 'dual' ? NULL : theme('fivestar_summary', NULL, $values['average'], $values['count'], $settings['stars'], $settings['feedback_enable']);
-      $form['vote']['#attributes']['class'] .= ' fivestar-average-text';
+      $form['vote']['#description'] = $settings['style'] == 'dual' ? NULL : theme('fivestar_summary', array(
+        'average_rating' => $values['average'],
+        'votes' => $values['count'],
+        'stars' => $settings['stars'],
+        'feedback_enable' => $settings['feedback_enable'],
+      ));
+      $form['vote']['#attributes']['class'][] = 'fivestar-average-text';
       break;
     case 'smart':
-      $form['vote']['#description'] = ($settings['style'] == 'dual' && !$values['user']) ? NULL : theme('fivestar_summary', $values['user'], $values['user'] ? NULL : $values['average'], $settings['style'] == 'dual' ? NULL : $values['count'], $settings['stars'], $settings['feedback_enable']);
-      $form['vote']['#attributes']['class'] .= ' fivestar-smart-text '. ($values['user'] ? 'fivestar-user-text' : 'fivestar-average-text');
+      $form['vote']['#description'] = ($settings['style'] == 'dual' && !$values['user']) ? NULL : theme('fivestar_summary', array(
+        'user_rating' => $values['user'],
+        'average_rating' => $values['user'] ? NULL : $values['average'],
+        'votes' => $settings['style'] == 'dual' ? NULL : $values['count'],
+        'stars' => $settings['stars'],
+        'feedback_enable' => $settings['feedback_enable'],
+      ));
+      $form['vote']['#attributes']['class'][] = 'fivestar-smart-text';
+      $form['vote']['#attributes']['class'][] = $values['user'] ? 'fivestar-user-text' : 'fivestar-average-text';
       break;
     case 'dual':
-      $form['vote']['#description'] = theme('fivestar_summary', $values['user'], $settings['style'] == 'dual' ? NULL : $values['average'], $settings['style'] == 'dual' ? NULL : $values['count'], $settings['stars'], $settings['feedback_enable']);
-      $form['vote']['#attributes']['class'] .= ' fivestar-combo-text';
+      $form['vote']['#description'] = theme('fivestar_summary', array(
+        'user_rating' => $values['user'],
+        'average_rating' => $settings['style'] == 'dual' ? NULL : $values['average'],
+        'votes' => $settings['style'] == 'dual' ? NULL : $values['count'],
+        'stars' => $settings['stars'],
+        'feedback_enable' => $settings['feedback_enable'],
+      ));
+      $form['vote']['#attributes']['class'][] = ' fivestar-combo-text';
       break;
   }
 
@@ -894,36 +952,49 @@ function fivestar_custom_widget(&$form_s
     case 'average':
       $form['vote']['#title'] = t('Average');
       $form['vote']['#default_value'] = $values['average'];
-      $form['vote']['#attributes']['class'] .= ' fivestar-average-stars';
+      $form['vote']['#attributes']['class'][] = 'fivestar-average-stars';
       break;
     case 'user':
       $form['vote']['#title'] = t('Your rating');
       $form['vote']['#default_value'] = $values['user'];
-      $form['vote']['#attributes']['class'] .= ' fivestar-user-stars';
+      $form['vote']['#attributes']['class'][] = 'fivestar-user-stars';
       break;
     case 'smart':
       $form['vote']['#title'] = $values['user'] ? t('Your rating') : t('Average');
       $form['vote']['#default_value'] = $values['user'] ? $values['user'] : $values['average'];
-      $form['vote']['#attributes']['class'] .= ' fivestar-smart-stars '. ($values['user'] ? 'fivestar-user-stars' : 'fivestar-average-stars');
+      $form['vote']['#attributes']['class'][] = 'fivestar-smart-stars '. ($values['user'] ? 'fivestar-user-stars' : 'fivestar-average-stars');
       break;
     case 'dual':
       $form['vote']['#title'] = t('Your rating');
       $form['vote']['#default_value'] = $values['user'];
-      $form['vote']['#attributes']['class'] .= ' fivestar-combo-stars';
-      $form['#attributes']['class'] .= ' fivestar-combo-stars';
-      $static_average = theme('fivestar_static', $values['average'], $settings['stars'], $settings['tag']);
+      $form['vote']['#attributes']['class'][] = 'fivestar-combo-stars';
+      $form['#attributes']['class'][] = 'fivestar-combo-stars';
+      $static_average = theme('fivestar_static', array(
+        'rating' => $values['average'],
+        'stars' => $settings['stars'],
+        'tag' => $settings['tag'],
+      ));
       if ($settings['text'] == 'none' && !$settings['labels_enable'] && !$settings['feedback_enable']) {
         $static_description = NULL;
       }
       elseif ($settings['text'] != 'none') {
-        $static_description = theme('fivestar_summary', NULL, $settings['text'] == 'user' ? NULL : (isset($values['average']) ? $values['average'] : 0), isset($values['count']) ? $values['count'] : 0, $settings['stars'], FALSE);
+        $static_description = theme('fivestar_summary', array(
+          'averrage_rating' => $settings['text'] == 'user' ? NULL : (isset($values['average']) ? $values['average'] : 0),
+          'votes' => isset($values['count']) ? $values['count'] : 0,
+          'stars' => $settings['stars'],
+          'feedback_enable' => FALSE
+        ));
       }
       else {
         $static_description = '&nbsp;';
       }
       $form['average'] = array(
         '#type' => 'markup',
-        '#value' => theme('fivestar_static_element', $static_average, $settings['title'] !== FALSE ? t('Average') : NULL, $static_description),
+        '#value' => theme('fivestar_static_element', array(
+          'star_display' => $static_average,
+          'title' => $settings['title'] !== FALSE ? t('Average') : NULL,
+          'description' => $static_description,
+        )),
         '#weight' => -1,
       );
       break;
@@ -992,7 +1063,8 @@ function fivestar_elements() {
 /**
  * Theme the fivestar form element by adding necessary css and javascript.
  */
-function theme_fivestar($element) {
+function theme_fivestar($variables) {
+  $element = $variables['element'];
   if (empty($element['#description'])) {
     if ($element['#feedback_enable']) {
       $element['#description'] = '<div class="fivestar-summary fivestar-feedback-enabled">&nbsp;</div>';
@@ -1002,14 +1074,15 @@ function theme_fivestar($element) {
     }
   }
 
-  return theme('form_element', $element, $element['#children']);
+  return theme('form_element', array('element' => $element));
 }
 
 /**
  * Theme the straight HTML version of the fivestar select list. This is used
  * to remove the wrapping 'form-item' div from the select list.
  */
-function theme_fivestar_select($element) {
+function theme_fivestar_select($variables) {
+  $element = $variables['element'];
   $select = '';
   $size = $element['#size'] ? ' size="'. $element['#size'] .'"' : '';
   _form_set_class($element, array('form-select'));
@@ -1021,7 +1094,8 @@ function theme_fivestar_select($element)
  * Theme an entire fivestar widget, including the submit button and the normal
  * fivestar widget themed in the theme_fivestar() function.
  */
-function theme_fivestar_widget($form) {
+function theme_fivestar_widget($variables) {
+  $form = $variables['form'];
   // Only print out the summary if text is being displayed or using rollover text.
   if (empty($form['vote']['#description']) && strpos($form['vote']['#prefix'], 'fivestar-labels-hover') === FALSE) {
     unset($form['vote']['#description']);
@@ -1050,7 +1124,10 @@ function theme_fivestar_widget($form) {
  * @return
  *   A themed HTML string representing the star widget.
  */
-function theme_fivestar_static($rating, $stars = 5, $tag = 'vote') {
+function theme_fivestar_static($variables) {
+  $rating  = $variables['rating'];
+  $stars = $variables['stars'];
+  $tag = $variables['tag'];
   $output = '';
   $output .= '<div class="fivestar-widget-static fivestar-widget-static-'. $tag .' fivestar-widget-static-'. $stars .' clear-block">';
   if (empty($stars)) {
@@ -1104,7 +1181,8 @@ function theme_fivestar_static($rating, 
  * @return
  *   A themed HTML string representing the star widget.
  */
-function theme_fivestar_summary($user_rating, $average_rating, $votes, $stars = 5, $feedback = TRUE) {
+function theme_fivestar_summary($variables) {
+  extract($variables, EXTR_SKIP);
   $output = '';
   $div_class = '';
   if (isset($user_rating)) {
@@ -1143,16 +1221,17 @@ function theme_fivestar_summary($user_ra
 /**
  * Display a static fivestar value as stars with a title and description.
  */
-function theme_fivestar_static_element($value, $title = NULL, $description = NULL) {
+function theme_fivestar_static_element($variables) {
   $output = '';
   $output .= '<div class="fivestar-static-form-item">';
   $element = array(
     '#type' => 'item',
-    '#title' => $title,
-    '#description' => $description,
+    '#title' => $variables['title'],
+    '#description' => $variables['description'],
+    '#children' => $variables['value'],
   );
 
-  $output .= theme('form_element', $element, $value);
+  $output .= theme('form_element', array('element' => $element));
   $output .= '</div>';
   return $output;
 }
@@ -1361,7 +1440,11 @@ function fivestar_views_value_display_ha
     $tag = 'vote';
   }
 
-  return theme('fivestar_static', $value, $stars, $tag);
+  return theme('fivestar_static', array(
+    'rating' => $value,
+    'stars' => $stars,
+    'tag' => $tag,
+  ));
 }
 
 /**
@@ -1369,7 +1452,7 @@ function fivestar_views_value_display_ha
  */
 function fivestar_views_value_text_handler($value, $field, $columns) {
   // Get the number of stars for this node type.
-  $node_type = isset($columns->node_type) ? $columns->node_type : db_result(db_query("SELECT type FROM {node} WHERE nid = %d", $columns->nid));
+  $node_type = isset($columns->node_type) ? $columns->node_type : db_query("SELECT type FROM {node} WHERE nid = %d", $columns->nid)->fetchField();
   $stars = variable_get('fivestar_stars_'. $node_type, 5);
 
   // If displaying a user's vote, always display a whole value.
@@ -1465,7 +1548,10 @@ function fivestar_views_widget_handler($
     return drupal_get_form('fivestar_custom_widget', $values, $settings);
   }
   else {
-    return theme('fivestar_static', $value, 5);
+    return theme('fivestar_static', array(
+      'rating' => $value,
+      'stars' => 5,
+    ));
   }
 }
 
@@ -1492,7 +1578,7 @@ function fivestar_get_tags() {
 }
 
 /**
- * Gets the variable suffix for node/tag-specific variables. 
+ * Gets the variable suffix for node/tag-specific variables.
  *
  * Note that for backwards compatibility, the tag suffix is omitted for the tag
  * "vote". So instead of "story_vote", this just returns "story".
@@ -1537,10 +1623,10 @@ function fivestar_get_settings($node_typ
  * Implementation of hook_votingapi_metadata_alter().
  */
 function fivestar_votingapi_metadata_alter(&$data) {
-  static $tags;  
+  static $tags;
   if (!isset($tags)) {
     $tags = array();
-    
+
     module_load_install('content');
     module_load_include('inc', 'content', 'includes/content.admin');
     module_load_include('inc', 'content', 'includes/content.crud');
Index: fivestar_comment.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/fivestar/fivestar_comment.module,v
retrieving revision 1.6
diff -u -p -r1.6 fivestar_comment.module
--- fivestar_comment.module	27 Aug 2009 21:13:11 -0000	1.6
+++ fivestar_comment.module	26 Jan 2010 02:01:01 -0000
@@ -255,6 +255,6 @@ function fivestar_comment_create_vote($c
 /**
  * Theme fivestar comment view.
  */
-function theme_fivestar_comment_view($comment, $fivestar) {
-  return $fivestar . $comment;
+function theme_fivestar_comment_view($variables) {
+  return $variables['fivestar'] . $variables['comment'];
 }
Index: includes/fivestar.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/fivestar/includes/fivestar.admin.inc,v
retrieving revision 1.2
diff -u -p -r1.2 fivestar.admin.inc
--- includes/fivestar.admin.inc	11 May 2009 15:56:23 -0000	1.2
+++ includes/fivestar.admin.inc	26 Jan 2010 02:01:01 -0000
@@ -9,11 +9,9 @@
 /**
  * Callback function for admin/settings/fivestar. Display the settings form.
  */
-function fivestar_settings() {
+function fivestar_settings($form, $form_state) {
   module_load_include('inc', 'fivestar', 'includes/fivestar.color');
 
-  $form = array();
-
   $form['widget'] = array(
     '#tree' => FALSE,
     '#type' => 'fieldset',
@@ -27,7 +25,7 @@ function fivestar_settings() {
   $color_widgets = array();
   foreach ($widgets as $path => $name) {
     $directory = dirname($path);
-    $matches = file_scan_directory($directory, '-template.');
+    $matches = file_scan_directory($directory, '/-template\./');
     if (empty($matches)) {
       $classic_widgets[$path] = $name;
     }
@@ -48,14 +46,14 @@ function fivestar_settings() {
     '#type' => 'radios',
     '#options' => array('default' => t('Default')) + $classic_widgets + $color_widgets,
     '#default_value' => $default_value,
-    '#attributes' => array('class' => 'fivestar-widgets'),
+    '#attributes' => array('class' => array('fivestar-widgets')),
   );
 
   $form['widget']['fivestar_color_widget'] = array(
     '#type' => 'radios',
     '#title' => t('Custom color widgets'),
     '#options' => $color_widgets,
-    '#attributes' => array('class' => 'fivestar-widgets'),
+    '#attributes' => array('class' => array('fivestar-widgets')),
   );
 
   $form['tags'] = array(
@@ -97,42 +95,44 @@ function fivestar_settings_submit($form,
   menu_rebuild();
 }
 
-function theme_fivestar_settings($form) {
+function theme_fivestar_settings($variables) {
+  $form = $variables['form'];
   drupal_add_css(drupal_get_path('module', 'fivestar') .'/css/fivestar-admin.css', 'module', 'all', FALSE);
   drupal_set_title(t('Fivestar Settings'));
 
   // Default preview.
-  $form['widget']['fivestar_widget']['default']['#description'] = 'Default '. t('Preview') .':<br />'. theme('fivestar_preview_widget', 'default');
+  $form['widget']['fivestar_widget']['default']['#description'] = 'Default '. t('Preview') .':<br />'. theme('fivestar_preview_widget', array('css_file' => 'default'));
 
   // Preview for each classic widget.
   foreach (element_children($form['widget']['fivestar_widget']) as $widget_key) {
     if ($widget_key != 'default') {
-      $form['widget']['fivestar_widget'][$widget_key]['#description'] = $form['widget']['fivestar_widget'][$widget_key]['#title'] .' '. t('Preview') .':<br />'. theme('fivestar_preview_widget', $widget_key);
+      $form['widget']['fivestar_widget'][$widget_key]['#description'] = $form['widget']['fivestar_widget'][$widget_key]['#title'] .' '. t('Preview') .':<br />'. theme('fivestar_preview_widget', array('css_file' => $widget_key));
     }
   }
 
   // Preview for each color-enabled widget.
   foreach (element_children($form['widget']['fivestar_color_widget']) as $widget_key) {
     $form['widget']['fivestar_color_widget'][$widget_key] = $form['widget']['fivestar_widget'][$widget_key];
-    $form['widget']['fivestar_color_widget'][$widget_key]['#description'] = $form['widget']['fivestar_color_widget'][$widget_key]['#title'] .' '. t('Preview') .':<br />'. theme('fivestar_preview_widget', $widget_key);
+    $form['widget']['fivestar_color_widget'][$widget_key]['#description'] = $form['widget']['fivestar_color_widget'][$widget_key]['#title'] .' '. t('Preview') .':<br />'. theme('fivestar_preview_widget', array('css_file' => $widget_key));
     unset($form['widget']['fivestar_widget'][$widget_key]);
   }
 
   // Add the new styles to the page.
-  drupal_set_html_head("<style type=\"text/css\" media=\"all\">\n". fivestar_get_inline_css() ."</style>");
+  drupal_add_html_head("<style type=\"text/css\" media=\"all\">\n". fivestar_get_inline_css() ."</style>");
 
-  $form['widget']['fivestar_widget']['#attributes']['class'] .= ' clear-block';
-  $form['widget']['fivestar_color_widget']['#attributes']['class'] .= ' fivestar-color-widgets clear-block';
+  $form['widget']['fivestar_widget']['#attributes']['class'][] = ' clear-block';
+  $form['widget']['fivestar_color_widget']['#attributes']['class'][] = ' fivestar-color-widgets clear-block';
 
-  return drupal_render($form);
+  return drupal_render_children($form);
 }
 
 /**
  * Show a preview of a widget using a custom CSS file.
  */
-function theme_fivestar_preview_widget($css_file) {
+function theme_fivestar_preview_widget($variables) {
   static $default_css_added = FALSE;
 
+  $css_file = $variables['css_file'];
   // Add the default CSS to the page to ensure the defaults take precedence.
   if (!$default_css_added) {
     $css = file_get_contents(drupal_get_path('module', 'fivestar') .'/css/fivestar.css');
@@ -160,8 +160,12 @@ function theme_fivestar_preview_widget($
     '#post' => array(),
     '#programmed' => FALSE,
     '#tree' => FALSE,
+    '#parents' => array(),
+    '#required' => FALSE,
+    '#attributes' => array(),
+    '#title_display' => 'before',
   );
-  $form_state = array();
+  $form_state = form_state_defaults();
   $form['vote'] = array(
     '#type' => 'fivestar',
     '#stars' => 5,
@@ -172,7 +176,7 @@ function theme_fivestar_preview_widget($
   $form = form_builder('fivestar_preview', $form, $form_state);
 
   $output = '<div class="fivestar-star-preview" id="fivestar-preview-'. $widget_name .'">';
-  $output .= drupal_render($form);
+  $output .= drupal_render_children($form);
   $output .= '</div>';
 
   return $output;
@@ -181,9 +185,7 @@ function theme_fivestar_preview_widget($
 /**
  * Adds fivestar enaable and position to the node-type configuration form.
  */
-function fivestar_node_type_tag_form(&$form_state, $type_name, $tag = 'vote') {
-  $form = array();
-
+function fivestar_node_type_tag_form($form, &$form_state, $type_name, $tag = 'vote') {
   $settings = fivestar_get_settings($type_name, $tag);
 
   $form_state['fivestar_tag'] = $tag;
@@ -319,22 +321,21 @@ function fivestar_node_type_tag_form(&$f
   $form['direct']['fivestar_direct_preview'] = array(
     '#type' => 'item',
     '#title' => t('Direct rating widget preview'),
-    '#value' => theme(
-      'fivestar_preview',
+    '#value' => theme('fivestar_preview', array(
       $form['direct']['fivestar_style']['#default_value'],
       $form['direct']['fivestar_text']['#default_value'],
       $form['fivestar_stars']['#default_value'],
       $form['direct']['fivestar_unvote']['#default_value'],
       $form['direct']['fivestar_title']['#default_value'] ? NULL : FALSE,
       $form['labels']['fivestar_labels_enable']['#default_value'],
-      $settings['labels']
-    ),
+      $settings['labels'],
+    )),
   );
   if (!$form['fivestar']['#default_value']) {
-    $form['direct']['fivestar_direct_preview']['#value'] = theme('fivestar_preview_wrapper', '');
+    $form['direct']['fivestar_direct_preview']['#value'] = theme('fivestar_preview_wrapper', array('content' => ''));
   }
   else {
-    $form['direct']['fivestar_direct_preview']['#value'] = theme('fivestar_preview_wrapper', $form['direct']['fivestar_direct_preview']['#value']);
+    $form['direct']['fivestar_direct_preview']['#value'] = theme('fivestar_preview_wrapper', array('content' => $form['direct']['fivestar_direct_preview']['#value']));
   }
 
   $form['submit'] = array(
@@ -390,7 +391,8 @@ function fivestar_node_type_tag_form_sub
 /**
  * Theme function to add the Fivestar preview to the node type form.
  */
-function theme_fivestar_node_type_tag_form($form) {
+function theme_fivestar_node_type_tag_form($variables) {
+  $form = $variables['form'];
   drupal_add_js(drupal_get_path('module', 'fivestar') .'/js/fivestar-admin.js');
   drupal_add_js(array('fivestar' => array('preview_url' => url('fivestar/preview/node'))), 'setting');
   drupal_add_css(drupal_get_path('module', 'fivestar') .'/css/fivestar-admin.css', 'module', 'all', FALSE);
@@ -435,7 +437,7 @@ function theme_fivestar_node_type_tag_fo
   }
 
   // Any remaining cruft (should be empty).
-  $output .= drupal_render($form);
+  $output .= drupal_render_children($form);
   return $output;
 }
 
@@ -458,12 +460,22 @@ function fivestar_preview() {
     $labels[$key] = filter_xss_admin($label);
   }
 
-  $output = theme('fivestar_preview', $style, $text, $stars, $unvote, $title ? NULL : FALSE, $feedback_enable, $labels_enable, $labels);
+  $output = theme('fivestar_preview', array(
+    'style' => $style,
+    'text' => $text,
+    'stars' => $stars,
+    'unvote' => $unvote,
+    'title' => $title ? NULL : FALSE,
+    'feedback' => $feedback_enable,
+    'labels_enable' => $labels_enable,
+    'labels' => $labels,
+  ));
   drupal_set_header('Content-Type: text/javascript; charset=utf-8');
   print drupal_to_js(array('status' => TRUE, 'data' => $output));
 }
 
-function theme_fivestar_preview($style = NULL, $text = NULL, $stars = NULL, $unvote = NULL, $title = NULL, $feedback_enable = TRUE, $labels_enable = TRUE, $labels = array()) {
+function theme_fivestar_preview($variables) {
+  extract($variables, EXTR_SKIP);
   $values = array(
     'average' => 50,
     'user' => 80,
@@ -491,6 +503,6 @@ function theme_fivestar_preview($style =
   return $form;
 }
 
-function theme_fivestar_preview_wrapper($content, $type = 'direct') {
-  return '<div class="fivestar-preview fivestar-preview-'. $type .'">'. $content .'</div>';
+function theme_fivestar_preview_wrapper($variables) {
+  return '<div class="fivestar-preview fivestar-preview-'. $variables['type'] .'">'. $variables['content'] .'</div>';
 }
Index: includes/fivestar.color.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/fivestar/includes/fivestar.color.inc,v
retrieving revision 1.3
diff -u -p -r1.3 fivestar.color.inc
--- includes/fivestar.color.inc	3 Nov 2009 04:43:37 -0000	1.3
+++ includes/fivestar.color.inc	26 Jan 2010 02:01:01 -0000
@@ -62,10 +62,14 @@ function fivestar_color_form() {
     '#description' => t('A custom color widget must be selected to choose colors. Only the selected widget will be previewed.'),
   );
 
+  // TODO: port this if you can.
+  $disabled = FALSE;
+  /*
   $disabled = variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PRIVATE;
   if ($disabled) {
     $form['#description'] = t('Custom colors are only supported when the <a href="!url">download method</a> is set to public.', array('!url' => url('admin/settings/file-system')));
   }
+  */
 
   // Create the list of available schemes.
   $options = array(
@@ -141,7 +145,8 @@ function fivestar_color_form() {
 /**
  * Theme color form.
  */
-function theme_fivestar_color_form($form) {
+function theme_fivestar_color_form($variables) {
+  $form = $variables['form'];
   if (isset($form['#access']) && $form['#access'] == FALSE) {
     return '';
   }
@@ -177,18 +182,19 @@ function theme_fivestar_color_form($form
       $title = $form['fivestar_colors'][$name]['#title'];
       unset($form['fivestar_colors'][$name]['#title']);
       $element = array(
-        '#type' => 'element',
+        '#type' => 'item',
         '#title' => $title,
+        '#title_display' => 'before',
         '#children' => drupal_render($form['fivestar_colors'][$name]) . drupal_render($form['fivestar_colors'][$name2]),
       );
-      $output .= theme('form_element', $element, $element['#children']);
+      $output .= theme('form_element', array('element' => $element));
     }
     $output .= drupal_render($form['fivestar_colors'][$name]);
   }
   $output .= '</div>';
 
   // Render the form.
-  $output .= drupal_render($form);
+  $output .= drupal_render_children($form);
   // Close wrapper.
   $output .= '</div>';
 
