### Eclipse Workspace Patch 1.0
#P Browscap 6
Index: browscap.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/browscap/Attic/browscap.info,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 browscap.info
--- browscap.info	30 Apr 2007 13:48:59 -0000	1.1.2.1
+++ browscap.info	29 May 2008 01:09:36 -0000
@@ -1,3 +1,4 @@
-; $Id: browscap.info,v 1.1.2.1 2007/04/30 13:48:59 jjeff Exp $
+; $Id$
 name = Browscap
-description = "Provides statistics on browsers and a replacement for PHPs get_browser() function."
\ No newline at end of file
+description = "Provides statistics on browsers and a replacement for PHPs get_browser() function."
+core = 6.x
Index: browscap.mysql
===================================================================
RCS file: browscap.mysql
diff -N browscap.mysql
--- browscap.mysql	30 Apr 2007 13:48:59 -0000	1.2.6.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,38 +0,0 @@
--- 
--- Table structure for table `browscap`
--- 
-
-CREATE TABLE browscap (
-  useragent varchar(255) NOT NULL default '',
-  `data` longblob NOT NULL,
-  PRIMARY KEY  (useragent)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-
--- --------------------------------------------------------
-
--- 
--- Table structure for table `browscap_statistics`
--- 
-
-CREATE TABLE browscap_statistics (
-  parent varchar(255) NOT NULL,
-  counter int(11) NOT NULL default '0',
-  is_crawler tinyint(1) NOT NULL default '0',
-  PRIMARY KEY  (parent)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-
--- --------------------------------------------------------
-
--- 
--- Table structure for table `cache_browscap`
--- 
-
-CREATE TABLE cache_browscap (
-  cid varchar(255) NOT NULL default '',
-  `data` longblob,
-  expire int(11) NOT NULL default '0',
-  created int(11) NOT NULL default '0',
-  headers text,
-  PRIMARY KEY  (cid),
-  KEY expire (expire)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8;
\ No newline at end of file
Index: browscap.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/browscap/browscap.module,v
retrieving revision 1.6.2.3
diff -u -r1.6.2.3 browscap.module
--- browscap.module	1 May 2007 23:44:35 -0000	1.6.2.3
+++ browscap.module	29 May 2008 01:09:36 -0000
@@ -15,71 +15,67 @@
  *
  * @return array
  */
-function browscap_menu($may_cache) {
-  $items = array();
-  $access = user_access('access administration pages');
-  
-  if ($may_cache) {
-    // LOG PAGES
-    $items[] = array('path' => 'admin/logs/browscap',
-      'title' => t('Browscap'),
-      'description' => t('Browser-specific site statistics.'),
-      'callback' => 'browscap_top_useragents',
-      'callback arguments' => array('all'),
-      'access' => $access,
-      'weight' => 5);
-    $items[] = array('path' => 'admin/logs/browscap/useragents',
-      'title' => t('All user agents'),
-      'access' => $access, 'weight' => 1,
-      'type' => MENU_DEFAULT_LOCAL_TASK);
-    $items[] = array('path' => 'admin/logs/browscap/browsers',
-      'callback' => 'browscap_top_useragents',
-      'callback arguments' => array('browsers'),
-      'title' => t('Browsers'),
-      'access' => $access,
-      'weight' => 2,
-      'type' => MENU_LOCAL_TASK);
-    $items[] = array('path' => 'admin/logs/browscap/crawlers',
-      'callback' => 'browscap_top_useragents',
-      'callback arguments' => array('crawlers'),
-      'title' => t('Crawlers'), 'access' => $access, 'weight' => 3,
-      'type' => MENU_LOCAL_TASK);
-    
-    // SETTINGS PAGE
-    $items[] = array(
-      'path' => 'admin/settings/browscap',
-      'title' => t('Browscap'),
-      'description' => t('Enable browscap site statistics.'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('browscap_settings'),
-      'access' => user_access('administer site configuration'),
-    );
-    
-    $items[] = array(
-      'path' => 'admin/settings/browscap/refresh',
-      'title' => t('Browscap Refresh'),
-      'callback' => 'browscap_refresh',
-      'access' => user_access('administer site configuration'),
-      'type' => MENU_CALLBACK
-    );
-    
-  }
-  else {
-    if (arg(0) == 'admin' && arg(1) == 'logs' && arg(2) == 'browscap' && arg(3) == 'useragent' && arg(4)) {
-      // INFORMATION ABOUT A USERAGENT
-      $items[] = array(
-        'path' => 'admin/logs/browscap/useragent',
-        'callback' => 'browscap_useragent_properties',
-        'title' => arg(4),
-        'access' => $access, 
-        'weight' => 5,
-        'type' => MENU_LOCAL_TASK
-      );
-    }
-  }
+function browscap_menu() {
+  // LOG PAGES
+  $items['admin/reports/browscap'] = array(
+    'title' => t('Browscap'),
+    'description' => t('Browser-specific site statistics.'),
+    'page callback' => 'browscap_top_useragents',
+    'page arguments' => array('all'),
+    'access' => array('access administration pages'),
+    'weight' => 5);
+  $items['admin/reports/browscap/useragents'] = array(
+    'title' => t('All user agents'),
+    'access arguments' => array('access administration pages'),
+    'weight' => 1,
+    'type' => MENU_DEFAULT_LOCAL_TASK
+  );
+  $items['admin/reports/browscap/browsers'] = array(
+    'title' => t('Browsers'),
+    'page callback' => 'browscap_top_useragents',
+    'page arguments' => array('browsers'),
+    'access arguments' => array('access administration pages'),
+    'weight' => 2,
+    'type' => MENU_LOCAL_TASK
+  );
+  $items['admin/reports/browscap/crawlers'] = array(
+    'title' => t('Crawlers'),
+    'page callback' => 'browscap_top_useragents',
+    'page arguments' => array('crawlers'),
+    'access arguments' => array('access administration pages'),
+    'weight' => 3,
+    'type' => MENU_LOCAL_TASK
+  );
+
+  // SETTINGS PAGE
+  $items['admin/settings/browscap'] = array(
+    'title' => t('Browscap'),
+    'description' => t('Enable browscap site statistics.'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('browscap_settings'),
+    'access arguments' => array('administer site configuration'),
+  );
+
+  $items['admin/settings/browscap/refresh'] = array(
+    'title' => t('Browscap Refresh'),
+    'page callback' => 'browscap_refresh',
+    'access arguments' => array('administer site configuration'),
+    'type' => MENU_CALLBACK
+  );
+  $items['admin/reports/browscap/useragent/%browscap'] = array(
+    'title' => arg(4),
+    'page callback' => 'browscap_useragent_properties',
+    'access arguments' => array('access administration pages'),
+    'weight' => 5,
+    'type' => MENU_LOCAL_TASK
+  );
   return $items;
 }
 
+function browscap_load($useragent) {
+  return $useragent;
+}
+
 /**
  * Implementation of hook_exit().
  *
@@ -181,7 +177,8 @@
       array('data' => t('Count'), 'field' => 'counter', 'sort' => 'desc'),
       array('data' => t('Percent'), 'field' => 'percent')
     );
-  } else {
+  }
+  else {
     $result = db_query('SELECT SUM(counter) FROM {browscap_statistics} WHERE is_crawler=1');
     $total = db_result($result);
     if (!$total) $total = 1;
@@ -203,7 +200,7 @@
 
   while ($useragent = db_fetch_object($result)) {
     if (db_result(db_query_range('SELECT useragent FROM {browscap} WHERE useragent = "%s"', $useragent->parent, 0, 1))) {
-      $parent = l($useragent->parent, 'admin/logs/browscap/useragent/'. urlencode($useragent->parent));
+      $parent = l($useragent->parent, 'admin/reports/browscap/useragent/'. urlencode($useragent->parent));
     }
     else {
       $parent = $useragent->parent;
@@ -211,11 +208,13 @@
     if ($view == 'all') {
       if ($useragent->is_crawler) {
         $is_crawler = 'Yes';
-      } else {
+      }
+      else {
         $is_crawler = 'No';
       }
       $rows[] = array($parent, $useragent->counter, $useragent->percent, $is_crawler);
-    } else {
+    }
+    else {
       $rows[] = array($parent, $useragent->counter, $useragent->percent);
     }
   }
@@ -239,8 +238,9 @@
   $cache = cache_get($cacheid, 'cache_browscap');
   if ((!empty($cache)) and ($cache->created > time() - 60*60*24)) {
     // Found a fresh entry in the cache
-    $browserinfo = unserialize($cache->data);
-  } else {
+    $browserinfo = $cache->data;
+  }
+  else {
     // Note the 'backwards' use of LIKE - the useragent column contains
     // the wildcarded pattern to match against our full-length string
     // The ORDER BY chooses the most-specific matching pattern
@@ -250,7 +250,7 @@
     // A couple of fieldnames not in our database, provided for
     // compatibility with PHP's get_browser()
     //$browserinfo->tables = $browserinfo->htmltables;
-    cache_set($cacheid, 'cache_browscap', serialize($browserinfo));
+    cache_set($cacheid, $browserinfo, 'cache_browscap');
   }
   $info = unserialize($browserinfo->data);
   $info['useragent'] = $useragent;
@@ -280,10 +280,10 @@
 function _browscap_import($cron = TRUE) {
   // Politely check the version for updates before fetching the file
   $versionpage = drupal_http_request('http://browsers.garykeith.com/version.asp');
-  if ($versionpage->error) {
-    watchdog('browscap', t("Couldn't check version: "). $versionpage->error);
+  if (isset($versionpage->error)) {
+    watchdog('browscap', 'Couldn\'t check version: '. $versionpage->error);
     if (!$cron) {
-      drupal_set_message(t("Couldn't check version: ") .$versionpage->error, 'error');
+      drupal_set_message(t('Couldn\'t check version: ') . $versionpage->error, 'error');
     }
     return;
   }
@@ -291,7 +291,7 @@
   $oldversion = variable_get('browscap_version', 'Never fetched');
   if ($browscapversion == $oldversion) {
     // No update, nothing to do here
-    watchdog('browscap', t('No new version of browscap to import'));
+    watchdog('browscap', 'No new version of browscap to import');
     if (!$cron) {
       drupal_set_message(t('No new version of browscap to import'));
     }
@@ -304,7 +304,7 @@
   $browscapfile = "$path/browscap_$server.ini";
 
   $browscap = drupal_http_request('http://browsers.garykeith.com/stream.asp?PHP_BrowsCapINI');
-  if ($browscap->error or !trim($browscap->data)) {
+  if (isset($browscap->error) || empty($browscap)) {
     watchdog('browscap', t("Couldn't retrieve updated browscap: ") . $browscap->error);
     if (!$cron) {
       drupal_set_message(t("Couldn't retrieve updated browscap: ") . $browscap->error);
@@ -323,8 +323,8 @@
       $e = $vals;
       // some recursive magic!
       $last_parent = array();
-      while ($vals['Parent'] && $vals['Parent'] !== $last_parent) {
-        $vals = $a[$vals['Parent']];
+      while (isset($vals['Parent']) && $vals['Parent'] !== $last_parent) {
+        $vals = isset($a[$vals['Parent']]) ? $a[$vals['Parent']] : array();
         $e = array_merge($vals, $e);
         $last_parent = $vals;
       }
@@ -335,9 +335,9 @@
     
     cache_clear_all('*', 'cache_browscap', TRUE);
     variable_set('browscap_version', $browscapversion);
-    watchdog('browscap', t("New version of browscap imported: "). $browscapversion);
+    watchdog('browscap', 'New version of browscap imported: '. $browscapversion);
     if (!$cron) {
-      drupal_set_message(t("New version of browscap imported: "). $browscapversion);
+      drupal_set_message(t('New version of browscap imported: ') . $browscapversion);
     }
   }
 }
@@ -378,7 +378,7 @@
   }
   $data = unserialize($row->data);
   $headers = array(t('property'), t('value'));
-  foreach($data as $key => $val) {
+  foreach ($data as $key => $val) {
     $rows[] = array($key, $val);
   }
   $output = theme('table', $header, $rows);
Index: browscap.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/browscap/Attic/browscap.install,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 browscap.install
--- browscap.install	30 Apr 2007 13:48:59 -0000	1.1.2.1
+++ browscap.install	29 May 2008 01:09:36 -0000
@@ -1,57 +1,57 @@
 <?php
-// **EC browscap.install,v 1.1, 2006-05-10 14:13:14   
-
+// $Id$
 
 /**
- * Implementation of hook_install()
+ * Implementation of hook_install.
  */
-
 function browscap_install() {
-  switch($GLOBALS['db_type']) {
-    case 'mysql':
-    case 'mysqli':
-      $queries = db_query("CREATE TABLE {browscap} (
-                  useragent varchar(255) NOT NULL default '',
-                  `data` longblob NOT NULL,
-                  PRIMARY KEY  (useragent)
-                  ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;");
-      $queries &= db_query("CREATE TABLE {browscap_statistics} (
-                  parent VARCHAR(255) NOT NULL,
-                  counter INT DEFAULT '0' NOT NULL,
-                  is_crawler TINYINT(1) DEFAULT '0' NOT NULL,
-                  PRIMARY KEY (parent)
-                ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;");
-      $queries &= db_query("CREATE TABLE cache_browscap (
-                  cid varchar(255) NOT NULL default '',
-                  `data` longblob,
-                  expire int(11) NOT NULL default '0',
-                  created int(11) NOT NULL default '0',
-                  headers text,
-                  PRIMARY KEY  (cid),
-                  KEY expire (expire)
-                  ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;");
-      if ($queries) {
-        drupal_set_message(t('Browscap tables installed into the database'));
-      }
-      else {
-        drupal_set_message(t('There was a problem installing the Browscap tables.'), 'error');
-      }
-      
-      break;
-    case 'pgsql':
-      // This space available...
-      break;
-  }
-}
+  drupal_install_schema('browscap');
+} // browscap_install
+
+/**
+ * Implementation of hook_schema.
+ */
+function browscap_schema() {
+  $schema['browscap'] = array(
+    'fields' => array(
+      'useragent' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'data' => array('type' => 'blob', 'size' => 'big'),
+    ),
+    'primary key' => array('useragent'),
+  );
+  $schema['browscap_statistics'] = array(
+    'fields' => array(
+      'parent' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'counter' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'is_crawler' => array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE),
+    ),
+    'primary key' => array('parent'),
+  );
+  $schema['cache_browscap'] = array(
+    'fields' => array(
+      'cid' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'data' => array('type' => 'blob', 'size' => 'big'),
+      'expire' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'created' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'headers' => array('type' => 'text'),
+      'serialized' => array('type' => 'int', 'size' => 'small', 'not null' => TRUE, 'default' => 0),
+    ),
+    'primary key' => array('cid'),
+    'indexes' => array(
+      'expire' => array('expire'),
+    ),
+  );
+  return $schema;
+} // browscap_schema
 
 function browscap_uninstall() {
-  db_query('DROP TABLE {browscap_statistics}');
-  db_query('DROP TABLE {browscap}');
-  db_query('DROP TABLE {cache_browscap}');
+  drupal_uninstall_schema('browscap');
+  drupal_uninstall_schema('browscap_statistics');
+  drupal_uninstall_schema('cache_browscap');
   variable_del('browscap_monitor');
   variable_del('browscap_imported');
   variable_del('browscap_version');
-}
+} // browscap_uninstall
 
 /**
  * Updates existing tables to UTF-8.
@@ -59,4 +59,4 @@
 function browscap_update_1() {
   return _system_update_utf8(array('browscap'));
   return _system_update_utf8(array('browscap_statistics'));
-}
\ No newline at end of file
+} // browscap_update_1
Index: browscap.pgsql
===================================================================
RCS file: browscap.pgsql
diff -N browscap.pgsql
--- browscap.pgsql	30 Apr 2007 13:48:59 -0000	1.1.6.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,18 +0,0 @@
-CREATE TABLE browscap (
-  useragent varchar(255) PRIMARY KEY,
-  data longblob NOT NULL
-);
-
-CREATE TABLE browscap_statistics (
-  parent VARCHAR(255) PRIMARY KEY,
-  counter integer DEFAULT 0 NOT NULL,
-  is_crawler smallint DEFAULT 0 NOT NULL
-);
-
-CREATE TABLE cache_browscap (
-  cid varchar(255) NOT NULL default '' PRIMARY KEY,
-  data longblob,
-  expire int(11) NOT NULL default '0' KEY,
-  created int(11) NOT NULL default '0',
-  headers text
-)
\ No newline at end of file
