You are here

function fivestar_fivestar_widgets in Fivestar 5

Same name and namespace in other branches
  1. 8 fivestar.module \fivestar_fivestar_widgets()
  2. 6.2 fivestar.module \fivestar_fivestar_widgets()
  3. 6 fivestar.module \fivestar_fivestar_widgets()
  4. 7.2 fivestar.module \fivestar_fivestar_widgets()

Implementation of hook_fivestar_widgets().

This hook allows other modules to create additional custom widgets for the fivestar module.

Return value

array An array of key => value pairs suitable for inclusion as the #options in a select or radios form element. Each key must be the location of a css file for a fivestar widget. Each value should be the name of the widget.

File

./fivestar.module, line 832
A simple n-star voting widget, usable in other forms.

Code

function fivestar_fivestar_widgets() {
  $widgets_directory = drupal_get_path('module', 'fivestar') . '/widgets';
  $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));
    }
  }
  return $widgets;
}