You are here

function fivestar_fivestar_widgets in Fivestar 7.2

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

Implements 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 417

Code

function fivestar_fivestar_widgets() {
  $widgets =& drupal_static(__FUNCTION__);
  if (!isset($widgets)) {
    $cache = cache_get(__FUNCTION__);
    if ($cache) {
      $widgets = $cache->data;
    }
  }
  if (!isset($widgets)) {
    $widgets_directory = drupal_get_path('module', 'fivestar') . '/widgets';
    $files = file_scan_directory($widgets_directory, '/\\.css$/');
    foreach ($files as $file) {
      if (strpos($file->filename, '-rtl.css') === FALSE) {
        $widgets[$file->uri] = drupal_ucfirst(str_replace('-color', '', $file->name));
      }
    }
    cache_set(__FUNCTION__, $widgets);
  }
  return $widgets;
}