Index: path_image.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/path_image/path_image.info,v
retrieving revision 1.2
diff -u -p -r1.2 path_image.info
--- path_image.info	30 Oct 2006 11:42:33 -0000	1.2
+++ path_image.info	28 Jan 2009 13:28:32 -0000
@@ -1,2 +1,4 @@
-name = path_image
+; $Id$
+name = Path Image
 description = A module to provide an image file within a block dependant upon the Drupal path
+core = 6.x
Index: path_image.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/path_image/path_image.install,v
retrieving revision 1.3
diff -u -p -r1.3 path_image.install
--- path_image.install	8 Jan 2007 22:57:19 -0000	1.3
+++ path_image.install	28 Jan 2009 13:04:51 -0000
@@ -5,31 +5,51 @@
  * @file
  */
 
+function path_image_schema() {
+  $schema['path_image_data'] = array(
+    'fields' => array(
+      'pid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
+      'path' => array('type' => 'varchar', 'length' => '128', 'not null' => FALSE),
+      'image_file' => array('type' => 'varchar', 'length' => '32', 'not null' => FALSE),
+    ),
+    'indexes' => array(
+      'path' => array(array('path', 32)),
+    ),
+    'primary key' => array('pid'),
+  );
+  return $schema;
+}
+
+/**
+ * Implementation of hook_install().
+ */
 function path_image_install() {
-  global $db_type;
+  drupal_install_schema('path_image');
+  db_query("UPDATE {system} SET weight = 5 WHERE name = 'path_image'");
+}
 
-  switch ($db_type) {
-    case 'mysql':
-    case 'mysqli':
-      db_query("CREATE TABLE IF NOT EXISTS {path_image_data} (".
-               "pid INT(10) NOT NULL,".
-               "path VARCHAR(128) NOT NULL,".
-               "image_file VARCHAR(32) NOT NULL,".
-               "PRIMARY KEY(pid),".
-               "INDEX(path(32)))");
-      break;
-    case 'pgsql':
-      db_query("CREATE TABLE {path_image_data} (".
-               "pid INT(10) NOT NULL,".
-               "path VARCHAR(128) NOT NULL,".
-               "image_file VARCHAR(32) NOT NULL,".
-               "PRIMARY KEY(pid))");
-      db_query("CREATE INDEX {path_image_data}_path_idx ON {path_image_data} (path)");
-               
-      break;
-  }
- 
-  db_query('update system set weight=5 WHERE name="path_image"');
+/**
+ * Implementation of hook_uninstall().
+ */
+function path_image_uninstall() {
+  drupal_uninstall_schema('path_image');
+  variable_del('path_image_block_subject');
+  variable_del('path_image_default_image');
+  variable_del('path_image_default_use');
+  variable_del('path_image_file_types');
+  variable_del('path_image_homepage_image');
+  variable_del('path_image_homepage_use');
+  variable_del('path_image_numeric_use');
+  variable_del('path_image_repository');
 }
 
+/**
+ * Convert column 'pid' into type serial.
+ */
+function path_image_update_6100() {
+  $ret = array();
+  db_drop_primary_key($ret, 'path_image_data');
+  db_change_field($ret, 'path_image_data', 'pid', 'pid', array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE), array('primary key' => array('pid')));
+  return $ret;
+}
 
Index: path_image.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/path_image/path_image.module,v
retrieving revision 1.9
diff -u -p -r1.9 path_image.module
--- path_image.module	8 Jan 2007 23:05:01 -0000	1.9
+++ path_image.module	28 Jan 2009 14:31:31 -0000
@@ -44,60 +44,50 @@ function path_image_perm() {
 }
 
 /**
- * Implementation of hook_help()
+ * Implementation of hook_theme().
  */
