In Mobile Tools, we're listing all the user agents available so users can select which ones active a particular device group.

We wrote a function which loads this data directly from the Browscap database. It would be nice if we could just call a function within Browscap instead so we don't have to manage updates to the schema as they occur.

/**
 * Create a mega options list of all user agents in the Browscap datagbase
 * @return type
 */
function mobile_tools_browscap_get_browscap_user_agents() {
  // @todo change to use database level sorting
  // @todo see if there's a function in browscap to do this
  $user_agent_data = db_select('browscap', 'b')
    ->fields('b')
    ->execute()
    ->fetchAll();
  $rows = array();
  if ($user_agent_data) {
    foreach ($user_agent_data as $key => $agent) {
      $properties = unserialize($agent->data);
      $rows[check_plain($agent->useragent)] = check_plain($properties['browser']) . ' (' . check_plain($agent->useragent) . ')';
    }
  }
  asort($rows);
  return $rows;
}

Something like that could work. Obviously some adjustments would be required.

Thanks!

Comments

greggles’s picture

You load 5,000+ records and display them to users?

This seems like a situation where an autocomplete would make a lot more sense, right?

I'm tempted to mark this as "won't fix" but will leave open in case someone else feels differently.

greggles’s picture

Status: Active » Closed (won't fix)

It seems nobody disagrees.