| 1 |
<?php |
<?php |
| 2 |
// $Id: browscap.module,v 1.6.2.3.2.9 2009/09/17 15:19:14 greggles Exp $ |
// $Id: browscap.module,v 1.6.2.3.2.10 2009/09/17 16:15:45 greggles Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 60 |
'title' => t('Browscap Refresh'), |
'title' => t('Browscap Refresh'), |
| 61 |
'page callback' => 'browscap_refresh', |
'page callback' => 'browscap_refresh', |
| 62 |
'access arguments' => array('administer site configuration'), |
'access arguments' => array('administer site configuration'), |
| 63 |
'type' => MENU_CALLBACK |
'type' => MENU_CALLBACK, |
| 64 |
); |
); |
| 65 |
$items['admin/reports/browscap/useragent/%browscap'] = array( |
$items['admin/reports/browscap/useragent/%browscap_useragent'] = array( |
| 66 |
'title callback' => 'browscap_load', |
'title' => 'Useragent details', |
|
'title arguments' => array(4), |
|
| 67 |
'page callback' => 'browscap_useragent_properties', |
'page callback' => 'browscap_useragent_properties', |
| 68 |
'page arguments' => array(4), |
'page arguments' => array(4), |
| 69 |
'access arguments' => array('access administration pages'), |
'access arguments' => array('access administration pages'), |
| 73 |
return $items; |
return $items; |
| 74 |
} |
} |
| 75 |
|
|
|
function browscap_load($useragent) { |
|
|
return $useragent; |
|
|
} |
|
|
|
|
| 76 |
/** |
/** |
| 77 |
* Implementation of hook_exit(). |
* Implementation of hook_exit(). |
| 78 |
* |
* |
| 212 |
$parent = l($useragent->parent, 'admin/reports/browscap/useragent/'. urlencode($useragent->parent)); |
$parent = l($useragent->parent, 'admin/reports/browscap/useragent/'. urlencode($useragent->parent)); |
| 213 |
} |
} |
| 214 |
else { |
else { |
| 215 |
$parent = $useragent->parent; |
$parent = check_plain($useragent->parent); |
| 216 |
} |
} |
| 217 |
if ($view == 'all') { |
if ($view == 'all') { |
| 218 |
if ($useragent->is_crawler) { |
if ($useragent->is_crawler) { |
| 398 |
} |
} |
| 399 |
} |
} |
| 400 |
|
|
| 401 |
function browscap_useragent_properties($useragent = NULL) { |
/** |
| 402 |
if ($useragent == NULL) { |
* Loads details about a given useragent. Also used as a menu object loader. |
| 403 |
drupal_not_found(); |
* |
| 404 |
return; |
* @param $useragent |
| 405 |
|
* The name of the useragent to load. |
| 406 |
|
* @return |
| 407 |
|
* The useragent array, FALSE otherwise. |
| 408 |
|
*/ |
| 409 |
|
function browscap_useragent_load($useragent = NULL) { |
| 410 |
|
if (empty($useragent)) { |
| 411 |
|
return FALSE; |
| 412 |
} |
} |
| 413 |
$row = db_fetch_object(db_query('SELECT * FROM {browscap} WHERE useragent = "%s"', $useragent)); |
$row = db_fetch_object(db_query('SELECT * FROM {browscap} WHERE useragent = "%s"', $useragent)); |
| 414 |
if (!$row) { |
if (!$row) { |
| 415 |
drupal_not_found(); |
return FALSE; |
|
return; |
|
| 416 |
} |
} |
| 417 |
$data = unserialize($row->data); |
return unserialize($row->data); |
| 418 |
$headers = array(t('property'), t('value')); |
} |
| 419 |
foreach ($data as $key => $val) { |
|
| 420 |
$rows[] = array($key, $val); |
/** |
| 421 |
|
* Page callback to show details about known useragents. |
| 422 |
|
* |
| 423 |
|
* @param $useragent |
| 424 |
|
* The useragent object, loaded from the database. |
| 425 |
|
* @return string an HTMl blob representing the data about this useragent. |
| 426 |
|
*/ |
| 427 |
|
function browscap_useragent_properties($useragent = NULL) { |
| 428 |
|
drupal_set_title(check_plain($useragent['browser'] .' '. $useragent['version'])); |
| 429 |
|
$headers = array(t('Property'), t('Value')); |
| 430 |
|
foreach ($useragent as $key => $val) { |
| 431 |
|
$rows[] = array(check_plain($key), check_plain($val)); |
| 432 |
} |
} |
| 433 |
$output = theme('table', $header, $rows); |
$output = theme('table', $headers, $rows); |
| 434 |
return $output; |
return $output; |
| 435 |
} |
} |