'. t("Provides attributes support for Storm") .'

'; break; } return $output; } function stormattribute_menu() { $items['storm/attributes'] = array( 'title' => 'Attributes', 'description' => 'Storm Attributes', 'page callback' => 'stormattribute_list', 'access arguments' => array('Storm: access administration pages'), 'file' => 'stormattribute.admin.inc', 'type' => MENU_NORMAL_ITEM); $items['storm/attributes/add'] = array( 'title' => 'Add a new attribute', 'description' => 'Storm Attributes', 'page callback' => 'drupal_get_form', 'page arguments' => array('stormattribute_add'), 'access arguments' => array('Storm: access administration pages'), 'file' => 'stormattribute.admin.inc', 'type' => MENU_CALLBACK); $items['storm/attributes/edit/%'] = array( 'title' => 'Edit an attribute', 'description' => 'Storm Attributes', 'page callback' => 'drupal_get_form', 'page arguments' => array('stormattribute_edit', 3), 'access arguments' => array('Storm: access administration pages'), 'file' => 'stormattribute.admin.inc', 'type' => MENU_CALLBACK); $items['storm/attributes/delete/%'] = array( 'title' => 'Delete an attribute', 'description' => 'Storm Attributes', 'page callback' => 'drupal_get_form', 'page arguments' => array('stormattribute_delete', 3), 'access arguments' => array('Storm: access administration pages'), 'file' => 'stormattribute.admin.inc', 'type' => MENU_CALLBACK); $items['storm/attributes/domain/autocomplete'] = array( 'title' => 'List of attributes', 'description' => 'Storm Attributes', 'page callback' => '_stormattribute_domain_autocomplete', 'page arguments' => array(4), 'access arguments' => array('Storm: access administration pages'), 'file' => 'stormattribute.admin.inc', 'type' => MENU_CALLBACK); return $items; } function stormattribute_theme() { return array( 'stormattribute_list' => array( 'file' => 'stormattribute.theme.inc', 'arguments' => array('form'), ), ); } function stormattribute_access($op, $item=NULL, $account=NULL) { if (empty($account)) { global $user; $account = $user; } if ($op == 'create') { return user_access('Storm: access administration pages'); } if ($op == 'delete') { return user_access('Storm: access administration pages'); } if ($op == 'update') { return user_access('Storm: access administration pages'); } return FALSE; } function stormattribute_attributes_bydomain($domain) { static $attributes_cache = array(); $attributes = array(); if (array_key_exists($domain, $attributes_cache)) return $attributes_cache[$domain]; $s = "SELECT * FROM {stormattribute} WHERE LOWER(domain) LIKE LOWER('%s') AND isactive=1 ORDER BY weight, avalue"; $r = db_query($s, $domain); $attributes['values'] = array(); while ($attribute = db_fetch_object($r)) { // The variable is deliberately passed through t() for translatability $attributes['values'][$attribute->akey] = t($attribute->avalue); if ($attribute->isdefault) { $attributes['default'] = $attribute->akey; } } if (is_array($attributes['values']) && !array_key_exists('default', $attributes)) { $v = array_flip($attributes['values']); $attributes['default'] = array_shift($v); } $attributes_cache[$domain] = $attributes; return $attributes; } function stormattribute_value($domain, $key) { $attributes_array = stormattribute_attributes_bydomain($domain); $attributes = $attributes_array['values']; if (array_key_exists($key, $attributes)) { return $attributes[$key]; } return $key; }