You are here

function recipe_unit_options in Recipe 5

Same name and namespace in other branches
  1. 6 recipe.module \recipe_unit_options()
  2. 7.2 recipe.module \recipe_unit_options()
  3. 7 recipe.module \recipe_unit_options()

Returns a cached array of recipe unit types

1 call to recipe_unit_options()
recipe_form in ./recipe.module
Implementation of hook_form().

File

./recipe.module, line 542
recipe.module - share recipes for drupal 5.x

Code

function recipe_unit_options() {
  static $options;
  static $unit_rs;
  if (!isset($unit_rs)) {
    $unit_rs = db_query('SELECT id,type,name,abbreviation FROM {recipe_unit} ORDER BY type ASC, metric');
    $options = array();
    while ($r = db_fetch_object($unit_rs)) {
      if (isset($r->type)) {
        if (!isset($options[$r->type])) {
          $options[$r->type] = array();
        }
        $options[$r->type][$r->id] = $r->name . ' (' . $r->abbreviation . ')';
      }
      else {
        $options[$r->id] = $r->name . ' (' . $r->abbreviation . ')';
      }
    }
  }
  return $options;
}