Index: opensearch_aggregator.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/opensearch_aggregator/Attic/opensearch_aggregator.install,v
retrieving revision 1.1.2.3
diff -u -p -r1.1.2.3 opensearch_aggregator.install
--- opensearch_aggregator.install	14 Feb 2007 05:40:23 -0000	1.1.2.3
+++ opensearch_aggregator.install	25 Jul 2008 18:57:07 -0000
@@ -1,41 +1,60 @@
 <?php
 // $Id: opensearch_aggregator.install,v 1.1.2.3 2007/02/14 05:40:23 unconed Exp $
+/**
+ * @file
+ * Install file for opensearch aggregator
+ */
+function opensearch_aggregator_schema() {
+  $schema['opensearch_aggregator_source'] = array();
+  $schema['opensearch_aggregator_result'] = array(
+    'fields' => array(
+       'sid' => array('type' => 'int', 'not null' => TRUE),
+       'keywords' => array('type' => 'varchar', 'length' => '255', 'not null' => TRUE, 'default' => ''),
+       'offset' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+       'score' => array('type' => 'float', 'not null' => TRUE, 'default' => 0),
+       'title' => array('type' => 'varchar', 'length' => '255', 'not null' => TRUE, 'default' => ''),
+       'link' => array('type' => 'varchar', 'length' => '255', 'not null' => TRUE, 'default' => ''),
+       'description' => array('type' => 'text', 'size' => 'big', 'not null' => TRUE),
+       'access' => array('type' => 'int', 'not null' => TRUE, 'default' => 0)),
+    'primary key' => array('sid', 'keywords', 'offset'),
+    'indexes' => array(
+       'access' => array('access'),
+       'keywords' => array('keywords', 'score'),
+       'keywords_2' => array('keywords')),
+  );
+  $schema['opensearch_aggregator_source'] = array(
+    'fields' => array(
+       'sid' => array('type' => 'serial', 'not null' => TRUE),
+       'title' => array('type' => 'varchar', 'length' => '255', 'not null' => TRUE, 'default' => ''),
+       'osd' => array('type' => 'varchar', 'length' => '255', 'not null' => TRUE, 'default' => ''),
+       'feed' => array('type' => 'varchar', 'length' => '255', 'not null' => TRUE, 'default' => ''),
+       'link' => array('type' => 'varchar', 'length' => '255', 'not null' => TRUE, 'default' => ''),
+       'per_page' => array('type' => 'int', 'not null' => TRUE, 'default' => 0)),
+    'primary key' => array('sid'),
+    'unique keys' => array(
+       'osd' => array('osd'),
+       'title' => array('title')),
+  );
+  $schema['opensearch_aggregator_total'] = array(
+    'fields' => array(
+       'sid' => array('type' => 'int', 'not null' => TRUE),
+       'keywords' => array('type' => 'varchar', 'length' => '255', 'not null' => TRUE, 'default' => ''),
+       'total' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+       'access' => array('type' => 'int', 'not null' => TRUE, 'default' => 0)),
+    'primary key' => array('sid', 'keywords'),
+    'indexes' => array(
+       'access' => array('access'),
+       'keywords' => array('keywords')),
+  );
+  return $schema;
+}
 
 function opensearch_aggregator_install() {
-  db_query("CREATE TABLE {opensearch_aggregator_source} (
-    sid int NOT NULL auto_increment,
-    title varchar(255) NOT NULL default '',
-    osd varchar(255) NOT NULL default '',
-    feed varchar(255) NOT NULL default '',
-    link varchar(255) NOT NULL default '',
-    per_page int NOT NULL default 0,
-    PRIMARY KEY (sid),
-    UNIQUE KEY osd (osd),
-    UNIQUE KEY title (title)
-  )");
-
-  db_query("CREATE TABLE {opensearch_aggregator_total} (
-    sid int NOT NULL,
-    keywords varchar(255) NOT NULL default '',
-    total int NOT NULL default 0,
-    access int NOT NULL default 0,
-    PRIMARY KEY (sid, keywords),
-    INDEX (keywords),
-    INDEX (access)
-  )");
+  // Create tables.
+  drupal_install_schema('opensearch_aggregator');
+}
 
-  db_query("CREATE TABLE {opensearch_aggregator_result} (
-    sid int NOT NULL,
-    keywords varchar(255) NOT NULL default '',
-    offset int NOT NULL default 0,
-    score float NOT NULL default 0,
-    title varchar(255) NOT NULL default '',
-    link varchar(255) NOT NULL default '',
-    description longtext NOT NULL,
-    access int NOT NULL default 0,
-    PRIMARY KEY (sid, keywords, offset),
-    INDEX (keywords, score),
-    INDEX (keywords),
-    INDEX (access)
-  )");
+function opensearch_aggregator_uninstall() {
+  // Remove tables.
+  drupal_uninstall_schema('opensearch_aggregator');
 }
