PHP Classes

List of brand name and model name

Recommend this page to a friend!

      WURFL PHP Library  >  All threads  >  List of brand name and model name  >  (Un) Subscribe thread alerts  
Subject:List of brand name and model name
Summary:Make HTML <select> list
Messages:4
Author:Ketil Stadskleiv
Date:2006-07-02 12:34:32
Update:2006-07-07 08:16:14
 

  1. List of brand name and model name   Reply   Report abuse  
Picture of Ketil Stadskleiv Ketil Stadskleiv - 2006-07-02 12:34:32
Hi

Can I use this package to create two HTML select lists? One with brand_names and one with model name. The model name list should have an id as value so when the form is posted it can be used for obtaining wallpaper_preferred_width and wallpaper_preferred_height.

Can these classes help me with this or do I have to parse the XML myself? Any tips and/ord code examples would be highly appreciated. (Running low on time on this project.)

  2. Re: List of brand name and model name   Reply   Report abuse  
Picture of Andrea Trasatti Andrea Trasatti - 2006-07-03 17:20:06 - In reply to message 1 from Ketil Stadskleiv
What you can do is initialize the class. Take the array of user agents, cycle through all of them and read brand and model.
Not hard. It will run for a while, like 1 minute or two.
I suggest that you check the actual_device_root attribute.

Something like this:

$wurflObj = new wurfl_class($wurfl, $wurfl_agents);
foreach ($wurflObj->_wurfl_agents as $id) {
if ( $_cached_devices[$id]['actual_device_root'] == 'true' ) {
$wurflObj->GetDeviceCapabilitiesFromAgent($_cached_devices[$id]['user_agent']);
$output_vals['oem'] = $wurflObj->getDeviceCapability('brand_name');
$output_vals['model'] = $wurflObj->getDeviceCapability('model_name');
}
}

print_r($output_vals);

I haven't tested this, just copied and pasted from existing code. Validate it.

  3. Re: List of brand name and model name   Reply   Report abuse  
Picture of Ketil Stadskleiv Ketil Stadskleiv - 2006-07-06 09:23:16 - In reply to message 2 from Andrea Trasatti
Hi. I tried this script:

<?php
set_time_limit(300);
include('wurfl_config.php');
include('wurfl_parser.php');
include('wurfl_class.php');

print_r($wurfl);
print_r($wurfl_agents);

$wurflObj = new wurfl_class($wurfl, $wurfl_agents);
foreach ($wurflObj->_wurfl_agents as $id) {

if ( $_cached_devices[$id]['actual_device_root'] == 'true' ) {
$wurflObj->GetDeviceCapabilitiesFromAgent($_cached_devices[$id]['user_agent']);
$output_vals['oem']= $wurflObj->getDeviceCapability('brand_name');
$output_vals['model']= $wurflObj->getDeviceCapability('model_name');
}

}
print_r($output_vals);
?>

The strange thing is that only the $wurfl_agents array has content, and therefore the $output_vals also gets empty. Do I have do do anything special for the $wurlf array to be populated?

This process seems very slow, these lists should be populated in a user interface. Is there any way to improve performance here.

  4. Re: List of brand name and model name   Reply   Report abuse  
Picture of Andrea Trasatti Andrea Trasatti - 2006-07-07 08:16:14 - In reply to message 3 from Ketil Stadskleiv
It is normal that $wurfl is empty, it gets populated only when needed and if needed will happen after you instantiate the wurfl object.

Make sure you read these pages:
wurfl.sourceforge.net/php/index.php ...
wurfl.sourceforge.net/php/config.ph ...

The process of checking each of 9000+ devices IS slow. Run it once and cache it in a file if you need it to be fast. Or export it to a DB