-function path_image_help($section) {
-  _path_image_debug("path_image_help('$section')");
-  
-  switch ($section) {
-    case 'admin/modules#description':
-      return t('Provides an block containing an image dependent upon the URL path');
-  }
-  
-  return '';
+function path_image_theme() {
+  return array(
+    'path_image_block_0' => array(
+      'arguments' => array('params' => NULL),
+    ),
+    'path_image_form_wrapper' => array(
+      'arguments' => array('arg' => NULL, 'params' => array()),
+    ),
+  );
 }
 
 /**
  * Implementation of hook_menu()
  */
-function path_image_menu($may_cache) {
-
-  if ($may_cache) {
-    $items[] = array(
-      'path' => 'admin/settings/path_image',
-      'title' => t('Path image'),
-      'access' => user_access('Path image admin'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => '_path_image_settings_form',
-      'description' => t('Provides an block containing an image dependent upon the URL path'),
-      'type' => MENU_NORMAL_ITEM
-    );
-  }
-  
+function path_image_menu() {
+  $items['admin/settings/path_image'] = array(
+    'title' => 'Path image',
+    'access arguments' => array('Path image admin'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('_path_image_settings_form'),
+    'description' => 'Provides an block containing an image dependent upon the URL path',
+  );
   return $items;
 }
 
 /**
- * Implementation of hook_form_alter()
+ * Implementation of hook_form_FORM_ID_alter().
  */
-function path_image_form_alter($form_id, &$form) {
+function path_image_form_block_admin_configure_alter(&$form, $form_state, $form_id) {
   _path_image_debug("path_image_form_alter('$form_id')");
   
-  if ('block_admin_configure' == $form_id) {
-    if (isset($form['module']['#value']) && 'path_image' == $form['module']['#value']) {
-      $form['path_image'] = array(
-        '#type' => 'fieldset',
-        '#title' => t('Block content set-up'),
-        '#collapsible' => TRUE,
-        '#weight' => -100
-      );
-      $form['path_image']['markup_help'] = array(
-        '#type' => 'markup',
-        '#value' => t('This section allows you to control the block\'s visibility. '.
-                      'To administer the block\'s content please visit the block\'s '.
-                      l('administration section', 'admin/settings/path_image'))
-      );  
-    }
+  if (isset($form['module']['#value']) && 'path_image' == $form['module']['#value']) {
+    $form['path_image'] = array(
+      '#type' => 'fieldset',
+      '#title' => t('Block content set-up'),
+      '#collapsible' => TRUE,
+      '#weight' => -100
+    );
+    $form['path_image']['markup_help'] = array(
+      '#type' => 'markup',
+      '#value' => t('This section allows you to control the visibility of the block. To administer the content please visit the <a href="@path-image-settings-url">administration section</a>.', array('@path-image-settings-url' => url('admin/settings/path_image'))),
+    );
   }
 }
 
@@ -226,9 +216,8 @@ function _path_image_block_main() {
              'ORDER BY path_len ASC';
     
       $r = db_query($sql, $path);
-      if (db_num_rows($r)) {
+      if ($row = db_fetch_array($r)) {
         // we have a match!
-        $row = db_fetch_array($r); // get just the first match if multiple return (see ORDER BY)
         $params = array(
           'image_file' => $row['image_file'],
           'image_repos' => variable_get('path_image_repository', 'files/images'),
@@ -435,65 +424,65 @@ function _path_image_settings_form() {
     );
   }
 
+  $form['path_image']['existing_entries'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Existing path %x', array('%x' => format_plural($num_of_rows, 'entry', 'entries'))),
+    '#tree' => TRUE,  
+  );
   $sql = 'SELECT * FROM {path_image_data} ORDER BY path ASC';
   $result = db_query($sql);
-  $num_of_rows = db_num_rows($result);
-  if ($num_of_rows > 0) {
-    $form['path_image']['existing_entries'] = array(
-      '#type' => 'fieldset',
-      '#title' => t('Existing path %x', array('%x' => format_plural($num_of_rows, 'entry', 'entries'))),
-      '#tree' => TRUE,  
-    );
-    $row_counter = 0;
-    while ($row = db_fetch_object($result)) {
-      if (count($files)) {
-        $form['path_image']['existing_entries'][$row_counter]['pid'] = array(
-          '#type' => 'hidden',
-          '#default_value' => $row->pid,
-        );
-        $form['path_image']['existing_entries'][$row_counter]['path'] = array(
-          '#type' => 'textfield',
-          '#title' => t('Alter a path'),
-          '#default_value' => $row->path,
-          '#size' => 50,
-          '#description' => t('Amend the path. <em>Note, no leading / (slash)</em>'),
-          '#prefix' => theme('path_image_form_wrapper', 'cell_first_prefix', array('cell' => array('valign' => 'top'))), 
-          '#suffix' => theme('path_image_form_wrapper', 'cell_first_suffix')         
-        );
-        $form['path_image']['existing_entries'][$row_counter]['image_file'] = array(
-          '#type' => 'select',
-          '#title' => t('Select an image'),
-          '#default_value' => $row->image_file,
-          '#options' => $files,
-          '#prefix' => theme('path_image_form_wrapper', 'cell_middle_prefix', array('cell' => array('valign' => 'top'))),
-          '#suffix' => theme('path_image_form_wrapper', 'cell_middle_suffix')        
-        );    
-        $form['path_image']['existing_entries'][$row_counter]['delete'] = array(
-          '#type' => 'checkbox',
-          '#title' => t('Delete'),
-          '#prefix' => theme('path_image_form_wrapper', 'cell_last_prefix', array('cell' => array('valign' => 'middle'))), 
-          '#suffix' => theme('path_image_form_wrapper', 'cell_last_suffix')            
-        );    
-      }
-      else {
-        $form['path_image']['existing_entries'][$row_counter]['path_markup'] = array(
-          '#type' => 'markup',
-          '#value' => check_plain($row->path),
-          '#suffix' => '&nbsp; -- &nbsp;'    
-        );      
-        $form['path_image']['existing_entries'][$row_counter]['image_file_markup'] = array(
-          '#type' => 'markup',
-          '#value' => t('No files available for selection'),
-          '#suffix' => theme('path_image_form_wrapper', 'new_line')
-        );
-      }
-      $row_counter++;
+  $row_counter = 0;
+  while ($row = db_fetch_object($result)) {
+    if (count($files)) {
+      $form['path_image']['existing_entries'][$row_counter]['pid'] = array(
+        '#type' => 'hidden',
+        '#default_value' => $row->pid,
+      );
+      $form['path_image']['existing_entries'][$row_counter]['path'] = array(
+        '#type' => 'textfield',
+        '#title' => t('Alter a path'),
+        '#default_value' => $row->path,
+        '#size' => 50,
+        '#description' => t('Amend the path. <em>Note, no leading / (slash)</em>'),
+        '#prefix' => theme('path_image_form_wrapper', 'cell_first_prefix', array('cell' => array('valign' => 'top'))), 
+        '#suffix' => theme('path_image_form_wrapper', 'cell_first_suffix')         
+      );
+      $form['path_image']['existing_entries'][$row_counter]['image_file'] = array(
+        '#type' => 'select',
+        '#title' => t('Select an image'),
+        '#default_value' => $row->image_file,
+        '#options' => $files,
+        '#prefix' => theme('path_image_form_wrapper', 'cell_middle_prefix', array('cell' => array('valign' => 'top'))),
+        '#suffix' => theme('path_image_form_wrapper', 'cell_middle_suffix')        
+      );    
+      $form['path_image']['existing_entries'][$row_counter]['delete'] = array(
+        '#type' => 'checkbox',
+        '#title' => t('Delete'),
+        '#prefix' => theme('path_image_form_wrapper', 'cell_last_prefix', array('cell' => array('valign' => 'middle'))), 
+        '#suffix' => theme('path_image_form_wrapper', 'cell_last_suffix')            
+      );    
+    }
+    else {
+      $form['path_image']['existing_entries'][$row_counter]['path_markup'] = array(
+        '#type' => 'markup',
+        '#value' => check_plain($row->path),
+        '#suffix' => '&nbsp; -- &nbsp;'    
+      );      
+      $form['path_image']['existing_entries'][$row_counter]['image_file_markup'] = array(
+        '#type' => 'markup',
+        '#value' => t('No files available for selection'),
+        '#suffix' => theme('path_image_form_wrapper', 'new_line')
+      );
     }
+    $row_counter++;
+  }
+  if (!$row_counter) {
+    $form['path_image']['existing_entries']['#access'] = FALSE;
   }
 
   $form['path_image']['submit'] = array(
     '#type' => 'submit',
-    '#value' => t('Save configuration')
+    '#value' => t('Save'),
   );
   
   return $form;
@@ -502,11 +491,11 @@ function _path_image_settings_form() {
 /**
  * Form validation function for the _settings page
  */
-function _path_image_settings_form_validate($form_id, $form_values) {
+function _path_image_settings_form_validate($form, &$form_state) {
   
   $return_value = TRUE;
   
-  if ($form_values['default_image'] == 'no image selected') {
+  if ($form_state['values']['default_image'] == 'no image selected') {
     form_set_error(
       'default_image', 
       t('You must set this even if you do not intend to use it'));
@@ -519,17 +508,17 @@ function _path_image_settings_form_valid
 /**
  * Form submit function for the _settings page
  */
-function _path_image_settings_form_submit($form_id, $form_values) {
+function _path_image_settings_form_submit($form, &$form_state) {
 
-  variable_set('path_image_block_subject', $form_values['block_subject']);
-  variable_set('path_image_repository', $form_values['repos']);
-  variable_set('path_image_default_image', $form_values['default_image']);
-  variable_set('path_image_default_use', $form_values['default_use']);
-  variable_set('path_image_homepage_image', $form_values['homepage_image']);
-  variable_set('path_image_homepage_use', $form_values['homepage_use']);
-  variable_set('path_image_numeric_use', $form_values['numeric_use']);
+  variable_set('path_image_block_subject', $form_state['values']['block_subject']);
+  variable_set('path_image_repository', $form_state['values']['repos']);
+  variable_set('path_image_default_image', $form_state['values']['default_image']);
+  variable_set('path_image_default_use', $form_state['values']['default_use']);
+  variable_set('path_image_homepage_image', $form_state['values']['homepage_image']);
+  variable_set('path_image_homepage_use', $form_state['values']['homepage_use']);
+  variable_set('path_image_numeric_use', $form_state['values']['numeric_use']);
     
-  $file_types = explode(',', $form_values['file_types']);
+  $file_types = explode(',', $form_state['values']['file_types']);
   if (is_array($file_types)) {
     foreach ($file_types as $k => $v) {
       $file_types[$k] = trim($v);
@@ -537,19 +526,17 @@ function _path_image_settings_form_submi
     variable_set('path_image_file_types', $file_types);
   }
   
-  if (strlen($form_values['new_entry']['new_path']) &&
-      strlen($form_values['new_entry']['new_image'])) {
+  if (strlen($form_state['values']['new_entry']['new_path']) &&
+      strlen($form_state['values']['new_entry']['new_image'])) {
     
-    $pid = db_next_id('{path_image_data}');  
     $sql = 'INSERT INTO {path_image_data} SET ' .
-           ' pid = %d, '.
            ' path = "%s", '.
            ' image_file = "%s"';
-    db_query($sql, $pid, $form_values['new_entry']['new_path'], $form_values['new_entry']['new_image']);
+    db_query($sql, $form_state['values']['new_entry']['new_path'], $form_state['values']['new_entry']['new_image']);
   }
   
-  if (isset($form_values['existing_entries']) && is_array($form_values['existing_entries'])) {
-    foreach ($form_values['existing_entries'] as $entry) {
+  if (isset($form_state['values']['existing_entries']) && is_array($form_state['values']['existing_entries'])) {
+    foreach ($form_state['values']['existing_entries'] as $entry) {
       if (isset($entry['delete']) && (int)$entry['delete']) {
         $sql = 'DELETE FROM {path_image_data} WHERE pid = %d';
         _path_image_expand_sql($sql, $entry['pid']);