Index: opensearch_aggregator.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/opensearch_aggregator/Attic/opensearch_aggregator.module,v
retrieving revision 1.1.2.8
diff -u -p -r1.1.2.8 opensearch_aggregator.module
--- opensearch_aggregator.module	14 Feb 2007 12:02:29 -0000	1.1.2.8
+++ opensearch_aggregator.module	25 Jul 2008 18:57:07 -0000
@@ -1,11 +1,15 @@
 <?php
 // $Id: opensearch_aggregator.module,v 1.1.2.8 2007/02/14 12:02:29 unconed Exp $
+/**
+ * @file
+ * Allows searching multiple sites at once using OpenSearch.
+ */
 
 /**
  * Implementation of hook_help().
  */
-function opensearch_aggregator_help($section = '') {
-  switch ($section) {
+function opensearch_aggregator_help($path = '', $arg) {
+  switch ($path) {
     case 'admin/modules#description':
       return t('Allows searching multiple sites at once using OpenSearch.');
   }
@@ -14,34 +18,34 @@ function opensearch_aggregator_help($sec
 /**
  * Implementation of hook_menu().
  */
-function opensearch_aggregator_menu($may_cache) {
-  $access = user_access('administer opensearch aggregator');
-  if ($may_cache) {
-    $items[] = array('path' => 'admin/opensearch',
-      'title' => t('opensearch'),
-      'callback' => 'opensearch_aggregator_admin',
-      'access' => $access);
-    $items[] = array('path' => 'admin/opensearch/list',
-      'title' => t('list'),
-      'type' => MENU_DEFAULT_LOCAL_TASK,
-      'weight' => -10,
-      'access' => $access);
-    $items[] = array('path' => 'admin/opensearch/add/source',
-      'title' => t('add source'),
-      'callback' => 'opensearch_aggregator_form_source',
-      'access' => $access,
-      'type' => MENU_LOCAL_TASK);
-  }
-  else if (arg(0) == 'admin' && arg(1) == 'opensearch' && arg(2) == 'edit' && arg(3) == 'source') {
-    $source = opensearch_aggregator_get_source(arg(4));
-
-    $items[] = array('path' => 'admin/opensearch/edit/source',
-      'title' => t('edit source'),
-      'callback' => 'opensearch_aggregator_form_source',
-      'callback arguments' => array(&$source),
-      'access' => $access,
-      'type' => MENU_CALLBACK);
-  }
+function opensearch_aggregator_menu() {
+  $access = array('administer opensearch aggregator');
+
+  $items['admin/settings/opensearch_aggregator'] = array(
+    'title' => 'Opensearch Aggregator',
+    'description' => 'Create nodes from opensearch feeds.',
+    'page callback' => 'opensearch_aggregator_admin',
+    'access arguments' => $access);
+
+  $items['admin/settings/opensearch_aggregator/list'] = array(
+    'title' => 'List',
+    'type' => MENU_DEFAULT_LOCAL_TASK,
+    'weight' => -10,
+    'access arguments' => $access);
+
+  $items['admin/settings/opensearch_aggregator/add/source'] = array(
+    'title' => 'Add source',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('opensearch_aggregator_form_source'),
+    'access arguments' => $access,
+    'type' => MENU_LOCAL_TASK);
+
+  $items['admin/settings/opensearch_aggregator/edit/source'] = array(
+    'title' => 'edit source',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('opensearch_aggregator_form_source'),
+    'access arguments' => $access,
+    'type' => MENU_CALLBACK);
   return $items;
 }
 
@@ -71,7 +75,7 @@ function opensearch_aggregator_cron() {
 /**
  * Implementation of hook_search().
  */
-function opensearch_aggregator_search($op = 'search', $keywords = null) {
+function opensearch_aggregator_search($op = 'search', $keywords = NULL) {
   switch ($op) {
     case 'name':
       return t('distributed');
@@ -176,7 +180,6 @@ function opensearch_aggregator_query($ke
 
   // See if we have fulfilled the query.
   while (is_null($results) || count($results) < $offset + $limit) {
-
     // Only fetch if the cache has been checked.
     if (is_array($results)) {
       // Check if we have more results than before.
@@ -249,8 +252,8 @@ function opensearch_aggregator_fetch(&$s
         break;
       }
     default:
-      watchdog('aggregator', t('The OpenSearch feed from %site seems to be broken, due to "%error".', array('%site' => theme('placeholder', $source->title), '%error' => theme('placeholder', $result->code .' '. $result->error))), WATCHDOG_WARNING);
-      drupal_set_message(t('The OpenSearch feed from %site seems to be broken, because of error "%error".', array('%site' => theme('placeholder', $source->title), '%error' => theme('placeholder', $result->code .' '. $result->error))));
+      watchdog('aggregator', 'The OpenSearch feed from %site seems to be broken, due to "%error".', array('%site' => $source->title, '%error' => $result->code .' '. $result->error), WATCHDOG_WARNING);
+      drupal_set_message(t('The OpenSearch feed from %site seems to be broken, because of error "%error".', array('%site' => $source->title, '%error' => $result->code .' '. $result->error)));
   }
 }
 
@@ -422,8 +425,8 @@ function opensearch_aggregator_parse_fee
 
   // Parse data.
   if (!xml_parse($xml_parser, $data, 1)) {
-    watchdog('aggregator', t('The OpenSearch feed from %site seems to be broken, due to an error "%error" on line %line.', array('%site' => theme('placeholder', $source->title), '%error' => xml_error_string(xml_get_error_code($xml_parser)), '%line' => xml_get_current_line_number($xml_parser))), WATCHDOG_WARNING);
-    drupal_set_message(t('The OpenSearch feed from %site seems to be broken, because of error "%error" on line %line.', array('%site' => theme('placeholder', $source->title), '%error' => xml_error_string(xml_get_error_code($xml_parser)), '%line' => xml_get_current_line_number($xml_parser))), 'error');
+    watchdog('aggregator', 'The OpenSearch feed from %site seems to be broken, due to an error "%error" on line %line.', array('%site' => $source->title, '%error' => xml_error_string(xml_get_error_code($xml_parser)), '%line' => xml_get_current_line_number($xml_parser)), WATCHDOG_WARNING);
+    drupal_set_message(t('The OpenSearch feed from %site seems to be broken, because of error "%error" on line %line.', array('%site' => $source->title, '%error' => xml_error_string(xml_get_error_code($xml_parser)), '%line' => xml_get_current_line_number($xml_parser))), 'error');
     return 0;
   }
   xml_parser_free($xml_parser);
@@ -553,8 +556,8 @@ function opensearch_aggregator_admin() {
   while ($source = db_fetch_object($result)) {
     $rows[] = array(
       check_plain($source->title),
-      check_url(url($source->osd)) . '<br /><small>'. check_url(url($source->feed)) .'</small>',
-      l(t('edit'), "admin/opensearch/edit/source/$source->sid"));
+      check_url(url($source->osd)) .'<br /><small>'. check_url(url($source->feed)) .'</small>',
+      l(t('edit'), "admin/settings/opensearch_aggregator/edit/source/$source->sid"));
   }
   if (count($rows) == 0) {
     $rows[] = array(array('colspan' => 3, 'data' => t('No sources defined.')));
@@ -567,7 +570,9 @@ function opensearch_aggregator_admin() {
 /**
  * Generate a form to add/edit feed sources.
  */
-function opensearch_aggregator_form_source($edit = array()) {
+function opensearch_aggregator_form_source($nid = 0) {
+  $edit = opensearch_aggregator_get_source($nid);
+
   $form['title'] = array('#type' => 'textfield',
     '#title' => t('Title'),
     '#default_value' => $edit['title'],
@@ -584,40 +589,40 @@ function opensearch_aggregator_form_sour
   );
   $form['feed'] = array('#type' => 'value');
 
-  $form['submit'] = array('#type' => 'submit', '#value' =>t('Submit'));
+  $form['submit'] = array('#type' => 'submit', '#value' => t('Submit'));
 
   if ($edit['sid']) {
-    $form['delete'] = array('#type' => 'submit', '#value' =>t('Delete'));
+    $form['delete'] = array('#type' => 'submit', '#value' => t('Delete'));
     $form['sid'] = array('#type' => 'hidden', '#value' => $edit['sid']);
   }
 
-  return drupal_get_form('opensearch_aggregator_form_source', $form);
+  return $form;
 }
 
 /**
  * Validate opensearch_aggregator_form_source form submissions.
  */
-function opensearch_aggregator_form_source_validate($form_id, &$form_values, &$form) {
-  if ($_POST['op'] == t('Submit')) {
+function opensearch_aggregator_form_source_validate($form, &$form_state) {
+  if ($form_state['values']['op'] == t('Submit')) {
     // Check for duplicate titles
-    if (isset($form_values['sid'])) {
-      $result = db_query("SELECT title, osd FROM {opensearch_aggregator_source} WHERE (title = '%s' OR osd = '%s') AND sid != %d", $form_values['title'], $form_values['osd'], $form_values['sid']);
+    if (isset($form_state['values']['sid'])) {
+      $result = db_query("SELECT title, osd FROM {opensearch_aggregator_source} WHERE (title = '%s' OR osd = '%s') AND sid <> %d", $form_state['values']['title'], $form_state['values']['osd'], $form_state['values']['sid']);
     }
     else {
-      $result = db_query("SELECT title, osd FROM {opensearch_aggregator_source} WHERE title = '%s' OR osd = '%s'", $form_values['title'], $form_values['osd']);
+      $result = db_query("SELECT title, osd FROM {opensearch_aggregator_source} WHERE title = '%s' OR osd = '%s'", $form_state['values']['title'], $form_state['values']['osd']);
     }
     while ($source = db_fetch_object($result)) {
-      if (strcasecmp($source->title, $form_values['title']) == 0) {
-        form_set_error('title', t('A source named %source already exists. Please enter a unique title.', array('%source' => theme('placeholder', $form_values['title']))));
+      if (strcasecmp($source->title, $form_state['values']['title']) == 0) {
+        form_set_error('title', t('A source named %source already exists. Please enter a unique title.', array('%source' => $form_state['values']['title'])));
       }
     }
     
-    $discover = opensearch_discover($form_values['osd']);
+    $discover = opensearch_discover($form_state['values']['osd']);
     if ($discover['success']) {
-      form_set_value($form['feed'], $discover['template']);
+      form_set_value($form['feed'], $discover['template'], $form_state);
     }
     else {
-      form_set_error('osd', t('Could not find a valid OpenSearch Description at the specified URL. The error was: %error', array('%error' => theme('placeholder', $discover['error']))));
+      form_set_error('osd', t('Could not find a valid OpenSearch Description at the specified URL. The error was: %error', array('%error' => $discover['error'])));
     }
   }
 }
@@ -639,7 +644,6 @@ function opensearch_aggregator_form_sour
 function opensearch_discover($url) {
   // Request URL.
   $result = drupal_http_request($url);
-
   // Process HTTP response code.
   switch ($result->code) {
     case 301:
@@ -682,27 +686,27 @@ function opensearch_discover($url) {
  * Process opensearch_aggregator_form_source form submissions.
  * @todo Add delete confirmation dialog.
  */
-function opensearch_aggregator_form_source_submit($form_id, $form_values) {
-  if ($_POST['op'] == t('Delete')) {
-    $title = $form_values['title'];
+function opensearch_aggregator_form_source_submit($form, &$form_state) {
+  if ($form_state['values']['op'] == t('Delete')) {
+    $title = $form_state['values']['title'];
     // Unset the title:
-    unset($form_values['title']);
+    unset($form_state['values']['title']);
   }
-  opensearch_aggregator_save_source($form_values);
-  if (isset($form_values['sid'])) {
-    if (isset($form_values['title'])) {
-      drupal_set_message(t('The source %source has been updated.', array('%source' => theme('placeholder', $form_values['title']))));
+  opensearch_aggregator_save_source($form_state['values']);
+  if (isset($form_state['values']['sid'])) {
+    if (isset($form_state['values']['title'])) {
+      drupal_set_message(t('The source %source has been updated.', array('%source' => $form_state['values']['title'])));
     }
     else {
-      watchdog('opensearch', t('Source %source deleted.', array('%source' => theme('placeholder', $title))));
-      drupal_set_message(t('The source %source has been deleted.', array('%source' => theme('placeholder', $title))));
+      watchdog('opensearch', 'Source %source deleted.', array('%source' => $title));
+      drupal_set_message(t('The source %source has been deleted.', array('%source' => $title)));
     }
   }
   else {
-    watchdog('opensearch', t('Source %source added.', array('%source' => theme('placeholder', $form_values['title']))), WATCHDOG_NOTICE, l(t('view'), 'admin/aggregator'));
-    drupal_set_message(t('The source %source has been added.', array('%source' => theme('placeholder', $form_values['title']))));
+    watchdog('opensearch', 'Source %source added.', array('%source' => $form_state['values']['title']), WATCHDOG_NOTICE, l(t('view'), 'admin/aggregator'));
+    drupal_set_message(t('The source %source has been added.', array('%source' => $form_state['values']['title'])));
   }
-  return 'admin/opensearch';
+  $form_state['redirect'] = 'admin/settings/opensearch_aggregator';
 }
 
 /**
@@ -725,8 +729,8 @@ function opensearch_aggregator_save_sour
     db_query('DELETE FROM {opensearch_aggregator_source} WHERE sid = %d', $edit['sid']);
   }
   else if ($edit['title']) {
-    $edit['sid'] = db_next_id('{opensearch_aggregator_source}_sid');
-    db_query("INSERT INTO {opensearch_aggregator_source} (sid, title, osd, feed, per_page) VALUES (%d, '%s', '%s', '%s', 0)", $edit['sid'], $edit['title'], $edit['osd'], $edit['feed']);
+    db_query("INSERT INTO {opensearch_aggregator_source} (title, osd, feed, per_page) VALUES ('%s', '%s', '%s', 0)", $edit['title'], $edit['osd'], $edit['feed']);
+    $edit['sid'] = db_last_insert_id('opensearch_aggregator_source', 'sid');
   }
 }
 
