Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
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
Comment #1
gregglesYou 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.
Comment #2
gregglesIt seems nobody disagrees.